Initial import.

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/spatial-data/gis-interface@99548 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Fabio Sinibaldi 2014-09-05 12:54:25 +00:00
parent fdbda47be8
commit f7bc543013
28 changed files with 0 additions and 1629 deletions

View File

@ -1,36 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<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 kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

View File

@ -1,23 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>gis-interface</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

View File

@ -1,6 +0,0 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
encoding/<project>=UTF-8

View File

@ -1,5 +0,0 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.6

View File

@ -1,4 +0,0 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=false
version=1

View File

@ -1 +0,0 @@
Used as library to communicate with Geonetwork

View File

@ -1,6 +0,0 @@
gCube System - License
------------------------------------------------------------
The gCube/gCore software is licensed as Free Open Source software conveying to the EUPL (http://ec.europa.eu/idabc/eupl).
The software and documentation is provided by its authors/distributors "as is" and no expressed or
implied warranty is given for its use, quality or fitness for a particular case.

View File

@ -1,2 +0,0 @@
* Sinibaldi Fabio (fabio.sinibaldi@isti.cnr.it), CNR Pisa,
Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo".

View File

@ -1,46 +0,0 @@
The gCube System - MetadataManager
------------------------------------------------------------
This work has been partially supported by the following European projects: iMarine (FP7-INFRASTRUCTURES-2011-2), and EUBrazilOpenBio (FP7-ICT-2011-EU-Brazil).
Authors
-------
* Sinibaldi Fabio (fabio.sinibaldi@isti.cnr.it), CNR Pisa,
Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo".
Version and Release Date
------------------------
v. 1.0.0 (2013-03-01)
* Geonetwwork interaction
Description
-----------
Geonetwork communication layer
Download information
--------------------
Source code is available from SVN:
http://svn.d4science.research-infrastructures.eu/gcube/trunk/spatial-data/geonetwork
Documentation
-------------
Documentation is available on-line from the Projects Documentation Wiki:
https://technical.wiki.d4science.research-infrastructures.eu/documentation/index.php
Licensing
---------
This software is licensed under the terms you may find in the file named "LICENSE" in this directory.

View File

@ -1,6 +0,0 @@
<ReleaseNotes xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="xsd/changelog.xsd">
<Changeset component="org.gcube.spatial-data.geonetowrk.1-0-0" date="2013-03-01">
<Change>First Release</Change>
</Changeset>
</ReleaseNotes>

View File

@ -1,42 +0,0 @@
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>servicearchive</id>
<formats>
<format>tar.gz</format>
</formats>
<baseDirectory>/</baseDirectory>
<fileSets>
<fileSet>
<directory>${distroDirectory}</directory>
<outputDirectory>/</outputDirectory>
<useDefaultExcludes>true</useDefaultExcludes>
<includes>
<include>README</include>
<include>LICENSE</include>
<include>INSTALL</include>
<include>MAINTAINERS</include>
<include>changelog.xml</include>
</includes>
<fileMode>755</fileMode>
<filtered>true</filtered>
</fileSet>
</fileSets>
<files>
<file>
<source>${distroDirectory}/profile.xml</source>
<outputDirectory>/</outputDirectory>
<filtered>true</filtered>
</file>
<file>
<source>target/${build.finalName}.jar</source>
<outputDirectory>/${artifactId}</outputDirectory>
</file>
<file>
<source>${distroDirectory}/svnpath.txt</source>
<outputDirectory>/${artifactId}</outputDirectory>
<filtered>true</filtered>
</file>
</files>
</assembly>

View File

@ -1,25 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<Resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ID />
<Type>Service</Type>
<Profile>
<Description>${description}</Description>
<Class>SpatialData</Class>
<Name>${artifactId}</Name>
<Version>1.0.0</Version>
<Packages>
<Software>
<Name>${artifactId}</Name>
<Version>${version}</Version>
<MavenCoordinates>
<groupId>${groupId}</groupId>
<artifactId>${artifactId}</artifactId>
<version>${version}</version>
</MavenCoordinates>
<Files>
<File>${build.finalName}.jar</File>
</Files>
</Software>
</Packages>
</Profile>
</Resource>

View File

@ -1 +0,0 @@
${scm.url}

152
pom.xml
View File

@ -1,152 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>maven-parent</artifactId>
<groupId>org.gcube.tools</groupId>
<version>1.0.0</version>
</parent>
<groupId>org.gcube.spatial.data</groupId>
<artifactId>gis-interface</artifactId>
<version>2.0.1-SNAPSHOT</version>
<name>gis-interface</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<geotools.version>8.0-M4</geotools.version>
<distroDirectory>distro</distroDirectory>
</properties>
<scm>
<connection>scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/spatial-data/${project.artifactId}</connection>
<developerConnection>scm:svn:https://svn.d4science.research-infrastructures.eu/gcube/trunk/spatial-data/${project.artifactId}</developerConnection>
<url>http://svn.d4science.research-infrastructures.eu/gcube/trunk/spatial-data/${project.artifactId}</url>
</scm>
<dependencies>
<dependency>
<groupId>org.gcube.spatial.data</groupId>
<artifactId>geonetwork</artifactId>
<version>[2.0.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>it.geosolutions</groupId>
<artifactId>geoserver-manager</artifactId>
<version>1.5.1</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</exclusion>
</exclusions>
</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>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-utils-encryption</artifactId>
<version>1.0.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.geotoolkit.pending</groupId>
<artifactId>geotk-style</artifactId>
<version>3.20</version>
</dependency>
<dependency>
<groupId>org.geotoolkit.pending</groupId>
<artifactId>geotk-xml-sld</artifactId>
<version>3.20</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<repositories>
<repository>
<id>GeoSolutions</id>
<url>http://maven.research-infrastructures.eu:8081/nexus/content/repositories/geo-solutions/</url>
</repository>
<repository>
<id>maven.geotoolkit</id>
<name>maven.geotoolkit</name>
<url>http://maven.research-infrastructures.eu/nexus/content/repositories/geotoolkit/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<executions>
<execution>
<id>copy-profile</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>target</outputDirectory>
<resources>
<resource>
<directory>${distroDirectory}</directory>
<filtering>true</filtering>
<includes>
<include>profile.xml</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>${distroDirectory}/descriptor.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>servicearchive</id>
<phase>install</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,213 +0,0 @@
package org.gcube.spatial.data.gis;
import it.geosolutions.geonetwork.util.GNInsertConfiguration;
import it.geosolutions.geoserver.rest.GeoServerRESTManager;
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher;
import it.geosolutions.geoserver.rest.GeoServerRESTReader;
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder.ProjectionPolicy;
import java.io.File;
import java.io.FileNotFoundException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Date;
import java.util.NoSuchElementException;
import java.util.SortedSet;
import java.util.concurrent.ConcurrentSkipListSet;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.spatial.data.geonetwork.GeoNetwork;
import org.gcube.spatial.data.geonetwork.GeoNetworkPublisher;
import org.gcube.spatial.data.geonetwork.GeoNetworkReader;
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.report.DeleteReport;
import org.gcube.spatial.data.gis.model.report.PublishResponse;
import org.gcube.spatial.data.gis.model.report.Report;
import org.gcube.spatial.data.gis.model.report.Report.OperationState;
import org.opengis.metadata.Metadata;
import org.opengis.metadata.citation.DateType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class GISInterface {
final static Logger logger= LoggerFactory.getLogger(GISInterface.class);
private static final long MAX_GEOSERVER_CACHE_TIME=2*60*1000;
public static GISInterface get() throws Exception{
return new GISInterface();
}
//************ INSTANCE
private GISInterface() throws Exception{
}
//*******************READER getter METHODS
public GeoNetworkReader getGeoNetworkReader() throws Exception{
return getGN();
}
public GeoNetworkPublisher getGeoNewtorkPublisher()throws Exception{
return getGN();
}
public GeoServerRESTReader getGeoServerReader(ResearchMethod method,boolean forceRefresh) throws Exception{
GeoServerDescriptor desc=getGeoServerSet(forceRefresh).last();
return getGeoServerManager(desc.getUrl(), desc.getUser(), desc.getPassword()).getReader();
}
public GeoServerRESTReader getGeoServerReader(String url,String user,String password) throws IllegalArgumentException, MalformedURLException{
return getGeoServerManager(url, user, password).getReader();
}
public GeoServerRESTReader getGeoServerReader(String url) throws MalformedURLException{
return new GeoServerRESTReader(url);
}
//******************* Create logic
/**
* @see it.geosolutions.geoserver.rest.GeoServerRESTPublisher#publishGeoTIFF(String, String, String, File, String, ProjectionPolicy, String, double[])
*
* @param geoNetworkMeta
* @param config
* @return
*/
public PublishResponse addGeoTIFF(String workspace, String storeName, String coverageName,
File toPublishFile,String srs,
ProjectionPolicy policy,String defaultStyle, double[] bbox,
Metadata geoNetworkMeta, GNInsertConfiguration config, LoginLevel level){
boolean publishResult = false;
PublishResponse toReturn=new PublishResponse(geoNetworkMeta);
GeoServerRESTPublisher publisher=null;
try{
GeoServerDescriptor desc=getGeoServerSet(false).last();
logger.debug("Using "+desc);
publisher=getGeoServerManager(desc.getUrl(), desc.getUser(), desc.getPassword()).getPublisher();
// Publishing the file to geoserver depends on file type
publishResult=publisher.publishGeoTIFF(workspace, storeName, coverageName, toPublishFile, srs, policy, defaultStyle, bbox);
if(publishResult){
toReturn.setDataOperationResult(Report.OperationState.COMPLETE);
ArrayList<String> distributionUris=new ArrayList<String>();
// distributionUris.add(desc.getUrl()+"gwc/service/wms")
MetadataEnricher enricher=new MetadataEnricher(geoNetworkMeta, true);
enricher.addDate(new Date(System.currentTimeMillis()), DateType.CREATION);
enricher.addPreview(distributionUris.get(0));
enricher.setdistributionURIs(distributionUris);
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());
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)
toReturn.getDataOperationMessages().add("Unable to instatiate GeoServerRESTPublisher, cause :"+e.getMessage());
else toReturn.getDataOperationMessages().add("Unable to publish data, cause :"+e.getMessage());
} catch (MalformedURLException e) {
toReturn.getDataOperationMessages().add("Unable to instatiate GeoServerRESTPublisher, cause :"+e.getMessage());
} catch (FileNotFoundException e) {
toReturn.getDataOperationMessages().add("Unable to publish data, cause :"+e.getMessage());
} catch (Exception e) {
// exceptions raised by publishing metadata, need to clean up
toReturn.getMetaOperationMessages().add("Unable to publish metadata, cause :"+e.getMessage());
DeleteReport delRep=deleteStore(workspace,storeName,null);
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()+")");
toReturn.getDataOperationMessages().addAll(delRep.getDataOperationMessages());
}
}
return toReturn;
}
// ********************* DELETE Logic
/**
* @see it.geosolutions.geoserver.rest.GeoServerRESTPublisher#removeDatastore(String, String, boolean)
*
*/
public DeleteReport deleteStore(String workspace,String storeName,Long metadataUUID){
DeleteReport toReturn=new DeleteReport();
GeoServerRESTPublisher publisher=null;
try{
GeoServerDescriptor desc=getGeoServerSet(false).last();
publisher=getGeoServerManager(desc.getUrl(), desc.getUser(), desc.getPassword()).getPublisher();
boolean removed=publisher.removeDatastore(workspace, storeName,true);
if(removed){
toReturn.setDataOperationResult(Report.OperationState.COMPLETE);
if(metadataUUID!=null){
getGN().deleteMetadata(metadataUUID);
}else {
toReturn.setMetaOperationResult(OperationState.WARN);
toReturn.getMetaOperationMessages().add("Passed meta UUID is null, no metadata deleted");
}
}else toReturn.getDataOperationMessages().add("Remove data operation returned false, unable to delete Store");
}catch(NoSuchElementException e){
toReturn.getDataOperationMessages().add("No GeoServer Found under scope "+ScopeProvider.instance.get());
} catch (IllegalArgumentException e) {
if(publisher==null)
toReturn.getDataOperationMessages().add("Unable to instatiate GeoServerRESTPublisher, cause :"+e.getMessage());
else toReturn.getDataOperationMessages().add("Unable to publish data, cause :"+e.getMessage());
} catch (MalformedURLException e) {
toReturn.getDataOperationMessages().add("Unable to instatiate GeoServerRESTPublisher, cause :"+e.getMessage());
} catch (Exception e) {
toReturn.getMetaOperationMessages().add("Unable to delete metadata, cause :"+e.getMessage());
}
return toReturn;
}
//************ PRIVATE
private GeoNetworkPublisher geoNetwork=null;
private ConcurrentSkipListSet<GeoServerDescriptor> geoservers=new ConcurrentSkipListSet<GeoServerDescriptor>();
private long lastAccessedTime=0l;
private synchronized SortedSet<GeoServerDescriptor> getGeoServerSet(boolean forceRefresh){
if(forceRefresh||geoservers.size()==0||System.currentTimeMillis()-lastAccessedTime>MAX_GEOSERVER_CACHE_TIME){
geoservers.clear();
geoservers.addAll(InfrastructureCrawler.queryforGeoServer());
lastAccessedTime=System.currentTimeMillis();
}
return geoservers;
}
private synchronized GeoNetworkPublisher getGN() throws Exception{
if(geoNetwork==null) geoNetwork=GeoNetwork.get();
return geoNetwork;
}
private GeoServerRESTManager getGeoServerManager(String url,String user,String password) throws IllegalArgumentException, MalformedURLException{
return new GeoServerRESTManager(new URL(url), user, password);
}
//********************* PRIVATE PUBLISH BY FILE TYPE
}

View File

@ -1,6 +0,0 @@
package org.gcube.spatial.data.gis;
public enum ResearchMethod {
RANDOM,MOSTUNLOAD
}

View File

@ -1,144 +0,0 @@
package org.gcube.spatial.data.gis.is;
public class GeoServerDescriptor implements Comparable<GeoServerDescriptor>{
private String url;
private String user;
private String password;
private Long hostedLayersCount;
public GeoServerDescriptor(String url, String user, String password,
Long hostedLayersCount) {
super();
this.url = url;
this.user = user;
this.password = password;
this.hostedLayersCount = hostedLayersCount;
}
/* (non-Javadoc)
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
@Override
public int compareTo(GeoServerDescriptor o) {
// TODO Auto-generated method stub
return hostedLayersCount.compareTo(o.hostedLayersCount);
}
/**
* @return the url
*/
public String getUrl() {
return url;
}
/**
* @param url the url to set
*/
public void setUrl(String url) {
this.url = url;
}
/**
* @return the user
*/
public String getUser() {
return user;
}
/**
* @param user the user to set
*/
public void setUser(String user) {
this.user = user;
}
/**
* @return the password
*/
public String getPassword() {
return password;
}
/**
* @param password the password to set
*/
public void setPassword(String password) {
this.password = password;
}
/**
* @return the hostedLayersCount
*/
public Long getHostedLayersCount() {
return hostedLayersCount;
}
/**
* @param hostedLayersCount the hostedLayersCount to set
*/
public void setHostedLayersCount(Long hostedLayersCount) {
this.hostedLayersCount = hostedLayersCount;
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((url == null) ? 0 : url.hashCode());
return result;
}
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
GeoServerDescriptor other = (GeoServerDescriptor) obj;
if (url == null) {
if (other.url != null)
return false;
} else if (!url.equals(other.url))
return false;
return true;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("GeoServerDescriptor [url=");
builder.append(url);
builder.append(", user=");
builder.append(user);
builder.append(", password=");
builder.append(password);
builder.append(", hostedLayersCount=");
builder.append(hostedLayersCount);
builder.append("]");
return builder.toString();
}
}

