GeoPortal Service

From Gcube Wiki
Revision as of 17:03, 31 August 2021 by Fabio.sinibaldi (Talk | contribs) (Concessioni)

Jump to: navigation, search

GeoPortal Service is a new REST service designed to manage complex space-temporal Documents defined by metadata Profiles. It has been released as a component of the gCube framework, and SmartGears powers it. It has been designed to manage publication lifecycle of complex space-temporal Documents, supporting their materialization & Indexing in different platforms (Databases, Catalogues, OGC Services..) and maximising reusability.

Overview

Users can define their model as a Profile in the VRE and then manage their Documents publication lifecycle both via gateway’s GUIs and by interacting with the service’s API (both JAVA and/or REST). The service provides a set of Handlers which can be declared and configured in the Profile (defaults apply) in order to be invoked in the different phases of the publication lifecycle. The set of Event Handlers is dynamically loaded by the service allowing support for custom implementation of Event Handlers. The provided java client library allows for dynamic model Serialization / Deserialization of custom provided Java model classes, allowing for easy integration of different systems.


Its main features are :

Documents Publication Management
CRUD (Create, Read, Update, Delete) operations, publication lifecycle, Profiles-based validation;
Role-based access to resources and metadata sections;
Cooperative workflow;
Automatic Indexing & aggregation based on Profiles annotations
GIS indexes (both centroids & multi-polygon), with dynamic aggregation based on zoom level;
Text indexes;
Time indexes and aggregation;
Extensible Document model
Generic meta-model Profile;
Custom extensions of the model;
Extensible behaviour
Core engine based on a meta-model;
Publication management implemented by an extendable set of Event Handlers;
Behaviour configured in Profiles by declaring Event Handlers call in cascade;

Architecture

GeoPortal Service Architecture

API

REST Interface

This section describes the HTTP methods and interfaces exposed by the service. Base relative PATH for all interfaces (BASE_PATH) is "geoportal-service/srv/".

Profiles

Projects

HTTP Interface for Project objects management.

All exposed methods are listed in the tables below with path relative to BASE_PATH/projects.

Caption: Access and search Methods
Method Name HTTP Method Sub Path Parameters Description
List GET List al registered projects
List GET <Profile> List al registered projects related to specified Profile
Get By Id GET <Profile>/<ID> Path : Profile,ID Returns the corresponding project if any
Search All POST search Body : Filter Returns all projects matching the Filter
Search POST search/<Profile> Path : Profile
Body : Filter
Returns all projects related to Profile and matching the Filter
Query All POST query Body : QueryRequest Returns all projects matching the QueryRequest
Query POST query/<Profile> Path : Profile
Body : QueryRequest
Returns all projects related to Profile and matching the QueryRequest
Caption: Projects lifecycle
Method Name HTTP Method Sub Path Parameters Description
Create New POST <Profile> Path : Profile
Body : Project
Creates a new project
Delete By ID DELETE <Profile>/<ID> Path : Profile,ID Deletes the corresponding project if any
Update By ID PUT <Profile>/<ID> Path : Profile,ID
Body : Project
Updates the corresponding project if any
Register FileSet By ID POST registerFiles/<Profile>/<ID> Path : Profile,ID
Body : FileSet
Registers the FileSet into the corresponding project if any
Step By ID PUT step/<Profile>/<ID> Path : Profile,ID Advances the corresponding project status according to workflow
Unpublish By ID DELETE publish/<Profile>/<ID> Path : Profile,ID Unpublishes the corresponding project if any
Caption: Management
Method Name HTTP Method Sub Path Parameters Description
Get Configuration HEAD Returns the current environment configuration
Replace PUT <Profile> Path : Profile
Body : Project record
Replaces any existing record with the same ID (if any) as passed parameter's
Search and Query

Search and Query methods allows refined access to registered records by exploiting the underlying Document Store DB (MongoDB).

Search method allows to specify filters just like with a MongoDB instance, like in the following examples (HTTP Request Body):

//Get validated
{"report.status": {$eq : "PASSED"}}
//All but fabio.sinibaldi's records
{"creationUser" : {$ne : "fabio.sinibaldi"}}


While Search methods accept Filters as directly supported by the underlying engine, the Query method introduces a proprietary JSON object allowing for:

  • Filtering
  • Ordering
  • Paging
  • Transformation
//Get last registered record
{
  "paging" : {
    "offset" : 0,
    "limit" : 1
  },
  "ordering" : {
    "direction" : "DESCENDING",
    "fields" : ["creationTime","nome"]
  }
}
 
//Get last registerd record by fabio.sinibaldi
{
  "paging" : {
    "offset" : 0,
    "limit" : 1
  },
  "ordering" : {
    "direction" : "DESCENDING",
    "fields" : ["creationTime","nome"]
  }
  "filter" : {"creationUser" : {$eq : "fabio.sinibaldi"}}
}

Concessioni

