Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/develop' into csw-insert-new-e…
Browse files Browse the repository at this point in the history
…lement

Conflicts:
	core/src/test/java/org/fao/geonet/AbstractCoreIntegrationTest.java
  • Loading branch information
Jesse Eichar committed Dec 10, 2013
2 parents 7aca0dc + 2afe0f8 commit 31f70eb
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 37 deletions.
29 changes: 13 additions & 16 deletions core/src/main/java/org/fao/geonet/kernel/SchemaManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,18 @@
package org.fao.geonet.kernel;

import jeeves.server.ServiceConfig;

import org.fao.geonet.Constants;
import org.fao.geonet.exceptions.OperationAbortedEx;

import jeeves.server.context.ServiceContext;
import jeeves.server.dispatchers.guiservices.XmlFile;
import jeeves.server.overrides.ConfigurationOverrides;

import org.fao.geonet.utils.BinaryFile;
import org.fao.geonet.utils.IO;
import org.fao.geonet.utils.Log;
import org.fao.geonet.utils.Xml;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringUtils;
import org.fao.geonet.constants.Geonet;
Expand Down Expand Up @@ -69,6 +71,7 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;

Expand Down Expand Up @@ -1694,21 +1697,15 @@ private boolean isMatchingElementInMetadata(Element needle, Element haystack, bo
if(Log.isDebugEnabled(Geonet.SCHEMA_MANAGER))
Log.debug(Geonet.SCHEMA_MANAGER, " Searching value for element: " + tempElement.getName());

String needleVal = needle.getValue();
String[] needleToken = StringUtils.deleteWhitespace(needleVal).split("\\|");
String tempVal = StringUtils.deleteWhitespace(tempElement.getValue());

for (String t : needleToken) {
Log.debug(Geonet.SCHEMA_MANAGER, " Comparing: '" + t + "' \n****with****\n '" + tempVal + "'");
if(tempVal!=null && needleVal!=null){
returnVal = t.equals(tempVal);
if (returnVal) {
if(Log.isDebugEnabled(Geonet.SCHEMA_MANAGER))
Log.debug(Geonet.SCHEMA_MANAGER, " Found value: " + t + " for needle: " + needleName);
break;
}
}
}
String needleVal = StringUtils.deleteWhitespace(needle.getValue());
String tempVal = StringUtils.deleteWhitespace(tempElement.getValue());
returnVal = Pattern.matches(needleVal, tempVal);
if(Log.isDebugEnabled(Geonet.SCHEMA_MANAGER)) {
Log.debug(Geonet.SCHEMA_MANAGER, " Pattern " + needleVal + " applied to value " + tempVal + " match: " + returnVal);
}
if (returnVal) {
break;
}
} else {
returnVal = true;
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void configureAppContext() throws Exception {
((FeatureStore<?,?>) _datastore.getFeatureSource(name)).removeFeatures(Filter.INCLUDE);
}
final String initializedString = "initialized";
final String webappDir = getWebappDir();
final String webappDir = getWebappDir(getClass());
final File templateDataDir = new File(webappDir, "WEB-INF/data");
final GeonetworkDataDirectory geonetworkDataDirectory = _applicationContext.getBean(GeonetworkDataDirectory.class);

Expand Down Expand Up @@ -155,7 +155,7 @@ protected ServiceContext createServiceContext() throws Exception {
context.setLogger(Log.createLogger("Test"));
context.setMaxUploadSize(100);
context.setOutputMethod(ServiceRequest.OutputMethod.DEFAULT);
context.setAppPath(getWebappDir());
context.setAppPath(getWebappDir(getClass()));
context.setBaseUrl("geonetwork");

return context;
Expand Down Expand Up @@ -187,7 +187,7 @@ protected Element createParams(Pair<String, ? extends Object>... params) {
}

protected String getStyleSheets() {
final String file = getWebappDir();
final String file = getWebappDir(getClass());

return new File(file, "xsl/conversion").getPath();
}
Expand All @@ -197,8 +197,8 @@ protected String getStyleSheets() {
*
* @return
*/
public static String getWebappDir() {
File here = getClassFile();
public static String getWebappDir(Class<?> cl) {
File here = getClassFile(cl);
while (!new File(here, "pom.xml").exists() && !new File(here.getParentFile(), "web/src/main/webapp/").exists()) {
// System.out.println("Did not find pom file in: "+here);
here = here.getParentFile();
Expand All @@ -207,9 +207,9 @@ public static String getWebappDir() {
return new File(here.getParentFile(), "web/src/main/webapp/").getAbsolutePath()+"/";
}

private static File getClassFile() {
final String testClassName = AbstractCoreIntegrationTest.class.getSimpleName();
return new File(AbstractCoreIntegrationTest.class.getResource(testClassName + ".class").getFile());
private static File getClassFile(Class<?> cl) {
final String testClassName = cl.getSimpleName();
return new File(cl.getResource(testClassName + ".class").getFile());
}

protected User loginAsAdmin(ServiceContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@
import jeeves.server.context.ServiceContext;
import org.fao.geonet.Util;

import org.fao.geonet.GeonetContext;
import org.fao.geonet.constants.Geonet;
import org.fao.geonet.constants.Params;
import org.fao.geonet.kernel.DataManager;
import org.fao.geonet.kernel.setting.SettingManager;
import org.fao.geonet.lib.Lib;
import org.fao.geonet.services.Utils;
Expand All @@ -62,6 +60,7 @@ public Element exec(Element params, ServiceContext context)
String filename = Util.getParam(params, Params.FILENAME);
String access = Util.getParam(params, Params.ACCESS, "private");
String overwrite = Util.getParam(params, Params.OVERWRITE, "no");
String description = Util.getParam(params, Params.TITLE);

Lib.resource.checkEditPrivilege(context, id);

Expand All @@ -84,6 +83,7 @@ public Element exec(Element params, ServiceContext context)
// Set parameter and process metadata to reference the uploaded file
params.addContent(new Element("url").setText(filename));
params.addContent(new Element("name").setText(filename));
params.addContent(new Element("desc").setText(description));
params.addContent(new Element("protocol")
.setText("WWW:DOWNLOAD-1.0-http--download"));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,7 @@ GeoNetwork.editor.LinkResourcesWindow = Ext.extend(Ext.Window, {
this.uploadDocument = false;

protocolCombo.setVisible(true);
protocolCombo.ownerCt.find('name', 'name')[0].setVisible(true);

if (!fsUpload.collapsed) {
fsUpload.collapse();
Expand Down Expand Up @@ -776,6 +777,7 @@ GeoNetwork.editor.LinkResourcesWindow = Ext.extend(Ext.Window, {
this.uploadDocument = true;

protocolCombo.setVisible(false);
protocolCombo.ownerCt.find('name', 'name')[0].setVisible(false);

if (!fsUrl.collapsed) {
fsUrl.collapse();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@

<xsl:variable name="poundLangId" select="concat('#',upper-case(java:twoCharLangCode($isoDocLangId)))" />

<xsl:variable name="identification" select="/*[name(.)='gmd:MD_Metadata' or @gco:isoType='gmd:MD_Metadata']/gmd:identificationInfo/*"></xsl:variable>
<xsl:variable name="identification" select="/*[name(.)='gmd:MD_Metadata' or
name() = 'gmi:MI_Metadata' or
@gco:isoType='gmd:MD_Metadata' or
@gco:isoType='gmd:MI_Metadata']/gmd:identificationInfo/*"></xsl:variable>
<xsl:variable name="docLangTitle" select="$identification/gmd:citation/*/gmd:title//gmd:LocalisedCharacterString[@locale=$poundLangId]"/>
<xsl:variable name="charStringTitle" select="$identification/gmd:citation/*/gmd:title/gco:CharacterString"/>
<xsl:variable name="locStringTitles" select="$identification/gmd:citation/*/gmd:title//gmd:LocalisedCharacterString"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1397,16 +1397,19 @@
<xsl:with-param name="content">

<xsl:variable name="thesaurusName" select="gmd:MD_Keywords/gmd:thesaurusName/gmd:CI_Citation/gmd:title/gco:CharacterString"></xsl:variable>
<xsl:variable name="thesaurusCode" select="if (gmd:MD_Keywords/gmd:thesaurusName/gmd:CI_Citation/
gmd:identifier/gmd:MD_Identifier/gmd:code) then gmd:MD_Keywords/gmd:thesaurusName/gmd:CI_Citation/
gmd:identifier/gmd:MD_Identifier/gmd:code else /root/gui/thesaurus/thesauri/thesaurus[title=$thesaurusName]/key"/>
<xsl:variable name="thesaurusCode" select="if (gmd:thesaurusName/gmd:CI_Citation/
gmd:identifier/gmd:MD_Identifier/gmd:code/*[1]) then gmd:thesaurusName/gmd:CI_Citation/
gmd:identifier/gmd:MD_Identifier/gmd:code/*[1] else /root/gui/thesaurus/thesauri/thesaurus[title=$thesaurusName]/key"/>

<!-- Check that thesaurus is available locally. Check that the thesaurus is available in the catalogue to not
to try to initialize a widget with a non existing thesaurus. -->
<xsl:variable name="isThesaurusAvailable"
select="count(/root/gui/thesaurus/thesauri/thesaurus[key = $thesaurusCode]) > 0"></xsl:variable>

<xsl:choose>
<!-- If a thesaurus is attached to that keyword group
use a snippet editor.
TODO : check that the thesaurus is available in the catalogue to not
to try to initialize a widget with a non existing thesaurus. -->
<xsl:when test="$thesaurusCode != ''">
use a snippet editor.-->
<xsl:when test="$isThesaurusAvailable">
<xsl:apply-templates select="gmd:MD_Keywords" mode="snippet-editor">
<xsl:with-param name="edit" select="$edit"/>
<xsl:with-param name="schema" select="$schema"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,11 @@
</xsl:with-param>
</xsl:call-template>


<xsl:variable name="modifiedDate" select="gmd:dateStamp/*[1]"/>
<span class="madeBy">
<xsl:value-of select="/root/gui/strings/changeDate"/><xsl:value-of select="substring-before(gmd:dateStamp, 'T')"/> |
<xsl:value-of select="/root/gui/strings/uuid"/><xsl:value-of select="gmd:fileIdentifier"/>
<xsl:value-of select="/root/gui/strings/changeDate"/>&#160;<xsl:value-of
select="if (contains($modifiedDate, 'T')) then substring-before($modifiedDate, 'T') else $modifiedDate"/> |
<xsl:value-of select="/root/gui/strings/uuid"/>&#160;<xsl:value-of select="gmd:fileIdentifier"/>
</span>

</xsl:with-param>
Expand Down

0 comments on commit 31f70eb

Please sign in to comment.