merge from 2.17
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/spatial-data/gis-interface@85723 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
325f8973a5
commit
0ed5d6ae4f
|
@ -26,6 +26,7 @@ import org.gcube.spatial.data.geonetwork.LoginLevel;
|
|||
import org.gcube.spatial.data.gis.is.GeoServerDescriptor;
|
||||
import org.gcube.spatial.data.gis.is.InfrastructureCrawler;
|
||||
import org.gcube.spatial.data.gis.meta.MetadataEnricher;
|
||||
import org.gcube.spatial.data.gis.model.BoundingBox;
|
||||
import org.gcube.spatial.data.gis.model.report.DeleteReport;
|
||||
import org.gcube.spatial.data.gis.model.report.PublishResponse;
|
||||
import org.gcube.spatial.data.gis.model.report.Report;
|
||||
|
@ -113,34 +114,49 @@ public class GISInterface {
|
|||
|
||||
if(publishResult){
|
||||
toReturn.setDataOperationResult(Report.OperationState.COMPLETE);
|
||||
|
||||
|
||||
ArrayList<String> distributionUris=new ArrayList<String>();
|
||||
// distributionUris.add(desc.getUrl()+"gwc/service/wms")
|
||||
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)));
|
||||
|
||||
MetadataEnricher enricher=new MetadataEnricher(geoNetworkMeta, true);
|
||||
enricher.addDate(new Date(System.currentTimeMillis()), DateType.CREATION);
|
||||
enricher.addPreview(distributionUris.get(0));
|
||||
enricher.setdistributionURIs(distributionUris);
|
||||
enricher.setdistributionURIs(distributionUris,coverageName);
|
||||
toReturn.getMetaOperationMessages().addAll(enricher.getMessages());
|
||||
if(enricher.getMessages().size()>0)toReturn.setMetaOperationResult(OperationState.WARN);
|
||||
GeoNetworkPublisher pub=getGN();
|
||||
getGN().login(level);
|
||||
long returnedId=pub.insertMetadata(config,enricher.getEnriched());
|
||||
|
||||
Metadata enriched=enricher.getEnriched();
|
||||
toReturn.setPublishedMetadata(enriched);
|
||||
long returnedId=pub.insertMetadata(config,enriched);
|
||||
|
||||
toReturn.setReturnedMetaId(returnedId);
|
||||
toReturn.setMetaOperationResult(OperationState.COMPLETE);
|
||||
}else toReturn.getDataOperationMessages().add("Publish operation returned false, unable to publish data");
|
||||
}catch(NoSuchElementException e){
|
||||
toReturn.getDataOperationMessages().add("No GeoServer Found under scope "+ScopeProvider.instance.get());
|
||||
} catch (IllegalArgumentException e) {
|
||||
if(publisher==null)
|
||||
if(publisher==null){
|
||||
toReturn.getDataOperationMessages().add("Unable to instatiate GeoServerRESTPublisher, cause :"+e.getMessage());
|
||||
else toReturn.getDataOperationMessages().add("Unable to publish data, cause :"+e.getMessage());
|
||||
logger.debug("Unable to instatiate GeoServerRESTPublisher",e);
|
||||
}else {
|
||||
toReturn.getDataOperationMessages().add("Unable to publish data, cause :"+e.getMessage());
|
||||
logger.debug("Unable to publish data",e);
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
toReturn.getDataOperationMessages().add("Unable to instatiate GeoServerRESTPublisher, cause :"+e.getMessage());
|
||||
logger.debug("Unable to instatiate GeoServerRESTPublisher",e);
|
||||
} catch (FileNotFoundException e) {
|
||||
toReturn.getDataOperationMessages().add("Unable to publish data, cause :"+e.getMessage());
|
||||
logger.debug("Unable to publish data",e);
|
||||
} catch (Exception e) {
|
||||
// exceptions raised by publishing metadata, need to clean up
|
||||
toReturn.getMetaOperationMessages().add("Unable to publish metadata, cause :"+e.getMessage());
|
||||
logger.debug("Unable to publish metadata",e);
|
||||
DeleteReport delRep=deleteStore(workspace,storeName,null,desc);
|
||||
if(!delRep.getDataOperationResult().equals(OperationState.COMPLETE)){
|
||||
toReturn.setDataOperationResult(OperationState.WARN);
|
||||
|
@ -157,44 +173,65 @@ public class GISInterface {
|
|||
PublishResponse toReturn=new PublishResponse(geoNetworkMeta);
|
||||
GeoServerRESTPublisher publisher=null;
|
||||
GeoServerDescriptor desc=getGeoServerSet(false).last();
|
||||
logger.debug("Publish db table : "+storeName+" under ws : "+workspace);
|
||||
logger.debug("Publish db table : "+storeName+" under ws : "+workspace+", using geoserver "+desc);
|
||||
logger.debug("Using "+desc);
|
||||
try{
|
||||
publisher=getGeoServerManager(desc.getUrl(), desc.getUser(), desc.getPassword()).getPublisher();
|
||||
GeoServerRESTManager mng=getGeoServerManager(desc.getUrl(), desc.getUser(), desc.getPassword());
|
||||
publisher=mng.getPublisher();
|
||||
// Publishing the file to geoserver depends on file type
|
||||
publishResult=publisher.publishDBLayer(workspace, storeName, fte, layerEncoder);
|
||||
|
||||
if(publishResult){
|
||||
toReturn.setDataOperationResult(Report.OperationState.COMPLETE);
|
||||
|
||||
|
||||
logger.debug("Published data, enriching meta..");
|
||||
ArrayList<String> distributionUris=new ArrayList<String>();
|
||||
// distributionUris.add(desc.getUrl()+"gwc/service/wms")
|
||||
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));
|
||||
|
||||
MetadataEnricher enricher=new MetadataEnricher(geoNetworkMeta, true);
|
||||
enricher.addDate(new Date(System.currentTimeMillis()), DateType.CREATION);
|
||||
enricher.addPreview(distributionUris.get(0));
|
||||
enricher.setdistributionURIs(distributionUris);
|
||||
enricher.setdistributionURIs(distributionUris,fte.getName());
|
||||
|
||||
toReturn.getMetaOperationMessages().addAll(enricher.getMessages());
|
||||
if(enricher.getMessages().size()>0)toReturn.setMetaOperationResult(OperationState.WARN);
|
||||
|
||||
|
||||
GeoNetworkPublisher pub=getGN();
|
||||
getGN().login(level);
|
||||
long returnedId=pub.insertMetadata(config,enricher.getEnriched());
|
||||
Metadata enriched=enricher.getEnriched();
|
||||
toReturn.setPublishedMetadata(enriched);
|
||||
long returnedId=pub.insertMetadata(config,enriched);
|
||||
toReturn.setReturnedMetaId(returnedId);
|
||||
toReturn.setMetaOperationResult(OperationState.COMPLETE);
|
||||
}else toReturn.getDataOperationMessages().add("Publish operation returned false, unable to publish data");
|
||||
}else {
|
||||
toReturn.getDataOperationMessages().add("Publish operation returned false, unable to publish data");
|
||||
|
||||
}
|
||||
}catch(NoSuchElementException e){
|
||||
toReturn.getDataOperationMessages().add("No GeoServer Found under scope "+ScopeProvider.instance.get());
|
||||
} catch (IllegalArgumentException e) {
|
||||
if(publisher==null)
|
||||
if(publisher==null){
|
||||
toReturn.getDataOperationMessages().add("Unable to instatiate GeoServerRESTPublisher, cause :"+e.getMessage());
|
||||
else toReturn.getDataOperationMessages().add("Unable to publish data, cause :"+e.getMessage());
|
||||
logger.debug("Unable to instatiate GeoServerRESTPublisher",e);
|
||||
}else {
|
||||
toReturn.getDataOperationMessages().add("Unable to publish data, cause :"+e.getMessage());
|
||||
logger.debug("Unable to publish data",e);
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
toReturn.getDataOperationMessages().add("Unable to instatiate GeoServerRESTPublisher, cause :"+e.getMessage());
|
||||
logger.debug("Unable to instatiate GeoServerRESTPublisher",e);
|
||||
} catch (FileNotFoundException e) {
|
||||
toReturn.getDataOperationMessages().add("Unable to publish data, cause :"+e.getMessage());
|
||||
logger.debug("Unable to publish data",e);
|
||||
} catch (Exception e) {
|
||||
// exceptions raised by publishing metadata, need to clean up
|
||||
toReturn.getMetaOperationMessages().add("Unable to publish metadata, cause :"+e.getMessage());
|
||||
DeleteReport delRep=deleteLayer(workspace,fte.getName(),null,desc);
|
||||
logger.debug("Unable to publish metadata",e);
|
||||
DeleteReport delRep=deleteLayer(workspace,fte.getName(),null,desc,level);
|
||||
if(!delRep.getDataOperationResult().equals(OperationState.COMPLETE)){
|
||||
toReturn.setDataOperationResult(OperationState.WARN);
|
||||
toReturn.getDataOperationMessages().add("Unable to rollback data publishing, following messages from delete operation (state : "+delRep.getDataOperationResult()+")");
|
||||
|
@ -222,14 +259,20 @@ public class GISInterface {
|
|||
}catch(NoSuchElementException e){
|
||||
toReturn.getDataOperationMessages().add("No GeoServer Found under scope "+ScopeProvider.instance.get());
|
||||
} catch (IllegalArgumentException e) {
|
||||
if(publisher==null)
|
||||
if(publisher==null){
|
||||
toReturn.getDataOperationMessages().add("Unable to instatiate GeoServerRESTPublisher, cause :"+e.getMessage());
|
||||
else toReturn.getDataOperationMessages().add("Unable to publish data, cause :"+e.getMessage());
|
||||
logger.debug("Unable to instatiate GeoServerRESTPublisher",e);
|
||||
}else {
|
||||
toReturn.getDataOperationMessages().add("Unable to publish data, cause :"+e.getMessage());
|
||||
logger.debug("Unable to publish data",e);
|
||||
}
|
||||
} catch (MalformedURLException e) {
|
||||
toReturn.getDataOperationMessages().add("Unable to instatiate GeoServerRESTPublisher, cause :"+e.getMessage());
|
||||
logger.debug("Unable to instatiate GeoServerRESTPublisher",e);
|
||||
} catch (Exception e) {
|
||||
// exceptions raised by publishing metadata, need to clean up
|
||||
toReturn.getMetaOperationMessages().add("Unable to publish metadata, cause :"+e.getMessage());
|
||||
logger.debug("Unable to publish metadata",e);
|
||||
DeleteReport delRep=deleteStyle(styleName,desc);
|
||||
if(!delRep.getDataOperationResult().equals(OperationState.COMPLETE)){
|
||||
toReturn.setDataOperationResult(OperationState.WARN);
|
||||
|
@ -274,7 +317,7 @@ public class GISInterface {
|
|||
return toReturn;
|
||||
}
|
||||
|
||||
public DeleteReport deleteLayer(String workspace,String layerName, Long metadataUUID,GeoServerDescriptor desc){
|
||||
public DeleteReport deleteLayer(String workspace,String layerName, Long metadataUUID,GeoServerDescriptor desc,LoginLevel gnLoginLevel){
|
||||
DeleteReport toReturn=new DeleteReport();
|
||||
GeoServerRESTPublisher publisher=null;
|
||||
try{
|
||||
|
@ -283,7 +326,9 @@ public class GISInterface {
|
|||
if(removed){
|
||||
toReturn.setDataOperationResult(Report.OperationState.COMPLETE);
|
||||
if(metadataUUID!=null){
|
||||
getGN().deleteMetadata(metadataUUID);
|
||||
GeoNetworkPublisher gnPub=getGN();
|
||||
gnPub.login(gnLoginLevel);
|
||||
gnPub.deleteMetadata(metadataUUID);
|
||||
}else {
|
||||
toReturn.setMetaOperationResult(OperationState.WARN);
|
||||
toReturn.getMetaOperationMessages().add("Passed meta UUID is null, no metadata deleted");
|
||||
|
@ -352,9 +397,6 @@ public class GISInterface {
|
|||
|
||||
|
||||
|
||||
//********************* PRIVATE PUBLISH BY FILE TYPE
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,50 @@
|
|||
package org.gcube.spatial.data.gis;
|
||||
|
||||
import org.gcube.spatial.data.gis.model.BoundingBox;
|
||||
|
||||
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder;
|
||||
|
||||
public class URIUtils {
|
||||
|
||||
|
||||
public static final String CRS="EPSG:4326";
|
||||
public static final String WMS_PROTOCOL="OGC:WMS-1.3.0-http-get-map";
|
||||
public static final String WFS_PROTOCOL="OGC:WFS-1.0.0-http-get-feature";
|
||||
public static final String HTTP_PROTOCOL="WWW:LINK-1.0-http--link";
|
||||
|
||||
|
||||
public static String getWmsUrl(String geoServerUrl, String layerName,String style, BoundingBox bbox) {
|
||||
if(bbox==null) bbox=BoundingBox.WORLD_EXTENT;
|
||||
return geoServerUrl +
|
||||
"/wms?service=wms&version=1.1.0"
|
||||
+ "&request=GetMap&layers=" + layerName
|
||||
+ "&styles=" + (style == null ? "" : style)
|
||||
+ "&bbox=" + bbox + "&width=676&height=330" +
|
||||
"&srs=EPSG:4326&crs="+CRS+"&format=application/openlayers";
|
||||
}
|
||||
public static String getWfsUrl(String geoServerUrl, String layerName) {
|
||||
return geoServerUrl +
|
||||
"/ows?service=wfs&version=1.0.0"
|
||||
+ "&request=GetFeature&typeName=" + layerName
|
||||
+"&format=json";
|
||||
}
|
||||
public static String getWcsUrl(String geoServerUrl, String layerName,BoundingBox bbox) {
|
||||
if(bbox==null) bbox=BoundingBox.WORLD_EXTENT;
|
||||
return geoServerUrl + "/wcs?service=wcs&version=1.0.0" + "&request=GetCoverage&coverage=" +
|
||||
layerName + "&CRS=EPSG:4326" + "&bbox=" + bbox + "&width=676&height=330&format=geotiff";
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static String getStyleFromGSLayerEncoder(GSLayerEncoder encoder){
|
||||
return encoder.getRoot().getChildText("defaultStyle");
|
||||
}
|
||||
|
||||
public static final String getProtocol(String uri){
|
||||
uri=uri.toLowerCase();
|
||||
if(uri.contains(("service=wms"))) return WMS_PROTOCOL;
|
||||
else if(uri.contains("service=wfs")) return WFS_PROTOCOL;
|
||||
else return HTTP_PROTOCOL;
|
||||
}
|
||||
|
||||
}
|
|
@ -3,20 +3,23 @@ package org.gcube.spatial.data.gis.meta;
|
|||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.spatial.data.gis.model.report.Report.OperationState;
|
||||
import org.gcube.spatial.data.gis.URIUtils;
|
||||
import org.geotoolkit.metadata.iso.DefaultMetadata;
|
||||
import org.geotoolkit.metadata.iso.citation.DefaultCitation;
|
||||
import org.geotoolkit.metadata.iso.citation.DefaultCitationDate;
|
||||
import org.geotoolkit.metadata.iso.citation.DefaultOnlineResource;
|
||||
import org.geotoolkit.metadata.iso.distribution.DefaultDigitalTransferOptions;
|
||||
import org.geotoolkit.metadata.iso.distribution.DefaultDistribution;
|
||||
import org.geotoolkit.metadata.iso.distribution.DefaultFormat;
|
||||
import org.geotoolkit.metadata.iso.identification.DefaultBrowseGraphic;
|
||||
import org.geotoolkit.metadata.iso.identification.DefaultDataIdentification;
|
||||
import org.geotoolkit.util.DefaultInternationalString;
|
||||
import org.opengis.metadata.Metadata;
|
||||
import org.opengis.metadata.citation.CitationDate;
|
||||
import org.opengis.metadata.citation.DateType;
|
||||
|
@ -57,18 +60,37 @@ public class MetadataEnricher {
|
|||
}
|
||||
}
|
||||
|
||||
public void setdistributionURIs(List<String> uris){
|
||||
public void setdistributionURIs(List<String> uris,String layerName){
|
||||
DefaultDistribution distribution=new DefaultDistribution();
|
||||
|
||||
DefaultDigitalTransferOptions transferOptions=new DefaultDigitalTransferOptions();
|
||||
for(String uri:uris)
|
||||
for(String uriString:uris)
|
||||
try{
|
||||
transferOptions.getOnLines().add(new DefaultOnlineResource(new URI(uri)));
|
||||
URI uri=new URI(uriString);
|
||||
DefaultOnlineResource resource=new DefaultOnlineResource(uri);
|
||||
String protocol=URIUtils.getProtocol(uriString);
|
||||
resource.setName(layerName);
|
||||
resource.setProtocol(protocol);
|
||||
transferOptions.getOnLines().add(resource);
|
||||
|
||||
}catch(URISyntaxException e){
|
||||
String msg="Unable to set transfer option, passed URI is "+uri+", cause : "+e.getMessage();
|
||||
String msg="Unable to set transfer option, passed URI is "+uriString+", cause : "+e.getMessage();
|
||||
logger.warn(msg);
|
||||
messages.add(msg);
|
||||
}
|
||||
|
||||
//******* Assuming all formats available
|
||||
DefaultFormat format1 = new DefaultFormat();
|
||||
format1.setName(new DefaultInternationalString("WMS"));
|
||||
format1.setVersion(new DefaultInternationalString("1.1.0"));
|
||||
DefaultFormat format2 = new DefaultFormat();
|
||||
format2.setName(new DefaultInternationalString("WFS"));
|
||||
format2.setVersion(new DefaultInternationalString("1.1.0"));
|
||||
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)));
|
||||
|
||||
distribution.getTransferOptions().add(transferOptions);
|
||||
enriched.setDistributionInfo(distribution);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,84 @@
|
|||
package org.gcube.spatial.data.gis.model;
|
||||
|
||||
public class BoundingBox {
|
||||
|
||||
public static final BoundingBox WORLD_EXTENT=new BoundingBox(90, -90, 180, -180);
|
||||
|
||||
private double N=90;
|
||||
private double S=-90;
|
||||
private double W=180;
|
||||
private double E=-180;
|
||||
|
||||
public BoundingBox(double n, double s, double w, double e) {
|
||||
super();
|
||||
N = n;
|
||||
S = s;
|
||||
W = w;
|
||||
E = e;
|
||||
}
|
||||
|
||||
/**
|
||||
* Assumed order is E, S, W, N
|
||||
*
|
||||
* @param bbox
|
||||
*/
|
||||
public BoundingBox(double[] bbox) {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
|
||||
public double getN() {
|
||||
return N;
|
||||
}
|
||||
|
||||
public void setN(double n) {
|
||||
N = n;
|
||||
}
|
||||
|
||||
public double getS() {
|
||||
return S;
|
||||
}
|
||||
|
||||
public void setS(double s) {
|
||||
S = s;
|
||||
}
|
||||
|
||||
public double getW() {
|
||||
return W;
|
||||
}
|
||||
|
||||
public void setW(double w) {
|
||||
W = w;
|
||||
}
|
||||
|
||||
public double getE() {
|
||||
return E;
|
||||
}
|
||||
|
||||
public void setE(double e) {
|
||||
E = e;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return E, S, W, N
|
||||
*/
|
||||
public double[] toArray(){
|
||||
return new double[]{
|
||||
E,S,W,N
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return E, S, W, N
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return E+","+S+","+W+","+N;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,95 @@
|
|||
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;
|
||||
import org.geotoolkit.metadata.iso.extent.DefaultExtent;
|
||||
import org.opengis.metadata.citation.PresentationForm;
|
||||
import org.opengis.metadata.identification.TopicCategory;
|
||||
import org.opengis.metadata.spatial.GeometricObjectType;
|
||||
import org.opengis.metadata.spatial.TopologyLevel;
|
||||
|
||||
public class PublishTable {
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
|
||||
|
||||
|
||||
private static final String crs="GEOGCS[\"WGS 84\", DATUM[\"World Geodetic System 1984\", SPHEROID[\"WGS 84\", 6378137.0, 298.257223563, AUTHORITY[\"EPSG\",\"7030\"]],"+
|
||||
"AUTHORITY[\"EPSG\",\"6326\"]], PRIMEM[\"Greenwich\", 0.0, AUTHORITY[\"EPSG\",\"8901\"]], UNIT[\"degree\", 0.017453292519943295],"+
|
||||
"AXIS[\"Geodetic longitude\", EAST], AXIS[\"Geodetic latitude\", NORTH], AUTHORITY[\"EPSG\",\"4326\"]]";
|
||||
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
String scope="/gcube";
|
||||
String toPublishTable="mytable";
|
||||
String datastore="mydatastore";
|
||||
|
||||
|
||||
String defaultStyle="defaultStyle";
|
||||
String workspace="myworkspace";
|
||||
|
||||
|
||||
|
||||
GSFeatureTypeEncoder fte=new GSFeatureTypeEncoder();
|
||||
fte.setEnabled(true);
|
||||
fte.setLatLonBoundingBox(-180.0, -90.0, 180.0, 90.0, crs);
|
||||
fte.setName(toPublishTable);
|
||||
fte.setNativeCRS(crs);
|
||||
|
||||
GSLayerEncoder le=new GSLayerEncoder();
|
||||
le.setDefaultStyle(defaultStyle);
|
||||
le.setEnabled(true);
|
||||
|
||||
ScopeProvider.instance.set(scope);
|
||||
GcubeISOMetadata meta=fillMeta();
|
||||
|
||||
|
||||
GISInterface gis=GISInterface.get();
|
||||
Configuration gnConfig=gis.getGeoNetworkReader().getConfiguration();
|
||||
|
||||
PublishResponse resp=gis.publishDBTable(workspace, datastore, fte, le, meta.getMetadata(), new GNInsertConfiguration(gnConfig.getScopeGroup()+"", "datasets", "_none_", true), LoginLevel.DEFAULT);
|
||||
System.out.println(resp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static GcubeISOMetadata fillMeta() throws Exception{
|
||||
GcubeISOMetadata meta=new GcubeISOMetadata();
|
||||
meta.setAbstractField("This metadata is just a test");
|
||||
meta.setCreationDate(new Date(System.currentTimeMillis()));
|
||||
meta.setExtent((DefaultExtent) DefaultExtent.WORLD);
|
||||
meta.setGeometricObjectType(GeometricObjectType.SURFACE);
|
||||
meta.setPresentationForm(PresentationForm.MAP_DIGITAL);
|
||||
meta.setPurpose("Purpose of this layer is to test the library");
|
||||
meta.setResolution(0.5d);
|
||||
meta.setTitle("My Test Layer");
|
||||
meta.setTopologyLevel(TopologyLevel.GEOMETRY_ONLY);
|
||||
meta.setUser("fabio.sinibaldi");
|
||||
|
||||
|
||||
meta.addCredits("Thanks to me");
|
||||
meta.addGraphicOverview("http://www.d4science.org/D4ScienceOrg-Social-theme/images/custom/D4ScienceInfrastructure.png");
|
||||
|
||||
Thesaurus generalThesaurus=meta.getConfig().getThesauri().get("General");
|
||||
meta.addKeyword("TEST", generalThesaurus);
|
||||
meta.addKeyword("Geoserverinterface", generalThesaurus);
|
||||
|
||||
meta.addTopicCategory(TopicCategory.BIOTA);
|
||||
return meta;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
package org.gcube.spatial.data.gis;
|
||||
|
||||
import it.geosolutions.geoserver.rest.encoder.GSLayerEncoder;
|
||||
|
||||
|
||||
public class StringTest {
|
||||
|
||||
|
||||
public static void main (String[] args){
|
||||
String style="myDefaultStyle09";
|
||||
GSLayerEncoder lenc=new GSLayerEncoder();
|
||||
lenc.setDefaultStyle(style);
|
||||
lenc.setEnabled(true);
|
||||
lenc.setQueryable(true);
|
||||
|
||||
|
||||
String res=URIUtils.getStyleFromGSLayerEncoder(lenc);
|
||||
System.out.println(style+(style.equals(res)?" = ":" != ")+res);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue