This commit is contained in:
Fabio Sinibaldi 2017-01-25 14:26:44 +00:00
parent 0ce9a599f8
commit f58eb5f7d8
22 changed files with 424 additions and 55406 deletions

View File

@ -27,11 +27,6 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/xmlTemplates">
<attributes>
<attribute name="maven.pomderived" value="true"/>

View File

@ -1,6 +1,7 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/main/resources/org/gcube/spatial/data/geonetwork=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding//src/xmlTemplates=UTF-8

View File

@ -1,146 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Resource version="0.4.x">
<ID>4bf0d02a-0b66-47af-9fed-480249e74a9c</ID>
<Type>RuntimeResource</Type>
<Profile>
<Category>Gis</Category>
<Platform>
<Name>geonetwork</Name>
<Version>3</Version>
<MinorVersion>2</MinorVersion>
<RevisionVersion>1</RevisionVersion>
<BuildVersion>5</BuildVersion>
</Platform>
<RunTime>
<HostedOn>node3-d-d4s.d4science.org</HostedOn>
<Status>READY</Status>
</RunTime>
<AccessPoint>
<Interface>
<Endpoint EntryName="geonetwork">http://node3-d-d4s.d4science.org/geonetwork</Endpoint>
</Interface>
<AccessData>
<Username>admin</Username>
<Password>5jykeFZrlF1Xfa4vohyDYg==</Password>
</AccessData>
<Properties>
<Property>
<Name>priority</Name>
<Value encrypted="false">1</Value>
</Property>
<Property>
<Name>default1</Name>
<Value encrypted="false">1646</Value>
</Property>
<Property>
<Name>scopePwd1</Name>
<Value encrypted="true">r0w8yhRoTbtEpijz6UDX6A==</Value>
</Property>
<Property>
<Name>priority</Name>
<Value encrypted="false">1</Value>
</Property>
<Property>
<Name>suffixes</Name>
<Value encrypted="false">1</Value>
</Property>
<Property>
<Name>ckanUser1</Name>
<Value encrypted="false">L7xE1Vn</Value>
</Property>
<Property>
<Name>ckanPwd1</Name>
<Value encrypted="true">rL0ko4qaViHna/FnKEQjdQ==</Value>
</Property>
<Property>
<Name>private1</Name>
<Value encrypted="false">1645</Value>
</Property>
<Property>
<Name>public1</Name>
<Value encrypted="false">1646</Value>
</Property>
<Property>
<Name>scope1</Name>
<Value encrypted="false">gcube</Value>
</Property>
<Property>
<Name>scopeUser1</Name>
<Value encrypted="false">zbJKZCL</Value>
</Property>
<Property>
<Name>suffixes</Name>
<Value encrypted="false">1,2</Value>
</Property>
<Property>
<Name>ckanUser1</Name>
<Value encrypted="false">L7xE1Vn</Value>
</Property>
<Property>
<Name>ckanUser2</Name>
<Value encrypted="false">KHFKFUd</Value>
</Property>
<Property>
<Name>public2</Name>
<Value encrypted="false">1734</Value>
</Property>
<Property>
<Name>private1</Name>
<Value encrypted="false">1645</Value>
</Property>
<Property>
<Name>private2</Name>
<Value encrypted="false">1733</Value>
</Property>
<Property>
<Name>public1</Name>
<Value encrypted="false">1646</Value>
</Property>
<Property>
<Name>scopeUser1</Name>
<Value encrypted="false">zbJKZCL</Value>
</Property>
<Property>
<Name>scopeUser2</Name>
<Value encrypted="false">yr7T7i7</Value>
</Property>
<Property>
<Name>default1</Name>
<Value encrypted="false">1646</Value>
</Property>
<Property>
<Name>scopePwd2</Name>
<Value encrypted="true">E35j+f9fPbTDm9pJpoEyYg==</Value>
</Property>
<Property>
<Name>scopePwd1</Name>
<Value encrypted="true">r0w8yhRoTbtEpijz6UDX6A==</Value>
</Property>
<Property>
<Name>default2</Name>
<Value encrypted="false">1734</Value>
</Property>
<Property>
<Name>priority</Name>
<Value encrypted="false">1</Value>
</Property>
<Property>
<Name>ckanPwd1</Name>
<Value encrypted="true">rL0ko4qaViHna/FnKEQjdQ==</Value>
</Property>
<Property>
<Name>ckanPwd2</Name>
<Value encrypted="true">+zzxd3NyHUXF2VPFgRXN0w==</Value>
</Property>
<Property>
<Name>scope2</Name>
<Value encrypted="false">devsec</Value>
</Property>
<Property>
<Name>scope1</Name>
<Value encrypted="false">gcube</Value>
</Property>
</Properties>
</AccessPoint>
</Profile>
</Resource>

54885
log.txt

File diff suppressed because one or more lines are too long

View File

@ -186,7 +186,13 @@
</includes>
<targetPath>xml_templates</targetPath>
</resource>
<resource><directory>src/main/resources</directory></resource>
<resource>
<directory>src/main/resources/org/gcube/spatial/data/geonetwork</directory>
<includes>
<include>*.properties</include>
</includes>
<targetPath>org/gcube/spatial/data/geonetwork</targetPath>
</resource>
</resources>
</build>

View File

@ -107,6 +107,7 @@ public class GeoNetwork implements GeoNetworkAdministration {
}
}
setAccess(new ServerAccess(config.getGeoNetworkEndpoint(),config.getGeoNetworkVersion(),true,password,user,lvl));
getClient();
}

