Bufixing
This commit is contained in:
parent
85ceecda12
commit
aac6bdf49f
|
@ -58,17 +58,18 @@ public class ConcessioniLifeCycleManager implements LifecycleManager {
|
|||
public StepExecutionReport performStep(StepExecutionRequest request) throws StepException {
|
||||
log.info("Serving Request {}",request);
|
||||
StepExecutionReport report=new StepExecutionReport();
|
||||
LifecycleInformation info=new LifecycleInformation();
|
||||
info.setPhase(request.getStep());
|
||||
LifecycleInformation info=request.getDocument().getLifecycleInformation();
|
||||
info.setLastOperationStatus(LifecycleInformation.Status.OK);
|
||||
info.setLastInvokedStep(request.getStep());
|
||||
report.setRequest(request);
|
||||
report.setResult(request.getDocument());
|
||||
|
||||
try {
|
||||
switch (request.getStep()) {
|
||||
case "SUBMIT-FOR-REVIEW" :{
|
||||
|
||||
//TODO Checks
|
||||
if(!request.getDocument().getLifecycleInformation().getPhase().equals("Draft"))
|
||||
throw new StepException("Document is not in Draft phase");
|
||||
//Materialize layers
|
||||
MaterializationRequest matReq = new MaterializationRequest();
|
||||
matReq.setDocument(request.getDocument());
|
||||
|
@ -77,6 +78,7 @@ public class ConcessioniLifeCycleManager implements LifecycleManager {
|
|||
String workspace = request.getProfile().getId() + request.getContext().getId();
|
||||
params.put("workspace", Files.fixFilename(workspace));
|
||||
|
||||
|
||||
matReq.setParameters(params);
|
||||
MaterializationReport matRep = new SDIMaterializerPlugin().materialize(matReq);
|
||||
|
||||
|
@ -85,6 +87,8 @@ public class ConcessioniLifeCycleManager implements LifecycleManager {
|
|||
for(String msg : matRep.getMessages())
|
||||
info.addErrorMessage(msg);
|
||||
}
|
||||
|
||||
info.setPhase("Pending Approval");
|
||||
//TODO Index-confidential
|
||||
//TODO Notifications
|
||||
|
||||
|
|
|
@ -95,6 +95,8 @@ public class SDIMaterializerPlugin implements MaterializationPlugin {
|
|||
configuration.putIfAbsent("documentID",profiledDocument.get_id());
|
||||
if(configuration.containsKey("titleField"))
|
||||
configuration.putIfAbsent("layerTitle",fs.getString(configuration.getString("titleField")));
|
||||
else configuration.putIfAbsent("layerTitle",fs.getUUID());
|
||||
|
||||
RegisteredFileSet obtained = sdiManager.materializeLayer(fs,configuration);
|
||||
log.debug("Obtained {} ",obtained);
|
||||
documentNavigator.set("$..[?(@.uuid == "+fs.getUUID()+")]",obtained);
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
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;
|
||||
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
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>
|
||||
}
|
|
@ -1,11 +1,9 @@
|
|||
package org.gcube.application.geoportal.common.model.rest;
|
||||
|
||||
import com.sun.tools.jdeps.Archive;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.geoportal.common.model.configuration.Index;
|
||||
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
import java.time.LocalDateTime;
|
||||
|
@ -17,6 +15,14 @@ import java.util.List;
|
|||
@NoArgsConstructor
|
||||
public class Configuration{
|
||||
|
||||
public class Index extends Document {
|
||||
|
||||
}
|
||||
|
||||
public class Archive extends Document {
|
||||
|
||||
}
|
||||
|
||||
public static String PROFILE_ID="profile_id";
|
||||
public static String CONTEXT = "context";
|
||||
public static String LAST_UPDATED_TIME = "";
|
||||
|
|
|
@ -2,14 +2,19 @@ package org.gcube.application.geoportal.service.engine.handlers;
|
|||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.gcube.application.cms.plugins.LifecycleManager;
|
||||
import org.gcube.application.cms.plugins.faults.EventException;
|
||||
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.EventExecutionReport;
|
||||
import org.gcube.application.cms.plugins.reports.StepExecutionReport;
|
||||
import org.gcube.application.cms.plugins.reports.InitializationReport;
|
||||
import org.gcube.application.cms.plugins.requests.EventExecutionRequest;
|
||||
import org.gcube.application.cms.plugins.requests.StepExecutionRequest;
|
||||
import org.gcube.application.geoportal.common.model.document.ComparableVersion;
|
||||
import org.gcube.application.geoportal.common.model.rest.Configuration;
|
||||
import org.gcube.application.geoportal.common.model.rest.ConfigurationException;
|
||||
|
||||
@Slf4j
|
||||
public class SimpleLifeCycleManager implements LifecycleManager {
|
||||
|
@ -41,32 +46,22 @@ public class SimpleLifeCycleManager implements LifecycleManager {
|
|||
log.info("Received Request ");
|
||||
|
||||
switch(request.getStep()){
|
||||
case StepExecutionRequest.Steps.ON_INIT_DOCUMENT:{
|
||||
break;
|
||||
}
|
||||
case StepExecutionRequest.Steps.ON_MATERIALIZE_DOCUMENT:{
|
||||
break;
|
||||
}
|
||||
case StepExecutionRequest.Steps.ON_DEMATERIALIZE_DOCUMENT:{
|
||||
break;
|
||||
}
|
||||
case StepExecutionRequest.Steps.ON_DEINDEX_DOCUMENT:{
|
||||
break;
|
||||
}
|
||||
case StepExecutionRequest.Steps.ON_INDEX_DOCUMENT:{
|
||||
break;
|
||||
}
|
||||
case StepExecutionRequest.Steps.ON_DELETE_DOCUMENT:{
|
||||
break;
|
||||
}
|
||||
default : throw new StepException("Invalid Step "+request.getStep());
|
||||
}
|
||||
|
||||
|
||||
throw new StepException("Still to implement");
|
||||
//throw new StepException("Still to implement");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Configuration getCurrentConfiguration() throws ConfigurationException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EventExecutionReport onEvent(EventExecutionRequest request) throws EventException {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.gcube.application.geoportal.service.engine.mongo;
|
|||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.cms.plugins.faults.EventException;
|
||||
import org.gcube.application.cms.plugins.faults.StepException;
|
||||
import org.gcube.application.geoportal.common.faults.StorageException;
|
||||
import org.gcube.application.geoportal.common.model.rest.Configuration;
|
||||
|
@ -18,10 +19,10 @@ public interface MongoManagerI<T> {
|
|||
|
||||
// create
|
||||
|
||||
public T registerNew(Document toRegister) throws IOException, StepException;
|
||||
public T registerNew(Document toRegister) throws IOException, StepException, EventException;
|
||||
|
||||
// update
|
||||
public T update(String id,Document toSetDocument) throws IOException, StepException;
|
||||
public T update(String id,Document toSetDocument) throws IOException, StepException, EventException;
|
||||
|
||||
// delete
|
||||
|
||||
|
@ -38,8 +39,8 @@ public interface MongoManagerI<T> {
|
|||
|
||||
public T performStep(String id, String step, Document options) throws IOException, StepException;
|
||||
|
||||
public T registerFileSet(String id, RegisterFileSetRequest request) throws ConfigurationException, StorageHubException, StorageException, StepException, JsonProcessingException, DeletionException;
|
||||
public T deleteFileSet(String id, String destination, Boolean force) throws ConfigurationException, StorageHubException, StorageException, StepException, JsonProcessingException, DeletionException;
|
||||
public T registerFileSet(String id, RegisterFileSetRequest request) throws ConfigurationException, StorageHubException, StorageException, StepException, JsonProcessingException, DeletionException, EventException;
|
||||
public T deleteFileSet(String id, String destination, Boolean force) throws ConfigurationException, StorageHubException, StorageException, StepException, JsonProcessingException, DeletionException, EventException;
|
||||
|
||||
public Configuration getConfiguration()throws ConfigurationException;
|
||||
}
|
||||
|
|
|
@ -9,17 +9,22 @@ import org.apache.commons.io.IOUtils;
|
|||
import org.bson.Document;
|
||||
import org.bson.types.ObjectId;
|
||||
import org.gcube.application.cms.plugins.LifecycleManager;
|
||||
import org.gcube.application.cms.plugins.faults.EventException;
|
||||
import org.gcube.application.cms.plugins.faults.StepException;
|
||||
import org.gcube.application.cms.plugins.model.PluginDescriptor;
|
||||
import org.gcube.application.cms.plugins.reports.EventExecutionReport;
|
||||
import org.gcube.application.cms.plugins.reports.StepExecutionReport;
|
||||
import org.gcube.application.cms.plugins.requests.EventExecutionRequest;
|
||||
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.AccountingInfo;
|
||||
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.document.lifecycle.LifecycleInformation;
|
||||
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;
|
||||
|
@ -86,7 +91,7 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
}
|
||||
|
||||
@Getter(lazy = true)
|
||||
private final LifecycleManager manager=getLCManager();
|
||||
private final LifecycleManager manager=getLCManager();
|
||||
|
||||
private LifecycleManager getLCManager() {
|
||||
try{
|
||||
|
@ -122,7 +127,7 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
}
|
||||
|
||||
@Override
|
||||
public ProfiledDocument registerNew(Document toRegisterDoc) throws IOException, StepException {
|
||||
public ProfiledDocument registerNew(Document toRegisterDoc) throws IOException, StepException, EventException {
|
||||
log.info("Registering new document in {} ",profile.getId());
|
||||
log.debug("Going to register {}",toRegisterDoc.toJson());
|
||||
|
||||
|
@ -145,9 +150,14 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
toRegister.setProfileVersion(profile.getVersion());
|
||||
toRegister.setVersion(new Semver("1.0.0"));
|
||||
|
||||
// Apply Lifecycle
|
||||
|
||||
toRegister=step(toRegister,StepExecutionRequest.Steps.ON_INIT_DOCUMENT,null).getResult();
|
||||
LifecycleInformation draftInfo=new LifecycleInformation();
|
||||
draftInfo.setPhase("DRAFT");
|
||||
toRegister.setLifecycleInformation(draftInfo);
|
||||
|
||||
// Apply Lifecycle
|
||||
toRegister = triggerEvent(toRegister,EventExecutionRequest.Events.ON_INIT_DOCUMENT,null).getResult();
|
||||
|
||||
|
||||
log.debug("Going to register {} ",toRegister);
|
||||
|
||||
|
@ -159,7 +169,7 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
}
|
||||
|
||||
@Override
|
||||
public ProfiledDocument update(String id, Document toSet) throws IOException, StepException {
|
||||
public ProfiledDocument update(String id, Document toSet) throws IOException, EventException {
|
||||
log.trace("Replacing {} ",toSet);
|
||||
ProfiledDocument toUpdate=getByID(id);
|
||||
toUpdate.setTheDocument(toSet);
|
||||
|
@ -171,12 +181,11 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
}
|
||||
|
||||
|
||||
private ProfiledDocument onUpdate(ProfiledDocument toUpdate) throws StepException {
|
||||
private ProfiledDocument onUpdate(ProfiledDocument toUpdate) throws EventException {
|
||||
UserUtils.AuthenticatedUser u = UserUtils.getCurrent();
|
||||
toUpdate.getInfo().setLastEditInfo(u.asInfo());
|
||||
toUpdate.setVersion(toUpdate.getVersion().withIncPatch());
|
||||
|
||||
return step(toUpdate,StepExecutionRequest.Steps.ON_UPDATE_DOCUMENT,null).getResult();
|
||||
return triggerEvent(toUpdate,EventExecutionRequest.Events.ON_INIT_DOCUMENT,null).getResult();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -209,7 +218,7 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
}
|
||||
|
||||
@Override
|
||||
public ProfiledDocument getByID(String id){
|
||||
public ProfiledDocument getByID(String id) throws WebApplicationException{
|
||||
Document doc=super.getById(asId(id),getCollectionName());
|
||||
if(doc==null) throw new WebApplicationException("No document with ID "+id);
|
||||
return convert(doc,ProfiledDocument.class);
|
||||
|
@ -242,8 +251,21 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
|
||||
@Override
|
||||
public ProfiledDocument performStep(String id, String step, Document options) throws StepException, JsonProcessingException {
|
||||
StepExecutionReport report = step(getByID(id), step, options);
|
||||
return convert(replace(asDocumentWithId(report.getResult()),new ObjectId(id),getCollectionName()),ProfiledDocument.class);
|
||||
ProfiledDocument document = getByID(id);
|
||||
try{
|
||||
StepExecutionReport report = step(document, step, options);
|
||||
document = report.getResult();
|
||||
} catch(Throwable t){
|
||||
log.error("[Profile {} ] ERROR Invoking Step {} on document {}" ,profile.getId(),step,id,t);
|
||||
LifecycleInformation info = new LifecycleInformation();
|
||||
info.setPhase(document.getLifecycleInformation().getPhase());
|
||||
info.setLastOperationStatus(LifecycleInformation.Status.ERROR);
|
||||
info.addErrorMessage(t.getMessage());
|
||||
info.setLastInvokedStep(step);
|
||||
document.setLifecycleInformation(info);
|
||||
}finally{
|
||||
return convert(replace(asDocumentWithId(document),new ObjectId(id),getCollectionName()),ProfiledDocument.class);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -261,7 +283,7 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
*
|
||||
*/
|
||||
@Override
|
||||
public ProfiledDocument registerFileSet(String id,RegisterFileSetRequest request) throws ConfigurationException, StorageHubException, StorageException, StepException, JsonProcessingException, DeletionException {
|
||||
public ProfiledDocument registerFileSet(String id,RegisterFileSetRequest request) throws ConfigurationException, StorageHubException, StorageException, StepException, JsonProcessingException, DeletionException, EventException {
|
||||
List<TempFile> files=request.getStreams();
|
||||
|
||||
Document attributes =request.getAttributes();
|
||||
|
@ -339,7 +361,7 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
}
|
||||
|
||||
@Override
|
||||
public ProfiledDocument deleteFileSet(String id, String destination, Boolean force) throws ConfigurationException, StorageHubException, StorageException, StepException, JsonProcessingException, DeletionException {
|
||||
public ProfiledDocument deleteFileSet(String id, String destination, Boolean force) throws ConfigurationException, StorageHubException, JsonProcessingException, DeletionException, EventException {
|
||||
ProfiledDocument doc = getByID(id);
|
||||
doc=deleteFileSetRoutine(doc,destination,force,new WorkspaceManager());
|
||||
doc=onUpdate(doc);
|
||||
|
@ -349,7 +371,7 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
@Override
|
||||
public Configuration getConfiguration() throws ConfigurationException {
|
||||
log.debug("Asking configuration for {} in {} ",profile.getId(), UserUtils.getCurrent().getContext());
|
||||
Configuration toReturn= manager.getCurrentConfiguration();
|
||||
Configuration toReturn= getManager().getCurrentConfiguration();
|
||||
log.debug("Returning current configuration {}",toReturn);
|
||||
return toReturn;
|
||||
}
|
||||
|
@ -362,14 +384,28 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
|||
request.setDocument(theDocument);
|
||||
request.setProfile(profile);
|
||||
request.setStep(step);
|
||||
AccountingInfo user= UserUtils.getCurrent().asInfo();
|
||||
request.setUser(user.getUser());
|
||||
request.setContext(user.getContext());
|
||||
|
||||
log.debug("Requesting Step Execution {} ",request);
|
||||
StepExecutionReport report= getManager().performStep(request);
|
||||
log.debug("Report is {}",report);
|
||||
if(report.getResult()==null) throw new StepException("Report result is null");
|
||||
|
||||
StepExecutionReport report= getManager().performStep(request);
|
||||
log.debug("Report is {}",report);
|
||||
if(report.getResult()==null) throw new StepException("Report result is null");
|
||||
return report;
|
||||
}
|
||||
|
||||
|
||||
private EventExecutionReport triggerEvent(ProfiledDocument theDocument, String event, Document parameters) throws EventException {
|
||||
log.info("[Profile {} ] triggering event {} on {}" ,profile.getId(),event,getManager().getDescriptor());
|
||||
EventExecutionRequest request= new EventExecutionRequest();
|
||||
request.setEvent(event);
|
||||
request.setProfile(profile);
|
||||
request.setCallParameters(parameters);
|
||||
request.setDocument(theDocument);
|
||||
log.debug("Triggering {} ",request);
|
||||
return getManager().onEvent(request);
|
||||
}
|
||||
|
||||
|
||||
private static final RegisteredFileSet prepareRegisteredFileSet(ProfiledDocument doc, Profile profile,String destination,
|
||||
|
|
|
@ -30,7 +30,7 @@ public class ConcessioniOverMongo {
|
|||
@Override
|
||||
protected Configuration run() throws Exception, WebApplicationException {
|
||||
Configuration toReturn = new Configuration();
|
||||
toReturn.setIndex(new PostgisIndex().getInfo());
|
||||
//toReturn.setIndex(new PostgisIndex().getInfo());
|
||||
log.info("Returning configuration {} ",toReturn);
|
||||
return toReturn;
|
||||
}
|
||||
|
|
|
@ -4,13 +4,25 @@
|
|||
"name" : "Concessione",
|
||||
|
||||
"schema" : {
|
||||
"relazioneScavo" : {
|
||||
"_type" : "RegisteredFileSet",
|
||||
"_max" : 1,
|
||||
"_min" : 1},
|
||||
"relazioneScavo" : { "_max" : 1, "_min" : 1,
|
||||
"children" : [
|
||||
{"fileset" :{"_type" : "RegisteredFileSet"}},
|
||||
{"title" : {"_max" : 1, "_min" : 1}}
|
||||
]
|
||||
},
|
||||
"imgs" : {
|
||||
"_type" : "RegisteredFileSet",
|
||||
"_max" : -1}
|
||||
"_max" : -1,
|
||||
"children" : [
|
||||
{"fileset" :{"_type" : "RegisteredFileSet"}},
|
||||
{"title" : {"_max" : 1, "_min" : 1}}
|
||||
]
|
||||
},
|
||||
"posizionamentoScavo" : { "_max" : 1, "_min" : 1,
|
||||
"children" : [
|
||||
{"fileset" :{"_type" : "RegisteredFileSet"}},
|
||||
{"title" : {"_max" : 1, "_min" : 1}}
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
@ -44,8 +56,8 @@
|
|||
"type" : "Materializer",
|
||||
"configuration" : {
|
||||
"registeredFileSetPaths" : [
|
||||
{"pianteFineScavo" : "pianteFineScavo"},
|
||||
{"posizionamentoScavo" : "posizionamentoScavo"}
|
||||
{"schemaField" : "pianteFineScavo","documentPath" : "pianteFineScavo[*]"},
|
||||
{"schemaField" : "posizionamentoScavo","documentPath" : "posizionamentoScavo"}
|
||||
]
|
||||
}
|
||||
},
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package org.gcube.application.geoportal.service;
|
||||
|
||||
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class InexistentProfileTests extends ProfiledDocumentsTests {
|
||||
@Override
|
||||
protected WebTarget baseTarget() {
|
||||
String testProfileId="profiledConcessioni";
|
||||
return target(InterfaceConstants.Methods.PROJECTS).path(testProfileId);
|
||||
}
|
||||
|
||||
// GET
|
||||
@Test
|
||||
public void testMissingProfile(){
|
||||
Response resp = target(InterfaceConstants.Methods.PROJECTS)
|
||||
.path("non-existent-profile").request().get();
|
||||
assertEquals(404,resp.getStatus());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,49 @@
|
|||
package org.gcube.application.geoportal.service;
|
||||
|
||||
import org.bson.Document;
|
||||
import org.gcube.application.cms.tests.model.concessioni.TestConcessioniModel;
|
||||
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
|
||||
import org.gcube.application.geoportal.common.model.document.lifecycle.LifecycleInformation;
|
||||
import org.gcube.application.geoportal.common.model.rest.RegisterFileSetRequest;
|
||||
import org.gcube.application.geoportal.common.model.rest.StepExecutionRequest;
|
||||
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
|
||||
import org.gcube.application.geoportal.common.utils.StorageUtils;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class ProfiledConcessioniTests extends ProfiledDocumentsTests{
|
||||
|
||||
|
||||
@Override
|
||||
protected WebTarget baseTarget() {
|
||||
String testProfileId="profiledConcessioni";
|
||||
return target(InterfaceConstants.Methods.PROJECTS).path(testProfileId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSDI() throws Exception {
|
||||
// Create new
|
||||
ProfiledDocument doc = createNew();
|
||||
// register filesets
|
||||
doc = upload(
|
||||
new StorageUtils(),
|
||||
doc.get_id(),
|
||||
"posizionamentoScavo.fileset",
|
||||
"posizionamentoScavo.children[?(@.fileset)]",
|
||||
Document.parse("{\"titolo\" : \"mio titolo\",\"some\" : \"something\" }"),
|
||||
RegisterFileSetRequest.ClashOptions.MERGE_EXISTING,
|
||||
"pos.shp");
|
||||
|
||||
// invoke step SUBMIT-FOR-REVIEW
|
||||
StepExecutionRequest req=new StepExecutionRequest();
|
||||
req.setStepID("SUBMIT-FOR-REVIEW");
|
||||
doc=step(doc.get_id(),req);
|
||||
System.out.println(doc);
|
||||
assertTrue(doc.getLifecycleInformation().getLastOperationStatus().equals(LifecycleInformation.Status.OK));
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@ import org.gcube.application.geoportal.common.model.document.filesets.Registered
|
|||
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;
|
||||
import org.gcube.application.geoportal.common.model.rest.StepExecutionRequest;
|
||||
import org.gcube.application.geoportal.common.rest.InterfaceConstants;
|
||||
import org.gcube.application.geoportal.common.utils.FileSets;
|
||||
import org.gcube.application.geoportal.common.utils.StorageUtils;
|
||||
|
@ -29,9 +30,9 @@ import java.util.List;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class ProfiledDocumentsTests extends BasicServiceTestUnit{
|
||||
public abstract class ProfiledDocumentsTests extends BasicServiceTestUnit{
|
||||
|
||||
|
||||
String testProfileId="profiledConcessioni";
|
||||
|
||||
@Before
|
||||
public void setContext(){
|
||||
|
@ -39,16 +40,8 @@ public class ProfiledDocumentsTests extends BasicServiceTestUnit{
|
|||
}
|
||||
|
||||
|
||||
protected WebTarget baseTarget(){
|
||||
return target(InterfaceConstants.Methods.PROJECTS).path(testProfileId);
|
||||
}
|
||||
// GET
|
||||
@Test
|
||||
public void testMissingProfile(){
|
||||
Response resp = target(InterfaceConstants.Methods.PROJECTS)
|
||||
.path("non-existent-profile").request().get();
|
||||
assertEquals(404,resp.getStatus());
|
||||
}
|
||||
protected abstract WebTarget baseTarget();
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
|
@ -182,13 +175,13 @@ public class ProfiledDocumentsTests extends BasicServiceTestUnit{
|
|||
|
||||
|
||||
// @@@@@@@@@@@@@@@ Routines
|
||||
private ProfiledDocument createNew() throws Exception {
|
||||
protected ProfiledDocument createNew() throws Exception {
|
||||
Document document =new Document(Collections.singletonMap("dumbKey","dumbValue"));
|
||||
return check(baseTarget().request(MediaType.APPLICATION_JSON).
|
||||
post(Entity.entity(document, MediaType.APPLICATION_JSON)),ProfiledDocument.class);
|
||||
}
|
||||
|
||||
private ProfiledDocument upload(StorageUtils storage,
|
||||
protected ProfiledDocument upload(StorageUtils storage,
|
||||
String id,
|
||||
String path,
|
||||
String fieldDefinitionPath,
|
||||
|
@ -206,4 +199,15 @@ public class ProfiledDocumentsTests extends BasicServiceTestUnit{
|
|||
post(Entity.entity(Serialization.write(builder.getTheRequest()),
|
||||
MediaType.APPLICATION_JSON)),ProfiledDocument.class);
|
||||
}
|
||||
|
||||
|
||||
protected ProfiledDocument step(String id, StepExecutionRequest request) throws Exception {
|
||||
ProfiledDocument toReturn= check(baseTarget().
|
||||
path(InterfaceConstants.Methods.STEP).path(id).request(MediaType.APPLICATION_JSON).
|
||||
post(Entity.entity(Serialization.write(request),
|
||||
MediaType.APPLICATION_JSON)),ProfiledDocument.class);
|
||||
|
||||
assertTrue(toReturn.getLifecycleInformation().getLastInvokedStep().equals(request.getStepID()));
|
||||
return toReturn;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue