Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump commons-net:commons-net from 3.9.0 to 3.11.1 #262

Open
wants to merge 40 commits into
base: geocat_v4.2.3_report_custom_gracefull
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
1ba508d
[geocat]: CSP allowing iframe from '*.admin.ch' '*.cartoriviera.ch' '…
cmangeat Oct 30, 2022
7042d0f
[gn] Seems there is a trouble with regex filter and clause or empty f…
cmangeat Mar 19, 2022
89bb70d
[geocat] Harvester / Local folder / Allow known scripts.
fxprunayre Jul 27, 2021
3f1547d
[geocat]: add che contact translation in directories
fgravin Jul 6, 2022
2656020
[geocat]: translations
fgravin Jul 6, 2022
045de62
[geocat]: legal constraints translations
cmangeat Jan 24, 2023
7792a4f
[geocat] ellipsis for long group name in result cards
cmangeat Oct 30, 2022
76f3a3b
[geocat] need cleaning / splitting, many fixes ('Fix build when empty…
cmangeat Jan 25, 2023
16884f0
[geocat]: sort thematic facet by translation
cmangeat Apr 29, 2022
2c8ad7e
[geocat]: increase size of facets for tag and topic
fgravin Jul 13, 2022
06279f7
[geocat]: don't let socket connection troubles make idle connections …
cmangeat Nov 28, 2020
52b755d
[geocat]: container with 'embedded' mail.smtp.ssl.protocols def (as '…
cmangeat Feb 8, 2023
80da6b9
[geocat] facets def. in catController, seems that cl_geodataType.key …
cmangeat Feb 15, 2023
f4c7bbb
[gn]: last facet displayed with first ones ???
cmangeat May 5, 2022
4bc0c05
[gn] try a 'hard' fix for log4j2 trouble
cmangeat Mar 1, 2023
ec9e415
[geocat] add log4j-web for tomcat
cmangeat Mar 1, 2023
3b566f6
[gn] test with no log4j-slf4j18-impl and no messaging -> maybe better
cmangeat Mar 1, 2023
be6e3f1
[gn] try to update maven git id plugin so to esae wro4j startup, maybe
cmangeat Mar 7, 2023
c7a23d8
[deja reporte dans gn] avoid race condition, resize map once target s…
cmangeat Mar 21, 2023
f4cd4e4
[geocat], simple view, update frequency in metadata section
cmangeat Mar 28, 2023
dcfbfb3
[deja reporté dans gn] Support negative dates for temporal extents
sebr72 Mar 15, 2023
28067f7
[geocat] Revert "Record view / Display bounding polygon if set"
cmangeat Apr 6, 2023
74bd0b1
[geocat] INSPIRE conformity improvement (#234)
fgravin Apr 11, 2023
849f375
[gn] hack: disable 'cache at thesaurus level' when looking for keywor…
cmangeat Apr 17, 2023
b40a7f3
[geocat] Make harvesting/geocat_banner.png configurable by Swisstopo
sebr72 Jun 20, 2023
a4edae4
[geocat] Apply prettier to changed files, WARNING: drop before rebase…
sebr72 Jun 20, 2023
d31c007
[déjà dans gn] API / CSV export / Add support for custom export. (#7132)
fxprunayre Aug 24, 2023
1c3cd53
[geocat] New source to CSP frame-ancestors for city of Fribourg
cmangeat Oct 22, 2023
b626339
[geocat] Set XSRF cookie path to /
fgravin Dec 14, 2023
1b8f9d8
[geocat] Gnui lang package: add che topic category
fgravin Dec 15, 2023
0bf04e1
[gn] While using the filesystem harvester: Delete datadir when deleti…
sebr72 Jan 8, 2024
e2ce322
[geocat] Add link to https://www.geocat.ch/datahub/search/ (datahub) …
Dec 4, 2023
9060568
[gn] Maintenance Swagger API to clean data dir of orphaned metadata a…
sebr72 Jan 17, 2024
855b157
[déjà dans gn] Use Java 21 for Sonarcloud plugin (#7622)
juanluisrp Jan 16, 2024
a228cba
[déjà dans gn] SEO / Set HTML head title and description
fxprunayre May 15, 2023
557e8a2
[geocat ou gn si rework] Add Google Analytics Tag to html pages, only…
Jan 26, 2023
11c7f1e
[gn] on subtemplate's update, trigger indexation for every md referen…
cmangeat Jan 29, 2024
ae6fddf
[geocat] change basemap to greyscale swisstopo in EPSG:3857
Jan 16, 2024
17f94b4
[geocat] set global CRS to EPSG:3857 and add support for EPSG:2056 (L…
Jan 16, 2024
bd95dbe
Bump commons-net:commons-net from 3.9.0 to 3.11.1
dependabot[bot] Jun 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ name: SonarCloud QA
on:
push:
branches:
- main
- 4.0.x
- 3.12.x
- geocat_v4.2.3_report_custom
pull_request:
types: [opened, synchronize, reopened]
jobs:
Expand All @@ -19,12 +17,9 @@ jobs:
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
submodules: 'recursive'
# For building GeoNetwork, JDK8 is necessary, but for running
# the SonarQube plugin, JDK11 is necessary.
# So, first install JDK 8, build GeoNetwork, then install JDK11
# and run SonarQube:
- name: Set up JDK 8
uses: actions/[email protected]
show-progress: 'false'
- name: Set up JDK 11
uses: actions/[email protected]
with:
java-version: 8
distribution: 'temurin'
Expand All @@ -37,11 +32,13 @@ jobs:
restore-keys: ${{ runner.os }}-sonar
- name: Build GN
run: mvn -B package -DskipTests
- name: Set up JDK 11
uses: actions/[email protected]

- name: Set up JDK 21 # Sonarcloud analyzer needs at least JDK 17
uses: actions/[email protected]
with:
distribution: 'temurin'
java-version: '11'
java-version: '21'
cache: 'maven'
- name: Analyze with Sonar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
Expand Down
34 changes: 34 additions & 0 deletions common/src/main/java/org/fao/geonet/exceptions/GNException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//=============================================================================
//=== Copyright (C) 2001-2023 Food and Agriculture Organization of the
//=== United Nations (FAO-UN), United Nations World Food Programme (WFP)
//=== and United Nations Environment Programme (UNEP)
//===
//=== This program is free software; you can redistribute it and/or modify
//=== it under the terms of the GNU General Public License as published by
//=== the Free Software Foundation; either version 2 of the License, or (at
//=== your option) any later version.
//===
//=== This program is distributed in the hope that it will be useful, but
//=== WITHOUT ANY WARRANTY; without even the implied warranty of
//=== MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
//=== General Public License for more details.
//===
//=== You should have received a copy of the GNU General Public License
//=== along with this program; if not, write to the Free Software
//=== Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
//===
//=== Contact: Jeroen Ticheler - FAO - Viale delle Terme di Caracalla 2,
//=== Rome - Italy. email: [email protected]
//==============================================================================
package org.fao.geonet.exceptions;

public class GNException extends RuntimeException {

public GNException(String msg) {
super(msg);
}

public GNException(String msg, Throwable cause) {
super(msg, cause);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
*/
package org.fao.geonet.kernel;

import org.fao.geonet.NodeInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.mock.web.MockHttpSession;
Expand All @@ -43,16 +41,19 @@

public class SpringLocalServiceInvoker {

@Autowired
public RequestMappingHandlerMapping requestMappingHandlerMapping;
public final RequestMappingHandlerMapping requestMappingHandlerMapping;

@Autowired
public RequestMappingHandlerAdapter requestMappingHandlerAdapter;
public final RequestMappingHandlerAdapter requestMappingHandlerAdapter;

private HandlerMethodArgumentResolverComposite argumentResolvers;
private HandlerMethodReturnValueHandlerComposite returnValueHandlers;
private DefaultDataBinderFactory webDataBinderFactory;

public SpringLocalServiceInvoker(RequestMappingHandlerMapping requestMappingHandlerMapping, RequestMappingHandlerAdapter requestMappingHandlerAdapter) {
this.requestMappingHandlerMapping = requestMappingHandlerMapping;
this.requestMappingHandlerAdapter = requestMappingHandlerAdapter;
}

public void init() {
argumentResolvers = new HandlerMethodArgumentResolverComposite().addResolvers(requestMappingHandlerAdapter.getArgumentResolvers());
returnValueHandlers = new HandlerMethodReturnValueHandlerComposite().addHandlers(requestMappingHandlerAdapter.getReturnValueHandlers());
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/fao/geonet/kernel/Thesaurus.java
Original file line number Diff line number Diff line change
Expand Up @@ -1100,7 +1100,7 @@ public KeywordBean getKeyword(String uri, String... languages) {
String cacheKey = "getKeyword" + uri + Arrays.stream(languages).collect(Collectors.joining(""));
Object cacheValue = THESAURUS_SEARCH_CACHE.getIfPresent(cacheKey);
if (cacheValue != null) {
return (KeywordBean) cacheValue;
//return (KeywordBean) cacheValue;
}

List<KeywordBean> keywords;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

package org.fao.geonet.kernel.datamanager.base;

import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Predicate;
Expand All @@ -33,19 +34,20 @@
import jeeves.transaction.TransactionTask;
import jeeves.xlink.Processor;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.action.search.SearchResponse;
import org.fao.geonet.ApplicationContextHolder;
import org.fao.geonet.constants.Edit;
import org.fao.geonet.constants.Geonet;
import org.fao.geonet.constants.Params;
import org.fao.geonet.domain.*;
import org.fao.geonet.exceptions.GNException;
import org.fao.geonet.exceptions.UnAuthorizedException;
import org.fao.geonet.kernel.*;
import org.fao.geonet.kernel.datamanager.*;
import org.fao.geonet.kernel.schema.MetadataSchema;
import org.fao.geonet.kernel.schema.SchemaPlugin;
import org.fao.geonet.kernel.search.EsSearchManager;
import org.fao.geonet.kernel.search.IndexingMode;
import org.fao.geonet.kernel.search.MetaSearcher;
import org.fao.geonet.kernel.search.index.BatchOpsMetadataReindexer;
import org.fao.geonet.kernel.setting.SettingManager;
import org.fao.geonet.kernel.setting.Settings;
Expand Down Expand Up @@ -104,8 +106,6 @@ public class BaseMetadataManager implements IMetadataManager {
@Autowired
private GroupRepository groupRepository;
@Autowired
private MetadataStatusRepository metadataStatusRepository;
@Autowired
private MetadataValidationRepository metadataValidationRepository;
@Autowired
private MetadataRepository metadataRepository;
Expand Down Expand Up @@ -141,6 +141,10 @@ public class BaseMetadataManager implements IMetadataManager {

@Autowired
private ApplicationContext _applicationContext;

@VisibleForTesting
public int maxMdsReferencingSubTemplate = 10000;

@PersistenceContext
private EntityManager _entityManager;

Expand Down Expand Up @@ -747,6 +751,9 @@ public synchronized AbstractMetadata updateMetadata(final ServiceContext context
getSearchManager().delete(String.format("+uuid:\"%s\"", uuidBeforeUfo));
}
metadataIndexer.indexMetadata(metadataId, true, indexingMode);
if (metadata.getDataInfo().getType() == MetadataType.SUB_TEMPLATE) {
indexMdsReferencingSubTemplate(context, metadata);
}
}
}

Expand Down Expand Up @@ -1314,4 +1321,26 @@ boolean hasReferencingMetadata(ServiceContext context, AbstractMetadata metadata
return this.searchManager.query(query.toString(), null, 0, 0).getHits().getTotalHits().value > 0;
}

private void indexMdsReferencingSubTemplate(ServiceContext context, AbstractMetadata subTemplate) throws Exception {
StringBuilder query = new StringBuilder(String.format("xlink:*%s*", subTemplate.getUuid()));
SearchResponse response = this.searchManager.query(query.toString(), null, 0, maxMdsReferencingSubTemplate);
if (response.getHits().getTotalHits().value > maxMdsReferencingSubTemplate) {
throw new GNException("Not implemented");
}
ArrayList<String> toIndex = new ArrayList<>();
response.getHits().forEach(consumer -> {
String consumerUuid = consumer.getId();
try {
String consumerId = this.metadataUtils.getMetadataId(consumerUuid);
if (consumerId != null) {
toIndex.add(consumerId);
}
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException(e);
}
});
metadataIndexer.batchIndexInThreadPool(context, toIndex);
}
}
2 changes: 2 additions & 0 deletions core/src/main/java/org/fao/geonet/kernel/mef/Importer.java
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,8 @@ public static void importRecord(String uuid, MEFLib.UuidAction uuidAction, List<
if (Log.isDebugEnabled(Geonet.MEF)) {
Log.debug(Geonet.MEF, "Deleting existing metadata with UUID : " + uuid);
}
Store store = context.getBean("resourceStore", Store.class);
store.delResources(context, uuid, true);
metadataManager.deleteMetadata(context, dm.getMetadataId(uuid));
metadataManager.flush();
}
Expand Down
11 changes: 11 additions & 0 deletions core/src/main/java/org/fao/geonet/util/XslUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,17 @@ public static String getNodeLogo(String key) {
return source.isPresent() ? source.get().getLogo() : "";
}

public static String getDiscoveryServiceUuid(String key) {
Optional<Source> source = getSource(key);
if (source.isPresent() && source.get().getType() == SourceType.subportal) {
return source.get().getServiceRecord();
} else {
SettingManager settingsMan = ApplicationContextHolder.get().getBean(SettingManager.class);
String uuid = settingsMan.getValue(SYSTEM_CSW_CAPABILITY_RECORD_UUID);
return "-1".equals(uuid) ? "" : uuid;
}
}

private static Optional<Source> getSource(String idOrUuid) {
SettingManager settingsMan = ApplicationContextHolder.get().getBean(SettingManager.class);
if (StringUtils.isEmpty(idOrUuid)) {
Expand Down
11 changes: 1 addition & 10 deletions core/src/main/java/org/fao/geonet/web/XFrameOptionsFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,7 @@ public void init(FilterConfig filterConfig) throws ServletException {
"XFrameOptions filter url parameter is missing for mode ALLOW-FROM. Setting mode to DENY.");
mode = MODE_DENY;
} else {
try {
URL urlValue = new URL(url);
domain = urlValue.getHost() +
((urlValue.getPort() == -1) ? "" : ":" + urlValue.getPort());

} catch (MalformedURLException ex) {
Log.info(Geonet.GEONETWORK, String.format(
"XFrameOptions filter url parameter (%s) is not valid for mode ALLOW-FROM. Setting mode to DENY.", url));
mode = MODE_DENY;
}
domain = url;
}
}

Expand Down
46 changes: 18 additions & 28 deletions core/src/test/java/org/fao/geonet/GeonetTestFixture.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import org.fao.geonet.utils.IO;
import org.fao.geonet.utils.TransformerFactoryFactory;
import org.fao.geonet.utils.Xml;
import org.geotools.data.DataStore;
import org.jdom.Element;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -68,14 +67,21 @@ public class GeonetTestFixture {
private volatile static FileSystemPool.CreatedFs templateFs;
private volatile static SchemaManager templateSchemaManager;
@Autowired
private EsSearchManager templateSearchManager;
@Autowired
protected DataStore dataStore;
private EsSearchManager esSearchManager;
@Autowired
private ConfigurableApplicationContext _applicationContext;
@Autowired
private IsoLanguagesMapper isoLanguagesMapper;

@Autowired
private GeonetworkDataDirectory geonetworkDataDirectory;
@Autowired
private ThesaurusManager thesaurusManager;
@Autowired
private DataManager dataManager;
@Autowired
private DataSource dataSource;
@Autowired
private SettingManager settingManager;
private FileSystemPool.CreatedFs currentFs;


Expand Down Expand Up @@ -111,17 +117,15 @@ public boolean accept(Path entry) throws IOException {
}
});


Path schemaPluginsDir = templateDataDirectory.resolve("config/schema_plugins");
deploySchema(webappDir, schemaPluginsDir);

final GeonetworkDataDirectory geonetworkDataDirectory = _applicationContext.getBean(GeonetworkDataDirectory.class);
final ServiceConfig serviceConfig = new ServiceConfig(Lists.<Element>newArrayList());
final ServiceConfig serviceConfig = new ServiceConfig(Lists.newArrayList());
geonetworkDataDirectory.init("geonetwork", webappDir, templateDataDirectory, serviceConfig, null);
test.addTestSpecificData(geonetworkDataDirectory);

// Create ES index
_applicationContext.getBean(EsSearchManager.class).init(false, Optional.empty());
esSearchManager.init(true, Optional.empty());

templateSchemaManager = initSchemaManager(webappDir, geonetworkDataDirectory);

Expand All @@ -130,7 +134,7 @@ public boolean accept(Path entry) throws IOException {
isoLanguagesMapper.reinit();
}

final String fsName = test.getClass().getSimpleName().replaceAll("[^a-z0-9A-Z]", "") + UUID.randomUUID().toString();
final String fsName = test.getClass().getSimpleName().replaceAll("[^a-z0-9A-Z]", "") + UUID.randomUUID();
currentFs = FILE_SYSTEM_POOL.get(fsName);

assertTrue(Files.isDirectory(currentFs.dataDir.resolve("config")));
Expand All @@ -142,35 +146,21 @@ public boolean accept(Path entry) throws IOException {
final GeonetworkDataDirectory dataDir = configureDataDir(test, webappDir, currentFs.dataDir);
configureNewSchemaManager(dataDir, webappDir);

// TODO: I don't know why but this corrupts other tests that will fail depending on the run order:
// assertCorrectDataDir();
// for example, running GeonetworkDataDirectoryMultiNodeServiceConfigOnlySystemDataDirSetTest, then
// GeonetworkDataDirectoryMultiNodeSystemPropertyOnlySystemDataDirSetTest with that line enabled, the second fails.

// if (test.resetLuceneIndex()) {
// _directoryFactory.resetIndex();
// }

ServiceContext serviceContext = test.createServiceContext();

ApplicationContextHolder.set(_applicationContext);
serviceContext.setAsThreadLocal();
// TODOES
// _applicationContext.getBean(EsSearchManager.class).initNonStaticData(100);
_applicationContext.getBean(DataManager.class).init(serviceContext, false);
_applicationContext.getBean(ThesaurusManager.class).init(true, serviceContext, "WEB-INF/data/config/codelist");

dataManager.init(serviceContext, false);
thesaurusManager.init(true, serviceContext, "WEB-INF/data/config/codelist");

addSourceUUID(dataDir);

final DataSource dataSource = _applicationContext.getBean(DataSource.class);
try (Connection conn = dataSource.getConnection()) {
ThreadUtils.init(conn.getMetaData().getURL(), _applicationContext.getBean(SettingManager.class));
ThreadUtils.init(conn.getMetaData().getURL(), settingManager);
}

}


protected void configureNewSchemaManager(GeonetworkDataDirectory dataDir, Path webappDir) throws Exception {
final SchemaManager schemaManager = _applicationContext.getBean(SchemaManager.class);
schemaManager.configureFrom(templateSchemaManager, webappDir, dataDir);
Expand All @@ -179,7 +169,7 @@ protected void configureNewSchemaManager(GeonetworkDataDirectory dataDir, Path w

protected void addSourceUUID(GeonetworkDataDirectory dataDirectory) {
String siteUuid = dataDirectory.getSystemDataDir().getFileName().toString();
_applicationContext.getBean(SettingManager.class).setSiteUuid(siteUuid);
settingManager.setSiteUuid(siteUuid);
final SourceRepository sourceRepository = _applicationContext.getBean(SourceRepository.class);
List<Source> sources = sourceRepository.findAll();
if (sources.isEmpty()) {
Expand Down
Loading
Loading