Skip to content

Commit

Permalink
Merge branch 'main' into 44-doi-servers
Browse files Browse the repository at this point in the history
  • Loading branch information
fxprunayre authored Sep 23, 2024
2 parents 0f117f7 + 8436990 commit 680eb2a
Show file tree
Hide file tree
Showing 189 changed files with 3,725 additions and 1,284 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
show-progress: 'false'

- name: Setup Java JDK
uses: actions/setup-java@v4.1.0
uses: actions/setup-java@v4.2.1
with:
java-version: 11
# Java distribution. See the list of supported distributions in README file
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
submodules: 'recursive'
show-progress: 'false'
- name: Set up JDK
uses: actions/setup-java@v4.1.0
uses: actions/setup-java@v4.2.1
with:
distribution: 'temurin'
java-version: ${{ matrix.jdk }}
Expand Down Expand Up @@ -55,7 +55,7 @@ jobs:
submodules: 'recursive'
show-progress: 'false'
- name: Set up JDK
uses: actions/setup-java@v4.1.0
uses: actions/setup-java@v4.2.1
with:
distribution: 'temurin'
java-version: 11
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mvn-dep-tree.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
show-progress: 'false'

- name: Setup Java JDK
uses: actions/setup-java@v4.1.0
uses: actions/setup-java@v4.2.1
with:
java-version: 11
# Java distribution. See the list of supported distributions in README file
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/sonarcloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
submodules: 'recursive'
show-progress: 'false'
- name: Set up JDK 11
uses: actions/setup-java@v4.1.0
uses: actions/setup-java@v4.2.1
with:
distribution: 'temurin'
java-version: '11'
Expand All @@ -34,7 +34,7 @@ jobs:
run: mvn -B package -DskipTests

