Interface

This commit is contained in:
Fabio Sinibaldi 2020-11-10 18:19:30 +01:00
parent 4522871825
commit a25a9be20e
16 changed files with 377 additions and 54 deletions

128
pom.xml
View File

@ -12,14 +12,14 @@
<artifactId>maven-parent</artifactId>
<groupId>org.gcube.tools</groupId>
<version>1.1.0</version>
</parent>
<properties>
<gitBaseUrl>https://code-repo.d4science.org/gCubeSystem</gitBaseUrl>
<sis.version>1.0</sis.version>
</properties>
<properties>
<gitBaseUrl>https://code-repo.d4science.org/gCubeSystem</gitBaseUrl>
<sis.version>1.0</sis.version>
</properties>
@ -40,73 +40,82 @@
<type>pom</type>
<scope>import</scope>
</dependency>
<!-- <dependency> -->
<!-- <groupId> org.glassfish.jersey </groupId> -->
<!-- <artifactId>jersey-bom</artifactId> -->
<!-- <version>${jersey.version}</version> -->
<!-- <type>pom</type> -->
<!-- <scope>import</scope> -->
<!-- </dependency> -->
</dependencies>
<!-- <dependency> -->
<!-- <groupId> org.glassfish.jersey </groupId> -->
<!-- <artifactId>jersey-bom</artifactId> -->
<!-- <version>${jersey.version}</version> -->
<!-- <type>pom</type> -->
<!-- <scope>import</scope> -->
<!-- </dependency> -->
</dependencies>
</dependencyManagement>
<dependencies>
<!-- SMARTGEARS -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-csv</artifactId>
<version>1.8</version>
<groupId>org.gcube.core</groupId>
<artifactId>common-smartgears-app</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-smartgears</artifactId>
</dependency>
<!-- JERSEY -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.14.8</version>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
</dependency>
<!-- INTERNAL LOGIC -->
<!-- Used to write centroids-->
<dependency>
<groupId>net.postgis</groupId>
<artifactId>postgis-jdbc</artifactId>
<version>2.5.0</version>
</dependency>
<!-- <dependency> <groupId>postgresql</groupId> <artifactId>postgresql</artifactId>
<version>9.1-901-1.jdbc4</version> <scope>compile</scope> </dependency> -->
<!-- jackson java time -->
<!-- Serialization from library -->
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.8.8</version>
</dependency>
<!-- read XLS -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
<!-- GPKG -->
<!-- Read Geopackage -->
<dependency>
<groupId>mil.nga.geopackage</groupId>
<artifactId>geopackage</artifactId>
<version>3.5.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.5.0</version>
</dependency>
<!-- gCube SW -->
<dependency>
<groupId>org.gcube.spatial.data</groupId>
@ -120,7 +129,7 @@
</dependency>
<dependency>
<dependency>
<groupId>org.gcube.spatial.data</groupId>
<artifactId>gis-interface</artifactId>
<version>[2.4.0,3.0.0)</version>
@ -150,13 +159,31 @@
<!-- SIS -->
<dependency>
<groupId>org.apache.sis.core</groupId>
<artifactId>sis-referencing</artifactId>
<version>${sis.version}</version>
</dependency>
<dependency>
<groupId>org.apache.sis.core</groupId>
<artifactId>sis-referencing</artifactId>
<version>${sis.version}</version>
</dependency>
<!-- Common - basic -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.14.8</version>
</dependency>
<!-- TEST -->
<dependency>
<groupId>org.eclipse.persistence</groupId>
<artifactId>eclipselink</artifactId>
<version>2.5.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@ -170,12 +197,6 @@
<scope>test</scope>
</dependency>
<!-- <dependency> -->
<!-- <groupId>commons-logging</groupId> -->
<!-- <artifactId>commons-logging</artifactId> -->
<!-- <version>1.2</version> -->
<!-- </dependency> -->
<dependency>
<groupId>ch.qos.logback</groupId>
@ -187,6 +208,7 @@
<groupId>org.apache.derby</groupId>
<artifactId>derby</artifactId>
<version>10.8.3.0</version>
<scope>test</scope>
</dependency>
</dependencies>

View File

@ -0,0 +1,18 @@
package org.gcube.application.geoportal.service;
import org.gcube.application.geoportal.service.engine.ImplementationProvider;
import org.gcube.smartgears.ApplicationManager;
public class AppManager implements ApplicationManager{
@Override
public void onInit() {
ImplementationProvider.get().shutdown();
}
@Override
public void onShutdown() {
ImplementationProvider.get().shutdown();
}
}

View File