View File

@ -1,47 +0,0 @@
package org.gcube.spatial.data.gis.is;
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
import java.util.ArrayList;
import java.util.List;
import org.gcube.common.resources.gcore.ServiceEndpoint;
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
import org.gcube.common.utils.encryption.StringEncrypter;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.gcube.spatial.data.gis.GISInterface;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class InfrastructureCrawler {
final static Logger logger= LoggerFactory.getLogger(InfrastructureCrawler.class);
public static List<GeoServerDescriptor> queryforGeoServer(){
List<GeoServerDescriptor> toReturn=new ArrayList<GeoServerDescriptor>();
SimpleQuery query = queryFor(ServiceEndpoint.class);
query.addCondition("$resource/Profile/Category/text() eq 'Gis'")
.addCondition("$resource/Profile/Platform/Name/text() eq 'GeoServer'")
.setResult("$resource/Profile/AccessPoint");
DiscoveryClient<AccessPoint> client = clientFor(AccessPoint.class);
List<AccessPoint> accesspoints = client.submit(query);
// if(accesspoints.size()==0) throw new Exception("No Resource found under current scope "+ScopeProvider.instance.get());
for (AccessPoint point : accesspoints) {
try{
toReturn.add(new GeoServerDescriptor(point.address(),point.username(),StringEncrypter.getEncrypter().decrypt(point.password()),0l));
}catch(Exception e){
logger.warn("Unable to decript password for "+point.username()+" in access point "+point.address()+", access to modify methods may fail");
}
// url=point.address();
// user=point.username();
// pwd=point.password();
}
return toReturn;
}
}

