Generic SDIManager

This commit is contained in:
Fabio Sinibaldi 2022-02-14 12:23:13 +01:00
parent a4e90a9f64
commit da148707f6
32 changed files with 698 additions and 88 deletions

View File

@ -44,6 +44,21 @@
<groupId>org.gcube.application.cms</groupId>
<artifactId>concessioni-model</artifactId>
</dependency>
<!-- SDI -->
<dependency>
<groupId>org.gcube.spatial.data</groupId>
<artifactId>gis-interface</artifactId>
<version>[2.4.6,3.0.0)</version>
</dependency>
<!-- DT -->
<dependency>
<groupId>org.gcube.data.transfer</groupId>
<artifactId>data-transfer-library</artifactId>
<version>[1.2.1,2.0.0]</version>
</dependency>
</dependencies>

View File

@ -5,6 +5,9 @@ import org.bson.BsonDocument;
import org.bson.BsonString;
import org.bson.BsonValue;
import org.bson.Document;
import org.gcube.application.cms.plugins.faults.EventException;
import org.gcube.application.cms.plugins.reports.EventExecutionReport;
import org.gcube.application.cms.plugins.requests.EventExecutionRequest;
import org.gcube.application.cms.serialization.Serialization;
import org.gcube.application.cms.custom.gna.concessioni.model.ProfiledConcessione;
import org.gcube.application.cms.plugins.LifecycleManager;
@ -12,10 +15,15 @@ import org.gcube.application.cms.plugins.faults.InitializationException;
import org.gcube.application.cms.plugins.faults.ShutDownException;
import org.gcube.application.cms.plugins.faults.StepException;
import org.gcube.application.cms.plugins.model.PluginDescriptor;
import org.gcube.application.cms.plugins.reports.ExecutionReport;
import org.gcube.application.cms.plugins.reports.StepExecutionReport;
import org.gcube.application.cms.plugins.reports.InitializationReport;
import org.gcube.application.cms.plugins.requests.StepExecutionRequest;
import org.gcube.application.geoportal.common.model.document.*;
import org.gcube.application.geoportal.common.model.document.access.Access;
import org.gcube.application.geoportal.common.model.document.access.AccessPolicy;
import org.gcube.application.geoportal.common.model.document.filesets.RegisteredFileSet;
import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation;
import org.gcube.application.geoportal.common.model.document.lifecycle.TriggeredEvents;
import org.gcube.application.geoportal.common.model.legacy.report.ConstraintCheck;
import org.gcube.application.geoportal.common.model.rest.Configuration;
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
@ -46,9 +54,9 @@ public class ConcessioniLifeCycleManager implements LifecycleManager {
}
@Override
public ExecutionReport performStep(StepExecutionRequest request) throws StepException {
public StepExecutionReport performStep(StepExecutionRequest request) throws StepException {
log.info("Serving Request {}",request);
ExecutionReport report=new ExecutionReport();
StepExecutionReport report=new StepExecutionReport();
LifecycleInformation info=new LifecycleInformation();
info.setPhase(request.getStep());
info.setLastOperationStatus(LifecycleInformation.Status.OK);
@ -57,28 +65,42 @@ public class ConcessioniLifeCycleManager implements LifecycleManager {
try {
switch (request.getStep()) {
case StepExecutionRequest.Steps.ON_INIT_DOCUMENT:
// Set Defaults as for on update
case StepExecutionRequest.Steps.ON_UPDATE_DOCUMENT: {
log.debug("Setting default values..");
report.setResult(setDefaults(request.getDocument()));
break;
}
case StepExecutionRequest.Steps.ON_MATERIALIZE_DOCUMENT: {
// SDI Create Layers
break;
}
case StepExecutionRequest.Steps.ON_DEMATERIALIZE_DOCUMENT: {
// SDI Remove Layers
break;
}
case StepExecutionRequest.Steps.ON_DEINDEX_DOCUMENT: {
// SDI Remove from centroids
break;
}
case StepExecutionRequest.Steps.ON_INDEX_DOCUMENT: {
// SDI Add to centroids
break;
}
case StepExecutionRequest.Steps.ON_DELETE_DOCUMENT: {
case "SUBMIT-FOR-REVIEW" :{
//Checks
//Materialize layers
//Index-confidential
//Notifications
break;
}
case "REJECT-DRAFT":{
// Notification
// Set
break;
}
case "APPROVE DRAFT":{
break;
}
default:
throw new StepException("Invalid Step " + request.getStep());
}
@ -92,6 +114,41 @@ public class ConcessioniLifeCycleManager implements LifecycleManager {
return report;
}
@Override
public EventExecutionReport onEvent(EventExecutionRequest request) throws EventException {
log.info("Executing Event {}",request);
EventExecutionReport report=new EventExecutionReport();
report.setRequest(request);
report.setResult(request.getDocument());
TriggeredEvents info=new TriggeredEvents();
try {
switch(request.getEvent()){
case EventExecutionRequest.Events.ON_INIT_DOCUMENT:
// Set Defaults as for on update
case EventExecutionRequest.Events.ON_UPDATE_DOCUMENT: {
log.debug("Setting default values..");
report.setResult(setDefaults(request.getDocument()));
break;
}
case EventExecutionRequest.Events.ON_DELETE_DOCUMENT: {
//DELETE ALL
break;
}
default: throw new EventException("Unexpected Event "+request.getEvent());
}
}catch (EventException e){
throw e;
}catch (Throwable t){
log.error("Unable to execute on event "+request.getEvent(),t);
info.setLastOperationStatus(LifecycleInformation.Status.ERROR);
info.addErrorMessage("Unable to execute on event "+request.getEvent()+". Error was "+t.getMessage());
}finally{
report.getResult().getLifecycleInformation().addEventReport(info);
}
return report;
}
@Override
public Configuration getCurrentConfiguration() throws ConfigurationException {
return null;
@ -103,6 +160,12 @@ public class ConcessioniLifeCycleManager implements LifecycleManager {
}
// Materialization
private static final void materialize(){
}
// STATIC ROUTINES
private static final ProfiledDocument setDefaults(ProfiledDocument document){

View File

@ -0,0 +1,76 @@
package org.gcube.application.cms.concessioni.plugins;
import lombok.extern.slf4j.Slf4j;
import org.bson.Document;
import org.gcube.application.cms.concessioni.sdi.SDIManager;
import org.gcube.application.cms.plugins.MaterializationPlugin;
import org.gcube.application.cms.plugins.faults.InitializationException;
import org.gcube.application.cms.plugins.faults.MaterializationException;
import org.gcube.application.cms.plugins.faults.ShutDownException;
import org.gcube.application.cms.plugins.model.PluginDescriptor;
import org.gcube.application.cms.plugins.reports.InitializationReport;
import org.gcube.application.cms.plugins.reports.MaterializationReport;
import org.gcube.application.cms.plugins.requests.MaterializationRequest;
import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation;
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
import org.gcube.application.geoportal.common.model.document.filesets.RegisteredFileSet;
import org.gcube.application.geoportal.common.model.profile.HandlerDeclaration;
import org.gcube.application.geoportal.common.model.profile.Profile;
@Slf4j
public class SDIMaterializerPlugin implements MaterializationPlugin {
SDIManager sdiManager;
@Override
public InitializationReport initInContext() throws InitializationException {
return null;
}
@Override
public InitializationReport init() throws InitializationException {
return null;
}
@Override
public void shutdown() throws ShutDownException {
}
@Override
public MaterializationReport materialize(MaterializationRequest request) throws MaterializationException {
log.info("Materializer {} : Performing {} ",this.getDescriptor().getId(),request);
ProfiledDocument doc=request.getDocument();
Profile profile = request.getProfile();
Document configuration=request.getParameters();
Document profileConfiguration =null;
for (HandlerDeclaration h : profile.getHandlers()) {
if (h.getId().equals("SDI-Default-Materializer")) {
profileConfiguration = h.getConfiguration();
}
}
log.debug("Profile Configuration is {} ",profileConfiguration);
try{
// for each
RegisteredFileSet fileSet=null;
sdiManager.materializeLayer()
}catch (MaterializationException e){
throw e;
}catch (Throwable t){
log.error("Unable to execute on event "+request.getEvent(),t);
info.setLastOperationStatus(LifecycleInformation.Status.ERROR);
info.addErrorMessage("Unable to execute on event "+request.getEvent()+". Error was "+t.getMessage());
}finally{
}
}
@Override
public PluginDescriptor getDescriptor() {
return null;
}
}

View File

@ -0,0 +1,283 @@
package org.gcube.application.cms.concessioni.sdi;
import it.geosolutions.geoserver.rest.GeoServerRESTPublisher;
import it.geosolutions.geoserver.rest.GeoServerRESTReader;
import it.geosolutions.geoserver.rest.decoder.RESTFeatureType;
import it.geosolutions.geoserver.rest.decoder.RESTLayer;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.bson.Document;
import org.gcube.application.cms.concessioni.sdi.faults.SDIInteractionException;
import org.gcube.application.cms.serialization.Serialization;
import org.gcube.application.geoportal.common.model.document.filesets.GCubeSDILayer;
import org.gcube.application.geoportal.common.model.document.filesets.RegisteredFile;
import org.gcube.application.geoportal.common.model.document.filesets.RegisteredFileSet;
import org.gcube.application.geoportal.common.utils.Files;
import org.gcube.data.transfer.library.DataTransferClient;
import org.gcube.data.transfer.library.TransferResult;
import org.gcube.data.transfer.model.Destination;
import org.gcube.data.transfer.model.DestinationClashPolicy;
import org.gcube.spatial.data.gis.GISInterface;
import org.gcube.spatial.data.gis.is.AbstractGeoServerDescriptor;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
@Slf4j
public class SDIManager {
static private final String EPSG_4326="EPSG:4326";
static private final String WGS84_FULL="GEOGCS[\"WGS 84\", DATUM[\"World Geodetic System 1984\", SPHEROID[\"WGS 84\", 6378137.0, 298.257223563, AUTHORITY[\"EPSG\",\"7030\"]],"+
"AUTHORITY[\"EPSG\",\"6326\"]], PRIMEM[\"Greenwich\", 0.0, AUTHORITY[\"EPSG\",\"8901\"]], UNIT[\"degree\", 0.017453292519943295],"+
"AXIS[\"Geodetic longitude\", EAST], AXIS[\"Geodetic latitude\", NORTH], AUTHORITY[\"EPSG\",\"4326\"]]";
public static final Pattern HOSTNAME_PATTERN=Pattern.compile("(?<=\\:\\/\\/)[^\\:]*");
public static final Pattern PORT_PATTERN=Pattern.compile("(?<=\\:)[\\d]+");
public static final Pattern DB_NAME_PATTERN=Pattern.compile("(?<=\\/)[^\\/]*(?=$)");
private final GISInterface gis;
@Getter
private final DataTransferClient dtGeoServer;
private final String geoserverHostName;
private final AbstractGeoServerDescriptor currentGeoserver;
public SDIManager() throws SDIInteractionException {
try{
log.debug("Initializing GIS Interface..");
gis=GISInterface.get();
currentGeoserver=gis.getCurrentGeoServer();
if(currentGeoserver==null)
throw new Exception("Unable to contact data transfer for geoserver ");
log.debug("Found geoserver descriptor "+currentGeoserver);
geoserverHostName=new URL(currentGeoserver.getUrl()).getHost();
log.debug("Contacting Data Transfer from geoserver {} ",geoserverHostName);
dtGeoServer=DataTransferClient.getInstanceByEndpoint("https://"+geoserverHostName);
if(!currentGeoserver.getReader().existGeoserver())
throw new Exception("Geoserver not reachable");
}catch(Exception e) {
throw new SDIInteractionException("Unable to initialize SDI Manager",e);
}
}
/**
* Expected paramters :
* - "workspace"
* - "layerTitle"
* - "documentID"
* - "basePersistencePath" (profile specific, e.g. "GNA")
*
* @param fileSet
* @param params
* @return
* @throws SDIInteractionException
*/
public RegisteredFileSet materializeLayer(RegisteredFileSet fileSet, Document params) throws SDIInteractionException{
try {
log.debug("Materializing FS {} on {} ", fileSet, geoserverHostName);
// validate parameters
String workspace = getMandatory("workspace", params);
String documentID = getMandatory("documentID", params);
String basePersistencePAth = getMandatory("basePersistencePath", params);
// check if empty
if (fileSet.getPayloads().isEmpty()) throw new SDIInteractionException("No payload to materialize");
Document geoserverInfo = new Document();
geoserverInfo.put("_type", "Geoserver");
geoserverInfo.put("workspace", workspace);
// Evaluate Layer Name
String baseName = getToUseBaseLayerName(fileSet);
log.debug("Base layer name is {}, checking conflicts.. ");
String toSetLayerName = baseName;
//Check if layer already exists
int count = 0;
GeoServerRESTReader gsReader = currentGeoserver.getReader();
while (gsReader.getLayer(workspace, toSetLayerName) != null) {
count++;
toSetLayerName = baseName + "_" + count;
log.debug("layer for " + baseName + " already existing, trying " + toSetLayerName);
}
geoserverInfo.put("layerName", toSetLayerName);
log.debug("Layer name will be {} ", toSetLayerName);
String folderRelativePath = basePersistencePAth + "/" + documentID + "/" + fileSet.getUUID() + "/" + toSetLayerName;
log.debug("GS Relative destination path is {} ", folderRelativePath);
geoserverInfo.put("persistencePath", folderRelativePath);
List<String> filenames = new ArrayList<>();
String absolutePath = null;
for (Object o : fileSet.getPayloads()) {
RegisteredFile file = Serialization.convert(o, RegisteredFile.class);
log.info("Sending {} to GS {} at {} ", file, geoserverHostName, folderRelativePath);
String completeFilename = Files.fixFilename(file.getName());
completeFilename = completeFilename.replaceAll(baseName, toSetLayerName);
Destination destination = new Destination(completeFilename);
destination.setCreateSubfolders(true);
destination.setOnExistingFileName(DestinationClashPolicy.REWRITE);
destination.setOnExistingSubFolder(DestinationClashPolicy.APPEND);
destination.setPersistenceId("geoserver");
destination.setSubFolder(folderRelativePath);
log.debug("Sending {} to {}", file, destination);
TransferResult result = getDtGeoServer().httpSource(new URL(file.getLink()), destination);
log.debug("Transferred " + result);
filenames.add(completeFilename);
// NB Clash con subfolder is APPEND, thus FOLDER is expected to be the one specified by caller
//geoserverInfo.put(""result.getRemotePath().substring(0, result.getRemotePath().lastIndexOf("/")));
absolutePath = result.getRemotePath().substring(0, result.getRemotePath().lastIndexOf("/"));
}
geoserverInfo.put("files", filenames);
// Publishing layer in GS
String storeName = toSetLayerName + "_store";
geoserverInfo.put("storeName", storeName);
GeoServerRESTPublisher publisher = currentGeoserver.getPublisher();
log.debug("Trying to create remote workspace : " + workspace);
createWorkspace(workspace);
log.debug("Publishing remote folder " + absolutePath);
URL directoryPath = new URL("file:" + absolutePath + "/" + toSetLayerName + ".shp");
//TODO Evaluate SRS
boolean published = publisher.publishShp(
workspace,
storeName,
null,
toSetLayerName,
// UploadMethod.FILE, // neeeds zip
GeoServerRESTPublisher.UploadMethod.EXTERNAL, // needs shp
directoryPath.toURI(),
EPSG_4326, //SRS
""); // default style
if (!published) {
throw new SDIInteractionException("Unable to publish layer " + toSetLayerName + " under " + workspace + ". Unknown Geoserver fault.");
}
RESTLayer l = gsReader.getLayer(workspace, toSetLayerName);
RESTFeatureType f = gsReader.getFeatureType(l);
/*https://geoserver1.dev.d4science.org/geoserver/gna_conc_18/wms?
service=WMS&version=1.1.0&request=GetMap&layers=gna_conc_18:pos&
styles=&bbox=8.62091913167495,40.62975046683799,8.621178639172953,40.630257904721645&
width=392&height=768&srs=EPSG:4326&format=application/openlayers */
List<Document> ogcLinks = new ArrayList<>();
Document wmsLink = new Document();
wmsLink.put("wms", String.format("https://%1$s/geoserver/%2$s/wms?"
+ "service=WMS&version=1.1.0&request=GetMap&layers=%2$s:%3$s&"
+ "styles=&bbox=%4$f,%5$f,%6$f,%7$f&srs=%8$s&format=application/openlayers&width=%9$d&height=%10$d",
geoserverHostName,
workspace,
toSetLayerName,
f.getMinX(),
f.getMinY(),
f.getMaxX(),
f.getMaxY(),
EPSG_4326,
400,
400));
ogcLinks.add(wmsLink);
List<Document> platformInfo = new ArrayList<>();
platformInfo.add(geoserverInfo);
// TODO Metadata
// Materialization object
GCubeSDILayer materialization = new GCubeSDILayer();
materialization.put(GCubeSDILayer.OGC_LINKS, ogcLinks);
materialization.put(GCubeSDILayer.B_BOX, new GCubeSDILayer.BBOX(f.getMaxX(), f.getMaxY(), f.getMinX(), f.getMinY()));
materialization.put(GCubeSDILayer.PLATFORM_INFO, platformInfo);
log.info("Generated Materialization {}", materialization);
//Add Materialization to registered file set
List materializations = fileSet.getMaterializations();
if (materializations == null) materializations = new ArrayList();
materializations.add(materialization);
fileSet.put(RegisteredFileSet.MATERIALIZATIONS, materializations);
return fileSet;
}catch(SDIInteractionException e){
throw e;
}catch (Throwable t){
throw new SDIInteractionException("Unexpected exception while trying to materialize File Set "+t.getMessage(),t);
}
}
public String createWorkspace(String toCreate) throws SDIInteractionException {
try {
if(!currentGeoserver.getReader().getWorkspaceNames().contains(toCreate)) {
log.debug("Creating workspace : "+toCreate);
if(!currentGeoserver.getPublisher().createWorkspace(toCreate))
throw new SDIInteractionException("Unable to create workspace "+toCreate);
}else log.debug("Workspace "+toCreate+" exists.");
return toCreate;
} catch (IllegalArgumentException | MalformedURLException e) {
throw new SDIInteractionException("Unable to create workspace "+toCreate,e);
}
}
private static final String getToUseBaseLayerName(RegisteredFileSet fileset){
// ******** IDENTIFY LAYER NAME correct layer name
// Must be unique under same WS
// equal to shp base name
String baseName= "";
// Chose layer name first identifying filename
for(Object p:fileset.getPayloads()){
RegisteredFile f = Serialization.convert(p,RegisteredFile.class);
String name=f.getName();
if(name.endsWith(".shp")) {
log.debug("SHP is {}",name);
baseName= Files.fixFilename(name.substring(0,name.lastIndexOf('.')));
break;
}
}
return baseName;
}
private static final String getMandatory(String param,Document params) throws SDIInteractionException {
if(!params.containsKey(param)) throw new SDIInteractionException("Missing mandatory parameter "+param);
return params.getString(param);
}
}

View File

@ -0,0 +1,23 @@
package org.gcube.application.cms.concessioni.sdi.faults;
public class SDIInteractionException extends Exception {
public SDIInteractionException() {
}
public SDIInteractionException(String message) {
super(message);
}
public SDIInteractionException(String message, Throwable cause) {
super(message, cause);
}
public SDIInteractionException(Throwable cause) {
super(cause);
}
public SDIInteractionException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
}

View File

@ -0,0 +1,16 @@
package org.gcube.application.cms.concessioni.sdi.model;
import org.bson.Document;
import java.util.HashMap;
import java.util.Map;
public class SDIConfiguration {
public static final String GEOSERVER_PLATFORM="GeoServer";
public static final String GEONETWORK_PLATFORM="GeoNetwork";
private Map<String,Document> platformConfiguration=new HashMap<>();
}

View File

@ -1,17 +1,7 @@
package org.gcube.application.cms.custom.gna.concessioni.model;
import org.bson.BsonDocument;
import org.bson.BsonString;
import org.bson.BsonValue;
import org.bson.Document;
import org.gcube.application.geoportal.common.model.document.Access;
import org.gcube.application.geoportal.common.model.document.AccessPolicy;
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
import org.gcube.application.geoportal.common.model.document.RegisteredFileSet;
import org.gcube.application.geoportal.common.model.legacy.report.ConstraintCheck;
import java.util.List;
public class ProfiledConcessione extends ProfiledDocument {

View File

@ -1,7 +0,0 @@
package org.gcube.application.geoportal.common.model.document;
public enum AccessPolicy {
OPEN,RESTRICTED,EMBARGOED;
}

View File

@ -1,12 +0,0 @@
package org.gcube.application.geoportal.common.model.document;
import lombok.*;
import org.bson.Document;
public class Materialization extends Document {
public static final String TYPE ="_type";
public String getType(){return super.getString(TYPE);}
}

View File

@ -4,6 +4,8 @@ import com.mongodb.client.model.geojson.GeoJsonObjectType;
import com.vdurmont.semver4j.Semver;
import lombok.*;
import org.bson.Document;
import org.gcube.application.geoportal.common.model.document.accounting.PublicationInfo;
import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation;
@NoArgsConstructor
@ -40,7 +42,8 @@ public class ProfiledDocument {
private Relationship[] relationships;
private GeoJsonObjectType spatialReference;
// Expected GEOJSON
private Document spatialReference;
private TemporalReference temporalReference;

View File

@ -1,4 +1,4 @@
package org.gcube.application.geoportal.common.model.document;
package org.gcube.application.geoportal.common.model.document.access;
import lombok.*;

View File

@ -0,0 +1,7 @@
package org.gcube.application.geoportal.common.model.document.access;
public enum AccessPolicy {
OPEN,RESTRICTED,EMBARGOED;
}

View File

@ -1,4 +1,4 @@
package org.gcube.application.geoportal.common.model.document;
package org.gcube.application.geoportal.common.model.document.accounting;
import lombok.*;

View File

@ -1,4 +1,4 @@
package org.gcube.application.geoportal.common.model.document;
package org.gcube.application.geoportal.common.model.document.accounting;
import lombok.*;

View File

@ -1,7 +1,7 @@
package org.gcube.application.geoportal.common.model.document;
package org.gcube.application.geoportal.common.model.document.accounting;
import lombok.*;
import org.gcube.application.geoportal.common.model.legacy.AccessPolicy;
import org.gcube.application.geoportal.common.model.document.access.Access;
@NoArgsConstructor
@AllArgsConstructor

View File

@ -1,4 +1,4 @@
package org.gcube.application.geoportal.common.model.document;
package org.gcube.application.geoportal.common.model.document.accounting;
import lombok.*;

View File

@ -0,0 +1,51 @@
package org.gcube.application.geoportal.common.model.document.filesets;
import com.sun.xml.internal.ws.message.PayloadElementSniffer;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import java.util.List;
public class GCubeSDILayer extends Materialization{
@Data
@NoArgsConstructor
public static class BBOX {
public static final BBOX WORLD=new BBOX(180d,90d,-180d,-90d);
public static final String MAX_X="maxX";
public static final String MAX_Y="maxY";
public static final String MIN_X="minX";
public static final String MIN_Y="minY";
public BBOX(Double maxX,Double maxY,Double minX,Double minY){
this.maxX=maxX;
this.minX=minX;
this.maxY=maxY;
this.minY=minY;
}
private Double maxY;
private Double maxX;
private Double minY;
private Double minX;
}
public static final String GCUBE_SDY_LAYER_TYPE="gcube-sdi-layer";
public static final String OGC_LINKS="ogcLinks";
public static final String B_BOX = "bbox";
public static final String PLATFORM_INFO="platformInfo";
public GCubeSDILayer(){
super(GCUBE_SDY_LAYER_TYPE);
}
public List getOGCLinks(){return this.get(OGC_LINKS, List.class);}
public BBOX getBBox(){return this.get(B_BOX,BBOX.class);}
public List getPlatformInfo(){return this.get(PLATFORM_INFO,List.class);}
}

View File

@ -0,0 +1,17 @@
package org.gcube.application.geoportal.common.model.document.filesets;
import lombok.*;
import org.bson.Document;
@ToString (callSuper = true)
public class Materialization extends Document {
public static final String TYPE ="_type";
public String getType(){return super.getString(TYPE);}
public Materialization(){super();}
public Materialization (String type){
this.put(TYPE,type);
}
}

View File

@ -1,12 +1,8 @@
package org.gcube.application.geoportal.common.model.document;
package org.gcube.application.geoportal.common.model.document.filesets;
import lombok.*;
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@ToString
@Data
public class RegisteredFile {
public static String MIMETYPE="mimetype";

View File

@ -1,4 +1,4 @@
package org.gcube.application.geoportal.common.model.document;
package org.gcube.application.geoportal.common.model.document.filesets;
import lombok.*;
import org.bson.Document;
@ -6,11 +6,10 @@ import org.bson.Document;
import java.util.List;
@Getter
@Setter
@ToString (callSuper = true)
public class RegisteredFileSet extends Document {
public static final String UUID="uuid";
public static final String CREATION_INFO="creationInfo";
public static final String ACCESS="access";
public static final String FOLDER_ID="folderID";
@ -26,4 +25,6 @@ public class RegisteredFileSet extends Document {
public List getPayloads(){return super.get(PAYLOADS,List.class);}
public List getMaterializations(){return super.get(MATERIALIZATIONS,List.class);}
public String getUUID(){return super.getString(UUID);}
}

View File

@ -0,0 +1,17 @@
package org.gcube.application.geoportal.common.model.document.filesets;
import lombok.Data;
import lombok.ToString;
import org.bson.Document;
import sun.jvm.hotspot.utilities.PlatformInfo;
import java.util.List;
@Data
public class SDILayer extends Materialization{
private
private List<Document> ogcLinks;
private List<PlatformInfo>
}

View File

@ -1,33 +1,30 @@
package org.gcube.application.geoportal.common.model.document;
package org.gcube.application.geoportal.common.model.document.lifecycle;
import lombok.*;
import java.util.ArrayList;
import java.util.List;
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@ToString
@Data
public class LifecycleInformation {
public static final String PHASE="phase";
public static final String LAST_INVOKED_STEP="lastInvokedStep";
public static final String LAST_OPERATION_STATUS="lastOperationStatus";
public static final String ERROR_MESSAGES="errorMessages";
public static final String WARNING_MESSAGES="warningMEssages";
public static final String CHILDREN="children";
public static final String WARNING_MESSAGES="warningMessages";
public static final String TRIGGERED_EVENTS="triggeredEvents";
public static enum Status{
OK,ERROR,WARNING
}
private String phase;
private String lastInvokedStep;
private Status lastOperationStatus;
private List<String> errorMessages;
private List<String> warningMessages;
private List<LifecycleInformation> children;
private List<TriggeredEvents> triggeredEvents;
public void addErrorMessage(String msg){
@ -40,4 +37,9 @@ public class LifecycleInformation {
warningMessages=new ArrayList<>();
warningMessages.add(msg);
}
public void addEventReport(TriggeredEvents info){
if(triggeredEvents==null) triggeredEvents=new ArrayList<>();
triggeredEvents.add(info);
}
}

View File

@ -0,0 +1,33 @@
package org.gcube.application.geoportal.common.model.document.lifecycle;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class TriggeredEvents {
public static final String PHASE="phase";
public static final String LAST_INVOKED_STEP="lastInvokedStep";
public static final String LAST_OPERATION_STATUS="lastOperationStatus";
public static final String ERROR_MESSAGES="errorMessages";
public static final String WARNING_MESSAGES="warningMessages";
public static final String TRIGGERED_EVENTS="triggeredEvents";
private String event;
private LifecycleInformation.Status lastOperationStatus;
private List<String> errorMessages;
private List<String> warningMessages;
public void addErrorMessage(String msg){
if(errorMessages==null)
errorMessages=new ArrayList<>();
errorMessages.add(msg);
}
public void addWarningMessage(String msg){
if(warningMessages==null)
warningMessages=new ArrayList<>();
warningMessages.add(msg);
}
}

View File

@ -9,11 +9,8 @@ import javax.xml.bind.annotation.XmlRootElement;
import com.vdurmont.semver4j.Semver;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.bson.Document;
import org.gcube.application.geoportal.common.model.document.AccountingInfo;
import org.gcube.application.geoportal.common.model.document.ComparableVersion;
import org.gcube.application.geoportal.common.model.document.accounting.AccountingInfo;
@Data
@NoArgsConstructor

View File

@ -2,7 +2,7 @@ package org.gcube.application.geoportal.service.engine;
import lombok.*;
import lombok.extern.slf4j.Slf4j;
import org.gcube.application.geoportal.common.model.document.RegisteredFile;
import org.gcube.application.geoportal.common.model.document.filesets.RegisteredFile;
import org.gcube.application.geoportal.common.model.legacy.WorkspaceContent;
import org.gcube.application.geoportal.common.utils.Files;
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;

View File

@ -1,13 +1,12 @@
package org.gcube.application.geoportal.service.engine.handlers;
import com.google.protobuf.DescriptorProtos;
import lombok.extern.slf4j.Slf4j;
import org.gcube.application.cms.plugins.LifecycleManager;
import org.gcube.application.cms.plugins.faults.InitializationException;
import org.gcube.application.cms.plugins.faults.ShutDownException;
import org.gcube.application.cms.plugins.faults.StepException;
import org.gcube.application.cms.plugins.model.PluginDescriptor;
import org.gcube.application.cms.plugins.reports.ExecutionReport;
import org.gcube.application.cms.plugins.reports.StepExecutionReport;
import org.gcube.application.cms.plugins.reports.InitializationReport;
import org.gcube.application.cms.plugins.requests.StepExecutionRequest;
import org.gcube.application.geoportal.common.model.document.ComparableVersion;
@ -38,7 +37,7 @@ public class SimpleLifeCycleManager implements LifecycleManager {
}
@Override
public ExecutionReport performStep(StepExecutionRequest request) throws StepException {
public StepExecutionReport performStep(StepExecutionRequest request) throws StepException {
log.info("Received Request ");
switch(request.getStep()){

View File

@ -11,10 +11,15 @@ import org.bson.types.ObjectId;
import org.gcube.application.cms.plugins.LifecycleManager;
import org.gcube.application.cms.plugins.faults.StepException;
import org.gcube.application.cms.plugins.model.PluginDescriptor;
import org.gcube.application.cms.plugins.reports.ExecutionReport;
import org.gcube.application.cms.plugins.reports.StepExecutionReport;
import org.gcube.application.cms.plugins.requests.StepExecutionRequest;
import org.gcube.application.geoportal.common.faults.StorageException;
import org.gcube.application.geoportal.common.model.document.*;
import org.gcube.application.geoportal.common.model.document.access.Access;
import org.gcube.application.geoportal.common.model.document.access.AccessPolicy;
import org.gcube.application.geoportal.common.model.document.accounting.PublicationInfo;
import org.gcube.application.geoportal.common.model.document.filesets.RegisteredFile;
import org.gcube.application.geoportal.common.model.document.filesets.RegisteredFileSet;
import org.gcube.application.geoportal.common.model.legacy.Concessione;
import org.gcube.application.geoportal.common.model.profile.Field;
import org.gcube.application.geoportal.common.model.profile.HandlerDeclaration;
@ -43,6 +48,7 @@ import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.function.Consumer;
@ -236,7 +242,7 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
@Override
public ProfiledDocument performStep(String id, String step, Document options) throws StepException, JsonProcessingException {
ExecutionReport report = step(getByID(id), step, options);
StepExecutionReport report = step(getByID(id), step, options);
return convert(replace(asDocumentWithId(report.getResult()),new ObjectId(id),getCollectionName()),ProfiledDocument.class);
}
@ -349,7 +355,7 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
}
private ExecutionReport step(ProfiledDocument theDocument,String step,Document callParameters) throws StepException {
private StepExecutionReport step(ProfiledDocument theDocument, String step, Document callParameters) throws StepException {
log.info("[Profile {} ] Invoking Step {} on {}" ,profile.getId(),step,getManager().getDescriptor());
StepExecutionRequest request=new StepExecutionRequest();
request.setCallParameters(callParameters);
@ -357,7 +363,7 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
request.setProfile(profile);
request.setStep(step);
log.debug("Requesting Step Execution {} ",request);
ExecutionReport report= getManager().performStep(request);
StepExecutionReport report= getManager().performStep(request);
log.debug("Report is {}",report);
if(report.getResult()==null) throw new StepException("Report result is null");
return report;
@ -371,6 +377,7 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
log.debug("Preparing Registered FileSet..");
RegisteredFileSet toReturn = new RegisteredFileSet();
if(attributes!=null) toReturn.putAll(attributes);
toReturn.put(RegisteredFileSet.UUID, UUID.randomUUID().toString());
toReturn.put(RegisteredFileSet.CREATION_INFO,UserUtils.getCurrent().asInfo());
toReturn.putIfAbsent(RegisteredFileSet.ACCESS,doc.getInfo().getAccess());
FolderContainer base=ws.createFolder(new WorkspaceManager.FolderOptions(

View File

@ -3,9 +3,9 @@ package org.gcube.application.geoportal.service.utils;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.gcube.application.geoportal.common.model.document.AccountingInfo;
import org.gcube.application.geoportal.common.model.document.Context;
import org.gcube.application.geoportal.common.model.document.User;
import org.gcube.application.geoportal.common.model.document.accounting.AccountingInfo;
import org.gcube.application.geoportal.common.model.document.accounting.Context;
import org.gcube.application.geoportal.common.model.document.accounting.User;
import org.gcube.common.authorization.library.provider.AccessTokenProvider;
import org.gcube.common.authorization.library.provider.AuthorizationProvider;
import org.gcube.common.authorization.library.provider.ClientInfo;

View File

@ -1,11 +1,17 @@
{
"ogc_links" : [
"_type" : "gcube-sdi-layer",
"ogcLinks" : [
{"wms":""},{"wfs": ""},{"csw": ""}
],
"platform_info" : [
"bbox" : {"maxY" : 90,"maxX" : 180,"minY" : -90, "minX": -180},
"platformInfo" : [
{"_type" : "Geoserver",
"layername" : "...",
"workspace" : ""},
"layerName" : "...",
"workspace" : "",
"storeName" : "",
"persistencePath" : "..",
"files" : ["","",""]},
{"_type" : "GeoNetwork",
"layerID" : 0,
"layerUUID" : ".."}

View File

@ -0,0 +1,16 @@
{
"uuid" : "",
"creationInfo" : {},
"access" : {},
"folderID" : {},
"payloads" : [
{"mimetype" : "",
"storageID" : "",
"link" : "",
"name" : ""
}
],
"materializations" : [
{"_type" : "gcube-sdi-layer", ...}
]
}

View File

@ -39,6 +39,19 @@
}
},
{
"id" : "SDI-Default-Materializer",
"type" : "Materializer",
"configuration" : {
"registeredFileSetPaths" : [
{"pianteFineScavo" : "pianteFineScavo"},
{"posizionamentoScavo" : "posizionamentoScavo"}
]
}
},
{
"id" : "org.gcube....geoportal-data-entry-portlet",
"type" : "DATA_ENTRY_GUI",

View File

@ -1,15 +1,13 @@
package org.gcube.application.geoportal.service;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.jayway.jsonpath.TypeRef;
import org.bson.Document;
import org.gcube.application.cms.serialization.Serialization;
import org.gcube.application.cms.custom.gna.concessioni.model.ProfiledConcessione;
import org.gcube.application.cms.tests.TokenSetter;
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniModel;
import org.gcube.application.geoportal.common.model.JSONPathWrapper;
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
import org.gcube.application.geoportal.common.model.document.RegisteredFileSet;
import org.gcube.application.geoportal.common.model.document.filesets.RegisteredFileSet;
import org.gcube.application.geoportal.common.model.rest.Configuration;
import org.gcube.application.geoportal.common.model.rest.QueryRequest;
import org.gcube.application.geoportal.common.model.rest.RegisterFileSetRequest;