@ -1,6 +1,18 @@
package org.gcube.application.geoportal.service;
import javax.ws.rs.ApplicationPath;
public class GeoportalService {
import org.gcube.application.geoportal.service.rest.InterfaceConstants;
import org.glassfish.jersey.server.ResourceConfig;
@ApplicationPath(InterfaceConstants.APPLICATION_PATH)
public class GeoportalService extends ResourceConfig{
public GeoportalService() {
super();
// TODO register servlets
// TODO register packages
}
}

View File

@ -0,0 +1,5 @@
package org.gcube.application.geoportal.service;
public class InterfaceUtils {
}

View File

@ -0,0 +1,9 @@
package org.gcube.application.geoportal.service;
public class ServiceConstants {
}

View File

@ -0,0 +1,24 @@
package org.gcube.application.geoportal.service.engine;
import lombok.Synchronized;
public class ImplementationProvider {
private static ImplementationProvider instance=null;
@Synchronized
public static ImplementationProvider get() {
if(instance==null) {
instance=new ImplementationProvider();
}
return instance;
}
public void shutdown() {
}
public void startup() {
}
}

View File

@ -0,0 +1,16 @@
package org.gcube.application.geoportal.service.engine;
import java.util.Collection;
import org.gcube.application.geoportal.service.model.Project;
public interface ProjectsArchiveManagerI {
public Project getByID();
public Collection<Project> getByFilters();
public Project addSection();
// public Project
}

View File

@ -0,0 +1,5 @@
package org.gcube.application.geoportal.service.model;
public class Profile {
}

View File

@ -0,0 +1,5 @@
package org.gcube.application.geoportal.service.model;
public class Project {
}

View File

@ -0,0 +1,5 @@
package org.gcube.application.geoportal.service.model;
public class Section {
}

View File

@ -0,0 +1,27 @@
package org.gcube.application.geoportal.service.rest;
public class InterfaceConstants {
public static final String APPLICATION_PATH="/srv/";
public static final String SERVICE_CLASS="Application";
public static final String SERVICE_NAME="GeoPortal";
public static final class Methods{
public static final String PROFILES="profiles";
public static final String SECTIONS="sections";
public static final String PROJECTS="projects";
}
public static final class Parameters{
public static final String PROJECT_ID="project_id";
public static final String SECTION_ID="section_id";
public static final String PROFILE_ID="profile_id";
//INVESTIGATE CAPABILITIES
public static final String ORDER_BY="order_by";
public static final String LIMIT="limit";
public static final String OFFSET="offset";
}
}

View File

@ -0,0 +1,5 @@
package org.gcube.application.geoportal.service.rest;
public class Profiles {
}

View File

@ -0,0 +1,77 @@
package org.gcube.application.geoportal.service.rest;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import org.gcube.application.geoportal.service.model.Project;
import lombok.extern.slf4j.Slf4j;
@Path(InterfaceConstants.Methods.PROJECTS)
@Slf4j
public class Projects {
// GET BY ID
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("{"+InterfaceConstants.Parameters.PROJECT_ID+"}")
public Project getByID(@PathParam(InterfaceConstants.Parameters.PROJECT_ID) String id) {
try {
log.info("Looking for profile [ID :{} ]",id);
throw new RuntimeException("Feature not yet available");
}catch(WebApplicationException e){
log.warn("Unable to serve request",e);
throw e;
}catch(Throwable e){
log.warn("Unable to serve request",e);
throw new WebApplicationException("Unable to serve request", e);
}
}
// GET ALL (Filters apply)
@GET
@Produces(MediaType.APPLICATION_JSON)
public Project getAll() {
try {
log.info("Loading all projects..");
throw new RuntimeException("Feature not yet available");
}catch(WebApplicationException e){
log.warn("Unable to serve request",e);
throw e;
}catch(Throwable e){
log.warn("Unable to serve request",e);
throw new WebApplicationException("Unable to serve request", e);
}
}
// Create new Project
@PUT
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Project registerNew(Project toRegister) {
try {
log.info("Loading all projects..");
throw new RuntimeException("Feature not yet available");
}catch(WebApplicationException e){
log.warn("Unable to serve request",e);
throw e;
}catch(Throwable e){
log.warn("Unable to serve request",e);
throw new WebApplicationException("Unable to serve request", e);
}
}
// Modify Project Document
// Delete Project
}

View File

@ -0,0 +1,60 @@
package org.gcube.application.geoportal.service.rest;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import org.gcube.application.geoportal.service.model.Project;
import org.gcube.application.geoportal.service.model.Section;
import lombok.extern.slf4j.Slf4j;
@Slf4j
@Path(InterfaceConstants.Methods.SECTIONS+"/{"+InterfaceConstants.Parameters.PROJECT_ID+"}")
public class Sections {
@PathParam(InterfaceConstants.Parameters.PROJECT_ID) String projectID;
// Add Section to Project Document
@PUT
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Section registerNewSection(Section toRegister) {
try {
log.info("Creating new Section [PROJECT_ID:{}]",projectID);
throw new RuntimeException("Feature not yet available");
}catch(WebApplicationException e){
log.warn("Unable to serve request",e);
throw e;
}catch(Throwable e){
log.warn("Unable to serve request",e);
throw new WebApplicationException("Unable to serve request", e);
}
}
// Remove Section to Project Document
@DELETE
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@Path("{"+InterfaceConstants.Parameters.SECTION_ID+"}")
public Project deleteSection(@QueryParam(InterfaceConstants.Parameters.SECTION_ID) String sectionID) {
try {
log.info("Deleting Section [ID : {}, PROJECT_ID:{}]",projectID,sectionID);
throw new RuntimeException("Feature not yet available");
}catch(WebApplicationException e){
log.warn("Unable to serve request",e);
throw e;
}catch(Throwable e){
log.warn("Unable to serve request",e);
throw new WebApplicationException("Unable to serve request", e);
}
}
}

View File

@ -0,0 +1,8 @@
<application mode='online'>
<name>GeoPortal-Service</name>
<group>Application</group>
<version>1.0.0</version>
<description>REST service for GeoPortal</description>
<local-persistence location='target' />
</application>

View File

@ -0,0 +1,25 @@
<web-app>
<servlet>
<servlet-name>org.gcube.application.geoportal.service.GeoPortalService</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.application.geoportal.service.GeoPortalService</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>
<init-param>
<param-name>jersey.config.xml.formatOutput</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>org.gcube.application.geoportal.service.GeoPortalService</servlet-name>
<url-pattern>/srv/*</url-pattern>
</servlet-mapping>
</web-app>