View File

@ -1,102 +0,0 @@
package org.gcube.spatial.data.gis.meta;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
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.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.identification.DefaultBrowseGraphic;
import org.geotoolkit.metadata.iso.identification.DefaultDataIdentification;
import org.opengis.metadata.Metadata;
import org.opengis.metadata.citation.CitationDate;
import org.opengis.metadata.citation.DateType;
import org.opengis.metadata.identification.DataIdentification;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class MetadataEnricher {
final static Logger logger= LoggerFactory.getLogger(MetadataEnricher.class);
private Metadata toEnrich;
private DefaultMetadata enriched;
private ArrayList<String> messages=new ArrayList<String>();
private DefaultDataIdentification ident=null;
public MetadataEnricher(Metadata toEnrich,boolean generateUUID) {
this.toEnrich=toEnrich;
this.enriched=castMeta(toEnrich);
if(generateUUID){
enriched.setFileIdentifier(UUID.randomUUID().toString());
}
if(enriched.getIdentificationInfo().isEmpty()){
ident=new DefaultDataIdentification();
enriched.getIdentificationInfo().add(ident);
}else ident=new DefaultDataIdentification((DataIdentification)enriched.getIdentificationInfo().iterator().next());
}
public void addPreview(String previewURL){
try{
ident.getGraphicOverviews().add(new DefaultBrowseGraphic(new URI(previewURL)));
}catch(URISyntaxException e){
String msg="Unable to set preview, passed URI is "+previewURL+", cause : "+e.getMessage();
logger.warn(msg);
messages.add(msg);
}
}
public void setdistributionURIs(List<String> uris){
DefaultDistribution distribution=new DefaultDistribution();
DefaultDigitalTransferOptions transferOptions=new DefaultDigitalTransferOptions();
for(String uri:uris)
try{
transferOptions.getOnLines().add(new DefaultOnlineResource(new URI(uri)));
}catch(URISyntaxException e){
String msg="Unable to set transfer option, passed URI is "+uri+", cause : "+e.getMessage();
logger.warn(msg);
messages.add(msg);
}
distribution.getTransferOptions().add(transferOptions);
enriched.setDistributionInfo(distribution);
}
public void addDate(Date toAdd,DateType type){
DefaultCitationDate publishDate=new DefaultCitationDate(toAdd, type);
if(ident.getCitation()==null){
DefaultCitation citation=new DefaultCitation();
citation.getDates().add(publishDate);
}else ((Collection<CitationDate>)ident.getCitation().getDates()).add((CitationDate)publishDate);
}
public DefaultMetadata getEnriched() {
return enriched;
}
public Metadata getToEnrich() {
return toEnrich;
}
public ArrayList<String> getMessages() {
return messages;
}
private static final DefaultMetadata castMeta(Metadata meta){
if(meta.getClass().isAssignableFrom(DefaultMetadata.class))
return (DefaultMetadata)meta;
else return new DefaultMetadata(meta);
}
}

View File

@ -1,9 +0,0 @@
package org.gcube.spatial.data.gis.model;
public class Costants {
public static final double[] WORLD_BOUNDING_BOX=new double[]{
-180.0,-90.0,180.0,90.0
};
}

View File

@ -1,8 +0,0 @@
package org.gcube.spatial.data.gis.model.report;
public class DeleteReport extends Report {
private String metadataUUID;
}

View File

@ -1,86 +0,0 @@
package org.gcube.spatial.data.gis.model.report;
import org.geotoolkit.metadata.iso.DefaultMetadata;
import org.opengis.metadata.Metadata;
public class PublishResponse extends Report{
private Metadata passedMetadata;
private Metadata publishedMetadata;
private long returnedMetaId;
public PublishResponse() {
// TODO Auto-generated constructor stub
}
public PublishResponse(Metadata passedMetadata){
setPassedMetadata(passedMetadata);
}
/**
* @return the passedMetadata
*/
public Metadata getPassedMetadata() {
return passedMetadata;
}
/**
* @param passedMetadata the passedMetadata to set
*/
public void setPassedMetadata(Metadata passedMetadata) {
this.passedMetadata = new DefaultMetadata(passedMetadata);
}
/**
* @return the publishedMetadata
*/
public Metadata getPublishedMetadata() {
return publishedMetadata;
}
/**
* @param publishedMetadata the publishedMetadata to set
*/
public void setPublishedMetadata(Metadata publishedMetadata) {
this.publishedMetadata = publishedMetadata;
}
/**
* @return the returnedMetaId
*/
public long getReturnedMetaId() {
return returnedMetaId;
}
/**
* @param returnedMetaId the returnedMetaId to set
*/
public void setReturnedMetaId(long returnedMetaId) {
this.returnedMetaId = returnedMetaId;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("PublishResponse [passedMetadata=");
builder.append(passedMetadata);
builder.append(", publishedMetadata=");
builder.append(publishedMetadata);
builder.append(", returnedMetaId=");
builder.append(returnedMetaId);
builder.append(", report=");
builder.append(super.toString());
builder.append("]");
return builder.toString();
}
}

