swagger integration

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/spatial-data/sdi-service@146280 82a268e6-3cf1-43bd-a215-b396298e98cf
master
Fabio Sinibaldi 7 years ago
parent 94c5df31e7
commit f55b114740

@ -5,6 +5,11 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
@ -19,5 +24,6 @@
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>
</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>

@ -11,7 +11,7 @@
<version>0.0.1-SNAPSHOT</version>
<name>SDI Service</name>
<description>REST Interface towards SDI facilities</description>
<packaging>war</packaging>
<properties>
<webappDirectory>${project.basedir}/src/main/webapp/WEB-INF</webappDirectory>
<distroDirectory>${project.basedir}/distro</distroDirectory>
@ -39,9 +39,31 @@
<groupId>org.gcube.spatial.data</groupId>
<artifactId>gis-interface</artifactId>
<version>[2.4.0-SNAPSHOT,3.0.0-SNAPSHOT)</version>
<exclusions>
<exclusion>
<artifactId>slf4j-log4j12</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</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 -->
<dependency>
<groupId>javax.ws.rs</groupId>
@ -74,7 +96,7 @@
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>${jersey-version}</version>
<version>${jersey-version}</version>
</dependency>
@ -114,6 +136,20 @@
<version>1.2.2.Final</version>
</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 -->
<dependency>
@ -154,7 +190,7 @@
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<warName>data-transfer-service</warName>
<warName>${project.artifactId}</warName>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
@ -184,6 +220,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2</version>
<configuration>
<descriptors>
<descriptor>${distroDirectory}/descriptor.xml</descriptor>

@ -2,14 +2,48 @@ package org.gcube.spatial.data.sdi;
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 io.swagger.jaxrs.config.BeanConfig;
@ApplicationPath(Constants.APPLICATION)
public class SDIService extends ResourceConfig{
public SDIService() {
super();
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
--------------------------------------------------
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.

@ -23,7 +23,7 @@
</fileSets>
<files>
<file>
<source>target/sdi-service.jar</source>
<source>target/sdi-service.war</source>
<outputDirectory>/sdi-service</outputDirectory>
</file>
</files>

@ -9,7 +9,7 @@ import org.glassfish.hk2.api.Factory;
public class GeoNetworkProviderFactory implements Factory<GeoNetworkProvider>{
private class GeoNetworkTestProvider extends GeoNetworkProviderImpl{
private static class GeoNetworkTestProvider extends GeoNetworkProviderImpl{
@Override
public GeoNetworkAdministration getGeoNetwork() throws ClientInitializationException {
@ -17,6 +17,7 @@ public class GeoNetworkProviderFactory implements Factory<GeoNetworkProvider>{
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.SDIService;
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.jersey.server.ResourceConfig;
import org.glassfish.jersey.test.JerseyTest;
import org.junit.Test;
import io.swagger.jaxrs.config.BeanConfig;
public class MainTest extends JerseyTest{
public static class MyBinder extends AbstractBinder{
@ -32,8 +35,23 @@ public class MainTest extends JerseyTest{
ResourceConfig config= new ResourceConfig(SDIService.class);
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
// config.packages("org.glassfish.jersey.media.multipart");
config.packages("org.gcube.spatial.data");
@ -47,5 +65,15 @@ public class MainTest extends JerseyTest{
System.out.println(target(Constants.GEONETWORK_INTERFACE).
path(Constants.GEONETWORK_CONFIGURATION_PATH).
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…
Cancel
Save