Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions schemas/iso19115-3.2018/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,24 @@
<groupId>org.xmlunit</groupId>
<artifactId>xmlunit-matchers</artifactId>
</dependency>
<dependency>
<scope>test</scope>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.13.0</version>
</dependency>
<dependency>
<groupId>org.owasp.esapi</groupId>
<artifactId>esapi</artifactId>
<version>2.5.4.0</version>
<exclusions>
<exclusion>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</exclusion>
</exclusions>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -53,6 +71,26 @@
<testResource>
<directory>src/main/plugin/iso19115-3.2018</directory>
</testResource>
<testResource>
<directory>../../web/src/main/webapp</directory>
<targetPath>gn-site</targetPath>
</testResource>
<testResource>
<directory>src/main/plugin/iso19115-3.2018</directory>
<targetPath>gn-site/WEB-INF/data/config/schema_plugins/iso19115-3.2018</targetPath>
</testResource>
<testResource>
<directory>../iso19139/src/main/plugin/iso19139</directory>
<targetPath>gn-site/WEB-INF/data/config/schema_plugins/iso19139</targetPath>
</testResource>
<testResource>
<directory>../dublin-core/src/main/plugin/dublin-core</directory>
<targetPath>gn-site/WEB-INF/data/config/schema_plugins/dublin-core</targetPath>
</testResource>
<testResource>
<directory>../iso19110/src/main/plugin/iso19110</directory>
<targetPath>gn-site/WEB-INF/data/config/schema_plugins/iso19110</targetPath>
</testResource>
</testResources>

<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -860,17 +860,21 @@
</xsl:variable>

<xsl:choose>
<xsl:when test="string(*/cit:linkage/*)">
<a href="{*/cit:linkage/*}" target="_blank">
<xsl:when test="string(*/cit:linkage/gco:CharacterString)">
<xsl:variable name="url">
<xsl:apply-templates mode="render-value" select="*/cit:linkage"/>
</xsl:variable>
<a href="{$url}" target="_blank">
<xsl:apply-templates mode="render-value"
select="if (*/cit:name != '') then */cit:name else */cit:linkage"/>
select="if (normalize-space(*/cit:name) != '') then */cit:name else */cit:linkage"/>
</a>
</xsl:when>
<xsl:otherwise>
<xsl:when test="normalize-space(*/cit:name) != ''">
<span>
<xsl:value-of select="if (*/cit:name != '') then */cit:name else */cit:linkage"/>
<xsl:apply-templates mode="render-value" select="*/cit:name"/>
</span>
</xsl:otherwise>
</xsl:when>
<xsl:otherwise/>
</xsl:choose>
<p>
<xsl:value-of select="normalize-space($linkDescription)"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* Copyright (C) 2001-2025 Food and Agriculture Organization of the
* United Nations (FAO-UN), United Nations World Food Programme (WFP)
* and United Nations Environment Programme (UNEP)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* Contact: Jeroen Ticheler - FAO - Viale delle Terme di Caracalla 2,
* Rome - Italy. email: geonetwork@osgeo.org
*/

package org.fao.geonet.api.records.formatters;

import org.jdom.JDOMException;

import java.io.IOException;

public class SchemaLocalizations {

public static SchemaLocalizations create(String schema, final String lang3) throws IOException, JDOMException {
return new SchemaLocalizations();
}

public static SchemaLocalizations create(String schema) throws IOException, JDOMException {
return new SchemaLocalizations();
}

public String codelistValueLabel(String codelist, String value) throws Exception {
return String.format("cl_%s#%s", codelist, value);
}

public String nodeLabel(String qualifiedNodeName, String qualifiedParentNodeName, String qualifiedXpath) {
return qualifiedNodeName;
}

public String nodeLabel(String qualifiedNodeName, String qualifiedParentNodeName) throws Exception {
return qualifiedNodeName;
}

public String codelistValueDesc(String codelist, String value) throws Exception {
return "";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (C) 2001-2017 Food and Agriculture Organization of the
* United Nations (FAO-UN), United Nations World Food Programme (WFP)
* and United Nations Environment Programme (UNEP)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* Contact: Jeroen Ticheler - FAO - Viale delle Terme di Caracalla 2,
* Rome - Italy. email: geonetwork@osgeo.org
*/

package org.fao.geonet.kernel.security.keycloak;

public final class KeycloakXslUtil {

public static String getRealm() {
return "keycloak-realm";
}

public static String getAuthServerBaseUrl() {
return "keycloak_auth_server_base_url";
}

public static String getClientId() {
return "keycloak_clientid";
}

public static String getInitOnLoad() {
return "keycloak_init_on_load";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* 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)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*
* Contact: Jeroen Ticheler - FAO - Viale delle Terme di Caracalla 2,
* Rome - Italy. email: geonetwork@osgeo.org
*/
package org.fao.geonet.schema;

import org.fao.geonet.utils.PrefixUrlRewrite;
import org.fao.geonet.utils.ResolverWrapper;
import org.fao.geonet.utils.TransformerFactoryFactory;
import org.fao.geonet.utils.Xml;
import org.fao.geonet.utils.nio.NioPathAwareCatalogResolver;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import java.lang.reflect.Field;
import java.net.URISyntaxException;
import java.nio.file.Path;
import java.util.Map;

import static org.fao.geonet.schema.TestSupport.getResource;
import static org.fao.geonet.schema.TestSupport.getResourceInsideSchema;

public class FullViewTest {

private static final boolean GENERATE_EXPECTED_FILE = false;

private static Field resolverMapField;

@BeforeClass
public static void initSaxon() {
TransformerFactoryFactory.init("net.sf.saxon.TransformerFactoryImpl");
}

@BeforeClass
public static void initOasis() throws NoSuchFieldException, IllegalAccessException, URISyntaxException {
resolverMapField = ResolverWrapper.class.getDeclaredField("resolverMap");
resolverMapField.setAccessible(true);
((Map<?, ?>) resolverMapField.get(null)).clear();

String catFiles = getResource("gn-site/WEB-INF/oasis-catalog.xml") + ";" + addRequiredSchemasAndDisableConflictingOne();
System.setProperty("jeeves.xml.catalog.files", catFiles);
ResolverWrapper.createResolverForSchema("DEFAULT", null);
ResolverWrapper.getInstance().setBlankXSLFile(getResource("config/blank.xsl").toAbsolutePath().toString());
NioPathAwareCatalogResolver.addRewriteDirective(
new PrefixUrlRewrite("sharedFormatterDir/",
getResource("gn-site/WEB-INF/data/data/formatter").toAbsolutePath() + "/"));
}

@AfterClass
public static void clearOasis() throws IllegalAccessException {
((Map<?,?>) resolverMapField.get(null)).clear();
}


@Test
public void fullView() throws Exception {
Path xslFile = getResourceInsideSchema("formatter/xsl-view/view.xsl");
Path xmlFile = getResource("UpperRhineCastles-ISO19115-3-full-view-form.xml");
Element source = Xml.loadFile(xmlFile);

Element transformed = Xml.transform(source, xslFile, Map.of("view", "advanced", "approved", "true", "root", "div"));


XMLOutputter xmlOutputter = new XMLOutputter(Format.getPrettyFormat().setLineSeparator("\n"));
String actual = xmlOutputter.outputString(new Document(transformed));
TestSupport.assertGeneratedDataByteMatchExpected("UpperRhineCastles-ISO19115-3-full-view.html", actual, GENERATE_EXPECTED_FILE);
}

private static Path addRequiredSchemasAndDisableConflictingOne() throws URISyntaxException {
return getResource("config/schemaplugin-uri-catalog.xml");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
*/
package org.fao.geonet.util;

import org.apache.commons.text.StringEscapeUtils;
import org.owasp.esapi.reference.DefaultEncoder;

import java.util.List;

public class XslUtil {
public static String twoCharLangCode(String iso3code) {
return iso3code.substring(0, 2);
Expand Down Expand Up @@ -55,4 +60,83 @@ public static String twoCharLangCode(String iso3code, String defaultValue) {
return defaultValue;
}
}

public static String escapeForJson(String value) {
return StringEscapeUtils.escapeJson(value);
}

public static String getIsoLanguageLabel(String code, String language) {
return "dutch";
}

public static String getIndexField(Object appName, Object uuid, Object field, Object lang) {
return "";
}

public static String getDefaultUrl(String uuid, String language) {
return "www.geonet.org";
}

public static String getSiteUrl() {
return "";
}

public static String getCodelistTranslation(Object codelist, Object value, Object langCode) {
return String.format("%s--%s--%s", codelist, value, langCode);
}


public static List<String> getKeywordHierarchy(String keyword, String thesaurusId, String langCode) {
return List.of();
}

public static String getBuildNumber() {
return "buildNumber-666";
}


public static String encodeForJavaScript(String str) {
return DefaultEncoder.getInstance().encodeForJavaScript(str);
}

public static boolean isDisableLoginForm() {
return false;
}

public static boolean isShowLoginAsLink() {
return false;
}

public static boolean isUserProfileUpdateEnabled() {
return true;
}

public static boolean isUserGroupUpdateEnabled() {
return true;
}

public static String getUiConfigurationJsonProperty(String key, String path) {
return key + "-" + path;
}

public static String getWebAnalyticsService() {
return "";
}

public static String getWebAnalyticsJavascriptCode() {
return "";
}

public static String getUiConfiguration(String key) {
return "{}";
}

public static String getSecurityProvider() {
return "";
}

public static boolean isAuthenticated() {
return false;
}

}
Loading
Loading