View File

@ -1,83 +0,0 @@
package org.gcube.spatial.data.gis.model.report;
import java.util.ArrayList;
public class Report {
public static enum OperationState{
COMPLETE,ERROR,WARN
}
private Report.OperationState dataOperationResult = Report.OperationState.ERROR;
private Report.OperationState metaOperationResult = Report.OperationState.ERROR;
private ArrayList<String> dataOperationMessages = new ArrayList<String>();
private ArrayList<String> metaOperationMessages = new ArrayList<String>();
/**
* @return the dataOperationResult
*/
public Report.OperationState getDataOperationResult() {
return dataOperationResult;
}
/**
* @param dataOperationResult the dataOperationResult to set
*/
public void setDataOperationResult(Report.OperationState dataOperationResult) {
this.dataOperationResult = dataOperationResult;
}
/**
* @return the metaOperationResult
*/
public Report.OperationState getMetaOperationResult() {
return metaOperationResult;
}
/**
* @param metaOperationResult the metaOperationResult to set
*/
public void setMetaOperationResult(Report.OperationState metaOperationResult) {
this.metaOperationResult = metaOperationResult;
}
/**
* @return the dataOperationMessages
*/
public ArrayList<String> getDataOperationMessages() {
return dataOperationMessages;
}
/**
* @param dataOperationMessages the dataOperationMessages to set
*/
public void setDataOperationMessages(ArrayList<String> dataOperationMessages) {
this.dataOperationMessages = dataOperationMessages;
}
/**
* @return the metaOperationMessages
*/
public ArrayList<String> getMetaOperationMessages() {
return metaOperationMessages;
}
/**
* @param metaOperationMessages the metaOperationMessages to set
*/
public void setMetaOperationMessages(ArrayList<String> metaOperationMessages) {
this.metaOperationMessages = metaOperationMessages;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("Report [dataOperationResult=");
builder.append(dataOperationResult);
builder.append(", metaOperationResult=");
builder.append(metaOperationResult);
builder.append(", dataOperationMessages=");
builder.append(dataOperationMessages);
builder.append(", metaOperationMessages=");
builder.append(metaOperationMessages);
builder.append("]");
return builder.toString();
}
}

View File

@ -1,87 +0,0 @@
package org.gcube.spatial.data.gis.symbology;
import java.awt.Color;
public class Range {
public Range(String toFilterProperty, Color toAssignColor, Object min,
Object max, Condition condition) {
super();
this.toFilterProperty = toFilterProperty;
this.toAssignColor = toAssignColor;
this.min = min;
this.max = max;
this.condition = condition;
}
public static enum Condition{
GREATER_THEN_MIN,UP_TO_MAX,BETWEEN
}
private String toFilterProperty;
private Color toAssignColor;
private Object min;
private Object max;
private Condition condition;
/**
* @return the min
*/
public Object getMin() {
return min;
}
/**
* @param min the min to set
*/
public void setMin(Object min) {
this.min = min;
}
/**
* @return the max
*/
public Object getMax() {
return max;
}
/**
* @param max the max to set
*/
public void setMax(Object max) {
this.max = max;
}
/**
* @return the toFilterProperty
*/
public String getToFilterProperty() {
return toFilterProperty;
}
/**
* @param toFilterProperty the toFilterProperty to set
*/
public void setToFilterProperty(String toFilterProperty) {
this.toFilterProperty = toFilterProperty;
}
/**
* @return the toAssignColor
*/
public Color getToAssignColor() {
return toAssignColor;
}
/**
* @param toAssignColor the toAssignColor to set
*/
public void setToAssignColor(Color toAssignColor) {
this.toAssignColor = toAssignColor;
}
public Condition getCondition() {
return condition;
}
@Override
public String toString() {
return min+"-"+max+":"+toAssignColor;
}
}

View File

