Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into gn4-harvester
Browse files Browse the repository at this point in the history
  • Loading branch information
josegar74 committed Nov 13, 2024
2 parents f5c229f + 6dbaa47 commit d09aa34
Show file tree
Hide file tree
Showing 478 changed files with 47,755 additions and 3,554 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 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
2 changes: 1 addition & 1 deletion cachingxslt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<parent>
<groupId>org.geonetwork-opensource</groupId>
<artifactId>geonetwork</artifactId>
<version>4.4.6-SNAPSHOT</version>
<version>4.4.7-SNAPSHOT</version>
</parent>


Expand Down
2 changes: 1 addition & 1 deletion common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<parent>
<groupId>org.geonetwork-opensource</groupId>
<artifactId>geonetwork</artifactId>
<version>4.4.6-SNAPSHOT</version>
<version>4.4.7-SNAPSHOT</version>
</parent>


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
2 changes: 1 addition & 1 deletion core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<parent>
<artifactId>geonetwork</artifactId>
<groupId>org.geonetwork-opensource</groupId>
<version>4.4.6-SNAPSHOT</version>
<version>4.4.7-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* =============================================================================
* === Copyright (C) 2019 Food and Agriculture Organization of the
* === Copyright (C) 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 @@ -44,12 +44,16 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

public abstract class AbstractStore implements Store {
protected static final String RESOURCE_MANAGEMENT_EXTERNAL_PROPERTIES_SEPARATOR = ":";
protected static final String RESOURCE_MANAGEMENT_EXTERNAL_PROPERTIES_ESCAPED_SEPARATOR = "\\:";

@Override
public final List<MetadataResource> getResources(final ServiceContext context, final String metadataUuid, final Sort sort,
final String filter) throws Exception {
Expand Down Expand Up @@ -279,4 +283,28 @@ public String toString() {
}
};
}

private String escapeResourceManagementExternalProperties(String value) {
return value.replace(RESOURCE_MANAGEMENT_EXTERNAL_PROPERTIES_SEPARATOR, RESOURCE_MANAGEMENT_EXTERNAL_PROPERTIES_ESCAPED_SEPARATOR);
}

/**
* Create an encoded base 64 object id contains the following fields to uniquely identify the resource
* The fields are separated by a colon ":"
* @param type to identify type of storage - document/folder
* @param visibility of the resource public/private
* @param metadataId internal metadata id
* @param version identifier which can be used to directly get this version.
* @param resourceId or filename of the resource
* @return based 64 object id
*/
protected String getResourceManagementExternalPropertiesObjectId(final String type, final MetadataResourceVisibility visibility, final Integer metadataId, final String version,
final String resourceId) {
return Base64.getEncoder().encodeToString(
((type + RESOURCE_MANAGEMENT_EXTERNAL_PROPERTIES_SEPARATOR +
escapeResourceManagementExternalProperties(visibility == null ? "" : visibility.toString().toLowerCase()) + RESOURCE_MANAGEMENT_EXTERNAL_PROPERTIES_SEPARATOR +
metadataId + RESOURCE_MANAGEMENT_EXTERNAL_PROPERTIES_SEPARATOR +
escapeResourceManagementExternalProperties(version == null ? "" : version) + RESOURCE_MANAGEMENT_EXTERNAL_PROPERTIES_SEPARATOR +
escapeResourceManagementExternalProperties(resourceId)).getBytes()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -232,34 +232,45 @@ 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);
Log.info(Geonet.RESOURCES,
String.format("Metadata '%d' directory removed.", metadataId));
return String.format("Metadata '%d' directory removed.", metadataId);
} catch (Exception e) {
return String.format("Unable to remove metadata '%s' directory.", metadataId);
return String.format("Unable to remove metadata '%d' directory.", metadataId);
}
}

@Override
public String delResource(ServiceContext context, String metadataUuid, String resourceId, Boolean approved) throws Exception {
canEdit(context, metadataUuid, approved);
int metadataId = canEdit(context, metadataUuid, approved);

try (ResourceHolder filePath = getResource(context, metadataUuid, resourceId, approved)) {
Files.deleteIfExists(filePath.getPath());
return String.format("MetadataResource '%s' removed.", resourceId);
Log.info(Geonet.RESOURCES,
String.format("Resource '%s' removed for metadata %d (%s).", resourceId, metadataId, metadataUuid));
return String.format("Metadata resource '%s' removed.", resourceId);
} catch (IOException e) {
Log.warning(Geonet.RESOURCES,
String.format("Unable to remove resource '%s' for metadata %d (%s). %s", resourceId, metadataId, metadataUuid, e.getMessage()));
return String.format("Unable to remove resource '%s'.", resourceId);
}
}

@Override
public String delResource(final ServiceContext context, final String metadataUuid, final MetadataResourceVisibility visibility,
final String resourceId, Boolean approved) throws Exception {
canEdit(context, metadataUuid, approved);
int metadataId = canEdit(context, metadataUuid, approved);

try (ResourceHolder filePath = getResource(context, metadataUuid, visibility, resourceId, approved)) {
Files.deleteIfExists(filePath.getPath());
return String.format("MetadataResource '%s' removed.", resourceId);
Log.info(Geonet.RESOURCES,
String.format("Resource '%s' removed for metadata %d (%s).", resourceId, metadataId, metadataUuid));
return String.format("Metadata resource '%s' removed.", resourceId);
} catch (IOException e) {
Log.warning(Geonet.RESOURCES,
String.format("Unable to remove resource '%s' for metadata %d (%s). %s", resourceId, metadataId, metadataUuid, e.getMessage()));
return String.format("Unable to remove resource '%s'.", resourceId);
}
}
Expand Down
Loading

0 comments on commit d09aa34

Please sign in to comment.