diff --git a/schemas/iso19139/src/main/plugin/iso19139/index-fields/index.xsl b/schemas/iso19139/src/main/plugin/iso19139/index-fields/index.xsl
index 090ca87e747..bbc4c321f47 100644
--- a/schemas/iso19139/src/main/plugin/iso19139/index-fields/index.xsl
+++ b/schemas/iso19139/src/main/plugin/iso19139/index-fields/index.xsl
@@ -29,7 +29,7 @@
xmlns:gco="http://www.isotc211.org/2005/gco"
xmlns:srv="http://www.isotc211.org/2005/srv"
xmlns:gml="http://www.opengis.net/gml/3.2"
- xmlns:gml31="http://www.opengis.net/gml"
+ xmlns:gml320="http://www.opengis.net/gml"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:gn-fn-index="http://geonetwork-opensource.org/xsl/functions/index"
xmlns:index="java:org.fao.geonet.kernel.search.EsSearchManager"
@@ -333,7 +333,7 @@
-
+
{
"code": "",
"codeSpace": "",
@@ -650,7 +650,7 @@
@@ -668,6 +668,10 @@
+
+
+
+
,-->
-
+
+ select="gml:beginPosition
+ |gml:begin/gml:TimeInstant/gml:timePosition
+ |gml320:beginPosition
+ |gml320:begin/gml320:TimeInstant/gml320:timePosition"/>
+ select="gml:endPosition
+ |gml:end/gml:TimeInstant/gml:timePosition
+ |gml320:endPosition
+ |gml320:end/gml320:TimeInstant/gml320:timePosition"/>
diff --git a/schemas/iso19139/src/main/plugin/iso19139/layout/layout-custom-fields-keywords.xsl b/schemas/iso19139/src/main/plugin/iso19139/layout/layout-custom-fields-keywords.xsl
index c16ed552ee5..80c82f1e00d 100644
--- a/schemas/iso19139/src/main/plugin/iso19139/layout/layout-custom-fields-keywords.xsl
+++ b/schemas/iso19139/src/main/plugin/iso19139/layout/layout-custom-fields-keywords.xsl
@@ -118,11 +118,12 @@
+
+ select="if ($thesaurusList/thesaurus[@key = substring-after($thesaurusIdentifier, 'geonetwork.thesaurus.')])
+ then $thesaurusList/thesaurus[@key = substring-after($thesaurusIdentifier, 'geonetwork.thesaurus.')]
+ else $listOfThesaurus/thesaurus[title = $thesaurusTitle]"/>
@@ -170,12 +171,18 @@
-
+
+
+ select="if ($thesaurusList/thesaurus[@key = $thesaurusKey])
+ then $thesaurusList/thesaurus[@key = $thesaurusKey]
+ else if ($listOfThesaurus/thesaurus[key = $thesaurusKey])
+ then $listOfThesaurus/thesaurus[key = $thesaurusKey]
+ else if ($listOfThesaurus/thesaurus[multilingualTitles/multilingualTitle/title = $thesaurusTitle])
+ then $listOfThesaurus/thesaurus[multilingualTitles/multilingualTitle/title = $thesaurusTitle]
+ else $listOfThesaurus/thesaurus[title = $thesaurusTitle]"/>
diff --git a/schemas/iso19139/src/main/plugin/iso19139/loc/ger/codelists.xml b/schemas/iso19139/src/main/plugin/iso19139/loc/ger/codelists.xml
index bb34ecdb566..a715df4a283 100644
--- a/schemas/iso19139/src/main/plugin/iso19139/loc/ger/codelists.xml
+++ b/schemas/iso19139/src/main/plugin/iso19139/loc/ger/codelists.xml
@@ -1452,7 +1452,7 @@
otherRestrictions
-
+
Andere Einschränkungen, die oben nicht aufgeführt sind
diff --git a/schemas/iso19139/src/main/plugin/iso19139/process/onlinesrc-add.xsl b/schemas/iso19139/src/main/plugin/iso19139/process/onlinesrc-add.xsl
index dafdcd1590b..6947108375b 100644
--- a/schemas/iso19139/src/main/plugin/iso19139/process/onlinesrc-add.xsl
+++ b/schemas/iso19139/src/main/plugin/iso19139/process/onlinesrc-add.xsl
@@ -518,7 +518,7 @@ Insert is made in first transferOptions found.
-
+
diff --git a/schemas/iso19139/src/main/plugin/iso19139/update-fixed-info-keywords.xsl b/schemas/iso19139/src/main/plugin/iso19139/update-fixed-info-keywords.xsl
index 6f8c837b513..6a0e9d630f3 100644
--- a/schemas/iso19139/src/main/plugin/iso19139/update-fixed-info-keywords.xsl
+++ b/schemas/iso19139/src/main/plugin/iso19139/update-fixed-info-keywords.xsl
@@ -250,6 +250,7 @@
getRecordPopularity(
AbstractMetadata metadata;
try {
metadata = ApiUtils.canViewRecord(metadataUuid, request);
+
+ // If the workflow is enabled, don't use the working copy to increase the popularity
+ if (metadata instanceof MetadataDraft) {
+ metadata = metadataRepository.findOneByUuid(metadataUuid);
+ }
} catch (ResourceNotFoundException e) {
Log.debug(API.LOG_MODULE_NAME, e.getMessage(), e);
throw e;
@@ -563,6 +571,11 @@ public ResponseEntity increaseRecordPopularity(
AbstractMetadata metadata;
try {
metadata = ApiUtils.canViewRecord(metadataUuid, request);
+
+ // If the workflow is enabled, don't use the working copy to increase the popularity
+ if (metadata instanceof MetadataDraft) {
+ metadata = metadataRepository.findOneByUuid(metadataUuid);
+ }
} catch (ResourceNotFoundException e) {
Log.debug(API.LOG_MODULE_NAME, e.getMessage(), e);
throw e;
@@ -570,9 +583,9 @@ public ResponseEntity increaseRecordPopularity(
Log.debug(API.LOG_MODULE_NAME, e.getMessage(), e);
throw new NotAllowedException(ApiParams.API_RESPONSE_NOT_ALLOWED_CAN_VIEW);
}
- ServiceContext context = ApiUtils.createServiceContext(request);
+ ServiceContext serviceContext = ApiUtils.createServiceContext(request);
- dataManager.increasePopularity(context, metadata.getId() + "");
+ dataManager.increasePopularity(serviceContext, metadata.getId() + "");
return new ResponseEntity<>(metadata.getDataInfo().getPopularity() + "",
HttpStatus.CREATED);
@@ -625,9 +638,9 @@ public RelatedResponse getAssociatedResources(
}
String language = languageUtils.getIso3langCode(request.getLocales());
- final ServiceContext context = ApiUtils.createServiceContext(request);
+ final ServiceContext serviceContext = ApiUtils.createServiceContext(request);
- return getAssociatedResources(language, context, md, type, start, rows);
+ return getAssociatedResources(language, serviceContext, md, type, start, rows);
}
@io.swagger.v3.oas.annotations.Operation(
@@ -694,7 +707,7 @@ public FeatureResponse getFeatureCatalog(
private boolean isIncludedAttributeTable(RelatedResponse.Fcat fcat) {
return fcat != null
&& fcat.getItem() != null
- && fcat.getItem().size() > 0
+ && !fcat.getItem().isEmpty()
&& fcat.getItem().get(0).getFeatureType() != null
&& fcat.getItem().get(0).getFeatureType().getAttributeTable() != null
&& fcat.getItem().get(0).getFeatureType().getAttributeTable().getElement() != null;
diff --git a/services/src/main/java/org/fao/geonet/api/records/MetadataIndexApi.java b/services/src/main/java/org/fao/geonet/api/records/MetadataIndexApi.java
index b84cf0c2005..57303c9be00 100644
--- a/services/src/main/java/org/fao/geonet/api/records/MetadataIndexApi.java
+++ b/services/src/main/java/org/fao/geonet/api/records/MetadataIndexApi.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001-2016 Food and Agriculture Organization of the
+ * 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)
*
@@ -36,6 +36,7 @@
import org.fao.geonet.api.ApiUtils;
import org.fao.geonet.kernel.DataManager;
import org.fao.geonet.kernel.SelectionManager;
+import org.fao.geonet.kernel.datamanager.IMetadataUtils;
import org.fao.geonet.kernel.search.index.BatchOpsMetadataReindexer;
import org.fao.geonet.kernel.setting.SettingManager;
import org.springframework.beans.factory.annotation.Autowired;
@@ -66,6 +67,9 @@ public class MetadataIndexApi {
@Autowired
SettingManager settingManager;
+ @Autowired
+ IMetadataUtils metadataUtils;
+
@io.swagger.v3.oas.annotations.Operation(
summary = "Index a set of records",
description = "Index a set of records provided either by a bucket or a list of uuids")
@@ -96,28 +100,19 @@ JSONObject index(
)
String bucket,
@Parameter(hidden = true)
- HttpSession httpSession,
- @Parameter(hidden = true)
- HttpServletRequest request
+ HttpSession httpSession
)
throws Exception {
- ServiceContext serviceContext = ApiUtils.createServiceContext(request);
UserSession session = ApiUtils.getUserSession(httpSession);
- SelectionManager selectionManager =
- SelectionManager.getManager(serviceContext.getUserSession());
-
Set records = ApiUtils.getUuidsParameterOrSelection(uuids, bucket, session);
Set ids = Sets.newHashSet();
int index = 0;
for (String uuid : records) {
try {
- final String metadataId = dataManager.getMetadataId(uuid);
- if (metadataId != null) {
- ids.add(Integer.valueOf(metadataId));
- }
+ metadataUtils.findAllByUuid(uuid).forEach(m -> ids.add(m.getId()));
} catch (Exception e) {
try {
ids.add(Integer.valueOf(uuid));
diff --git a/services/src/main/java/org/fao/geonet/api/records/MetadataSharingApi.java b/services/src/main/java/org/fao/geonet/api/records/MetadataSharingApi.java
index 7a4aab50c24..70f0872e85d 100644
--- a/services/src/main/java/org/fao/geonet/api/records/MetadataSharingApi.java
+++ b/services/src/main/java/org/fao/geonet/api/records/MetadataSharingApi.java
@@ -558,7 +558,8 @@ private void setOperations(
java.util.Optional allGroupOpsAfter =
privileges.stream().filter(p -> p.getGroup() == ReservedGroup.all.getId()).findFirst();
- boolean publishedAfter = allGroupOpsAfter.get().getOperations().get(ReservedOperation.view.name());
+ // If we cannot find it then default to before value so that it will fail the next condition.
+ boolean publishedAfter = allGroupOpsAfter.isPresent()?allGroupOpsAfter.get().getOperations().getOrDefault(ReservedOperation.view.name(), publishedBefore):publishedBefore;
if (publishedBefore != publishedAfter) {
MetadataPublicationNotificationInfo metadataNotificationInfo = new MetadataPublicationNotificationInfo();
@@ -1214,19 +1215,42 @@ private MetadataProcessingReport shareSelection(String[] uuids, String bucket, S
}
List privileges = sharing.getPrivileges();
+ List allGroupPrivileges = new ArrayList<>();
try {
- setOperations(sharing, dataManager, context, appContext, metadata, operationMap, privileges,
- ApiUtils.getUserSession(session).getUserIdAsInt(), skipAllReservedGroup, report, request,
- metadataListToNotifyPublication, notifyByEmail);
+ if (metadata instanceof MetadataDraft) {
+ // If the metadata is a working copy, publish privileges (ALL and INTRANET groups)
+ // should be applied to the approved version.
+ Metadata md = this.metadataRepository.findOneByUuid(metadata.getUuid());
+
+ if (md != null) {
+ setOperations(sharing, dataManager, context, appContext, md, operationMap, allGroupPrivileges,
+ ApiUtils.getUserSession(session).getUserIdAsInt(), skipAllReservedGroup, report, request,
+ metadataListToNotifyPublication, notifyByEmail);
+
+ report.incrementProcessedRecords();
+ listOfUpdatedRecords.add(String.valueOf(md.getId()));
+ } else {
+ setOperations(sharing, dataManager, context, appContext, metadata, operationMap, privileges,
+ ApiUtils.getUserSession(session).getUserIdAsInt(), skipAllReservedGroup, report, request,
+ metadataListToNotifyPublication, notifyByEmail);
+
+ report.incrementProcessedRecords();
+ listOfUpdatedRecords.add(String.valueOf(metadata.getId()));
+ }
+
+ } else {
+ setOperations(sharing, dataManager, context, appContext, metadata, operationMap, privileges,
+ ApiUtils.getUserSession(session).getUserIdAsInt(), skipAllReservedGroup, report, request,
+ metadataListToNotifyPublication, notifyByEmail);
+
+ report.incrementProcessedRecords();
+ listOfUpdatedRecords.add(String.valueOf(metadata.getId()));
+ }
} catch (NotAllowedException ex) {
report.addMetadataError(metadata, ex.getMessage());
report.incrementUnchangedRecords();
- continue;
}
-
- report.incrementProcessedRecords();
- listOfUpdatedRecords.add(String.valueOf(metadata.getId()));
}
}
diff --git a/services/src/main/java/org/fao/geonet/api/records/MetadataTagApi.java b/services/src/main/java/org/fao/geonet/api/records/MetadataTagApi.java
index a38870e8df1..11a2cd603d4 100644
--- a/services/src/main/java/org/fao/geonet/api/records/MetadataTagApi.java
+++ b/services/src/main/java/org/fao/geonet/api/records/MetadataTagApi.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001-2016 Food and Agriculture Organization of the
+ * 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)
*
@@ -38,7 +38,9 @@
import org.fao.geonet.api.processing.report.SimpleMetadataProcessingReport;
import org.fao.geonet.constants.Geonet;
import org.fao.geonet.domain.AbstractMetadata;
+import org.fao.geonet.domain.Metadata;
import org.fao.geonet.domain.MetadataCategory;
+import org.fao.geonet.domain.MetadataDraft;
import org.fao.geonet.domain.utils.ObjectJSONUtils;
import org.fao.geonet.events.history.RecordCategoryChangeEvent;
import org.fao.geonet.kernel.AccessManager;
@@ -192,8 +194,16 @@ private void indexTags(AbstractMetadata metadata) throws Exception {
}
fields.put(Geonet.IndexFieldNames.CAT, categories);
}
- searchManager.updateFields(metadata.getUuid(), fields,
- Sets.newHashSet(new String[] {Geonet.IndexFieldNames.CAT}));
+
+ if (metadata instanceof MetadataDraft) {
+ searchManager.updateFields(metadata.getUuid() + "-draft", fields,
+ Sets.newHashSet(new String[] {Geonet.IndexFieldNames.CAT}));
+ } else {
+ searchManager.updateFields(metadata.getUuid(), fields,
+ Sets.newHashSet(new String[] {Geonet.IndexFieldNames.CAT}));
+ }
+
+
}
@io.swagger.v3.oas.annotations.Operation(
diff --git a/services/src/main/java/org/fao/geonet/api/records/attachments/AttachmentsApi.java b/services/src/main/java/org/fao/geonet/api/records/attachments/AttachmentsApi.java
index a0874f7162d..361f542d6bb 100644
--- a/services/src/main/java/org/fao/geonet/api/records/attachments/AttachmentsApi.java
+++ b/services/src/main/java/org/fao/geonet/api/records/attachments/AttachmentsApi.java
@@ -49,6 +49,7 @@
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Service;
import org.springframework.util.MultiValueMap;
+import org.springframework.util.StreamUtils;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.PathVariable;
@@ -254,22 +255,21 @@ public MetadataResource putResourceFromURL(
@ApiResponses(value = {@ApiResponse(responseCode = "201", description = "Record attachment."),
@ApiResponse(responseCode = "403", description = "Operation not allowed. "
+ "User needs to be able to download the resource.")})
- @ResponseBody
public void getResource(
@Parameter(description = "The metadata UUID", required = true, example = "43d7c186-2187-4bcd-8843-41e575a5ef56") @PathVariable String metadataUuid,
@Parameter(description = "The resource identifier (ie. filename)", required = true) @PathVariable String resourceId,
@Parameter(description = "Use approved version or not", example = "true") @RequestParam(required = false, defaultValue = "true") Boolean approved,
@Parameter(description = "Size (only applies to images). From 1px to 2048px.", example = "200") @RequestParam(required = false) Integer size,
@Parameter(hidden = true) HttpServletRequest request,
- @Parameter(hidden = true) HttpServletResponse response) throws Exception {
+ @Parameter(hidden = true) HttpServletResponse response
+ ) throws Exception {
ServiceContext context = ApiUtils.createServiceContext(request);
ApiUtils.canViewRecord(metadataUuid, request);
-
ServletOutputStream out = response.getOutputStream();
if (store instanceof FMEStore
- || (store instanceof ResourceLoggerStore && ((ResourceLoggerStore) store).getDecoratedStore() instanceof FMEStore)) {
+ || (store instanceof ResourceLoggerStore && ((ResourceLoggerStore) store).getDecoratedStore() instanceof FMEStore)) {
response.setHeader("Content-Disposition", "inline; filename=\"" + resourceId + "\"");
response.setHeader("Cache-Control", "no-cache");
@@ -278,32 +278,19 @@ public void getResource(
try (Store.ResourceHolder file = store.getResource(context, metadataUuid, resourceId, approved)) {
response.setHeader("Content-Disposition", "inline; filename=\"" + file.getMetadata().getFilename() + "\"");
response.setHeader("Cache-Control", "no-cache");
-
- Path path = file.getPath();
- String contentType = getFileContentType(path);
+ String contentType = getFileContentType(file.getPath());
response.setHeader("Content-Type", contentType);
if (contentType.startsWith("image/") && size != null) {
if (size >= MIN_IMAGE_SIZE && size <= MAX_IMAGE_SIZE) {
- BufferedImage image = ImageIO.read(path.toFile());
+ BufferedImage image = ImageIO.read(file.getPath().toFile());
BufferedImage resized = ImageUtil.resize(image, size);
- ByteArrayOutputStream output = new ByteArrayOutputStream();
- ImageIO.write(resized, "png", output);
- output.flush();
- byte[] imagesB = output.toByteArray();
- output.close();
- out.write(imagesB);
- out.flush();
- out.close();
+ ImageIO.write(resized, "png", response.getOutputStream());
} else {
- throw new IllegalArgumentException(String.format(
- "Image can only be resized from %d to %d. You requested %d.",
- MIN_IMAGE_SIZE, MAX_IMAGE_SIZE, size));
+ StreamUtils.copy(Files.newInputStream(file.getPath()), response.getOutputStream());
}
} else {
- IOUtils.copy(Files.newInputStream(path, StandardOpenOption.READ), out);
- out.flush();
- out.close();
+ StreamUtils.copy(Files.newInputStream(file.getPath()), response.getOutputStream());
}
}
}
diff --git a/services/src/main/java/org/fao/geonet/api/records/editing/MetadataEditingApi.java b/services/src/main/java/org/fao/geonet/api/records/editing/MetadataEditingApi.java
index b75f845233f..e38140c0809 100644
--- a/services/src/main/java/org/fao/geonet/api/records/editing/MetadataEditingApi.java
+++ b/services/src/main/java/org/fao/geonet/api/records/editing/MetadataEditingApi.java
@@ -373,6 +373,10 @@ public void saveEdits(
boolean reindex = false;
+ String lang = String.valueOf(languageUtils.parseAcceptLanguage(request.getLocales()));
+ ResourceBundle messages = ResourceBundle.getBundle("org.fao.geonet.api.Messages",
+ new Locale(lang));
+
// Save validation if the forceValidationOnMdSave is enabled
if (forceValidationOnMdSave) {
validator.doValidate(metadata, context.getLanguage());
@@ -412,7 +416,7 @@ public void saveEdits(
metadataStatus.setChangeDate(new ISODate());
metadataStatus.setUserId(session.getUserIdAsInt());
metadataStatus.setStatusValue(statusValue);
- metadataStatus.setChangeMessage("Save and submit metadata");
+ metadataStatus.setChangeMessage(messages.getString("metadata_save_submit_text"));
List listOfStatusChange = new ArrayList<>(1);
listOfStatusChange.add(metadataStatus);
@@ -434,7 +438,7 @@ public void saveEdits(
metadataStatus.setChangeDate(new ISODate());
metadataStatus.setUserId(session.getUserIdAsInt());
metadataStatus.setStatusValue(statusValue);
- metadataStatus.setChangeMessage("Save and approve metadata");
+ metadataStatus.setChangeMessage(messages.getString("metadata_save_approve_text"));
List listOfStatusChange = new ArrayList<>(1);
listOfStatusChange.add(metadataStatus);
diff --git a/services/src/main/java/org/fao/geonet/api/records/formatters/FormatterApi.java b/services/src/main/java/org/fao/geonet/api/records/formatters/FormatterApi.java
index 15e2db9f089..9145f38336a 100644
--- a/services/src/main/java/org/fao/geonet/api/records/formatters/FormatterApi.java
+++ b/services/src/main/java/org/fao/geonet/api/records/formatters/FormatterApi.java
@@ -285,7 +285,7 @@ public void getRecordFormattedBy(
long roundedChangeDate = changeDateAsTime / 1000 * 1000;
if (request.checkNotModified(language, roundedChangeDate) &&
context.getBean(CacheConfig.class).allowCaching(key)) {
- if (!skipPopularityBool) {
+ if (!skipPopularityBool && approved) {
context.getBean(DataManager.class).increasePopularity(context, String.valueOf(metadata.getId()));
}
return;
@@ -310,7 +310,7 @@ public void getRecordFormattedBy(
bytes = context.getBean(FormatterCache.class).get(key, validator, formatMetadata, false);
}
if (bytes != null) {
- if (!skipPopularityBool) {
+ if (!skipPopularityBool && approved) {
context.getBean(DataManager.class).increasePopularity(context, String.valueOf(metadata.getId()));
}
writeOutResponse(context, metadataUuid,
diff --git a/services/src/main/java/org/fao/geonet/api/records/formatters/XsltFormatter.java b/services/src/main/java/org/fao/geonet/api/records/formatters/XsltFormatter.java
index 05523f50dfa..112f7444859 100644
--- a/services/src/main/java/org/fao/geonet/api/records/formatters/XsltFormatter.java
+++ b/services/src/main/java/org/fao/geonet/api/records/formatters/XsltFormatter.java
@@ -24,14 +24,24 @@
package org.fao.geonet.api.records.formatters;
import org.fao.geonet.ApplicationContextHolder;
+import org.fao.geonet.constants.Geonet;
import org.fao.geonet.kernel.SchemaManager;
+import org.fao.geonet.kernel.search.JSONLocCacheLoader;
import org.fao.geonet.kernel.setting.SettingManager;
+import org.fao.geonet.utils.Log;
import org.fao.geonet.utils.Xml;
import org.jdom.Element;
+import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
+import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.stereotype.Component;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import static org.fao.geonet.api.records.formatters.SchemaLocalizations.loadSchemaLocalizations;
@@ -51,6 +61,16 @@
@Component
public class XsltFormatter implements FormatterImpl {
+ private final Map translationElements = new HashMap<>();
+
+ private final ConfigurableApplicationContext configurableApplicationContext;
+
+ @Autowired
+ public XsltFormatter(ConfigurableApplicationContext configurableApplicationContext) {
+ this.configurableApplicationContext = configurableApplicationContext;
+ }
+
+
/**
* @param schema Use all to return all schemas translations
* @param schemasToLoadList
@@ -97,9 +117,33 @@ public String format(FormatterParams fparams) throws Exception {
root.addContent(new Element("lang").setText(fparams.context.getLanguage()));
root.addContent(new Element("url").setText(fparams.url));
- // FIXME: This is a hack to mimic what Jeeves service are doing.
- // Some XSLT are used by both formatters and Jeeves and Spring MVC services
- Element translations = new Element("translations");
+
+ if (!translationElements.containsKey(fparams.context.getLanguage())) {
+ // Get translation keys and add them to the cache
+ Element translations = new Element("translations");
+ Map translationMap = new JSONLocCacheLoader(configurableApplicationContext, fparams.context.getLanguage()).call();
+ for (Map.Entry entry : translationMap.entrySet()) {
+ // Attempt to only use name that are valid element names.
+ // https://www.w3.org/TR/REC-xml/#NT-Name
+ // https://www.w3.org/TR/REC-xml/#NT-NameStartChar
+ // Skip keys that are not alphanumeric only including "." - otherwise certain chars like ':?+...' can cause problem when creating element as they are invalid element names
+ // i.e. some properties look like the following
+ // "cron-0 0 12 * * ?": "Fire at 12pm (noon) every day"
+ // "system/feedback"="Feedback"
+
+ if (entry.getKey().matches("[a-zA-Z0-9\\.]+")) {
+ try {
+ translations.addContent(new Element(entry.getKey()).setText(entry.getValue()));
+ } catch (Exception e) {
+ // If errors are generated here then it may mean that the regular expression needs to be updated.
+ Log.error(Geonet.GEONETWORK, "Failed to add translation key for \"" + entry.getKey() + "\"=\"" + entry.getValue() + "\". " + e.getMessage());
+ }
+ }
+ }
+
+ translationElements.put(fparams.context.getLanguage(), translations);
+ }
+ root.addContent((Element)translationElements.get(fparams.context.getLanguage()).clone());
Element gui = new Element("gui");
String baseUrl = settingManager.getBaseURL();
String context = baseUrl.replace(settingManager.getServerURL(), "");
@@ -107,6 +151,7 @@ public String format(FormatterParams fparams) throws Exception {
context.substring(0, context.length() - 1)
));
gui.addContent(new Element("nodeUrl").setText(settingManager.getNodeURL()));
+ gui.addContent(new Element("nodeId").setText(settingManager.getNodeId()));
gui.addContent(new Element("baseUrl").setText(baseUrl));
gui.addContent(new Element("serverUrl").setText(settingManager.getServerURL()));
gui.addContent(new Element("language").setText(fparams.context.getLanguage()));
diff --git a/services/src/main/java/org/fao/geonet/api/site/SiteInformation.java b/services/src/main/java/org/fao/geonet/api/site/SiteInformation.java
index 66cbb1f0baf..3adae15438e 100644
--- a/services/src/main/java/org/fao/geonet/api/site/SiteInformation.java
+++ b/services/src/main/java/org/fao/geonet/api/site/SiteInformation.java
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2001-2016 Food and Agriculture Organization of the
+ * 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)
*
@@ -29,7 +29,7 @@
import org.apache.commons.dbcp2.BasicDataSource;
import org.fao.geonet.GeonetContext;
import org.fao.geonet.constants.Geonet;
-import org.fao.geonet.kernel.GeonetworkDataDirectory;
+import org.fao.geonet.kernel.search.EsSearchManager;
import org.fao.geonet.utils.Log;
import org.fao.geonet.utils.TransformerFactoryFactory;
@@ -49,11 +49,11 @@
*/
public class SiteInformation {
final Properties properties = System.getProperties();
- private HashMap catProperties = new HashMap();
- private HashMap indexProperties = new HashMap();
- private HashMap systemProperties = new HashMap();
- private HashMap databaseProperties = new HashMap();
- private HashMap versionProperties = new HashMap();
+ private Map catProperties = new HashMap<>();
+ private Map indexProperties = new HashMap<>();
+ private Map systemProperties = new HashMap<>();
+ private Map databaseProperties = new HashMap<>();
+ private Map versionProperties = new HashMap<>();
public SiteInformation(final ServiceContext context, final GeonetContext gc) {
if (context.getUserSession().isAuthenticated()) {
@@ -68,44 +68,44 @@ public SiteInformation(final ServiceContext context, final GeonetContext gc) {
} catch (IOException e) {
Log.error(Geonet.GEONETWORK, e.getMessage(), e);
}
- loadVersionInfo(context);
+ loadVersionInfo();
loadSystemInfo();
}
}
@JsonProperty(value = "catalogue")
- public HashMap getCatProperties() {
+ public Map getCatProperties() {
return catProperties;
}
- public void setCatProperties(HashMap catProperties) {
+ public void setCatProperties(Map catProperties) {
this.catProperties = catProperties;
}
@JsonProperty(value = "index")
- public HashMap getIndexProperties() {
+ public Map getIndexProperties() {
return indexProperties;
}
- public void setIndexProperties(HashMap indexProperties) {
+ public void setIndexProperties(Map indexProperties) {
this.indexProperties = indexProperties;
}
@JsonProperty(value = "main")
- public HashMap getSystemProperties() {
+ public Map getSystemProperties() {
return systemProperties;
}
- public void setSystemProperties(HashMap systemProperties) {
+ public void setSystemProperties(Map systemProperties) {
this.systemProperties = systemProperties;
}
@JsonProperty(value = "database")
- public HashMap getDatabaseProperties() {
+ public Map getDatabaseProperties() {
return databaseProperties;
}
- public void setDatabaseProperties(HashMap databaseProperties) {
+ public void setDatabaseProperties(Map databaseProperties) {
this.databaseProperties = databaseProperties;
}
@@ -114,7 +114,7 @@ public Map getVersionProperties() {
return versionProperties;
}
- public void setVersionProperties(HashMap versionProperties) {
+ public void setVersionProperties(Map versionProperties) {
this.versionProperties = versionProperties;
}
@@ -162,8 +162,11 @@ private void loadSystemInfo() {
* Compute information about index.
*/
private void loadIndexInfo(ServiceContext context) throws IOException {
- final GeonetworkDataDirectory dataDirectory = context.getBean(GeonetworkDataDirectory.class);
- // TODOES - give information about the index status ?
+ EsSearchManager esSearchManager = context.getBean(EsSearchManager.class);
+
+ indexProperties.put("es.url", esSearchManager.getClient().getServerUrl());
+ indexProperties.put("es.version", esSearchManager.getClient().getServerVersion());
+ indexProperties.put("es.index", esSearchManager.getDefaultIndex());
}
/**
@@ -203,7 +206,7 @@ private void loadDatabaseInfo(ServiceContext context) throws SQLException {
/**
* Compute information about git commit.
*/
- private void loadVersionInfo(ServiceContext context) {
+ private void loadVersionInfo() {
Properties prop = new Properties();
try (InputStream input = getClass().getResourceAsStream("/git.properties")) {
diff --git a/services/src/main/java/org/fao/geonet/api/sld/SldApi.java b/services/src/main/java/org/fao/geonet/api/sld/SldApi.java
index f19f4626f66..047925870ae 100644
--- a/services/src/main/java/org/fao/geonet/api/sld/SldApi.java
+++ b/services/src/main/java/org/fao/geonet/api/sld/SldApi.java
@@ -2,9 +2,10 @@
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
-
+import jeeves.transaction.TransactionManager;
+import jeeves.transaction.TransactionTask;
import org.apache.commons.lang3.StringUtils;
-import org.fao.geonet.api.API;
+import org.fao.geonet.ApplicationContextHolder;
import org.fao.geonet.api.exception.ResourceNotFoundException;
import org.fao.geonet.constants.Geonet;
import org.fao.geonet.domain.TextFile;
@@ -25,13 +26,11 @@
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.TransactionStatus;
import org.springframework.web.bind.annotation.*;
import javax.mail.internet.ParseException;
-import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import javax.xml.transform.TransformerException;
-
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
@@ -40,8 +39,9 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
-import java.util.Map;
import java.util.List;
+import java.util.Map;
+import java.util.Optional;
@Service
@RequestMapping(value = {
@@ -52,14 +52,14 @@
public class SldApi {
public static final String LOGGER = Geonet.GEONETWORK + ".api.sld";
+
@Autowired
TextFileRepository fileRepository;
@Autowired
SettingManager settingManager;
@io.swagger.v3.oas.annotations.Operation(summary = "Test form", hidden = true)
- @RequestMapping(value = "/sldform",
- method = RequestMethod.GET)
+ @GetMapping(value = "/sldform")
@ResponseBody
@ResponseStatus(value = HttpStatus.OK)
public String getSLDTestingForm() {
@@ -71,75 +71,46 @@ public String getSLDTestingForm() {
"Layers :" +
"
" +
"JSON Custom filters : " +
- "
" +
+ "
" +
"" +
"" +
"