git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/spatial-data/sdi-service@146254 82a268e6-3cf1-43bd-a215-b396298e98cf
parent
fb7d3b6958
commit
94c5df31e7
@ -0,0 +1,36 @@
|
||||
<?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.7">
|
||||
<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>
|
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>sdi-service</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>
|
@ -0,0 +1,6 @@
|
||||
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
|
@ -0,0 +1,5 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
||||
org.eclipse.jdt.core.compiler.compliance=1.7
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.source=1.7
|
@ -0,0 +1,4 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=false
|
||||
version=1
|
@ -0,0 +1 @@
|
||||
${gcube.license}
|
@ -0,0 +1,65 @@
|
||||
The gCube System - ${name}
|
||||
--------------------------------------------------
|
||||
|
||||
${description}
|
||||
|
||||
|
||||
${gcube.description}
|
||||
|
||||
${gcube.funding}
|
||||
|
||||
|
||||
Version
|
||||
--------------------------------------------------
|
||||
|
||||
${version} (${buildDate})
|
||||
|
||||
Please see the file named "changelog.xml" in this directory for the release notes.
|
||||
|
||||
|
||||
|
||||
Authors
|
||||
--------------------------------------------------
|
||||
|
||||
* Fabio Sinibaldi (fabio.sinibaldi-AT-isti.cnr.it) Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy).
|
||||
|
||||
Maintainers
|
||||
-----------
|
||||
|
||||
* Fabio Sinibaldi (fabio.sinibaldi-AT-isti.cnr.it) Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy).
|
||||
|
||||
|
||||
Download information
|
||||
--------------------------------------------------
|
||||
|
||||
Source code is available from SVN:
|
||||
${scm.url}
|
||||
|
||||
Binaries can be downloaded from the gCube website:
|
||||
${gcube.website}
|
||||
|
||||
Installation
|
||||
--------------------------------------------------
|
||||
|
||||
Installation documentation is available on-line in the gCube Wiki:
|
||||
${gcube.wikiRoot}/Data_Transfer_2
|
||||
|
||||
Documentation
|
||||
--------------------------------------------------
|
||||
|
||||
Documentation is available on-line in the gCube Wiki:
|
||||
${gcube.wikiRoot}/Data_Transfer_2
|
||||
${gcube.wikiRoot}/How_to_use_Data_Transfer_2
|
||||
|
||||
|
||||
Support
|
||||
--------------------------------------------------
|
||||
|
||||
Bugs and support requests can be reported in the gCube issue tracking tool:
|
||||
${gcube.issueTracking}
|
||||
|
||||
|
||||
Licensing
|
||||
--------------------------------------------------
|
||||
|
||||
This software is licensed under the terms you may find in the file named "LICENSE" in this directory.
|
@ -0,0 +1,5 @@
|
||||
<ReleaseNotes>
|
||||
<Changeset component="sdi-service-1.0.0" date="2017-03-22">
|
||||
<Change>First Release</Change>
|
||||
</Changeset>
|
||||
</ReleaseNotes>
|
@ -0,0 +1,30 @@
|
||||
<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>changelog.xml</include>
|
||||
</includes>
|
||||
<fileMode>755</fileMode>
|
||||
<filtered>true</filtered>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
<files>
|
||||
<file>
|
||||
<source>target/${build.finalName}.${project.packaging}</source>
|
||||
<outputDirectory>/${artifactId}</outputDirectory>
|
||||
</file>
|
||||
</files>
|
||||
</assembly>
|
@ -0,0 +1,8 @@
|
||||
<application mode='online'>
|
||||
<name>${artifactId}</name>
|
||||
<group>SDI</group>
|
||||
<version>${version}</version>
|
||||
<description>${description}</description>
|
||||
<local-persistence location='target' />
|
||||
</application>
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?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>SDI</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>
|
||||
|
||||
|
@ -0,0 +1,205 @@
|
||||
<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>
|
||||
<groupId>org.gcube.tools</groupId>
|
||||
<artifactId>maven-parent</artifactId>
|
||||
<version>LATEST</version>
|
||||
</parent>
|
||||
<groupId>org.gcube.spatial.data</groupId>
|
||||
<artifactId>sdi-service</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>SDI Service</name>
|
||||
<description>REST Interface towards SDI facilities</description>
|
||||
|
||||
<properties>
|
||||
<webappDirectory>${project.basedir}/src/main/webapp/WEB-INF</webappDirectory>
|
||||
<distroDirectory>${project.basedir}/distro</distroDirectory>
|
||||
<jersey-version>2.14</jersey-version>
|
||||
<jersey-cdi-version>2.14</jersey-cdi-version>
|
||||
<weld-version>2.2.4.Final</weld-version>
|
||||
</properties>
|
||||
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>maven-smartgears-bom</artifactId>
|
||||
<version>LATEST</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.spatial.data</groupId>
|
||||
<artifactId>gis-interface</artifactId>
|
||||
<version>[2.4.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- jersey -->
|
||||
<dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>javax.ws.rs-api</artifactId>
|
||||
<version>2.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.containers</groupId>
|
||||
<artifactId>jersey-container-servlet</artifactId>
|
||||
<version>${jersey-version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.containers.glassfish</groupId>
|
||||
<artifactId>jersey-gf-cdi</artifactId>
|
||||
<version>${jersey-cdi-version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.transaction</groupId>
|
||||
<artifactId>javax.transaction-api</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>javax.servlet-api</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.media</groupId>
|
||||
<artifactId>jersey-media-json-jackson</artifactId>
|
||||
<version>${jersey-version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.media</groupId>
|
||||
<artifactId>jersey-media-multipart</artifactId>
|
||||
<version>${jersey-version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.bundles</groupId>
|
||||
<artifactId>jaxrs-ri</artifactId>
|
||||
<version>${jersey-version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.core</groupId>
|
||||
<artifactId>jersey-common</artifactId>
|
||||
<version>${jersey-version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- weld -->
|
||||
<dependency>
|
||||
<groupId>javax.enterprise</groupId>
|
||||
<artifactId>cdi-api</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss.weld.servlet</groupId>
|
||||
<artifactId>weld-servlet</artifactId>
|
||||
<version>${weld-version}</version> <!-- 2.0.4 doesn't find implementations. 2.2.4 doesn't find CDI... -->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jboss</groupId>
|
||||
<artifactId>jandex</artifactId>
|
||||
<version>1.2.2.Final</version>
|
||||
</dependency>
|
||||
|
||||
<!-- test -->
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.0.13</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.glassfish.jersey.test-framework.providers</groupId>
|
||||
<artifactId>jersey-test-framework-provider-simple</artifactId>
|
||||
<version>${jersey-version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>2.3.2</version>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<version>2.4</version>
|
||||
<configuration>
|
||||
<warName>data-transfer-service</warName>
|
||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.6</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-profile</id>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<phase>process-resources</phase>
|
||||
<configuration>
|
||||
<outputDirectory>${webappDirectory}</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${distroDirectory}</directory>
|
||||
<filtering>true</filtering>
|
||||
</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>
|
@ -0,0 +1,11 @@
|
||||
package org.gcube.spatial.data.sdi;
|
||||
|
||||
public class Constants {
|
||||
|
||||
|
||||
public static final String APPLICATION="SDI-Service";
|
||||
public static final String GEONETWORK_INTERFACE="GeoNetwork";
|
||||
public static final String GEONETWORK_CONFIGURATION_PATH="configuration";
|
||||
public static final String GEONETWORK_GROUPS_PATH="groups";
|
||||
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
package org.gcube.spatial.data.sdi;
|
||||
|
||||
import javax.ws.rs.ApplicationPath;
|
||||
|
||||
import org.glassfish.jersey.server.ResourceConfig;
|
||||
|
||||
@ApplicationPath(Constants.APPLICATION)
|
||||
public class SDIService extends ResourceConfig{
|
||||
|
||||
public SDIService() {
|
||||
super();
|
||||
packages("org.gcube.spatial.data");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package org.gcube.spatial.data.sdi.engine;
|
||||
|
||||
import org.gcube.spatial.data.geonetwork.GeoNetworkAdministration;
|
||||
import org.gcube.spatial.data.sdi.engine.impl.faults.ClientInitializationException;
|
||||
|
||||
public interface GeoNetworkProvider {
|
||||
|
||||
public GeoNetworkAdministration getGeoNetwork() throws ClientInitializationException;
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package org.gcube.spatial.data.sdi.engine.impl;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.gcube.spatial.data.geonetwork.GeoNetwork;
|
||||
import org.gcube.spatial.data.geonetwork.GeoNetworkAdministration;
|
||||
import org.gcube.spatial.data.sdi.engine.GeoNetworkProvider;
|
||||
import org.gcube.spatial.data.sdi.engine.impl.faults.ClientInitializationException;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@Singleton
|
||||
public class GeoNetworkProviderImpl implements GeoNetworkProvider {
|
||||
|
||||
@Override
|
||||
public GeoNetworkAdministration getGeoNetwork() throws ClientInitializationException{
|
||||
log.debug("Getting GeoNetwork .. ");
|
||||
try{
|
||||
return GeoNetwork.get();
|
||||
}catch(Exception e){
|
||||
throw new ClientInitializationException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package org.gcube.spatial.data.sdi.engine.impl.faults;
|
||||
|
||||
public class ClientInitializationException extends Exception {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -4466379337497096292L;
|
||||
|
||||
public ClientInitializationException() {
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public ClientInitializationException(String message) {
|
||||
super(message);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public ClientInitializationException(Throwable cause) {
|
||||
super(cause);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public ClientInitializationException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public ClientInitializationException(String message, Throwable cause, boolean enableSuppression,
|
||||
boolean writableStackTrace) {
|
||||
super(message, cause, enableSuppression, writableStackTrace);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package org.gcube.spatial.data.sdi.rest;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.WebApplicationException;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
||||
import org.gcube.spatial.data.geonetwork.GeoNetworkAdministration;
|
||||
import org.gcube.spatial.data.geonetwork.LoginLevel;
|
||||
import org.gcube.spatial.data.geonetwork.model.Group;
|
||||
import org.gcube.spatial.data.geonetwork.model.ScopeConfiguration;
|
||||
import org.gcube.spatial.data.geonetwork.model.faults.AuthorizationException;
|
||||
import org.gcube.spatial.data.geonetwork.model.faults.MissingConfigurationException;
|
||||
import org.gcube.spatial.data.geonetwork.model.faults.MissingServiceEndpointException;
|
||||
import org.gcube.spatial.data.geonetwork.utils.ScopeUtils;
|
||||
import org.gcube.spatial.data.sdi.Constants;
|
||||
import org.gcube.spatial.data.sdi.engine.GeoNetworkProvider;
|
||||
import org.gcube.spatial.data.sdi.engine.impl.faults.ClientInitializationException;
|
||||
|
||||
import it.geosolutions.geonetwork.exception.GNLibException;
|
||||
import it.geosolutions.geonetwork.exception.GNServerException;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
@Path(Constants.GEONETWORK_INTERFACE)
|
||||
public class GeoNetwork {
|
||||
|
||||
@Inject
|
||||
GeoNetworkProvider geonetworkProvider;
|
||||
|
||||
|
||||
@GET
|
||||
@Path(Constants.GEONETWORK_CONFIGURATION_PATH)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public ScopeConfiguration getConfiguration(){
|
||||
try {
|
||||
return geonetworkProvider.getGeoNetwork().getConfiguration().getScopeConfiguration();
|
||||
} catch (MissingConfigurationException | MissingServiceEndpointException e) {
|
||||
log.warn("Unable to get GeoNetwork configuration. Current scope is {} ",ScopeUtils.getCurrentScope(),e);
|
||||
throw new WebApplicationException("Scope is not well configured. Please contact administrator.", e, Status.PRECONDITION_FAILED);
|
||||
} catch (ClientInitializationException e) {
|
||||
log.warn("Unable to get GN Client",e);
|
||||
throw new WebApplicationException("Internal Error. Please contact administrator.", e, Status.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path(Constants.GEONETWORK_GROUPS_PATH)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Collection<Group> getGroups(){
|
||||
try {
|
||||
GeoNetworkAdministration admin=geonetworkProvider.getGeoNetwork();
|
||||
admin.login(LoginLevel.ADMIN);
|
||||
return admin.getGroups();
|
||||
} catch (MissingConfigurationException | MissingServiceEndpointException e) {
|
||||
log.warn("Unable to get GeoNetwork configuration. Current scope is {} ",ScopeUtils.getCurrentScope(),e);
|
||||
throw new WebApplicationException("Scope is not well configured. Please contact administrator.", e, Status.PRECONDITION_FAILED);
|
||||
} catch (AuthorizationException e) {
|
||||
log.warn("Unable to use Admin rights.",e);
|
||||
throw new WebApplicationException("Unable to use Admin rights on GeoNetwork. Please contact administrator.", e, Status.INTERNAL_SERVER_ERROR);
|
||||
} catch (GNLibException e) {
|
||||
log.warn("Internal library exception.",e);
|
||||
throw new WebApplicationException("Internal library exception.", e, Status.INTERNAL_SERVER_ERROR);
|
||||
} catch (GNServerException e) {
|
||||
log.warn("GeoNEtwork service exception.",e);
|
||||
throw new WebApplicationException("GeoNetwork service exception.", e, Status.INTERNAL_SERVER_ERROR);
|
||||
} catch (ClientInitializationException e) {
|
||||
log.warn("Unable to get GN Client",e);
|
||||
throw new WebApplicationException("Internal Error. Please contact administrator.", e, Status.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee
|
||||
http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd" bean-discovery-mode="annotated">
|
||||
</beans>
|
@ -0,0 +1,78 @@
|
||||
The gCube System - SDI Service
|
||||
--------------------------------------------------
|
||||
|
||||
REST Interface towards SDI facilities
|
||||
|
||||
|
||||
This software is part of the gCube Framework (https://www.gcube-system.org/): an
|
||||
open-source software toolkit used for building and operating Hybrid Data
|
||||
Infrastructures enabling the dynamic deployment of Virtual Research Environments
|
||||
by favouring the realisation of reuse oriented policies.
|
||||
|
||||
The projects leading to this software have received funding from a series of
|
||||
European Union programmes including:
|
||||
* the Sixth Framework Programme for Research and Technological Development -
|
||||
DILIGENT (grant no. 004260);
|
||||
* the Seventh Framework Programme for research, technological development and
|
||||
demonstration - D4Science (grant no. 212488), D4Science-II (grant no.
|
||||
239019),ENVRI (grant no. 283465), EUBrazilOpenBio (grant no. 288754), iMarine
|
||||
(grant no. 283644);
|
||||
* the H2020 research and innovation programme - BlueBRIDGE (grant no. 675680),
|
||||
EGIEngage (grant no. 654142), ENVRIplus (grant no. 654182), Parthenos (grant
|
||||
no. 654119), SoBigData (grant no. 654024);
|
||||
|
||||
|
||||
Version
|
||||
--------------------------------------------------
|
||||
|
||||
0.0.1-SNAPSHOT (2017-03-21)
|
||||
|
||||
Please see the file named "changelog.xml" in this directory for the release notes.
|
||||
|
||||
|
||||
|
||||
Authors
|
||||
--------------------------------------------------
|
||||
|
||||
* Fabio Sinibaldi (fabio.sinibaldi-AT-isti.cnr.it) Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy).
|
||||
|
||||
Maintainers
|
||||
-----------
|
||||
|
||||
* Fabio Sinibaldi (fabio.sinibaldi-AT-isti.cnr.it) Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy).
|
||||
|
||||
|
||||
Download information
|
||||
--------------------------------------------------
|
||||
|
||||
Source code is available from SVN:
|
||||
${scm.url}
|
||||
|
||||
Binaries can be downloaded from the gCube website:
|
||||
https://www.gcube-system.org/
|
||||
|
||||
Installation
|
||||
--------------------------------------------------
|
||||
|
||||
Installation documentation is available on-line in the gCube Wiki:
|
||||
https://wiki.gcube-system.org/gcube/index.php/Data_Transfer_2
|
||||
|
||||
Documentation
|
||||
--------------------------------------------------
|
||||
|
||||
Documentation is available on-line in the gCube Wiki:
|
||||
https://wiki.gcube-system.org/gcube/index.php/Data_Transfer_2
|
||||
https://wiki.gcube-system.org/gcube/index.php/How_to_use_Data_Transfer_2
|
||||
|
||||
|
||||
Support
|
||||
--------------------------------------------------
|
||||
|
||||
Bugs and support requests can be reported in the gCube issue tracking tool:
|
||||
https://support.d4science.org/projects/gcube/
|
||||
|
||||
|
||||
Licensing
|
||||
--------------------------------------------------
|
||||
|
||||
This software is licensed under the terms you may find in the file named "LICENSE" in this directory.
|
@ -0,0 +1,5 @@
|
||||
<ReleaseNotes>
|
||||
<Changeset component="sdi-service-1.0.0" date="2017-03-22">
|
||||
<Change>First Release</Change>
|
||||
</Changeset>
|
||||
</ReleaseNotes>
|
@ -0,0 +1,30 @@
|
||||
<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>/home/fabio/workspaces/trunk_workspace/sdi-service/distro</directory>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
<useDefaultExcludes>true</useDefaultExcludes>
|
||||
<includes>
|
||||
<include>README</include>
|
||||
<include>LICENSE</include>
|
||||
<include>changelog.xml</include>
|
||||
</includes>
|
||||
<fileMode>755</fileMode>
|
||||
<filtered>true</filtered>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
<files>
|
||||
<file>
|
||||
<source>target/sdi-service.jar</source>
|
||||
<outputDirectory>/sdi-service</outputDirectory>
|
||||
</file>
|
||||
</files>
|
||||
</assembly>
|
@ -0,0 +1,8 @@
|
||||
<application mode='online'>
|
||||
<name>sdi-service</name>
|
||||
<group>SDI</group>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<description>REST Interface towards SDI facilities</description>
|
||||
<local-persistence location='target' />
|
||||
</application>
|
||||
|
@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Resource xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<ID />
|
||||
<Type>Service</Type>
|
||||
<Profile>
|
||||
<Description>REST Interface towards SDI facilities</Description>
|
||||
<Class>SDI</Class>
|
||||
<Name>sdi-service</Name>
|
||||
<Version>1.0.0</Version>
|
||||
<Packages>
|
||||
<Software>
|
||||
<Name>sdi-service</Name>
|
||||
<Version>0.0.1-SNAPSHOT</Version>
|
||||
<MavenCoordinates>
|
||||
<groupId>org.gcube.spatial.data</groupId>
|
||||
<artifactId>sdi-service</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
</MavenCoordinates>
|
||||
<Files>
|
||||
<File>sdi-service.jar</File>
|
||||
</Files>
|
||||
</Software>
|
||||
</Packages>
|
||||
</Profile>
|
||||
</Resource>
|
||||
|
||||
|
@ -0,0 +1,19 @@
|
||||
<web-app>
|
||||
<servlet>
|
||||
<servlet-name>org.gcube.spatial.data.sdi.SDIService</servlet-name>
|
||||
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
|
||||
<init-param>
|
||||
<param-name>javax.ws.rs.Application</param-name>
|
||||
<param-value>org.gcube.spatial.data.sdi.SDIService</param-value>
|
||||
</init-param>
|
||||
<init-param>
|
||||
<param-name>jersey.config.server.provider.classnames</param-name>
|
||||
<param-value>org.glassfish.jersey.media.multipart.MultiPartFeature</param-value>
|
||||
</init-param>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>org.gcube.spatial.data.sdi.SDIService</servlet-name>
|
||||
<url-pattern>/gcube/service/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
</web-app>
|
@ -0,0 +1,36 @@
|
||||
package org.gcube.spatial.data.sdi.test;
|
||||
|
||||
import org.gcube.spatial.data.geonetwork.GeoNetworkAdministration;
|
||||
import org.gcube.spatial.data.sdi.engine.GeoNetworkProvider;
|
||||
import org.gcube.spatial.data.sdi.engine.impl.GeoNetworkProviderImpl;
|
||||
import org.gcube.spatial.data.sdi.engine.impl.faults.ClientInitializationException;
|
||||
import org.glassfish.hk2.api.Factory;
|
||||
|
||||
|
||||
public class GeoNetworkProviderFactory implements Factory<GeoNetworkProvider>{
|
||||
|
||||
private class GeoNetworkTestProvider extends GeoNetworkProviderImpl{
|
||||
|
||||
@Override
|
||||
public GeoNetworkAdministration getGeoNetwork() throws ClientInitializationException {
|
||||
TokenSetter.set("/gcube/devsec");
|
||||
return super.getGeoNetwork();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public GeoNetworkProvider provide() {
|
||||
return new GeoNetworkTestProvider();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose(GeoNetworkProvider arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package org.gcube.spatial.data.sdi.test;
|
||||
|
||||
import javax.ws.rs.core.Application;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import org.gcube.spatial.data.sdi.Constants;
|
||||
import org.gcube.spatial.data.sdi.SDIService;
|
||||
import org.gcube.spatial.data.sdi.engine.GeoNetworkProvider;
|
||||
import org.glassfish.hk2.utilities.binding.AbstractBinder;
|
||||
import org.glassfish.jersey.server.ResourceConfig;
|
||||
import org.glassfish.jersey.test.JerseyTest;
|
||||
import org.junit.Test;
|
||||
|
||||
public class MainTest extends JerseyTest{
|
||||
|
||||
public static class MyBinder extends AbstractBinder{
|
||||
|
||||
public MyBinder() {
|
||||
super();
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bindFactory(GeoNetworkProviderFactory.class).to(GeoNetworkProvider.class);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Application configure() {
|
||||
System.out.println("Configuration for "+Constants.APPLICATION);
|
||||
|
||||
ResourceConfig config= new ResourceConfig(SDIService.class);
|
||||
config.register(new MyBinder());
|
||||
|
||||
|
||||
//Multipart
|
||||
// config.packages("org.glassfish.jersey.media.multipart");
|
||||
config.packages("org.gcube.spatial.data");
|
||||
// config.register(MultiPartFeature.class);
|
||||
return config;
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void getConfiguration(){
|
||||
System.out.println(target(Constants.GEONETWORK_INTERFACE).
|
||||
path(Constants.GEONETWORK_CONFIGURATION_PATH).
|
||||
request(MediaType.APPLICATION_JSON_TYPE).get(String.class));
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package org.gcube.spatial.data.sdi.test;
|
||||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Slf4j
|
||||
public class TokenSetter {
|
||||
|
||||
|
||||
private static Properties props=new Properties();
|
||||
|
||||
static{
|
||||
try {
|
||||
props.load(TokenSetter.class.getResourceAsStream("/tokens.properties"));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("YOU NEED TO SET TOKEN FILE IN CONFIGURATION");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void set(String scope){
|
||||
try{
|
||||
if(!props.containsKey(scope)) throw new RuntimeException("No token found for scope : "+scope);
|
||||
SecurityTokenProvider.instance.set(props.getProperty(scope));
|
||||
}catch(Throwable e){
|
||||
log.warn("Unable to set token for scope "+scope,e);
|
||||
}
|
||||
ScopeProvider.instance.set(scope);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue