Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into 44-translationprovide…
Browse files Browse the repository at this point in the history
…rs-sql
  • Loading branch information
fxprunayre committed Jun 3, 2024
2 parents 71b4ebd + e98fa93 commit 25ef12f
Show file tree
Hide file tree
Showing 656 changed files with 31,720 additions and 17,431 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ jobs:
if: ${{ github.event_name == 'pull_request' }}
working-directory: docs/manual
run: |
mike deploy --title "4.4 Latest" --alias-type=copy --update-aliases 4.4 latest
mike deploy --title "4.4" --alias-type=copy --update-aliases 4.4 latest
- name: deploy latest docs to gh-pages branch
if: ${{ github.event_name != 'pull_request' }}
working-directory: docs/manual
run: |
mike deploy --push --title "4.4 Latest" --alias-type=copy --update-aliases 4.4 latest
mike deploy --push --title "4.4" --alias-type=copy --update-aliases 4.4 latest
4 changes: 2 additions & 2 deletions .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.6.3
maven-version: 3.8.3
- name: Build with Maven
run: |
mvn -B -ntp -V install -DskipTests=true -Dmaven.javadoc.skip=true -Drelease -Pwith-doc
Expand All @@ -63,7 +63,7 @@ jobs:
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.6.3
maven-version: 3.8.3
- name: Test with maven
run: |
mvn -B resources:resources@copy-index-schema-to-source -f web
Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ release/jetty/*
schemas/*/doc/*/*.rst
schematrons/.build
target/

# build and release
transifex/transifex-format/
build/
web-ui/LICENSE
web-ui/tx

# web-app, clear using: mvn -f web/pom.xml clean:clean@reset

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@

[![Build Status](https://github.com/geonetwork/core-geonetwork/actions/workflows/linux.yml/badge.svg?branch=main)](https://github.com/geonetwork/core-geonetwork/actions/workflows/linux.yml?query=branch%3Amain)

## Open Source Security Foundation (OpenSSF) best practices status
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8626/badge)](https://www.bestpractices.dev/projects/8626)

## Features

* Immediate search access to local and distributed geospatial catalogues
Expand All @@ -33,3 +30,6 @@ Developer documentation located in ``README.md`` files in the code-base:
* General documentation for the project as a whole is in this [README.md](README.md)
* [Software Development Documentation](/software_development/) provides instructions for setting up a development environment, building GeoNetwork, compiling user documentation, and making a releases.
* Module specific documentation can be found in each module:

## Open Source Security Foundation (OpenSSF) best practices status
[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8626/badge)](https://www.bestpractices.dev/projects/8626)
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.3-SNAPSHOT</version>
<version>4.4.5-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.3-SNAPSHOT</version>
<version>4.4.5-SNAPSHOT</version>
</parent>


Expand Down
62 changes: 16 additions & 46 deletions common/src/main/java/org/fao/geonet/utils/Xml.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,7 @@
import org.fao.geonet.utils.nio.NioPathAwareEntityResolver;
import org.fao.geonet.utils.nio.NioPathHolder;
import org.fao.geonet.utils.nio.PathStreamSource;
import org.jdom.Attribute;
import org.jdom.Content;
import org.jdom.DocType;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.Namespace;
import org.jdom.Text;
import org.jdom.*;
import org.jdom.filter.ElementFilter;
import org.jdom.input.SAXBuilder;
import org.jdom.output.Format;
Expand All @@ -64,27 +57,14 @@
import javax.xml.XMLConstants;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.URIResolver;
import javax.xml.transform.*;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.ValidatorHandler;
import java.io.BufferedOutputStream;
import java.io.ByteArrayInputStream;
import java.io.DataInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.StringReader;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URI;
import java.net.URISyntaxException;
Expand All @@ -99,14 +79,7 @@
import java.nio.file.Files;
import java.nio.file.NoSuchFileException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -403,22 +376,16 @@ public static Element transform(Element xml, Path styleSheetPath, Map<String, Ob
/**
* Transforms an xml tree putting the result to a stream (uses a stylesheet on disk).
*/
public static void transform(Element xml, Path styleSheetPath, OutputStream out) throws Exception {
public static void transform(Element xml, Path styleSheetPath, Map<String, Object> params, OutputStream out) throws Exception {
StreamResult resStream = new StreamResult(out);
transform(xml, styleSheetPath, resStream, null);
transform(xml, styleSheetPath, resStream, params);
out.flush();
}


public static void transformXml(Element xml, Path styleSheetPath, OutputStream out) throws Exception {
StreamResult resStream = new StreamResult(out);
Map<String, Object> map = new HashMap<>();
map.put("geonet-force-xml", "xml");
transform(xml, styleSheetPath, resStream, map);
out.flush();
public static void transform(Element xml, Path styleSheetPath, OutputStream out) throws Exception {
transform(xml, styleSheetPath, new HashMap<>(), out);
}

//--------------------------------------------------------------------------

/**
* Transforms an xml tree putting the result to a stream - no parameters.
Expand Down Expand Up @@ -484,6 +451,9 @@ protected static Path resolvePath(Source s) throws URISyntaxException {

/**
* Transforms an xml tree putting the result to a stream with optional parameters.
* <p>
* Add a geonet-force-xml parameter to force the formatting to be xml.
* The preferred method is to define it using xsl:output.
*/
public static void
transform(Element xml, Path styleSheetPath, Result result, Map<String, Object> params) throws Exception {
Expand Down Expand Up @@ -515,13 +485,13 @@ protected static Path resolvePath(Source s) throws URISyntaxException {
t.setParameter(param.getKey(), param.getValue());
}

if (params.containsKey("geonet-force-xml")) {
((Controller) t).setOutputProperty("indent", "yes");
((Controller) t).setOutputProperty("method", "xml");
((Controller) t).setOutputProperty("{http://saxon.sf.net/}indent-spaces", "3");
if (params.containsKey("geonet-force-xml")) {
((Controller) t).setOutputProperty("indent", "yes");
((Controller) t).setOutputProperty("method", "xml");
((Controller) t).setOutputProperty("{http://saxon.sf.net/}indent-spaces", "2");
}
}

}
t.transform(srcXml, result);
}
}
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.3-SNAPSHOT</version>
<version>4.4.5-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
5 changes: 2 additions & 3 deletions core/src/main/java/org/fao/geonet/kernel/SchemaManager.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2001-2023 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 @@ -1383,7 +1383,6 @@ private void checkAppSupported(Element schemaPluginCatRoot) throws Exception {
" requires max Geonetwork version: " + majorAppVersionSupported + ", current is: " +
version + ". Skip load schema.");
removes.add(schemaInfo.getKey());
continue;
}
}