@ -1,366 +0,0 @@
package org.gcube.spatial.data.gis.symbology;
import static org.geotoolkit.style.StyleConstants.DEFAULT_DESCRIPTION;
import static org.geotoolkit.style.StyleConstants.DEFAULT_DISPLACEMENT;
import static org.geotoolkit.style.StyleConstants.LITERAL_ZERO_FLOAT;
import java.awt.Color;
import java.io.StringWriter;
import java.util.ArrayList;
import javax.measure.unit.NonSI;
import javax.xml.bind.JAXBException;
import org.gcube.spatial.data.gis.symbology.Range.Condition;
import org.geotoolkit.factory.FactoryFinder;
import org.geotoolkit.factory.Hints;
import org.geotoolkit.sld.DefaultSLDFactory;
import org.geotoolkit.sld.MutableSLDFactory;
import org.geotoolkit.sld.xml.Specification;
import org.geotoolkit.sld.xml.XMLUtilities;
import org.geotoolkit.style.MutableFeatureTypeStyle;
import org.geotoolkit.style.MutableRule;
import org.geotoolkit.style.MutableStyle;
import org.geotoolkit.style.MutableStyleFactory;
import org.opengis.filter.FilterFactory;
import org.opengis.style.Style;
public class StyleUtils {
protected static final FilterFactory FF = FactoryFinder.getFilterFactory(null);
protected static final MutableSLDFactory SLDF = new DefaultSLDFactory();
protected static final MutableStyleFactory SF = (MutableStyleFactory) FactoryFinder.getStyleFactory(
new Hints(Hints.STYLE_FACTORY, MutableStyleFactory.class));
protected static XMLUtilities utils=new XMLUtilities();
public static String createStyle(String nameStyle, String attributeName, int maxClasses, Color c1, Color c2, Class typeValue, Object maxValue, Object minValue) throws Exception{
return createStyle(nameStyle, attributeName, maxClasses, c1, c2, typeValue, maxValue, minValue, true);
}
public static String createStyleLog(String nameStyle, String attributeName, int maxClasses, Color c1, Color c2, Class typeValue, Object maxValue, Object minValue) throws Exception{
return createStyle(nameStyle, attributeName, maxClasses, c1, c2, typeValue, maxValue, minValue, false);
}
public static String createStyleScatterColors(String nameStyle, String attributeName, int nClasses,Class typeValue, Object maxValue, Object minValue) throws Exception {
return createStyleScatterColors(nameStyle, attributeName, nClasses, typeValue, maxValue, minValue, true);
}
public static String createStyleLogScatterColors(String nameStyle, String attributeName, int nClasses,Class typeValue, Object maxValue, Object minValue) throws Exception {
return createStyleScatterColors(nameStyle, attributeName, nClasses, typeValue, maxValue, minValue, false);
}
public static String createStyle(String nameStyle, String attributeName, ArrayList<ClassStyleDef> classes, Color c1, Color c2) throws Exception {
if (classes.size() <= 0)
throw new Exception("Invalid number of classes!!");
MutableStyle style=SF.style();
MutableFeatureTypeStyle fts=SF.featureTypeStyle();
//Setting colors
ArrayList<Color> colors=scatterColor(classes.size());
for(int i=0;i<classes.size();i++){
ClassStyleDef classStyle=classes.get(i);
fts.rules().add(makeRule(new Range(attributeName, colors.get(i), classStyle.getFrom(), classStyle.getTo(), Condition.BETWEEN)));
}
style.featureTypeStyles().add(fts);
style.setName(nameStyle);
return marshall(style);
}
private static String createStyle(String nameStyle, String attributeName, int maxClasses, Color c1, Color c2, Class typeValue, Object maxValue, Object minValue,boolean linear)throws Exception{
if (maxClasses <= 0)
throw new Exception("Invalid number of classes!!");
MutableStyle style=SF.style();
MutableFeatureTypeStyle fts=SF.featureTypeStyle();
ArrayList<Range> ranges=getRanges(typeValue,maxClasses,maxValue,minValue,attributeName,linear);
//Setting colors
ArrayList<Color> colors=gradientColors(ranges.size(),c1,c2);
for(int i=0;i<ranges.size();i++)ranges.get(i).setToAssignColor(colors.get(i));
for(Range r:ranges){
fts.rules().add(makeRule(r));
}
style.featureTypeStyles().add(fts);
style.setName(nameStyle);
return marshall(style);
}
private static String createStyleScatterColors(String nameStyle, String attributeName, int maxClasses, Class typeValue, Object maxValue, Object minValue,boolean linear)throws Exception{
if (maxClasses <= 0)
throw new Exception("Invalid number of classes!!");
MutableStyle style=SF.style();
MutableFeatureTypeStyle fts=SF.featureTypeStyle();
ArrayList<Range> ranges=getRanges(typeValue,maxClasses,maxValue,minValue,attributeName,linear);
//Setting colors
ArrayList<Color> colors=scatterColor(ranges.size());
for(int i=0;i<ranges.size();i++)ranges.get(i).setToAssignColor(colors.get(i));
for(Range r:ranges){
fts.rules().add(makeRule(r));
}
style.featureTypeStyles().add(fts);
style.setName(nameStyle);
return marshall(style);
}
private static String marshall(Style toMarshal) throws JAXBException{
StringWriter writer=new StringWriter();
utils.writeStyle(writer, toMarshal, Specification.StyledLayerDescriptor.V_1_0_0);
return writer.toString().replaceAll("<([a-zA-Z][a-zA-Z0-9:]*)[^>]*>\\s*</\\1>", ""); //Erase all empty tags
}
private static MutableRule makeRule(Range r){
MutableRule toReturn=SF.rule();
toReturn.setName(r.getToFilterProperty()+" in ["+r.getMin()+" , "+r.getMax()+")");
switch(r.getCondition()){
case BETWEEN : toReturn.setFilter(FF.and( // property => min AND property < max
FF.greaterOrEqual(FF.property(r.getToFilterProperty()), FF.literal(r.getMin())),
FF.less(FF.property(r.getToFilterProperty()), FF.literal(r.getMax()))));
break;
case GREATER_THEN_MIN : toReturn.setFilter(// property => min
FF.greaterOrEqual(FF.property(r.getToFilterProperty()), FF.literal(r.getMin())));
break;
case UP_TO_MAX : toReturn.setFilter(// property < max
FF.less(FF.property(r.getToFilterProperty()), FF.literal(r.getMax())));
break;
}
toReturn.symbolizers().add(SF.polygonSymbolizer(toReturn.getName(),"the_geom",DEFAULT_DESCRIPTION,NonSI.PIXEL,null,SF.fill(r.getToAssignColor()),DEFAULT_DISPLACEMENT,LITERAL_ZERO_FLOAT));
return toReturn;
}
private static ArrayList<Range> getRanges(Class typeValue,int maxClasses, Object maxValue, Object minValue, String attributeName, boolean linear) throws Exception{
//Check class coherence
if(maxValue.getClass()!=minValue.getClass()) throw new Exception("Min ("+minValue.getClass()+")and Max ("+maxValue.getClass()+") value must be of same class");
boolean integerRanges=(typeValue.isAssignableFrom(Integer.class));
// Get double values
Double dMax;
Double dMin;
if(maxValue instanceof Double){
dMax=(Double) maxValue;
dMin=(Double) minValue;
}else if(maxValue instanceof Float){
dMax=new Double((Float) maxValue);
dMin=new Double((Float) minValue);
}else if(maxValue instanceof Integer){
dMax=(Integer)maxValue*1d;
dMin=(Integer)minValue*1d;
}else if(maxValue instanceof String){
dMax=Double.parseDouble((String)maxValue);
dMin=Double.parseDouble((String)minValue);
}else throw new Exception ("Unable to handle range values class "+maxValue.getClass());
if(dMax.compareTo(dMin)<0) throw new Exception("Specified Range ["+dMin+" , "+dMax+") is invalid");
//Check integer ranges -> can be less then max Classes
ArrayList<Range> toReturn=new ArrayList<Range>();
if(linear){ //Linear interpolation
double distance=Math.abs(dMin-dMax);
double step=distance/maxClasses;
if(integerRanges&&step<1)step=1;
Double toInsertMin=roundDecimal(dMin,integerRanges?0:2);
Double toInsertMax=roundDecimal(toInsertMin+step,integerRanges?0:2);
while(dMax.compareTo(toInsertMax)>=0){ //While in total range
//InsertRange
if(integerRanges)
toReturn.add(new Range(attributeName,Color.RED, toInsertMin.intValue(),toInsertMax.intValue(),Condition.BETWEEN));
else
toReturn.add(new Range(attributeName,Color.RED, toInsertMin,toInsertMax,Condition.BETWEEN));
toInsertMin=toInsertMax;
toInsertMax=roundDecimal(toInsertMin+step,integerRanges?0:2);
}
if(!dMax.equals(toInsertMin)){
if(integerRanges)
toReturn.add(new Range(attributeName,Color.RED, toInsertMin.intValue(),dMax.intValue(),Condition.BETWEEN));
else
toReturn.add(new Range(attributeName,Color.RED, toInsertMin,dMax,Condition.BETWEEN));
}
}else { // Logarithmic interpolation
Double[] logSub=logSubdivision(dMin, dMax, maxClasses);
for(int i =0;i<logSub.length;i++){
Double upperBound=(i==logSub.length-1?dMax:logSub[i+1]);
if(dMax.compareTo(upperBound)<=0) upperBound=roundDecimal(dMax,integerRanges?0:2);
else upperBound=roundDecimal(upperBound,integerRanges?0:2);
Double lowerBound=roundDecimal(logSub[i],integerRanges?0:2);
if(integerRanges)
toReturn.add(new Range(attributeName,Color.RED,lowerBound.intValue(),upperBound.intValue(),Condition.BETWEEN));
else
toReturn.add(new Range(attributeName,Color.RED,lowerBound,upperBound,Condition.BETWEEN));
}
}
return toReturn;
}
private static ArrayList<Color> gradientColors(int nColors, Color c1, Color c2) {
// a linear gradient.
ArrayList<Color> colors = new ArrayList<Color>();
for (int i = 0; i < nColors; i++) {
float ratio = (float) i / (float) nColors;
int red = (int) (c2.getRed() * ratio + c1.getRed() * (1 - ratio));
int green = (int) (c2.getGreen() * ratio + c1.getGreen() * (1 - ratio));
int blue = (int) (c2.getBlue() * ratio + c1.getBlue() * (1 - ratio));
colors.add(new Color(red, green, blue));
}
return colors;
}
// rounds to the xth decimal position
private static double roundDecimal(double number, int decimalposition) {
double n = (double) Math.round(number * Math.pow(10.00, decimalposition)) / Math.pow(10.00, decimalposition);
return n;
}
private static Double[] logSubdivision(double start, double end, int numberOfParts) {
if (end <= start)
return null;
double logStart = Math.log(start);
double logEnd = Math.log(end);
double difference = logEnd - logStart;
double step = 0;
if (numberOfParts > 0)
step = (difference / (double) numberOfParts);
// double [] points = new double[numberOfParts+1];
Double[] linearpoints = new Double[numberOfParts + 1];
for (int i = 0; i < numberOfParts + 1; i++) {
// points[i] = logStart+(i*step);
linearpoints[i] = Math.exp(logStart + (i * step));
if (linearpoints[i] < 0.011)
linearpoints[i] = 0.0;
}
return linearpoints;
}
public static ArrayList<Color> scatterColor(int nColors) {
ArrayList<Color> colors = new ArrayList<Color>();
float saturation = 1;
float brightness = 1;
for (int i = 0; i < nColors; i++) {
float ratio = (((float) i)*1.5f) / (float) nColors;
if (i%10==0)
brightness = (float) Math.max(0.1,brightness-0.1);
// else
// saturation = (float) Math.max(0.1,saturation-0.1);
// System.out.println("ratio degrees "+ratio);
int rgb = Color.HSBtoRGB(ratio, brightness, saturation);
Color color = new Color(rgb);
colors.add(color);
}
return colors;
}
/**
* Create a rendering style to display features from the given feature source by matching unique values of the specified feature attribute to colours
*
* @param reader
* the feature source
* @return a new Style instance
* @throws Exception
*/
public class ClassStyleDef {
public ClassStyleDef() {
super();
// TODO Auto-generated constructor stub
}
/**
* @uml.property name="from"
*/
Object from = 0;
/**
* @uml.property name="to"
*/
Object to = 0;
public ClassStyleDef(Object from, Object to) {
super();
this.from = from;
this.to = to;
}
/**
* @return
* @uml.property name="from"
*/
public Object getFrom() {
return from;
}
/**
* @return
* @uml.property name="to"
*/
public Object getTo() {
return to;
}
/**
* @param from
* @uml.property name="from"
*/
public void setFrom(Object from) {
this.from = from;
}
/**
* @param to
* @uml.property name="to"
*/
public void setTo(Object to) {
this.to = to;
}
}
}

