Skip to content

Commit

Permalink
Datastore - improvements to allow customise the metadata data folder …
Browse files Browse the repository at this point in the history
…names - hide visibility button in the metadata editor if 'datastore.folderPrivilegesStrategy' is set to NONE
  • Loading branch information
josegar74 committed Feb 7, 2024
1 parent a47494f commit 3ff9458
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 6 deletions.
31 changes: 26 additions & 5 deletions core/src/main/java/org/fao/geonet/util/XslUtil.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 @@ -59,6 +59,7 @@
import org.fao.geonet.api.records.attachments.FilesystemStore;
import org.fao.geonet.api.records.attachments.FilesystemStoreResourceContainer;
import org.fao.geonet.api.records.attachments.Store;
import org.fao.geonet.api.records.attachments.StoreFolderConfig;
import org.fao.geonet.constants.Geonet;
import org.fao.geonet.domain.*;
import org.fao.geonet.index.es.EsRestClient;
Expand Down Expand Up @@ -102,6 +103,7 @@
import org.owasp.esapi.errors.EncodingException;
import org.owasp.esapi.reference.DefaultEncoder;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.annotation.BeanFactoryAnnotationUtils;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ConfigurableApplicationContext;
Expand Down Expand Up @@ -150,7 +152,7 @@ public static MultiPolygon parseGml(Parser parser, String gml) throws IOExceptio
if (value instanceof HashMap) {
@SuppressWarnings("rawtypes")
HashMap map = (HashMap) value;
List<Polygon> geoms = new ArrayList<Polygon>();
List<Polygon> geoms = new ArrayList<>();
for (Object entry : map.values()) {
addToList(geoms, entry);
}
Expand Down Expand Up @@ -283,7 +285,7 @@ public static MultiPolygon toMultiPolygon(Geometry geometry) {
private static final char CS_DEFAULT = ',';
private static final char TS_WKT = ',';
private static final char CS_WKT = ' ';
private static ThreadLocal<Boolean> allowScripting = new InheritableThreadLocal<Boolean>();
private static ThreadLocal<Boolean> allowScripting = new InheritableThreadLocal<>();

/**
* clean the src of ' and <>
Expand Down Expand Up @@ -1063,7 +1065,10 @@ public static String reprojectCoords(Object minx, Object miny, Object maxx,
Element elemRet = new Element("EX_GeographicBoundingBox", ISO19139Namespaces.GMD);

boolean forceXY = Boolean.getBoolean(System.getProperty("org.geotools.referencing.forceXY", "false"));
Element elemminx, elemmaxx, elemminy, elemmaxy;
Element elemminx;
Element elemmaxx;
Element elemminy;
Element elemmaxy;
if (forceXY) {
elemminx = new Element("westBoundLongitude", ISO19139Namespaces.GMD)
.addContent(new Element("Decimal", ISO19139Namespaces.GCO).setText("" + reprojected.getMinX()));
Expand Down Expand Up @@ -1480,7 +1485,7 @@ public static String getIsoLanguageLabel(String code, String language) {


public static List<String> getKeywordHierarchy(String keyword, String thesaurusId, String langCode) {
List<String> res = new ArrayList<String>();
List<String> res = new ArrayList<>();
if (StringUtils.isEmpty(thesaurusId)) {
return res;
}
Expand Down Expand Up @@ -1711,4 +1716,20 @@ private static List<Element> buildRecordLink(SearchHits hits, String type) {
public static String escapeForJson(String value) {
return StringEscapeUtils.escapeJson(value);
}

/**
* get the metadata data directory folder privileges strategy
*
* @return the folder privileges strategy to be used.
*/
public static StoreFolderConfig.FolderPrivilegesStrategy getResourceFolderPrivilegesStrategy() {
try {
StoreFolderConfig storeFolderConfig = BeanFactoryAnnotationUtils.qualifiedBeanOfType(ApplicationContextHolder.get().getBeanFactory(), StoreFolderConfig.class, "storeFolderConfig");
return storeFolderConfig.getFolderPrivilegesStrategy();

} catch (NoSuchBeanDefinitionException ex) {
return StoreFolderConfig.FolderPrivilegesStrategy.DEFAULT;

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<i class="fa fa-eye"></i>
</a>
</td>
<td>
<td data-ng-if="gnCurrentEdit.resourceFolderPrivilegesStrategy == 'DEFAULT'">
<a
class="btn btn-link"
title="{{'setResourceStatus' | translate}}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,9 @@
resourceManagementExternalProperties: angular.fromJson(
getInputValue("resourceManagementExternalProperties")
),
resourceFolderPrivilegesStrategy: getInputValue(
"resourceFolderPrivilegesStrategy"
),
extent: extent,
dataFormats: dataFormats,
isMinor: getInputValue("minor") === "true",
Expand Down
3 changes: 3 additions & 0 deletions web/src/main/webapp/xslt/common/base-variables-metadata.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@
<xsl:variable name="resourceManagementExternalProperties"
select="util:getResourceManagementExternalProperties()"/>

<xsl:variable name="resourceFolderPrivilegesStrategy"
select="util:getResourceFolderPrivilegesStrategy()"/>

<xsl:variable name="isDisplayingAttributes"
select="if (/root/request/displayAttributes)
then /root/request/displayAttributes = 'true'
Expand Down
1 change: 1 addition & 0 deletions web/src/main/webapp/xslt/ui-metadata/edit/edit.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
<input type="hidden" id="otherLanguages" value="{$metadataOtherLanguagesAsJson}"/>
<input type="hidden" id="resourceContainerDescription" value="{$resourceContainerDescription}"/>
<input type="hidden" id="resourceManagementExternalProperties" value="{$resourceManagementExternalProperties}"/>
<input type="hidden" id="resourceFolderPrivilegesStrategy" value="{$resourceFolderPrivilegesStrategy}"/>
<input type="hidden" id="version" name="version" value="{$metadata/gn:info/version}"/>
<input type="hidden" id="currTab" name="currTab" value="{$tab}"/>
<input type="hidden" id="displayAttributes" name="displayAttributes"
Expand Down

0 comments on commit 3ff9458

Please sign in to comment.