- name: Set up JDK 21 # Sonarcloud analyzer needs at least JDK 17
uses: actions/setup-java@v4.1.0
uses: actions/setup-java@v4.2.1
with:
distribution: 'temurin'
java-version: '21'
Expand Down
6 changes: 1 addition & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ web/src/main/webapp/META-INF/MANIFEST.MF
web/src/main/webapp/WEB-INF/data/0*
web/src/main/webapp/WEB-INF/data/config/encryptor.properties
web/src/main/webapp/WEB-INF/data/config/index/records.json
web/src/main/webapp/WEB-INF/data/config/schema_plugins/*/schematron/schematron*.xsl
web/src/main/webapp/WEB-INF/data/config/schema_plugins/csw-record
web/src/main/webapp/WEB-INF/data/config/schema_plugins/dublin-core
web/src/main/webapp/WEB-INF/data/config/schema_plugins/iso19*
web/src/main/webapp/WEB-INF/data/config/schema_plugins/schemaplugin-uri-catalog.xml
web/src/main/webapp/WEB-INF/data/config/schema_plugins/*
web/src/main/webapp/WEB-INF/data/config/schemaplugin-uri-catalog.xml
web/src/main/webapp/WEB-INF/data/data/backup
web/src/main/webapp/WEB-INF/data/data/metadata_data
Expand Down
88 changes: 88 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: GeoNetwork opensource
message: >-
If you use this software, please cite it using the
metadata from this file.
type: software
authors:
- given-names: François
family-names: Prunayre
affiliation: Titellus
- given-names: Jose
family-names: García
affiliation: GeoCat BV
- given-names: Jeroen
family-names: Ticheler
affiliation: GeoCat BV
orcid: 'https://orcid.org/0009-0003-3896-0437'
email: [email protected]
- given-names: Florent
family-names: Gravin
affiliation: CamptoCamp
- given-names: Simon
family-names: Pigot
affiliation: CSIRO Australia
- name: GeoCat BV
address: Veenderweg 13
city: Bennekom
country: NL
post-code: 6721 WD
tel: +31 (0) 318 416 664
website: 'https://www.geocat.net/'
email: [email protected]
- name: Titellus
address: 321 Route de la Mollière
city: Saint Pierre de Genebroz
country: FR
post-code: 73360
website: 'https://titellus.net/'
email: [email protected]
- name: CamptoCamp
address: QG Center Rte de la Chaux 4
city: Bussigny
country: CH
post-code: 1030
tel: +41 (21) 619 10 10
website: 'https://camptocamp.com/'
email: [email protected]
- name: Open Source Geospatial Foundation - OSGeo
address: '9450 SW Gemini Dr. #42523'
location: Beaverton
region: Oregon
post-code: '97008'
country: US
email: [email protected]
website: 'https://www.osgeo.org/'
repository-code: 'http://github.com/geonetwork/core-geonetwork'
url: 'https://geonetwork-opensource.org'
repository-artifact: >-
https://sourceforge.net/projects/geonetwork/files/GeoNetwork_opensource/
abstract: >-
GeoNetwork is a catalog application to manage spatial and
non-spatial resources. It is compliant with critical
international standards from ISO, OGC and INSPIRE. It
provides powerful metadata editing and search functions as
well as an interactive web map viewer.
keywords:
- catalog
- gis
- sdi
- spatial data infrastructure
- dataspace
- search
- open data
- standards
- spatial
- CSW
- OGCAPI Records
- DCAT
- GeoDCAT-AP
- Catalog Service
- OGC
- open geospatial consortium
- osgeo
- open source geospatial foundation
license: GPL-2.0
10 changes: 5 additions & 5 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ Each GeoNetwork release is supported with bug fixes for a limited period, with p
- We recommend to update to latest incremental release as soon as possible to address security vulnerabilities.
- Some overlap is provided when major versions are announced with both a current version and a maintenance version being made available to provide time for organizations to upgrade.

| Version | Supported | Comment |
|---------|--------------------|---------------------|
| 4.4.x | :white_check_mark: | Latest version |
| 4.2.x | :white_check_mark: | Stable version |
| 3.12.x | :white_check_mark: | Maintenance version |
| Version | Supported | Comment |
|---------|--------------------|---------------------------------------------|
| 4.4.x | :white_check_mark: | Latest version |
| 4.2.x | :white_check_mark: | Stable version |
| 3.12.x | | End Of Life 2024-03-31 |

If your organisation is making use of a GeoNetwork version that is no longer in use by the community all is not lost. You can volunteer on the developer list to make additional releases, or engage with one of our [Commercial Support](https://www.osgeo.org/service-providers/?p=geonetwork) providers.

Expand Down
10 changes: 5 additions & 5 deletions add-schema.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ then
${insertLine} a\\
\ <dependency>\\
\ <groupId>org.geonetwork-opensource.schemas</groupId>\\
\ <artifactId>schema-${schema}</artifactId>\\
\ <artifactId>gn-schema-${schema}</artifactId>\\
\ <version>${gnSchemasVersion}</version>\\
\ </dependency>
SED_SCRIPT
Expand All @@ -103,7 +103,7 @@ SED_SCRIPT
\ <dependencies>\\
\ <dependency>\\
\ <groupId>org.geonetwork-opensource.schemas</groupId>\\
\ <artifactId>schema-${schema}</artifactId>\\
\ <artifactId>gn-schema-${schema}</artifactId>\\
\ <version>${gnSchemasVersion}</version>\\
\ </dependency>\\
\ </dependencies>\\
Expand All @@ -121,7 +121,7 @@ SED_SCRIPT
\ <artifactItems>\\
\ <artifactItem>\\
\ <groupId>org.geonetwork-opensource.schemas</groupId>\\
\ <artifactId>schema-${schema}</artifactId>\\
\ <artifactId>gn-schema-${schema}</artifactId>\\
\ <type>zip</type>\\
\ <overWrite>false</overWrite>\\
\ <outputDirectory>\$\{schema-plugins.dir\}</outputDirectory>\\
Expand All @@ -138,7 +138,7 @@ SED_SCRIPT
fi

# Add schema resources in service/pom.xml with test scope for unit tests
line=$(grep -n "<artifactId>schema-${schema}</artifactId>" services/pom.xml | cut -d: -f1)
line=$(grep -n "<artifactId>gn-schema-${schema}</artifactId>" services/pom.xml | cut -d: -f1)

if [ ! $line ]
then
Expand All @@ -154,7 +154,7 @@ then
${finalLine} a\\
\ <dependency>\\
\ <groupId>${projectGroupId}</groupId>\\
\ <artifactId>schema-${schema}</artifactId>\\
\ <artifactId>gn-schema-${schema}</artifactId>\\
\ <version>${gnSchemasVersion}</version>\\
\ <scope>test</scope>\\
\ </dependency>
Expand Down
6 changes: 3 additions & 3 deletions common/src/main/java/org/fao/geonet/utils/XmlRequest.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2001-2016 Food and Agriculture Organization of the
* Copyright (C) 2001-2024 Food and Agriculture Organization of the
* United Nations (FAO-UN), United Nations World Food Programme (WFP)
* and United Nations Environment Programme (UNEP)
*
Expand Down Expand Up @@ -124,13 +124,13 @@ protected final Element executeAndReadResponse(HttpRequestBase httpMethod) throw
" -- Response Code: " + httpResponse.getRawStatusCode());
}

byte[] data = null;
byte[] data;

try {
data = IOUtils.toByteArray(httpResponse.getBody());
return Xml.loadStream(new ByteArrayInputStream(data));
} catch (JDOMException e) {
throw new BadXmlResponseEx("Response: '" + new String(data, "UTF8") + "' (from URI " + httpMethod.getURI() + ")");
throw new BadXmlResponseEx("Invalid XML document from URI: " + httpMethod.getURI());
} finally {
httpMethod.releaseConnection();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ private Path getPath(ServiceContext context, int metadataId, MetadataResourceVis
public String delResources(ServiceContext context, int metadataId) throws Exception {
Path metadataDir = Lib.resource.getMetadataDir(getDataDirectory(context), metadataId);
try {
Log.info(Geonet.RESOURCES, String.format("Deleting all files from metadataId '%d'", metadataId));
IO.deleteFileOrDirectory(metadataDir, true);
return String.format("Metadata '%s' directory removed.", metadataId);
} catch (Exception e) {
Expand Down
31 changes: 18 additions & 13 deletions core/src/main/java/org/fao/geonet/kernel/EditLib.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,10 @@

import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.Vector;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.jxpath.ri.parser.Token;
Expand Down Expand Up @@ -272,7 +264,7 @@ private void addChildToParent(MetadataSchema mdSchema, Element targetElement, El
// remove everything and then, depending on removeExisting
// readd all children to the element and assure a correct position for the new one: at the end of the others
// or just add the new one
List existingAllType = new ArrayList(targetElement.getChildren());
List<Element> existingAllType = new ArrayList(targetElement.getChildren());
targetElement.removeContent();
for (String singleType: type.getAlElements()) {
List<Element> existingForThisType = filterOnQname(existingAllType, singleType);
Expand All @@ -283,9 +275,22 @@ private void addChildToParent(MetadataSchema mdSchema, Element targetElement, El
LOGGER_ADD_ELEMENT.debug("#### - add child {}", existingChild.toString());
}
}
if (qname.equals(singleType))
if (qname.equals(singleType)) {
targetElement.addContent(childToAdd);
}

filterOnQname(existingAllType, "geonet:child")
.stream()
.filter(gnChild -> (gnChild.getAttributeValue("prefix") + ":" + gnChild.getAttributeValue("name")).equals(singleType))
.findFirst()
.ifPresent(targetElement::addContent);
}

Stream.concat(
filterOnQname(existingAllType, "geonet:element").stream(),
filterOnQname(existingAllType, "geonet:attribute").stream()
).forEach(targetElement::addContent);

}

public void addXMLFragments(String schema, Element md, Map<String, String> xmlInputs) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@
import jeeves.server.sources.http.JeevesServlet;
import org.fao.geonet.ApplicationContextHolder;
import org.fao.geonet.constants.Geonet;
import org.fao.geonet.exceptions.BadParameterEx;
import org.fao.geonet.utils.FilePathChecker;
import org.fao.geonet.utils.IO;
import org.fao.geonet.utils.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ConfigurableApplicationContext;
Expand Down Expand Up @@ -63,6 +66,9 @@ public class GeonetworkDataDirectory {
*/
public static final String GEONETWORK_BEAN_KEY = "GeonetworkDataDirectory";

@Autowired
SchemaManager schemaManager;

private Path webappDir;
private Path systemDataDir;
private Path indexConfigDir;
Expand Down Expand Up @@ -797,11 +803,18 @@ public Path getXsltConversion(String conversionId) {
if (conversionId.startsWith(IMPORT_STYLESHEETS_SCHEMA_PREFIX)) {
String[] pathToken = conversionId.split(":");
if (pathToken.length == 3) {
String schema = pathToken[1];
if (!schemaManager.existsSchema(schema)) {
throw new BadParameterEx(String.format(
"Conversion not found. Schema '%s' is not registered in this catalog.", schema));
}
FilePathChecker.verify(pathToken[2]);
return this.getSchemaPluginsDir()
.resolve(pathToken[1])
.resolve(pathToken[2] + ".xsl");
}
} else {
FilePathChecker.verify(conversionId);
return this.getWebappDir().resolve(Geonet.Path.IMPORT_STYLESHEETS).
resolve(conversionId + ".xsl");
}
Expand Down
Loading

0 comments on commit 680eb2a

Please sign in to comment.