git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/spatial-data/gis-interface@129360 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Fabio Sinibaldi 2016-06-23 13:39:15 +00:00
parent 11a94c0394
commit 40d9a20bd0
6 changed files with 76 additions and 31 deletions

View File

@ -21,5 +21,6 @@
</Changeset>
<Changeset component="gis-interface.2-2-0" date="2016-06-01">
<Change>gCube 4 SDI policies integration</Change>
<Change>Added GIS link to generated distribution URIS</Change>
</Changeset>
</ReleaseNotes>

42
pom.xml
View File

@ -30,6 +30,12 @@
<artifactId>geonetwork</artifactId>
<version>[3.0.0-SNAPSHOT,4.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>uri-resolver-manager</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>it.geosolutions</groupId>
<artifactId>geoserver-manager</artifactId>
@ -41,30 +47,14 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>csv4j</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.gcube.resources.discovery</groupId>
<artifactId>ic-client</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-encryption</artifactId>
@ -104,9 +94,19 @@
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.6.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>csv4j</artifactId>
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>

View File

@ -157,13 +157,21 @@ public class GISInterface {
if(publishResult){
toReturn.setDataOperationResult(Report.OperationState.COMPLETE);
MetadataEnricher enricher=new MetadataEnricher(geoNetworkMeta, true);
ArrayList<String> distributionUris=new ArrayList<String>();
distributionUris.add(URIUtils.getWmsUrl(desc.getUrl(), coverageName, defaultStyle, new BoundingBox(bbox)));
distributionUris.add(URIUtils.getWfsUrl(desc.getUrl(), coverageName));
distributionUris.add(URIUtils.getWcsUrl(desc.getUrl(), coverageName, new BoundingBox(bbox)));
try{
distributionUris.add(URIUtils.getGisLinkByUUID(enricher.getMetadataIdentifier()));
}catch(Exception e){
logger.warn("Unabel to get Gis Link ",e);
toReturn.setMetaOperationResult(OperationState.WARN);
toReturn.getMetaOperationMessages().add("Unable to generate GIS link, cause : "+e.getMessage());
}
MetadataEnricher enricher=new MetadataEnricher(geoNetworkMeta, true);
enricher.addDate(new Date(System.currentTimeMillis()), DateType.CREATION);
enricher.addPreview(distributionUris.get(0));
enricher.setdistributionURIs(distributionUris,coverageName);
@ -228,12 +236,21 @@ public class GISInterface {
logger.debug("Published data, enriching meta..");
MetadataEnricher enricher=new MetadataEnricher(geoNetworkMeta, true);
ArrayList<String> distributionUris=new ArrayList<String>();
distributionUris.add(URIUtils.getWmsUrl(desc.getUrl(), fte.getName(), URIUtils.getStyleFromGSLayerEncoder(layerEncoder), null));
distributionUris.add(URIUtils.getWfsUrl(desc.getUrl(), fte.getName()));
distributionUris.add(URIUtils.getWcsUrl(desc.getUrl(), fte.getName(), null));
try{
distributionUris.add(URIUtils.getGisLinkByUUID(enricher.getMetadataIdentifier()));
}catch(Exception e){
logger.warn("Unabel to get Gis Link ",e);
toReturn.setMetaOperationResult(OperationState.WARN);
toReturn.getMetaOperationMessages().add("Unable to generate GIS link, cause : "+e.getMessage());
}
MetadataEnricher enricher=new MetadataEnricher(geoNetworkMeta, true);
enricher.addDate(new Date(System.currentTimeMillis()), DateType.CREATION);
enricher.addPreview(distributionUris.get(0));
enricher.setdistributionURIs(distributionUris,fte.getName());

View File

@ -1,9 +1,16 @@
package org.gcube.spatial.data.gis;
import org.gcube.spatial.data.gis.model.BoundingBox;
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder;
import java.util.HashMap;
import java.util.Map;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.portlets.user.uriresolvermanager.UriResolverManager;
import org.gcube.portlets.user.uriresolvermanager.exception.IllegalArgumentException;
import org.gcube.portlets.user.uriresolvermanager.exception.UriResolverMapException;
import org.gcube.spatial.data.gis.model.BoundingBox;
public class URIUtils {
@ -34,7 +41,13 @@ public class URIUtils {
layerName + "&CRS=EPSG:4326" + "&bbox=" + bbox + "&width=676&height=330&format=geotiff";
}
public static String getGisLinkByUUID(String uuid) throws UriResolverMapException, IllegalArgumentException{
Map<String,String> params=new HashMap();
params.put("scope", ScopeProvider.instance.get());
params.put("gis-UUID", uuid);
UriResolverManager resolver = new UriResolverManager("GIS");
return resolver.getLink(params, true);
}
public static String getStyleFromGSLayerEncoder(GSLayerEncoder encoder){
return encoder.getRoot().getChildText("defaultStyle");

View File

@ -34,13 +34,19 @@ public class MetadataEnricher {
private DefaultMetadata enriched;
private ArrayList<String> messages=new ArrayList<String>();
private String uuid;
private DefaultDataIdentification ident=null;
public MetadataEnricher(Metadata toEnrich,boolean generateUUID) {
this.toEnrich=toEnrich;
this.enriched=castMeta(toEnrich);
if(generateUUID){
enriched.setFileIdentifier(UUID.randomUUID().toString());
uuid=UUID.randomUUID().toString();
enriched.setFileIdentifier(uuid);
}else {
uuid=enriched.getFileIdentifier();
}
if(enriched.getIdentificationInfo().isEmpty()){
@ -50,6 +56,11 @@ public class MetadataEnricher {
}
public String getMetadataIdentifier(){
return uuid;
}
public void addPreview(String previewURL){
try{
ident.getGraphicOverviews().add(new DefaultBrowseGraphic(new URI(previewURL)));
@ -89,7 +100,13 @@ public class MetadataEnricher {
DefaultFormat format3 = new DefaultFormat();
format3.setName(new DefaultInternationalString("WCS"));
format3.setVersion(new DefaultInternationalString("1.0.0"));
distribution.setDistributionFormats(new ArrayList<DefaultFormat>(Arrays.asList(format1, format2, format3)));
//*** GIS-RESOLVER-LINK is HTTP
DefaultFormat format4 = new DefaultFormat();
format4.setName(new DefaultInternationalString("HTTP"));
format4.setVersion(new DefaultInternationalString("1.1.0"));
distribution.setDistributionFormats(new ArrayList<DefaultFormat>(Arrays.asList(format1, format2, format3,format4)));
distribution.getTransferOptions().add(transferOptions);
enriched.setDistributionInfo(distribution);

View File

@ -1,15 +1,12 @@
package org.gcube.spatial.data.gis;
import it.geosolutions.geonetwork.util.GNInsertConfiguration;
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder;
import it.geosolutions.geoserver.rest.encoder.feature.GSFeatureTypeEncoder;
import java.util.ArrayList;
import java.util.Date;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.spatial.data.geonetwork.LoginLevel;
import org.gcube.spatial.data.geonetwork.configuration.Configuration;
import org.gcube.spatial.data.geonetwork.iso.GcubeISOMetadata;
import org.gcube.spatial.data.geonetwork.iso.Thesaurus;
import org.gcube.spatial.data.gis.model.report.PublishResponse;