Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metadata resources #1385

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
a9f292c
Metadata resources / Add filestore and new resources API.
fxprunayre Jan 8, 2016
bfda9f0
Map print / Restore thumbnail layout (dropped in https://github.com/g…
fxprunayre Jan 8, 2016
486317c
Metadata resources / Use the filestore for linking document to a meta…
fxprunayre Jan 8, 2016
62b66bb
Metadata resources / Stop manipulating filestore resource URL in UFO.
fxprunayre Jan 8, 2016
f9d88a5
Add copyright.
fxprunayre Jan 8, 2016
020ff5a
Merge remote-tracking branch 'origin/3.0.x' into improvement/metadata…
fxprunayre Jan 8, 2016
5766f51
Metadata resources / Fix event name - properly refresh store content …
fxprunayre Jan 8, 2016
774a5a0
Add Swagger API configuration.
fxprunayre Jan 11, 2016
8b176cd
Metadata resources / Improve API, Fix reload after save.
fxprunayre Jan 12, 2016
cec27b3
Add swagger-ui.
fxprunayre Jan 12, 2016
b34eaa3
Fix API path.
fxprunayre Jan 12, 2016
6e3eadf
JSLint.
fxprunayre Jan 13, 2016
5adb298
Metadata relations / Add DC config.
fxprunayre Jan 13, 2016
887fa70
Metadata resources / ISO19139 / Add support for multilingual thumbnai…
fxprunayre Jan 13, 2016
e6acb9c
Metadata resources / Improve form validation.
fxprunayre Jan 13, 2016
6728aeb
Metadata resources / Add DB migration.
fxprunayre Jan 13, 2016
e5b87cb
Metadata resources / Add ISO19139 profil support and ISO19115-3 draft…
fxprunayre Jan 13, 2016
e65e94f
Merge remote-tracking branch 'origin/develop' into improvement/metada…
fxprunayre Jan 13, 2016
a268074
Metadata resources / Add example of extension for ISO19115-3 feature …
fxprunayre Jan 13, 2016
d585946
Merge remote-tracking branch 'origin/develop' into improvement/metada…
fxprunayre Jan 19, 2016
d1d1508
Metadata resources / Cleaning.
fxprunayre Jan 19, 2016
448d3db
Merge remote-tracking branch 'origin/develop' into improvement/metada…
fxprunayre Jan 19, 2016
653cada
Fix typo.
fxprunayre Jan 19, 2016
0ee4e7c
Merge remote-tracking branch 'origin/develop' into improvement/metada…
fxprunayre Jan 21, 2016
2c833de
Add FilesystemStore test. Fix errors in samples.
fxprunayre Jan 21, 2016
27fb6c1
ISO19139 / Templates / Remove empty graphic overview or online resour…
fxprunayre Jan 21, 2016
4d589f0
Metadata resources / Dublin core can have multiple thumbnails. Main t…
fxprunayre Jan 21, 2016
f241c8d
Use nio when possible.
fxprunayre Jan 21, 2016
a99ec1f
JSLint.
fxprunayre Jan 21, 2016
8e2b0fe
Move swagger-ui to api-doc folder.
fxprunayre Jan 22, 2016
afc3bea
Move swagger-ui to api-doc folder.
fxprunayre Jan 22, 2016
b5f4928
Metadata resources / Improve API Exceptions.
fxprunayre Jan 22, 2016
2ef456b
Metadata resources / Improve API status code and exceptions.
fxprunayre Jan 22, 2016
2311f6a
Remove API doc reload. Need more work.
fxprunayre Jan 22, 2016
4fc1b29
Dublin core / Avoid to insert duplicates in references.
fxprunayre Jan 26, 2016
44ad50a
Dublin core / Relations should be empty in template. The online resou…
fxprunayre Jan 26, 2016
c5c587b
Dublin core / Avoid to insert duplicate isPartOf element.
fxprunayre Jan 26, 2016
33cb541
Metadata resource / Properly align remove control in resource list. I…
fxprunayre Jan 26, 2016
4d5cf0c
ISO19139 / Add alias for function.
fxprunayre Jan 26, 2016
a7f7784
Log missing resource stats at DEBUG level.
fxprunayre Jan 26, 2016
1f336eb
Avoid JS error when map not yet initialized.
fxprunayre Jan 26, 2016
23008ba
Metadata resource / ISO19115-3 / Add configuration, appProfile, funct…
fxprunayre Jan 26, 2016
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
Original file line number Diff line number Diff line change
Expand Up @@ -355,17 +355,27 @@ public void setSiteUuid(String siteUuid) {
*/
public @Nonnull String getSiteURL(String language) {
LanguageRepository languageRepository = ApplicationContextHolder.get().getBean(LanguageRepository.class);
NodeInfo nodeInfo = ApplicationContextHolder.get().getBean(NodeInfo.class);

if(language == null) {
language = languageRepository.findOneByDefaultLanguage().getId();
}

return getNodeURL() + language + "/";
}

/**
* Return complete node URL
* eg. http://localhost:8080/geonetwork/srv/
*
* @return
*/
public @Nonnull String getNodeURL() {
NodeInfo nodeInfo = ApplicationContextHolder.get().getBean(NodeInfo.class);

String baseURL = pathFinder.getBaseUrl();
String protocol = getValue(Geonet.Settings.SERVER_PROTOCOL);
String host = getValue(Geonet.Settings.SERVER_HOST);
String port = getValue(Geonet.Settings.SERVER_PORT);
String locServ = baseURL +"/"+ nodeInfo.getId() +"/" + language + "/";
String locServ = baseURL +"/"+ nodeInfo.getId() +"/";

return protocol + "://" + host + (port.equals("80") ? "" : ":" + port) + locServ;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ protected ServiceContext createServiceContext() throws Exception {
final Constructor<?> constructor = GeonetContext.class.getDeclaredConstructors()[0];
constructor.setAccessible(true);
GeonetContext gc = new GeonetContext(_applicationContext, false, null);

contexts.put(Geonet.CONTEXT_NAME, gc);
final ServiceContext context = new ServiceContext("mockService", _applicationContext, contexts, _entityManager);
context.setAsThreadLocal();
Expand Down
43 changes: 43 additions & 0 deletions domain/src/main/java/org/fao/geonet/domain/MetadataResource.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* =============================================================================
* === Copyright (C) 2001-2016 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.domain;


import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;

/**
* Created by francois on 31/12/15.
*/
@XmlRootElement(name = "resource")
@XmlAccessorType(XmlAccessType.FIELD)
public interface MetadataResource {
String getId();
String getUrl();
String getType();
double getSize();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
* =============================================================================
* === Copyright (C) 2001-2016 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.domain;

import javax.persistence.Convert;
import java.util.Comparator;

/**
* Metadata resource visibility.
*/
@Convert(converter = MetadataResourceVisibilityConverter.class)
public enum MetadataResourceVisibility {
/**
* Accessible by all
*/
PUBLIC("public"),
/**
* Accessible to user with download privilege
*/
PRIVATE("private");

String value;

MetadataResourceVisibility(String value) {
this.value = value;
}

public static MetadataResourceVisibility parse(String value) {
for (MetadataResourceVisibility metadataResourceVisibility : MetadataResourceVisibility.values()) {
if (metadataResourceVisibility.toString().equals(value)) {
return metadataResourceVisibility;
}
}
return null;
}

public String toString() {
return this.value;
}

public static final Comparator<MetadataResource> sortByFileName =
new Comparator<MetadataResource>() {
public int compare(MetadataResource o1, MetadataResource o2) {
return o1.getId().compareTo(
o2.getId());
}
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* =============================================================================
* === Copyright (C) 2001-2016 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.domain;

import javax.persistence.AttributeConverter;
import java.beans.PropertyEditorSupport;

/**
* Created by francois on 31/12/15.
*/
public class MetadataResourceVisibilityConverter
extends PropertyEditorSupport
implements AttributeConverter<MetadataResourceVisibility, String> {
@Override
public void setAsText(final String visibility) throws IllegalArgumentException {
MetadataResourceVisibility value = MetadataResourceVisibility.parse(visibility.trim());
if (value != null) {
setValue(value);
} else {
throw new IllegalArgumentException(
String.format("Unsupported value '%s'. Values are %s.",
visibility,
MetadataResourceVisibility.values().toString()));
}
}

@Override
public String convertToDatabaseColumn(MetadataResourceVisibility visibility) {
switch (visibility) {
case PRIVATE:
return "P";
case PUBLIC:
return "A";
default:
throw new IllegalArgumentException(
String.format("Unsupported value '%s'. Values are %s.",
visibility,
MetadataResourceVisibility.values().toString()));
}
}

@Override
public MetadataResourceVisibility convertToEntityAttribute(String s) {
switch (s) {
case "P":
return MetadataResourceVisibility.PRIVATE;
case "A":
return MetadataResourceVisibility.PUBLIC;
default:
throw new IllegalArgumentException(
String.format("Unsupported value '%s'. Values are %s.",
s,
MetadataResourceVisibility.values().toString()));
}
}
}
3 changes: 2 additions & 1 deletion schemas-test/src/test/java/iso19139/UpdateFixedInfoTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import org.fao.geonet.AbstractCoreIntegrationTest;
import org.fao.geonet.kernel.DataManager;
import org.fao.geonet.kernel.UpdateDatestamp;
import org.fao.geonet.services.AbstractServiceIntegrationTest;
import org.fao.geonet.utils.Xml;
import org.jdom.Element;
import org.jdom.Namespace;
Expand All @@ -23,7 +24,7 @@
/**
* @author Jesse on 3/2/2015.
*/
public class UpdateFixedInfoTest extends AbstractCoreIntegrationTest {
public class UpdateFixedInfoTest extends AbstractServiceIntegrationTest {
private static final List<Namespace> NAMESPACES = Arrays.asList(SRV, GCO, GMD);
@Autowired
private DataManager dataManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,19 +93,23 @@
</xsl:for-each>


<xsl:for-each select="/simpledc/descendant::*
[name(.) = 'dct:references' or
name(.) = 'dc:relation']
[starts-with(., 'http') or
contains(. , 'resources.get') or
contains(., 'file.disclaimer')]">
<xsl:for-each select="/simpledc/(dct:references|dc:relation)[normalize-space(.) != '']">
<xsl:variable name="name" select="tokenize(., '/')[last()]"/>
<!-- Index link where last token after the last / is the link name. -->
<Field name="link"
string="{concat($name, '|', $name, '|', ., '|WWW-LINK|WWW:LINK|0')}"
string="{concat($name, '||', ., '|WWW-LINK|WWW:LINK|0')}"
store="true"
index="false"/>
</xsl:for-each>
<xsl:for-each select="/simpledc/(dct:references|dc:relation)[normalize-space(.) != ''
and matches(., '.*(.gif|.png.|.jpeg|.jpg)$', 'i')]">
<xsl:variable name="thumbnailType"
select="if (position() = 1) then 'thumbnail' else 'overview'"/>
<!-- First thumbnail is flagged as thumbnail and could be considered the main one -->
<Field name="image"
string="{concat($thumbnailType, '|', ., '|')}"
store="true" index="false"/>
</xsl:for-each>


<!-- This index for "coverage" requires significant expansion to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,11 @@ Stylesheet used to update metadata adding a reference to a parent record.
<xsl:copy-of
select="dc:*|dct:*"/>

<dct:references>
<xsl:choose>
<xsl:when test="not(starts-with($url, 'http'))">
upload@<xsl:value-of select="$name"/>
</xsl:when>
<xsl:otherwise>
<xsl:if test="not(dct:references[text() = $url])">
<dct:references>
<xsl:value-of select="$url"/>
</xsl:otherwise>
</xsl:choose>

</dct:references>
</dct:references>
</xsl:if>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ Stylesheet used to update metadata adding a reference to a parent record.
<xsl:copy-of
select="dc:*|dct:*"/>

<dct:isPartOf>
<xsl:value-of select="$parentUuid"/>
</dct:isPartOf>
<xsl:if test="not(dct:isPartOf[text() = $parentUuid])">
<dct:isPartOf>
<xsl:value-of select="$parentUuid"/>
</dct:isPartOf>
</xsl:if>
</xsl:copy>
</xsl:template>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<dc:subject/>
<dc:subject/>
<dc:description/>
<dc:relation>http://...</dc:relation>
<dct:created/>
<dct:dateSubmitted/>
<dc:rights/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<dc:subject/>
<dc:subject/>
<dc:description/>
<dc:relation>http://...</dc:relation>
<dct:created/>
<dct:dateSubmitted/>
<dc:rights/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,39 +38,4 @@
</dc:identifier>
</simpledc>
</xsl:template>

<!-- ================================================================= -->

<xsl:template match="dct:references">
<xsl:copy>
<xsl:variable name="value" select="normalize-space(.)"/>

<xsl:choose>
<!-- convention: use upload@ prefix in dct:references to identify an uploaded file from metadata editor
dct:refereces stores then the URL to download the uploaded file.
-->
<xsl:when test="starts-with($value, 'upload@')">
<xsl:variable name="valueFixed" select="replace($value,'upload@', '')"/>
<xsl:choose>
<xsl:when test="/root/env/system/downloadservice/simple='true'">
<xsl:value-of select="concat(/root/env/siteURL,'resources.get?uuid=',/root/env/uuid,'&amp;fname=',$valueFixed,'&amp;access=private')"/>
</xsl:when>
<xsl:when test="/root/env/system/downloadservice/withdisclaimer='true'">
<xsl:value-of select="concat(/root/env/siteURL,'file.disclaimer?uuid=',/root/env/uuid,'&amp;fname=',$valueFixed,'&amp;access=private')"/>
</xsl:when>
<xsl:otherwise> <!-- /root/env/config/downloadservice/leave='true' -->
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<!-- if not an uploaded file, keep the value -->
<xsl:otherwise> <!-- /root/env/config/downloadservice/leave='true' -->
<xsl:value-of select="."/>
</xsl:otherwise>
</xsl:choose>
</xsl:copy>
</xsl:template>

<!-- ================================================================= -->

</xsl:stylesheet>
Loading