View File

@ -1,56 +0,0 @@
package org.gcube.spatial.data.gis;
import it.geosolutions.geonetwork.util.GNInsertConfiguration;
import it.geosolutions.geoserver.rest.GeoServerRESTReader;
import it.geosolutions.geoserver.rest.decoder.RESTWorkspaceList.RESTShortWorkspace;
import it.geosolutions.geoserver.rest.encoder.GSResourceEncoder.ProjectionPolicy;
import java.io.File;
import java.util.Iterator;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.spatial.data.geonetwork.LoginLevel;
import org.gcube.spatial.data.gis.model.Costants;
import org.geotoolkit.metadata.iso.DefaultMetadata;
import org.opengis.metadata.Metadata;
public class PublishTest {
/**
* @param args
*/
private static final String defaultScope="/gcube/devsec";
public static void main(String[] args) throws Exception {
ScopeProvider.instance.set(defaultScope);
GISInterface gisInterface=GISInterface.get();
GeoServerRESTReader reader=gisInterface.getGeoServerReader(ResearchMethod.MOSTUNLOAD, false);
System.out.println("***************Workspaces : ");
Iterator<RESTShortWorkspace> it=reader.getWorkspaces().iterator();
while(it.hasNext()){
RESTShortWorkspace work=it.next();
System.out.println(work.getName());
}
String geoTiffPath = "/home/fabio/Downloads/aquamaps-lprognathodesfalcifer20121207161043540cet.geotiff";
File geoTiff=new File(geoTiffPath);
String workspace="aquamaps";
String storeName=geoTiff.getName()+"_store";
String coverageName="";
String srs="EPSG:4326";
ProjectionPolicy policy=ProjectionPolicy.REPROJECT_TO_DECLARED;
String defaultStyle="raster";
double[] bbox=Costants.WORLD_BOUNDING_BOX;
Metadata theMeta=new DefaultMetadata();
GNInsertConfiguration config=new GNInsertConfiguration("view-group", "datasets", "_none_", true);
gisInterface.addGeoTIFF(workspace, storeName, coverageName, geoTiff, srs, policy, defaultStyle, bbox, theMeta, config,LoginLevel.DEFAULT);
}
}