View File

@ -164,6 +164,7 @@ public class GNMetadataAdminExtension {
if(groups!=null){
for(Integer groupId:groups)request.addContent(new Element("groups").setText(groupId+""));
}
userRequest=request;
method=CREATE_USER_METHOD;
}else{
try{

View File

@ -1,184 +0,0 @@
package org.gcube.spatial.data.geonetwork.iso;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.UUID;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import org.gcube.common.resources.gcore.utils.XPathHelper;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
public class ISOMetadataFactoryLight {
private static Transformer transformer =null;
private static DocumentBuilder docBuilder =null;
private static HashMap<String,String> namespaces=new HashMap<String,String>();
private static final String BASE_TEMPLATE="xmlTemplates/BaseTemplates";
private static final String resourceIdentifier="<identifier xmlns=\"http://www.isotc211.org/2005/gmd\" xmlns:gco=\"http://www.isotc211.org/2005/gco\"> <MD_Identifier>"
+ " <code><gco:CharacterString>%s</gco:CharacterString></code>"
+ " </MD_Identifier>"
+ "</identifier>";
private static final String fileIdentifier="<fileIdentifier xmlns=\"http://www.isotc211.org/2005/gmd\" xmlns:gco=\"http://www.isotc211.org/2005/gco\">"
+ " <gco:CharacterString>%s</gco:CharacterString> </fileIdentifier>";
static{
try{
DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
docBuilder = factory.newDocumentBuilder();
TransformerFactory transformerFactory = TransformerFactory.newInstance();
transformer = transformerFactory.newTransformer();
namespaces.put("gmd", "http://www.isotc211.org/2005/gmd");
namespaces.put("gco", "http://www.isotc211.org/2005/gco");
namespaces.put("fra", "http://www.cnig.gouv.fr/2005/fra");
namespaces.put("xlink", "http://www.w3.org/1999/xlink");
namespaces.put("gml", "http://www.opengis.net/gml");
namespaces.put("xsi", "http://www.w3.org/2001/XMLSchema-instance");
namespaces.put("gmi", "http://www.isotc211.org/2005/gmi");
namespaces.put("gmx", "http://www.isotc211.org/2005/gmx");
}catch(Exception e){
throw new RuntimeException("Unable to init Fixer ",e);
}
}
public static String generateMetadata()throws Exception{
//Get document owner
Document document=null;
Element documentNode=null;
try{
documentNode = docBuilder.parse(BASE_TEMPLATE).getDocumentElement();
document=documentNode.getOwnerDocument();
// document = (Document)xpath.evaluate("/", inputSource, XPathConstants.NODE);
}catch(Exception e){
// throw e;
throw new RuntimeException("Unable to fix : unable to get Document",e);
}
//Set | get meta UUID
XPathHelper helper=getHelper(document);
String metaUUID=null;
// set File identifier and resource identifier
metaUUID=UUID.randomUUID().toString();
addContent("gmd:MD_Metadata",document,String.format(fileIdentifier, metaUUID),helper,Position.first_child);
addContent("//gmd:identificationInfo//gmd:edition",document,String.format(resourceIdentifier, metaUUID),helper,Position.sibling_after);
// set contact
// set Publication Date
//Add Keyword
addContent("//gmd:descriptiveKeywords",document,readFile("/home/fabio/workspaces/trunk_workspace/MetadataUseCases/XML_Pieces/keyword.xml"),helper,Position.sibling_before);
//Add AccessContraints
addContent("//gmd:resourceConstraints[last()]",document,readFile("/home/fabio/workspaces/trunk_workspace/MetadataUseCases/XML_Pieces/accessContraint.xml"),helper,Position.replace);
// //Add Distribution Info
// String layerName="geo_fea_"+new File(sourceFile).getName().toLowerCase();
// String gisLink=StringEscapeUtils.escapeXml10(getGisLinkByUUID(metaUUID));
// String distributionInfoContent=String.format(readFile("/home/fabio/workspaces/trunk_workspace/MetadataUseCases/XML_Pieces/distributionInfoTemplate.xml"), layerName,gisLink);
// addContent("//gmd:distributionInfo",document,distributionInfoContent,helper,Position.replace);
//Add Reference system
addContent("//gmd:spatialRepresentationInfo",document,readFile("/home/fabio/workspaces/trunk_workspace/MetadataUseCases/XML_Pieces/referenceSystem.xml"),helper,Position.sibling_after);
//Add Data Quality
addContent("//gmd:distributionInfo",document,readFile("/home/fabio/workspaces/trunk_workspace/MetadataUseCases/XML_Pieces/DataQuality.xml"),helper,Position.sibling_after);
return null;
}
private static XPathHelper getHelper(Node root){
XPathHelper toReturn =new XPathHelper(root);
for(Entry<String,String> entry:namespaces.entrySet())
toReturn.addNamespace(entry.getKey(), entry.getValue());
return toReturn;
}
private static String readFile(String path) throws IOException{
byte[] encoded = Files.readAllBytes(Paths.get(path));
return new String(encoded);
}
private static enum Position{
sibling_after,sibling_before,first_child,last_child,replace
}
public static void addContent(String path, Document doc, String toAddContent, XPathHelper documentHelper,Position position) throws SAXException, IOException{
NodeList nodelist=documentHelper.evaluateForNodes(path);
if(nodelist==null||nodelist.getLength()==0) throw new RuntimeException("Path "+path+" not found in document");
// if(nodelist.getLength()>1) throw new RuntimeException("Invalid Path "+path+"."+nodelist.getLength()+" entries found");
Node targetNode=nodelist.item(0);
Document online=docBuilder.parse(new ByteArrayInputStream(toAddContent.getBytes()));
Node toAdd=doc.importNode(online.getDocumentElement(), true);
switch(position){
case first_child: {
targetNode.insertBefore(toAdd, targetNode.getFirstChild());
break;
}
case last_child:{targetNode.appendChild(toAdd);
break;}
case replace : {
Node parent=targetNode.getParentNode();
parent.replaceChild(toAdd, targetNode);
break;
}
case sibling_after :{
Node currentlyNext=targetNode.getNextSibling();
Node parent=targetNode.getParentNode();
if(currentlyNext!=null)parent.insertBefore(toAdd, currentlyNext);
else parent.appendChild(toAdd);
break;
}
case sibling_before :{
Node parent=targetNode.getParentNode();
parent.insertBefore(toAdd, targetNode);
break;
}
}
}
}

View File

@ -1,6 +1,8 @@
package org.gcube.spatial.data.geonetwork.iso.tpl;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import org.gcube.spatial.data.geonetwork.iso.Protocol;
@ -15,11 +17,20 @@ public class DistributionInfo {
GeoServer,Thredds
}
private String type;
private DistributionInfoType type;
private Collection<Protocol> protocols;
private Collection<OnlineResource> onlines;
public DistributionInfo(DistributionInfoType type, Collection<OnlineResource> onlines) {
super();
this.type = type;
this.onlines = onlines;
Set<Protocol> protocols=new HashSet<Protocol>();
for(OnlineResource res:onlines){
protocols.add(res.getProtocol());
}
this.protocols=protocols;
}
}

View File

@ -64,7 +64,7 @@ public class ISOMetadataByTemplate {
public static final String createXML(MetadataDescriptor desc) throws TemplateNotFoundException, MalformedTemplateNameException, ParseException, IOException, TemplateException{
Writer out=null;
try{
Template temp = cfg.getTemplate("BaseTemplate.xml");
Template temp = cfg.getTemplate("BaseTemplate.ftlx");
File output=File.createTempFile("ISO_", ".xml");
out=new OutputStreamWriter(new FileOutputStream(output));
temp.process(desc, out);

View File

@ -1,6 +1,7 @@
package org.gcube.spatial.data.geonetwork.iso.tpl;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import lombok.AllArgsConstructor;
@ -12,8 +13,68 @@ import lombok.ToString;
@ToString
public class Keyword {
public static class Types{
public static final String DISCIPLINE="discipline";
public static final String PLACE="place";
public static final String STRATUM="stratum";
public static final String TEMPORAL="temporal";
public static final String THEME="theme";
}
public static class Themes{
public static final String ADDRESSES="Addresses";
public static final String ADMINISTRATIVE_UNITS="Administrative units";
public static final String CADASTRAL_PARCELS="Cadastral parcels";
public static final String COORDINATE_REFERENCE_SYSTEM="Coordinate reference systems";
public static final String GEOGRAPHICAL_GRID_SYSTEM="Geographical grid systems";
public static final String GEOGRAPHICAL_NAMES="Geographical names";
public static final String HYDROGRAPHY="Hydrography";
public static final String PROTECTED_SITES="Protected sites";
public static final String TRANSPORT_NETWORKS="Transport networks";
// ANNEX: 2
public static final String ELEVATION="Elevation";
public static final String GEOLOGY="Geology";
public static final String LAND_COVER="Land cover";
public static final String ORTHOIMAGERY="Orthoimagery";
// ANNEX: 3
public static final String AGRICULTURAL_AND_AQUACULTURE_FACILITIES="Agricultural and aquaculture facilities";
public static final String AREA_MANAGEMENT_RESTRICTION_REGULATION_ZONES_AND_REPORT_UNITS="Area management / restriction / regulation zones & reporting units";
public static final String ATMOSPHERIC_CONDITIONS="Atmospheric conditions";
public static final String BIO_GEOGRAPHICAL_REGIONS="Bio-geographical regions";
public static final String BUILDINGS="Buildings";
public static final String ENERGY_RESOURCES="Energy Resources";
public static final String ENVINROMENTAL_MONITORING_FACILITIES="Environmental monitoring Facilities";
public static final String HABITATS_AND_BIOTOPES="Habitats and biotopes";
public static final String HUMAN_HEALTH_AND_SAFETY="Human health and safety";
public static final String LAND_USE="Land use";
public static final String METEOROLOGICAL_GEOGRAPHICAL_FEATURES="Meteorological geographical features";
public static final String MINERAL_RESOURCES="Mineral Resources";
public static final String NATURAL_RISK_ZONES="Natural risk zones";
public static final String OCEANOGRAPHIC_GEOGRAPHICAL_FEATURES="Oceanographic geographical features";
public static final String POPULATION_DISTRIBUTION_AND_DEMOGRAPHY="Population distribution and demography";
public static final String PRODUCTION_AND_INDUSTRIAL_FACILITIES="Production and industrial facilities";
public static final String SEA_REGIONS="Sea regions";
public static final String SOIL="Soil";
public static final String SPECIES_DISTRIBUTION="Species distribution";
public static final String STATISTICAL_UNITS="Statistical units";
public static final String UTILITY_AND_GOVERNMENTAL_SERVICES="Utility and governmental services";
}
public static final Date INSPIRE_THEME_PUBLICATION_TIME=new Date(2008,06,01);
public static final String INSPIRE_THEME_THESAURUS_NAME="GEMET - INSPIRE themes, version 1.0";
private Collection<String> values;
private Date creationDate;
private String type;
private String thesaurus;
public static Keyword getInspireTheme(String theme){
return new Keyword(Collections.singleton(theme), INSPIRE_THEME_PUBLICATION_TIME, Types.THEME, INSPIRE_THEME_THESAURUS_NAME);
}
}

View File

@ -5,7 +5,11 @@ import java.util.Collection;
import java.util.Date;
import java.util.List;
import org.gcube.portlets.user.uriresolvermanager.exception.IllegalArgumentException;
import org.gcube.portlets.user.uriresolvermanager.exception.UriResolverMapException;
import org.gcube.spatial.data.geonetwork.iso.BoundingBox;
import org.gcube.spatial.data.geonetwork.iso.ISOMetadataFactory;
import org.gcube.spatial.data.geonetwork.iso.tpl.DistributionInfo.DistributionInfoType;
import lombok.AllArgsConstructor;
import lombok.Data;
@ -19,9 +23,7 @@ import lombok.ToString;
public class MetadataDescriptor {
private String UUIDIdentifier;
private Person author;
private Company distributor;
private Company provider;
private Collection<ResponsibleParty> responsibleParties;
private Date creationTime;
@ -43,10 +45,24 @@ public class MetadataDescriptor {
private Double spatialResolution;
private String topicCategory;
private String guidelinesConformityExplanation;
private Boolean guidelinesConformityPass;
private String lineageStatement;
public void setGeoServerDistributionInfo(){
public void setGeoServerDistributionInfo(String geoServerUrl,String layerName, String style, String CRS) throws UriResolverMapException, IllegalArgumentException{
List<OnlineResource> resources=new ArrayList<OnlineResource>();
resources.add(new OnlineResource(protocol, uri, description, title))
String bbox=this.getBoundingBox().toString();
String wmsUrl=ISOMetadataFactory.getWmsUrl(geoServerUrl, layerName, style, bbox, CRS);
String wcsUrl=ISOMetadataFactory.getWcsUrl(geoServerUrl, layerName, bbox);
String wfsUrl=ISOMetadataFactory.getWfsUrl(geoServerUrl, layerName);
String gisViewerUrl=ISOMetadataFactory.getGisLinkByUUID(UUIDIdentifier);
resources.add(new OnlineResource(wmsUrl, "WMS Link"));
resources.add(new OnlineResource(wcsUrl, "WCS Link"));
resources.add(new OnlineResource(wfsUrl, "WFS Link"));
resources.add(new OnlineResource(gisViewerUrl, "GISViewer Link"));
distributionInfo=new DistributionInfo(DistributionInfoType.GeoServer, resources);
}
}

View File

@ -14,8 +14,11 @@ public class OnlineResource {
private String description;
private String title;
public OnlineResource(String uri,String description){
protocol=
public OnlineResource(String uri,String title){
protocol=Protocol.getByURI(uri);
this.uri=uri;
this.title=title;
this.description=protocol.getName()+" link to resource.";
}
}

View File

@ -0,0 +1,46 @@
package org.gcube.spatial.data.geonetwork.iso.tpl;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data
@AllArgsConstructor
public class ResponsibleParty {
public static class Roles{
public static final String RESOURCE_PROVIDER="resourceProvider";
public static final String CUSTODIAN="custodian";
public static final String OWNER="owner";
public static final String USER="user";
public static final String DISTRIBUTOR="distributor";
public static final String ORIGINATOR="originator";
public static final String POINT_OF_CONTACT="pointOfContact";
public static final String PRINCIPAL_INVESTIGATOR="principalInvestigator";
public static final String PROCESSOR="processor";
public static final String PUBLISHER="publisher";
public static final String AUTHOR="author";
}
@Data
@AllArgsConstructor
public static class Contact{
private String email;
private String site;
}
private String individualName;
private String organization;
private String role;
private Contact contact;
public ResponsibleParty(String individualName, String organization, String role) {
super();
this.individualName = individualName;
this.organization = organization;
this.role = role;
this.contact=null;
}
}

View File

@ -1,29 +0,0 @@
package org.gcube.spatial.data.geonetwork.utils;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class XMLUtils {
public static String getElementContent(Element element){
NodeList children = element.getChildNodes();
String result = "";
for (int i = 0; i < children.getLength(); i++)
{
if (children.item(i).getNodeType() == Node.TEXT_NODE ||
children.item(i).getNodeType() == Node.CDATA_SECTION_NODE)
{
result += children.item(i).getNodeValue();
}
else if( children.item(i).getNodeType() == Node.COMMENT_NODE )
{
// Ignore comment nodes
}
}
return result.trim();
}
}

View File

@ -33,6 +33,6 @@ GNPasswordLength=10
isMaxWaitTimeMillis=600000
#GN_update_polling (milliseconds)
geonetworkUpdateTimeout=5000
geonetworkUpdateTimeout=50000
geonetworkUpdateWait=500

View File

@ -32,7 +32,7 @@ public class ScopeTests {
static{
scopes.add("/gcube");
scopes.add("/gcube/preprod");
scopes.add("/gcube/preprod/preVRE");
// scopes.add("/gcube/preprod/preVRE");
// scopes.add("/d4science.research-infrastructures.eu/gCubeApps/SIASPA");

View File

@ -24,16 +24,16 @@ public class TestConfiguration {
ResourceConfiguration resConfig=new ResourceConfiguration();
resConfig.setAdminPassword("admin");
resConfig.setVersion((short)3);
resConfig.setMinor((short)2);
resConfig.setRevision((short)1);
resConfig.setBuild((short)5);
resConfig.setHost("node3-d-d4s.d4science.org");
resConfig.setEndpoint("http://node3-d-d4s.d4science.org/geonetwork");
toUseConfiguration=new LocalResourceConfiguration(resConfig);
resConfig.setVersion((short)2);
resConfig.setMinor((short)6);
resConfig.setRevision((short)4);
resConfig.setBuild((short)0);
resConfig.setHost("geonetwork1-d-d4s.d4science.org");
resConfig.setEndpoint("http://geonetwork1-d-d4s.d4science.org/geonetwork");
toUseConfiguration=new LocalResourceConfiguration(resConfig);
// toUseConfiguration=new DefaultConfiguration();
// toUseConfiguration=new DefaultConfiguration();
}
return GeoNetwork.get(toUseConfiguration);
}

View File

@ -2,22 +2,19 @@ package org.gcube.spatial.data.geonetwork.test;
import java.io.File;
import java.util.Arrays;
import java.util.Collections;
import java.util.GregorianCalendar;
import java.util.UUID;
import org.gcube.spatial.data.geonetwork.GeoNetworkPublisher;
import org.gcube.spatial.data.geonetwork.LoginLevel;
import org.gcube.spatial.data.geonetwork.iso.BoundingBox;
import org.gcube.spatial.data.geonetwork.iso.ISOMetadataFactory;
import org.gcube.spatial.data.geonetwork.iso.tpl.Company;
import org.gcube.spatial.data.geonetwork.iso.tpl.DistributionInfo;
import org.gcube.spatial.data.geonetwork.iso.tpl.ISOMetadataByTemplate;
import org.gcube.spatial.data.geonetwork.iso.tpl.Keyword;
import org.gcube.spatial.data.geonetwork.iso.tpl.MetadataDescriptor;
import org.gcube.spatial.data.geonetwork.iso.tpl.Person;
import org.gcube.spatial.data.geonetwork.utils.ScopeUtils;
import org.geotoolkit.metadata.iso.DefaultMetadata;
import org.geotoolkit.xml.XML;
import org.opengis.metadata.Metadata;
import org.gcube.spatial.data.geonetwork.iso.tpl.ResponsibleParty;
import org.gcube.spatial.data.geonetwork.iso.tpl.ResponsibleParty.Contact;
import it.geosolutions.geonetwork.util.GNInsertConfiguration;
public class TrueMarbleMeta {
@ -45,27 +42,41 @@ public class TrueMarbleMeta {
MetadataDescriptor desc=new MetadataDescriptor();
desc.setResponsibleParties(Arrays.asList(
new ResponsibleParty("The scope ","the infra",ResponsibleParty.Roles.DISTRIBUTOR,new Contact("my.mail@this.place.com","www.mipiacitu.com")),
new ResponsibleParty("Io","me stesso",ResponsibleParty.Roles.POINT_OF_CONTACT,new Contact("point.of.contact.maiol@place.com","www.mipiacitu.com")),
new ResponsibleParty("Io","me stesso",ResponsibleParty.Roles.AUTHOR,new Contact("point.of.contact.maiol@place.com","www.mipiacitu.com"))
));
desc.setAbstractField("My Abstract Field");
desc.setAuthor(new Person("Idiota","Idiocracy"));
desc.setCredit("Fatto io");
desc.setDistributor(new Company(ScopeUtils.getCurrentScope(), "D4Nothing", "ti.piacerebbe@ciao.ne", "lemonparty.com"));
desc.setCreationTime(new GregorianCalendar().getTime());
desc.setGeometricObjectCount(1000l);
desc.setKeywords(Collections.singleton(new Keyword(Arrays.asList(new String[]{"bla, blabla", "eh beh"}),desc.getCreationTime(),"Theme","GENERAL")));
desc.setProvider(desc.getDistributor());
desc.setKeywords(Arrays.asList(Keyword.getInspireTheme(Keyword.Themes.SEA_REGIONS)));
desc.setPublicationTime(desc.getCreationTime());
desc.setPurpose("Just for fun");
desc.setTitle("Il mio bel titolone");
desc.setUUIDIdentifier(UUID.randomUUID().toString());
desc.setBoundingBox(BoundingBox.WORLD_EXTENT);
desc.setDistributionInfo(new DistributionInfo("GeoServer"));
desc.setGeoServerDistributionInfo("http://geoserver.d4science.org/geoserver", "ws:wmpa", "speciesProb", "EPSG:4326");
desc.setSpatialResolution(0.5d);
desc.setTopicCategory("environment");
desc.setLineageStatement("I made with my own hands");
System.out.println(desc.getBoundingBox());
System.out.println(ISOMetadataByTemplate.createXML(desc));
String metaPath=ISOMetadataByTemplate.createXML(desc);
System.out.println("Going to Publish ----->> "+metaPath);
GeoNetworkPublisher publisher=TestConfiguration.getClient();
publisher.login(LoginLevel.SCOPE);
GNInsertConfiguration config=publisher.getCurrentUserConfiguration("dataset", "_none_");
long id=publisher.insertMetadata(config, new File(metaPath));
System.out.println("PUBLISHED WITH ID : "+id);
// Metadata meta=gMeta.getMetadata();

View File

@ -1,4 +1,4 @@
log4j.rootLogger=DEBUG, A1, stdout
log4j.rootLogger=DEBUG, A1
log4j.appender.A1=org.apache.log4j.RollingFileAppender
log4j.appender.A1.File=log.txt
log4j.appender.A1.layout=org.apache.log4j.PatternLayout

View File

@ -1,3 +1,4 @@
<#setting url_escaping_charset='ISO-8859-1'>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<gmd:MD_Metadata xmlns:gco="http://www.isotc211.org/2005/gco"
xmlns:fra="http://www.cnig.gouv.fr/2005/fra" xmlns:gmx="http://www.isotc211.org/2005/gmx"
@ -19,106 +20,28 @@
<gmd:MD_ScopeCode codeSpace="eng" codeListValue="dataset"
codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#MD_ScopeCode">Dataset</gmd:MD_ScopeCode>
</gmd:hierarchyLevel>
<gmd:contact>
<gmd:CI_ResponsibleParty>
<gmd:individualName>
<gco:CharacterString>${author.name}</gco:CharacterString>
</gmd:individualName>
<gmd:organisationName>
<gco:CharacterString>${author.organization}</gco:CharacterString>
</gmd:organisationName>
<gmd:role>
<gmd:CI_RoleCode codeListValue="author"
codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#CI_RoleCode">Author</gmd:CI_RoleCode>
</gmd:role>
</gmd:CI_ResponsibleParty>
</gmd:contact>
<!-- RESPONSIBLE PARTIES : contact-->
<#list responsibleParties as responsibleParty>
<gmd:contact>
<gmd:CI_ResponsibleParty>
<gmd:individualName>
<gco:CharacterString>${distributor.name}</gco:CharacterString>
</gmd:individualName>
<gmd:organisationName>
<gco:CharacterString>${distributor.organization}
</gco:CharacterString>
</gmd:organisationName>
<gmd:contactInfo>
<gmd:CI_Contact>
<gmd:address>
<gmd:CI_Address>
<gmd:electronicMailAddress>
<gco:CharacterString>${distributor.email}</gco:CharacterString>
</gmd:electronicMailAddress>
</gmd:CI_Address>
</gmd:address>
<gmd:onlineResource>
<gmd:CI_OnlineResource>
<gmd:linkage>
<gmd:URL>${distributor.site}</gmd:URL>
</gmd:linkage>
<gmd:protocol>
<gco:CharacterString>WWW:LINK-1.0-http--link
</gco:CharacterString>
</gmd:protocol>
<gmd:name>
<gco:CharacterString>${distributor.organization} site.
</gco:CharacterString>
</gmd:name>
</gmd:CI_OnlineResource>
</gmd:onlineResource>
</gmd:CI_Contact>
</gmd:contactInfo>
<gmd:role>
<gmd:CI_RoleCode codeListValue="distributor"
codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#CI_RoleCode">Distributor</gmd:CI_RoleCode>
</gmd:role>
</gmd:CI_ResponsibleParty>
</gmd:contact>
<gmd:contact>
<gmd:CI_ResponsibleParty>
<gmd:individualName>
<gco:CharacterString>${provider.name}
</gco:CharacterString>
</gmd:individualName>
<gmd:organisationName>
<gco:CharacterString>${provider.organization}</gco:CharacterString>
</gmd:organisationName>
<gmd:contactInfo>
<gmd:CI_Contact>
<gmd:address>
<gmd:CI_Address>
<gmd:electronicMailAddress>
<gco:CharacterString>${provider.email}</gco:CharacterString>
</gmd:electronicMailAddress>
</gmd:CI_Address>
</gmd:address>
<gmd:onlineResource>
<gmd:CI_OnlineResource>
<gmd:linkage>
<gmd:URL>${provider.site}</gmd:URL>
</gmd:linkage>
<gmd:protocol>
<gco:CharacterString>WWW:LINK-1.0-http--link
</gco:CharacterString>
</gmd:protocol>
<gmd:name>
<gco:CharacterString>${provider.organization} site.
</gco:CharacterString>
</gmd:name>
</gmd:CI_OnlineResource>
</gmd:onlineResource>
</gmd:CI_Contact>
</gmd:contactInfo>
<gmd:role>
<gmd:CI_RoleCode codeListValue="resourceProvider"
codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#CI_RoleCode">Resource provider</gmd:CI_RoleCode>
</gmd:role>
</gmd:CI_ResponsibleParty>
<#include "ResponsibleParty.ftlx">
</gmd:contact>
</#list>
<!-- PUBLICATION TIME -->
<gmd:dateStamp>
<gco:DateTime>${publicationTime?datetime}</gco:DateTime>
<gco:DateTime>${.now?iso_utc}</gco:DateTime>
</gmd:dateStamp>
<!-- SPATIAL REPRESENTATION INFO -->
<gmd:spatialRepresentationInfo>
<gmd:MD_VectorSpatialRepresentation>
<gmd:topologyLevel>
@ -133,7 +56,7 @@
codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#MD_GeometricObjectTypeCode">Surface</gmd:MD_GeometricObjectTypeCode>
</gmd:geometricObjectType>
<gmd:geometricObjectCount>
<gco:Integer>${geometricObjectCount}</gco:Integer>
<gco:Integer>${geometricObjectCount?c}</gco:Integer>
</gmd:geometricObjectCount>
</gmd:MD_GeometricObjects>
</gmd:geometricObjects>
@ -144,13 +67,15 @@
<gmd:referenceSystemIdentifier>
<gmd:RS_Identifier>
<gmd:code>
<gco:CharacterString>http://www.opengis.net/def/crs/EPSG/0/4326
</gco:CharacterString>
<gco:CharacterString>http://www.opengis.net/def/crs/EPSG/0/4326</gco:CharacterString>
</gmd:code>
</gmd:RS_Identifier>
</gmd:referenceSystemIdentifier>
</gmd:MD_ReferenceSystem>
</gmd:referenceSystemInfo>
<!-- IDENTIFICATION INFO -->
<gmd:identificationInfo>
<gmd:MD_DataIdentification>
<gmd:citation>
@ -161,7 +86,7 @@
<gmd:date>
<gmd:CI_Date>
<gmd:date>
<gco:DateTime>${creationTime?datetime}</gco:DateTime>
<gco:Date>${creationTime?string["yyyy-MM-dd"]}</gco:Date>
</gmd:date>
<gmd:dateType>
<gmd:CI_DateTypeCode codeSpace="eng"
@ -193,6 +118,18 @@
<gmd:credit>
<gco:CharacterString>${credit}</gco:CharacterString>
</gmd:credit>
<!-- RESPONSIBLE PARTIES -->
<#list responsibleParties as responsibleParty>
<gmd:pointOfContact>
<#include "ResponsibleParty.ftlx">
</gmd:pointOfContact>
</#list>
<gmd:resourceMaintenance>
<gmd:MD_MaintenanceInformation>
<gmd:maintenanceAndUpdateFrequency>
@ -203,9 +140,10 @@
</gmd:MD_MaintenanceInformation>
</gmd:resourceMaintenance>
<gmd:descriptiveKeywords>
<!-- KEYWORDS -->
<#list keywords as keyword>
<#list keywords as keyword>
<gmd:descriptiveKeywords>
<gmd:MD_Keywords>
<#list keyword.values as value>
<gmd:keyword>
@ -213,8 +151,8 @@
</gmd:keyword>
</#list>
<gmd:type>
<gmd:MD_KeywordTypeCode codeListValue="theme"
codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#MD_KeywordTypeCode">${keyword.type}</gmd:MD_KeywordTypeCode>
<gmd:MD_KeywordTypeCode codeListValue="${keyword.type}"
codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#MD_KeywordTypeCode"/>
</gmd:type>
<gmd:thesaurusName>
<gmd:CI_Citation>
@ -224,22 +162,43 @@
<gmd:date>
<gmd:CI_Date>
<gmd:date>
<gco:DateTime>${keyword.creationDate?datetime}</gco:DateTime>
<gco:Date>${keyword.creationDate?string["yyyy-MM-dd"]}</gco:Date>
</gmd:date>
<gmd:dateType>
<gmd:CI_DateTypeCode codeSpace="eng"
codeListValue="creation"
codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#CI_DateTypeCode">Creation</gmd:CI_DateTypeCode>
codeListValue="publication"
codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#CI_DateTypeCode"/>
</gmd:dateType>
</gmd:CI_Date>
</gmd:date>
</gmd:CI_Citation>
</gmd:thesaurusName>
</gmd:MD_Keywords>
</#list>
</gmd:descriptiveKeywords>
</#list>
<!-- LEGAL ACCESS AND USE -->
<gmd:resourceConstraints>
<gmd:MD_Constraints>
<gmd:useLimitation>
<gco:CharacterString>The global seafloor geomorphic feature map is available for download from bluehabitats.org</gco:CharacterString>
</gmd:useLimitation>
</gmd:MD_Constraints>
</gmd:resourceConstraints>
<gmd:resourceConstraints>
<gmd:MD_LegalConstraints>
<gmd:accessConstraints>
<gmd:MD_RestrictionCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/gmxCodelists.xml#MD_RestrictionCode" codeListValue="otherRestrictions"/>
</gmd:accessConstraints>
<gmd:otherConstraints>
<gco:CharacterString>no limitations</gco:CharacterString>
</gmd:otherConstraints>
</gmd:MD_LegalConstraints>
</gmd:resourceConstraints>
<!-- SPATIAL RESOLUTION & TOPIC CATEGORY-->
<gmd:spatialResolution>
<gmd:MD_Resolution>
@ -258,6 +217,10 @@
</gmd:topicCategory>
<!-- EXTENT -->
<gmd:extent>
<gmd:EX_Extent>
<gmd:geographicElement>
@ -281,17 +244,124 @@
</gmd:geographicElement>
</gmd:EX_Extent>
</gmd:extent>
</gmd:MD_DataIdentification>
</gmd:identificationInfo>
<#if distributionInfo.type == "GeoServer">
<#include "/GS_DistributionInfo.xml">
<#else>
<#include "/TH_DistributionInfo.xml">
</#if>
<!-- ONLINE REsources and protocols -->
<gmd:distributionInfo>
<gmd:MD_Distribution>
<#list distributionInfo.protocols as protocol>
<gmd:distributionFormat>
<gmd:MD_Format>
<gmd:name>
<gco:CharacterString>${protocol.name()}</gco:CharacterString>
</gmd:name>
<gmd:version>
<gco:CharacterString>${protocol.version}</gco:CharacterString>
</gmd:version>
</gmd:MD_Format>
</gmd:distributionFormat>
</#list>
<gmd:transferOptions>
<gmd:MD_DigitalTransferOptions>
<#list distributionInfo.onlines as online>
<gmd:onLine>
<gmd:CI_OnlineResource>
<gmd:linkage>
<gmd:URL>${online.uri}</gmd:URL>
</gmd:linkage>
<gmd:protocol>
<gco:CharacterString>${online.protocol.declaration}</gco:CharacterString>
</gmd:protocol>
<gmd:name>
<gco:CharacterString>${online.title}</gco:CharacterString>
</gmd:name>
</gmd:CI_OnlineResource>
</gmd:onLine>
</#list>
</gmd:MD_DigitalTransferOptions>
</gmd:transferOptions>
</gmd:MD_Distribution>
</gmd:distributionInfo>
<!-- DATA QUALITY INFO -->
<gmd:dataQualityInfo>
<gmd:DQ_DataQuality>
<gmd:scope>
<gmd:DQ_Scope>
<gmd:level>
<gmd:MD_ScopeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/gmxCodelists.xml#MD_ScopeCode" codeListValue="dataset"/>
</gmd:level>
</gmd:DQ_Scope>
</gmd:scope>
<gmd:report>
<gmd:DQ_DomainConsistency>
<gmd:result>
<gmd:DQ_ConformanceResult>
<gmd:specification>
<gmd:CI_Citation>
<gmd:title>
<gco:CharacterString>Commission Regulation (EU) No 1089/2010 of 23 November 2010 implementing Directive 2007/2/EC of the European Parliament and of the Council as regards interoperability of spatial data sets and services</gco:CharacterString>
</gmd:title>
<gmd:alternateTitle>
<gco:CharacterString>INSPIRE Data Specifications on Species distribution Guidelines</gco:CharacterString>
</gmd:alternateTitle>
<gmd:date>
<gmd:CI_Date>
<gmd:date>
<gco:Date>2010-12-08</gco:Date>
</gmd:date>
<gmd:dateType>
<gmd:CI_DateTypeCode codeList="http://www.isotc211.org/2005/resources/codeList.xml#CI_DateTypeCode" codeListValue="publication" codeSpace="eng"/>
</gmd:dateType>
</gmd:CI_Date>
</gmd:date>
<gmd:date>
<gmd:CI_Date>
<gmd:date>
<gco:Date>2013-12-10</gco:Date>
</gmd:date>
<gmd:dateType>
<gmd:CI_DateTypeCode codeList="http://www.isotc211.org/2005/resources/codeList.xml#CI_DateTypeCode" codeListValue="lastRevision" codeSpace="eng"/>
</gmd:dateType>
</gmd:CI_Date>
</gmd:date>
</gmd:CI_Citation>
</gmd:specification>
<gmd:explanation>
<gco:CharacterString>${guidelinesConformityExplanation!"The conformity to the above INSPIRE data specification has not been fully evaluated. In the absence of an explicit way to specify in ISO 19115 such absence of full evaluation, or eventual intermediate degree of conformity, and in order to fulfill the INSPIRE metadata validation, a conformity metadata element has been added (with the degree arbitrarily set to 'false')"}</gco:CharacterString>
</gmd:explanation>
<gmd:pass>
<gco:Boolean>${guidelinesConformityPass!"false"}</gco:Boolean>
</gmd:pass>
</gmd:DQ_ConformanceResult>
</gmd:result>
</gmd:DQ_DomainConsistency>
</gmd:report>
<gmd:lineage>
<gmd:LI_Lineage>
<gmd:statement>
<gco:CharacterString>${lineageStatement}</gco:CharacterString>
</gmd:statement>
</gmd:LI_Lineage>
</gmd:lineage>
</gmd:DQ_DataQuality>
</gmd:dataQualityInfo>
<!--
<gmd:metadataConstraints>
<gmd:MD_LegalConstraints>
<gmd:useLimitation>
@ -310,4 +380,5 @@
</gmd:otherConstraints>
</gmd:MD_LegalConstraints>
</gmd:metadataConstraints>
-->
</gmd:MD_Metadata>

View File

@ -0,0 +1,39 @@
<gmd:CI_ResponsibleParty>
<gmd:individualName>
<gco:CharacterString>${responsibleParty.individualName}</gco:CharacterString>
</gmd:individualName>
<gmd:organisationName>
<gco:CharacterString>${responsibleParty.organization}</gco:CharacterString>
</gmd:organisationName>
<#if responsibleParty.contact?has_content>
<gmd:contactInfo>
<gmd:CI_Contact>
<gmd:address>
<gmd:CI_Address>
<gmd:electronicMailAddress>
<gco:CharacterString>${responsibleParty.contact.email}</gco:CharacterString>
</gmd:electronicMailAddress>
</gmd:CI_Address>
</gmd:address>
<gmd:onlineResource>
<gmd:CI_OnlineResource>
<gmd:linkage>
<gmd:URL>${responsibleParty.contact.site}</gmd:URL>
</gmd:linkage>
<gmd:protocol>
<gco:CharacterString>WWW:LINK-1.0-http--link</gco:CharacterString>
</gmd:protocol>
<gmd:name>
<gco:CharacterString>${responsibleParty.individualName} site.</gco:CharacterString>
</gmd:name>
</gmd:CI_OnlineResource>
</gmd:onlineResource>
</gmd:CI_Contact>
</gmd:contactInfo>
</#if>
<gmd:role>
<gmd:CI_RoleCode codeListValue="${responsibleParty.role}"
codeList="http://schemas.opengis.net/iso/19139/20070417/resources/Codelist/gmxCodelists.xml#CI_RoleCode"/>
</gmd:role>
</gmd:CI_ResponsibleParty>