Custom prototype interface for GNA case study (See GNA Usecase). All exposed methods are listed in the tables below with path relative to BASE_PATH/mongo-concessioni.

Caption: Access and search Methods
Method Name HTTP Method Sub Path Parameters Description
List GET List al registered records
Get By Id GET <ID> Path : ID Returns the corresponding record if any
Search POST search Body : Filter Returns all records matching the Filter
Query POST query Body : QueryRequest Returns all records matching the QueryRequest
Caption: Concessioni lifecycle
Method Name HTTP Method Sub Path Parameters Description
Create New POST Body Concessioni record Creates a new record
Delete By ID DELETE <ID> Path : ID Deletes the corresponding record if any
Update By ID PUT <ID> Path : ID Updates the corresponding record if any
Publish By ID PUT publish/<ID> Path : ID Publishes the corresponding record if any
Unpublish By ID DELETE publish/<ID> Path : ID Unpublishes the corresponding record if any
Register FileSet By ID POST registerFiles/<ID> Path : ID,</br>Body : FileSet Registers the FileSet into the corresponding record if any
Caption: Management
Method Name HTTP Method Sub Path Parameters Description
Get Configuration HEAD Returns the current environment configuration
Replace PUT Body : Concessioni record Replaces any existing record with the same ID (if any) as passed parameter's
Search and Query

Search and Query methods allows refined access to registered records by exploiting the underlying Document Store DB (MongoDB).

Search method allows to specify filters just like with a MongoDB instance, like in the following examples (HTTP Request Body):

//Get validated
{"report.status": {$eq : "PASSED"}}
//All but fabio.sinibaldi's records
{"creationUser" : {$ne : "fabio.sinibaldi"}}


While Search methods accept Filters as directly supported by the underlying engine, the Query method introduces a proprietary JSON object allowing for:

  • Filtering
  • Ordering
  • Paging
  • Transformation
//Get last registered record
{
  "paging" : {
    "offset" : 0,
    "limit" : 1
  },
  "ordering" : {
    "direction" : "DESCENDING",
    "fields" : ["creationTime","nome"]
  }
}
 
//Get last registerd record by fabio.sinibaldi
{
  "paging" : {
    "offset" : 0,
    "limit" : 1
  },
  "ordering" : {
    "direction" : "DESCENDING",
    "fields" : ["creationTime","nome"]
  }
  "filter" : {"creationUser" : {$eq : "fabio.sinibaldi"}}
}

Client Library

Java client library to interact with the service is distributed as maven artifact

<groupId>org.gcube.application</groupId>
<artifactId>geoportal-client</artifactId>


The library offers various wrappings of the REST interface, allowing for :

  • Both Custom & Generic management of Profiled Documents ;
  • Both Custom & Generic automatic parsing of JSON communications over REST interface;
  • Transparent authentication and service discovery, thanks to gCube Framework;

Generic Profiled Documents Managers

  • ProfiledDocumentsManagerI : JAVA interface for the management of Profiled Documents.

Custom Concessioni Managers

The library provides the following customized versions of the generic clients in order to manage Concessioni Documents :

MongoConcessioni

Interface for the stateless management of Concessioni Documents. It reflects the contract of the generic REST API. Following snippet shows typical usage :

import static org.gcube.application.geoportal.client.GeoportalAbstractPlugin.mongoConcessioni;
...
 
Concessione c=...
 
//Register New Concessione
c=client.createNew(c);
 
// Upload files to Concessione Section by Path (e.g. Relazione)
String mongoId=c.getMongo_id();	
List<TempFile> files=...
AddSectionToConcessioneRequest request=	new AddSectionToConcessioneRequest(Paths.RELAZIONE, files);
 
client.registerFile(mongoId, request);
 
 
// Publish
 
client.publish(mongoId);
ConcessioniManagerI

Interface for the statefull creation of Concessioni Documents. Stateful logic helps client to manage the management of the last loaded/registered Concessione, offering dedicated methods for adding FileSets (e.g. RelazioneScavo) to the current Document.

Following snippet shows typical usage :

import org.gcube.application.geoportal.client.GeoportalAbstractPlugin.statefulMongoConcessioni;
....
 
//Obtain the client
ConcessioniManagerI manager=statefulMongoConcessioni().build();
...
 
//Create a new Document from scratch
Concessione c = ...
...
manager.createNew(c);
 
//Adds an UploadedImage to the current document
 
UploadedImage toRegisterImg= ...
TempFile toUpload=....
 
manager.addImmagineRappresentativa(toRegisterImg, toUpload);
 
 
//Publishes current object
manager.publish();

Utility Classes

StorageUtils

In order to transfer FileSets to the REST service, an utility class is provided, allowing for the management of infrastructure's TempFiles. Following snippet is a typical usage :

StorageUtils storage=new StorageUtils();
 
InputStream myPayload=...
String payloadName=...
 
TempFile toUpload=storage.putOntoStorage(myPayload, payloadName);