View File

@ -1,52 +0,0 @@
package org.gcube.spatial.data.gis;
import static org.gcube.resources.discovery.icclient.ICFactory.clientFor;
import static org.gcube.resources.discovery.icclient.ICFactory.queryFor;
import java.util.ArrayList;
import java.util.List;
import org.gcube.common.resources.gcore.ServiceEndpoint;
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.utils.encryption.StringEncrypter;
import org.gcube.resources.discovery.client.api.DiscoveryClient;
import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.gcube.spatial.data.gis.is.GeoServerDescriptor;
public class Query {
/**
* @param args
*/
public static void main(String[] args) {
ScopeProvider.instance.set("/gcube/devsec");
System.out.println(queryforGeoServer());
}
public static List<GeoServerDescriptor> queryforGeoServer(){
List<GeoServerDescriptor> toReturn=new ArrayList<GeoServerDescriptor>();
SimpleQuery query = queryFor(ServiceEndpoint.class);
query.addCondition("$resource/Profile/Category/text() eq 'Gis'")
.addCondition("$resource/Profile/Platform/Name/text() eq 'GeoServer'")
.setResult("$resource/Profile/AccessPoint");
DiscoveryClient<AccessPoint> client = clientFor(AccessPoint.class);
List<AccessPoint> accesspoints = client.submit(query);
// if(accesspoints.size()==0) throw new Exception("No Resource found under current scope "+ScopeProvider.instance.get());
for (AccessPoint point : accesspoints) {
try{
toReturn.add(new GeoServerDescriptor(point.address(),point.username(),StringEncrypter.getEncrypter().decrypt(point.password()),0l));
}catch(Exception e){
System.err.println("Unable to decript password for "+point.username()+" in access point "+point.address()+", access to modify methods may fail");
}
// url=point.address();
// user=point.username();
// pwd=point.password();
}
return toReturn;
}
}

View File

@ -1,15 +0,0 @@
log4j.rootLogger=DEBUG, A1, stdout
log4j.appender.A1=org.apache.log4j.RollingFileAppender
log4j.appender.A1.File=log.txt
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
log4j.appender.A1.layout.ConversionPattern=%-4r [%t] %-5p %c %x - %m%n
# ***** Max file size is set to 100KB
log4j.appender.A1.MaxFileSize=100MB
# ***** Keep one backup file
log4j.appender.A1.MaxBackupIndex=1
#CONSOLE
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Threshold=INFO
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=[%t] %-5p %c %d{dd MMM yyyy ;HH:mm:ss.SSS} - %m%n