Expand Down Expand Up @@ -1901,7 +1900,7 @@ public boolean accept(Path entry) throws IOException {
try (DirectoryStream<Path> schemaplugins = Files.newDirectoryStream(schemaPluginDir, xsdFilter)) {
boolean missingXsdFiles = true;
for (Path schemaplugin : schemaplugins) {
IO.copyDirectoryOrFile(schemaplugin, webAppDirSchemaXSD.resolve(schemaplugin), false);
IO.copyDirectoryOrFile(schemaplugin, webAppDirSchemaXSD.resolve(schemaplugin.getFileName()), false);
missingXsdFiles = false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,14 @@ public interface IMetadataStatus {
MetadataStatus setStatusExt(ServiceContext context, int id, int status, ISODate changeDate, String changeMessage) throws Exception;

/**
* Set status of metadata id and do not reindex metadata id afterwards.
* Set status of metadata id and reindex metadata id afterwards based on updateIndex flag
*
* @param status metadata status to set
* @param updateIndex index update flag
*
* @return the saved status entity object
*/
MetadataStatus setStatusExt(MetadataStatus status) throws Exception;
MetadataStatus setStatusExt(MetadataStatus status, boolean updateIndex) throws Exception;

/**
* Set status of metadata id and reindex metadata id afterwards.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,11 @@ public MetadataStatus setStatus(ServiceContext context, int id, int status, ISOD
}

@Override
public MetadataStatus setStatusExt(MetadataStatus metatatStatus) throws Exception {
public MetadataStatus setStatusExt(MetadataStatus metatatStatus, boolean updateIndex) throws Exception {
metadataStatusRepository.save(metatatStatus);
metadataIndexer.indexMetadata(metatatStatus.getMetadataId() + "", true, IndexingMode.full);
if (updateIndex) {
metadataIndexer.indexMetadata(metatatStatus.getMetadataId() + "", true, IndexingMode.full);
}
return metatatStatus;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ protected String createDraft(ServiceContext context, String templateId, String g

List<MetadataStatus> listOfStatusChange = new ArrayList<>(1);
listOfStatusChange.add(metadataStatus);
sa.onStatusChange(listOfStatusChange);
sa.onStatusChange(listOfStatusChange, true);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public void onEdit(int id, boolean minorEdit) throws Exception {
* @return
* @throws Exception
*/
public Map<Integer, StatusChangeType> onStatusChange(List<MetadataStatus> listOfStatus) throws Exception {
public Map<Integer, StatusChangeType> onStatusChange(List<MetadataStatus> listOfStatus, boolean updateIndex) throws Exception {

if (listOfStatus.stream().map(MetadataStatus::getMetadataId).distinct().count() != listOfStatus.size()) {
throw new IllegalArgumentException("Multiple status update received on the same metadata");
Expand Down Expand Up @@ -179,16 +179,7 @@ public Map<Integer, StatusChangeType> onStatusChange(List<MetadataStatus> listOf
context.debug("Change status of metadata with id " + status.getMetadataId() + " from " + currentStatusId + " to " + statusId);

// we know we are allowed to do the change, apply any side effects
boolean deleted = applyStatusChange(status.getMetadataId(), status, statusId);

// inform content reviewers if the status is submitted
try {
notify(getUserToNotify(status), status);
} catch (Exception e) {
context.warning(String.format(
"Failed to send notification on status change for metadata %s with status %s. Error is: %s",
status.getMetadataId(), status.getStatusValue().getId(), e.getMessage()));
}
boolean deleted = applyStatusChange(status.getMetadataId(), status, statusId, updateIndex);

if (deleted) {
results.put(status.getMetadataId(), StatusChangeType.DELETED);
Expand All @@ -208,6 +199,15 @@ public Map<Integer, StatusChangeType> onStatusChange(List<MetadataStatus> listOf
}
}

// inform content reviewers if the status is submitted
try {
notify(getUserToNotify(status), status);
} catch (Exception e) {
context.warning(String.format(
"Failed to send notification on status change for metadata %s with status %s. Error is: %s",
status.getMetadataId(), status.getStatusValue().getId(), e.getMessage()));
}

}

return results;
Expand All @@ -218,10 +218,10 @@ public Map<Integer, StatusChangeType> onStatusChange(List<MetadataStatus> listOf
* eg. if APPROVED, publish a record,
* if RETIRED, unpublish or delete the record.
*/
private boolean applyStatusChange(int metadataId, MetadataStatus status, String toStatusId) throws Exception {
private boolean applyStatusChange(int metadataId, MetadataStatus status, String toStatusId, boolean updateIndex) throws Exception {
boolean deleted = false;
if (!deleted) {
metadataStatusManager.setStatusExt(status);
metadataStatusManager.setStatusExt(status, updateIndex);
}
return deleted;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ public interface StatusActions {

public void onEdit(int id, boolean minorEdit) throws Exception;

public Map<Integer, StatusChangeType> onStatusChange(List<MetadataStatus> status) throws Exception;
public Map<Integer, StatusChangeType> onStatusChange(List<MetadataStatus> status, boolean updateIndex) throws Exception;

}
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,7 @@ private void checkIndexResponse(BulkResponse bulkItemResponses,
static {
arrayFields = ImmutableSet.<String>builder()
.add(Geonet.IndexFieldNames.RECORDLINK)
.add("geom")
.add("topic")
.add("cat")
.add("keyword")
Expand Down Expand Up @@ -664,14 +665,7 @@ public ObjectNode documentToJson(Element xml) {
|| propertyName.endsWith("DateForResource")
|| propertyName.startsWith("cl_");

if (name.equals("geom")) {
try {
doc.set("geom", mapper.readTree(nodeElements.get(0).getTextNormalize()));
} catch (IOException e) {
LOGGER.error("Parsing invalid geometry for JSON node {}. Error is: {}",
nodeElements.get(0).getTextNormalize(), e.getMessage());
}
} else if (isArray) {
if (isArray) {
ArrayNode arrayNode = doc.putArray(propertyName);
for (Element node : nodeElements) {
if (isObject) {
Expand Down Expand Up @@ -817,8 +811,8 @@ public SearchResponse query(JsonNode jsonRequest, Set<String> includedFields,
return client.query(defaultIndex, jsonRequest, null, includedFields, from, size);
}

public Map<String, String> getFieldsValues(String id, Set<String> fields) throws IOException {
return client.getFieldsValues(defaultIndex, id, fields);
public Map<String, String> getFieldsValues(String id, Set<String> fields, String language) throws Exception {
return client.getFieldsValues(defaultIndex, id, fields, language);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
import org.springframework.security.oauth2.core.user.DefaultOAuth2User;
import org.springframework.security.oauth2.core.user.OAuth2User;
import org.springframework.security.oauth2.jwt.Jwt;
import org.springframework.security.oauth2.server.resource.BearerTokenAuthenticationToken;
import org.springframework.security.oauth2.server.resource.authentication.BearerTokenAuthenticationToken;
import org.springframework.security.oauth2.server.resource.BearerTokenError;
import org.springframework.security.oauth2.server.resource.BearerTokenErrorCodes;
import org.springframework.security.oauth2.server.resource.authentication.JwtAuthenticationConverter;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,13 @@
*/
public class UserInfoCache {

static Object lockobj = new Object();
static final Object lockobj = new Object();
Map<String, UserInfoCacheItem> cache = new HashMap<>();

public UserInfoCacheItem getItem(String accessKey) {
synchronized (lockobj) {
if (!cache.containsKey(accessKey))
return null;
UserInfoCacheItem item = cache.get(accessKey);
if (item.isExpired()) {
cache.remove(accessKey);
return null;
}
return item;
cache.entrySet().removeIf(e -> e.getValue().isExpired());
return cache.get(accessKey);
}
}

Expand Down
Loading

0 comments on commit 25ef12f

Please sign in to comment.