swagger integration
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/spatial-data/sdi-service@146280 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
94c5df31e7
commit
f55b114740
6
.project
6
.project
|
@ -5,6 +5,11 @@
|
||||||
<projects>
|
<projects>
|
||||||
</projects>
|
</projects>
|
||||||
<buildSpec>
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.wst.common.project.facet.core.builder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
<buildCommand>
|
<buildCommand>
|
||||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
<arguments>
|
<arguments>
|
||||||
|
@ -19,5 +24,6 @@
|
||||||
<natures>
|
<natures>
|
||||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||||
|
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
||||||
</natures>
|
</natures>
|
||||||
</projectDescription>
|
</projectDescription>
|
||||||
|
|
|
@ -0,0 +1,34 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<Resource version="0.4.x">
|
||||||
|
<ID>2a3131f6-6ef6-4520-b8bf-70b29c7824f9</ID>
|
||||||
|
<Type>RuntimeResource</Type>
|
||||||
|
<Profile>
|
||||||
|
<Category>Gis</Category>
|
||||||
|
<Platform>
|
||||||
|
<Name>geonetwork</Name>
|
||||||
|
<Version>3</Version>
|
||||||
|
<MinorVersion>0</MinorVersion>
|
||||||
|
<RevisionVersion>5</RevisionVersion>
|
||||||
|
<BuildVersion>0</BuildVersion>
|
||||||
|
</Platform>
|
||||||
|
<RunTime>
|
||||||
|
<HostedOn>node3-d-d4s.d4science.org</HostedOn>
|
||||||
|
<Status>READY</Status>
|
||||||
|
</RunTime>
|
||||||
|
<AccessPoint>
|
||||||
|
<Interface>
|
||||||
|
<Endpoint EntryName="geonetwork">http://node3-d-d4s.d4science.org/geonetwork</Endpoint>
|
||||||
|
</Interface>
|
||||||
|
<AccessData>
|
||||||
|
<Username>admin</Username>
|
||||||
|
<Password>5jykeFZrlF1Xfa4vohyDYg==</Password>
|
||||||
|
</AccessData>
|
||||||
|
<Properties>
|
||||||
|
<Property>
|
||||||
|
<Name>priority</Name>
|
||||||
|
<Value encrypted="false">1</Value>
|
||||||
|
</Property>
|
||||||
|
</Properties>
|
||||||
|
</AccessPoint>
|
||||||
|
</Profile>
|
||||||
|
</Resource>
|
43
pom.xml
43
pom.xml
|
@ -11,7 +11,7 @@
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
<name>SDI Service</name>
|
<name>SDI Service</name>
|
||||||
<description>REST Interface towards SDI facilities</description>
|
<description>REST Interface towards SDI facilities</description>
|
||||||
|
<packaging>war</packaging>
|
||||||
<properties>
|
<properties>
|
||||||
<webappDirectory>${project.basedir}/src/main/webapp/WEB-INF</webappDirectory>
|
<webappDirectory>${project.basedir}/src/main/webapp/WEB-INF</webappDirectory>
|
||||||
<distroDirectory>${project.basedir}/distro</distroDirectory>
|
<distroDirectory>${project.basedir}/distro</distroDirectory>
|
||||||
|
@ -39,9 +39,31 @@
|
||||||
<groupId>org.gcube.spatial.data</groupId>
|
<groupId>org.gcube.spatial.data</groupId>
|
||||||
<artifactId>gis-interface</artifactId>
|
<artifactId>gis-interface</artifactId>
|
||||||
<version>[2.4.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
|
<version>[2.4.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>slf4j-log4j12</artifactId>
|
||||||
|
<groupId>org.slf4j</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- SMARTGEARS -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.core</groupId>
|
||||||
|
<artifactId>common-smartgears-app</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.core</groupId>
|
||||||
|
<artifactId>common-smartgears</artifactId>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- jersey -->
|
<!-- jersey -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax.ws.rs</groupId>
|
<groupId>javax.ws.rs</groupId>
|
||||||
|
@ -74,7 +96,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.glassfish.jersey.media</groupId>
|
<groupId>org.glassfish.jersey.media</groupId>
|
||||||
<artifactId>jersey-media-json-jackson</artifactId>
|
<artifactId>jersey-media-json-jackson</artifactId>
|
||||||
<version>${jersey-version}</version>
|
<version>${jersey-version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
|
@ -114,6 +136,20 @@
|
||||||
<version>1.2.2.Final</version>
|
<version>1.2.2.Final</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- swagger -->
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger</groupId>
|
||||||
|
<artifactId>swagger-jersey2-jaxrs</artifactId>
|
||||||
|
<version>1.5.0</version>
|
||||||
|
<exclusions>
|
||||||
|
<exclusion>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
</exclusion>
|
||||||
|
</exclusions>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- test -->
|
<!-- test -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -154,7 +190,7 @@
|
||||||
<artifactId>maven-war-plugin</artifactId>
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
<version>2.4</version>
|
<version>2.4</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<warName>data-transfer-service</warName>
|
<warName>${project.artifactId}</warName>
|
||||||
<failOnMissingWebXml>false</failOnMissingWebXml>
|
<failOnMissingWebXml>false</failOnMissingWebXml>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
@ -184,6 +220,7 @@
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
|
<version>2.2</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<descriptors>
|
<descriptors>
|
||||||
<descriptor>${distroDirectory}/descriptor.xml</descriptor>
|
<descriptor>${distroDirectory}/descriptor.xml</descriptor>
|
||||||
|
|
|
@ -2,14 +2,48 @@ package org.gcube.spatial.data.sdi;
|
||||||
|
|
||||||
import javax.ws.rs.ApplicationPath;
|
import javax.ws.rs.ApplicationPath;
|
||||||
|
|
||||||
|
import org.gcube.smartgears.ContextProvider;
|
||||||
|
import org.gcube.smartgears.configuration.container.ContainerConfiguration;
|
||||||
|
import org.gcube.smartgears.context.application.ApplicationContext;
|
||||||
|
import org.gcube.spatial.data.sdi.rest.GeoNetwork;
|
||||||
import org.glassfish.jersey.server.ResourceConfig;
|
import org.glassfish.jersey.server.ResourceConfig;
|
||||||
|
|
||||||
|
import io.swagger.jaxrs.config.BeanConfig;
|
||||||
|
|
||||||
@ApplicationPath(Constants.APPLICATION)
|
@ApplicationPath(Constants.APPLICATION)
|
||||||
public class SDIService extends ResourceConfig{
|
public class SDIService extends ResourceConfig{
|
||||||
|
|
||||||
public SDIService() {
|
public SDIService() {
|
||||||
super();
|
super();
|
||||||
packages("org.gcube.spatial.data");
|
packages("org.gcube.spatial.data");
|
||||||
|
register(io.swagger.jaxrs.listing.ApiListingResource.class);
|
||||||
|
register(io.swagger.jaxrs.listing.SwaggerSerializers.class);
|
||||||
|
|
||||||
|
|
||||||
|
ApplicationContext context=ContextProvider.get();
|
||||||
|
ContainerConfiguration configuration=context.container().configuration();
|
||||||
|
|
||||||
|
String hostName=configuration.hostname();
|
||||||
|
Integer port=configuration.port();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//SWAGGER
|
||||||
|
BeanConfig beanConfig = new BeanConfig();
|
||||||
|
beanConfig.setVersion("1.0.0");
|
||||||
|
beanConfig.setSchemes(new String[]{"http","https"});
|
||||||
|
beanConfig.setHost(hostName+":"+port);
|
||||||
|
beanConfig.setBasePath("/gcube/service/");
|
||||||
|
beanConfig.setResourcePackage(GeoNetwork.class.getPackage().getName());
|
||||||
|
beanConfig.setScan(true);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ no. 654119), SoBigData (grant no. 654024);
|
||||||
Version
|
Version
|
||||||
--------------------------------------------------
|
--------------------------------------------------
|
||||||
|
|
||||||
0.0.1-SNAPSHOT (2017-03-21)
|
0.0.1-SNAPSHOT (2017-03-22)
|
||||||
|
|
||||||
Please see the file named "changelog.xml" in this directory for the release notes.
|
Please see the file named "changelog.xml" in this directory for the release notes.
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
</fileSets>
|
</fileSets>
|
||||||
<files>
|
<files>
|
||||||
<file>
|
<file>
|
||||||
<source>target/sdi-service.jar</source>
|
<source>target/sdi-service.war</source>
|
||||||
<outputDirectory>/sdi-service</outputDirectory>
|
<outputDirectory>/sdi-service</outputDirectory>
|
||||||
</file>
|
</file>
|
||||||
</files>
|
</files>
|
||||||
|
|
|
@ -9,7 +9,7 @@ import org.glassfish.hk2.api.Factory;
|
||||||
|
|
||||||
public class GeoNetworkProviderFactory implements Factory<GeoNetworkProvider>{
|
public class GeoNetworkProviderFactory implements Factory<GeoNetworkProvider>{
|
||||||
|
|
||||||
private class GeoNetworkTestProvider extends GeoNetworkProviderImpl{
|
private static class GeoNetworkTestProvider extends GeoNetworkProviderImpl{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GeoNetworkAdministration getGeoNetwork() throws ClientInitializationException {
|
public GeoNetworkAdministration getGeoNetwork() throws ClientInitializationException {
|
||||||
|
@ -17,6 +17,7 @@ public class GeoNetworkProviderFactory implements Factory<GeoNetworkProvider>{
|
||||||
return super.getGeoNetwork();
|
return super.getGeoNetwork();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,11 +6,14 @@ import javax.ws.rs.core.MediaType;
|
||||||
import org.gcube.spatial.data.sdi.Constants;
|
import org.gcube.spatial.data.sdi.Constants;
|
||||||
import org.gcube.spatial.data.sdi.SDIService;
|
import org.gcube.spatial.data.sdi.SDIService;
|
||||||
import org.gcube.spatial.data.sdi.engine.GeoNetworkProvider;
|
import org.gcube.spatial.data.sdi.engine.GeoNetworkProvider;
|
||||||
|
import org.gcube.spatial.data.sdi.rest.GeoNetwork;
|
||||||
import org.glassfish.hk2.utilities.binding.AbstractBinder;
|
import org.glassfish.hk2.utilities.binding.AbstractBinder;
|
||||||
import org.glassfish.jersey.server.ResourceConfig;
|
import org.glassfish.jersey.server.ResourceConfig;
|
||||||
import org.glassfish.jersey.test.JerseyTest;
|
import org.glassfish.jersey.test.JerseyTest;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import io.swagger.jaxrs.config.BeanConfig;
|
||||||
|
|
||||||
public class MainTest extends JerseyTest{
|
public class MainTest extends JerseyTest{
|
||||||
|
|
||||||
public static class MyBinder extends AbstractBinder{
|
public static class MyBinder extends AbstractBinder{
|
||||||
|
@ -32,8 +35,23 @@ public class MainTest extends JerseyTest{
|
||||||
|
|
||||||
ResourceConfig config= new ResourceConfig(SDIService.class);
|
ResourceConfig config= new ResourceConfig(SDIService.class);
|
||||||
config.register(new MyBinder());
|
config.register(new MyBinder());
|
||||||
|
config.register(io.swagger.jaxrs.listing.ApiListingResource.class);
|
||||||
|
config.register(io.swagger.jaxrs.listing.SwaggerSerializers.class);
|
||||||
|
|
||||||
|
// //SWAGGER
|
||||||
|
BeanConfig beanConfig = new BeanConfig();
|
||||||
|
beanConfig.setVersion("1.0.0");
|
||||||
|
beanConfig.setSchemes(new String[]{"http","https"});
|
||||||
|
beanConfig.setHost("localhost:9998");
|
||||||
|
beanConfig.setBasePath("gcube/service");
|
||||||
|
String packageName=GeoNetwork.class.getPackage().getName();
|
||||||
|
System.out.println("PACKAGE : "+packageName);
|
||||||
|
beanConfig.setResourcePackage(packageName);
|
||||||
|
beanConfig.setScan(true);
|
||||||
|
System.out.println(beanConfig.getSwagger());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Multipart
|
//Multipart
|
||||||
// config.packages("org.glassfish.jersey.media.multipart");
|
// config.packages("org.glassfish.jersey.media.multipart");
|
||||||
config.packages("org.gcube.spatial.data");
|
config.packages("org.gcube.spatial.data");
|
||||||
|
@ -47,5 +65,15 @@ public class MainTest extends JerseyTest{
|
||||||
System.out.println(target(Constants.GEONETWORK_INTERFACE).
|
System.out.println(target(Constants.GEONETWORK_INTERFACE).
|
||||||
path(Constants.GEONETWORK_CONFIGURATION_PATH).
|
path(Constants.GEONETWORK_CONFIGURATION_PATH).
|
||||||
request(MediaType.APPLICATION_JSON_TYPE).get(String.class));
|
request(MediaType.APPLICATION_JSON_TYPE).get(String.class));
|
||||||
|
System.out.println(target(Constants.GEONETWORK_INTERFACE).
|
||||||
|
path(Constants.GEONETWORK_CONFIGURATION_PATH).
|
||||||
|
getUri());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void getSwagger(){
|
||||||
|
String path="gcube/service/swagger.json";
|
||||||
|
System.out.println(target(path).getUri());
|
||||||
|
System.out.println(target(path).request(MediaType.APPLICATION_JSON_TYPE).get(String.class));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
<configuration debug="true">
|
||||||
|
|
||||||
|
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<!-- encoders are assigned the type
|
||||||
|
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<root level="debug">
|
||||||
|
<appender-ref ref="STDOUT" />
|
||||||
|
</root>
|
||||||
|
</configuration>
|
Loading…
Reference in New Issue