Check on get Mandatory
This commit is contained in:
parent
521b5c90a6
commit
ab4a8ef1dc
|
@ -1,9 +1,11 @@
|
||||||
package org.gcube.application.cms.plugins.requests;
|
package org.gcube.application.cms.plugins.requests;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||||
import com.fasterxml.jackson.databind.ser.Serializers;
|
import com.fasterxml.jackson.databind.ser.Serializers;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
import org.bson.Document;
|
import org.bson.Document;
|
||||||
import org.gcube.application.cms.plugins.faults.InvalidPluginRequestException;
|
import org.gcube.application.cms.plugins.faults.InvalidPluginRequestException;
|
||||||
|
import org.gcube.application.cms.serialization.Serialization;
|
||||||
import org.gcube.application.geoportal.common.faults.InvalidRequestException;
|
import org.gcube.application.geoportal.common.faults.InvalidRequestException;
|
||||||
import org.gcube.application.geoportal.common.model.document.accounting.Context;
|
import org.gcube.application.geoportal.common.model.document.accounting.Context;
|
||||||
import org.gcube.application.geoportal.common.model.document.accounting.User;
|
import org.gcube.application.geoportal.common.model.document.accounting.User;
|
||||||
|
@ -39,7 +41,11 @@ public class BaseRequest {
|
||||||
|
|
||||||
public static final String getMandatory(String param,Document params) throws InvalidPluginRequestException {
|
public static final String getMandatory(String param,Document params) throws InvalidPluginRequestException {
|
||||||
if(params==null || params.isEmpty()|| !params.containsKey(param)) throw new InvalidPluginRequestException("Missing mandatory parameter "+param);
|
if(params==null || params.isEmpty()|| !params.containsKey(param)) throw new InvalidPluginRequestException("Missing mandatory parameter "+param);
|
||||||
return params.getString(param);
|
try {
|
||||||
|
return Serialization.write(params.get(param));
|
||||||
|
} catch (JsonProcessingException e) {
|
||||||
|
throw new InvalidPluginRequestException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseRequest validate() throws InvalidPluginRequestException {
|
public BaseRequest validate() throws InvalidPluginRequestException {
|
||||||
|
|
|
@ -874,6 +874,7 @@ public class ProfiledMongoManager extends MongoManager implements MongoManagerI<
|
||||||
log.info("[UseCaseDescriptor {}] triggering event {} on {}" , useCaseDescriptor.getId(),event,getManager().getDescriptor());
|
log.info("[UseCaseDescriptor {}] triggering event {} on {}" , useCaseDescriptor.getId(),event,getManager().getDescriptor());
|
||||||
AccountingInfo user= UserUtils.getCurrent().asInfo();
|
AccountingInfo user= UserUtils.getCurrent().asInfo();
|
||||||
EventExecutionRequest request= new EventExecutionRequest(useCaseDescriptor,user.getUser(),user.getContext(),project,event);
|
EventExecutionRequest request= new EventExecutionRequest(useCaseDescriptor,user.getUser(),user.getContext(),project,event);
|
||||||
|
request.setCallParameters(parameters);
|
||||||
log.debug("Triggering {}",request);
|
log.debug("Triggering {}",request);
|
||||||
DocumentHandlingReport report = getManager().onEvent(request);
|
DocumentHandlingReport report = getManager().onEvent(request);
|
||||||
return report.prepareResult();
|
return report.prepareResult();
|
||||||
|
|
|
@ -98,10 +98,14 @@ public abstract class AbstractProfiledDocumentsTests extends BasicServiceTestUni
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void delete(String id) throws Exception {
|
protected void delete(String id) throws Exception {
|
||||||
check(baseTarget().path(id).request(MediaType.APPLICATION_JSON).
|
delete(id,false);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void delete(String id,Boolean force) throws Exception {
|
||||||
|
check(baseTarget().path(id).queryParam("force",force).request(MediaType.APPLICATION_JSON).
|
||||||
delete(), null);
|
delete(), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected Project update(String id, Document newContent)throws Exception {
|
protected Project update(String id, Document newContent)throws Exception {
|
||||||
Project doc = check(baseTarget().path(id).request(MediaType.APPLICATION_JSON).
|
Project doc = check(baseTarget().path(id).request(MediaType.APPLICATION_JSON).
|
||||||
|
|
|
@ -75,7 +75,7 @@ public class DummyProjectTest extends AbstractProfiledDocumentsTests{
|
||||||
@Test
|
@Test
|
||||||
public void testDelete() throws Exception {
|
public void testDelete() throws Exception {
|
||||||
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
assumeTrue(GCubeTest.isTestInfrastructureEnabled());
|
||||||
delete(createWithFileSet().getId());
|
delete(createWithFileSet().getId(),true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue