Mandatory parameters utils

This commit is contained in:
Fabio Sinibaldi 2022-02-17 11:05:17 +01:00
parent bdefe8bbc5
commit 283c72dec7
4 changed files with 31 additions and 12 deletions

View File

@ -0,0 +1,24 @@
package org.gcube.application.cms.plugins.requests;
import lombok.Data;
import org.bson.Document;
import org.gcube.application.geoportal.common.faults.InvalidRequestException;
import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
import org.gcube.application.geoportal.common.model.profile.Profile;
@Data
public class BaseExecutionRequest {
Profile profile;
ProfiledDocument document;
Document callParameters;
public final String getMandatory(String param) throws InvalidRequestException {
return getMandatory(param,callParameters);
}
public static final String getMandatory(String param,Document params) throws InvalidRequestException {
if(!params.containsKey(param)) throw new InvalidRequestException("Missing mandatory parameter "+param);
return params.getString(param);
}
}

View File

@ -7,7 +7,7 @@ import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
import org.gcube.application.geoportal.common.model.profile.Profile; import org.gcube.application.geoportal.common.model.profile.Profile;
@Data @Data
public class EventExecutionRequest { public class EventExecutionRequest extends BaseExecutionRequest{
public static class Events{ public static class Events{
public static final String ON_INIT_DOCUMENT="@@@INIT_DOCUMENT@@"; public static final String ON_INIT_DOCUMENT="@@@INIT_DOCUMENT@@";
@ -15,9 +15,8 @@ public class EventExecutionRequest {
public static final String ON_DELETE_DOCUMENT="@@@DELETE_DOCUMENT@@"; public static final String ON_DELETE_DOCUMENT="@@@DELETE_DOCUMENT@@";
} }
Profile profile;
ProfiledDocument document;
String event; String event;
Document callParameters;
} }

View File

@ -6,9 +6,7 @@ import org.gcube.application.geoportal.common.model.document.ProfiledDocument;
import org.gcube.application.geoportal.common.model.profile.Profile; import org.gcube.application.geoportal.common.model.profile.Profile;
@Data @Data
public class MaterializationRequest { public class MaterializationRequest extends BaseExecutionRequest{
ProfiledDocument document;
Document parameters;
Profile profile;
} }

View File

@ -8,7 +8,7 @@ import org.gcube.application.geoportal.common.model.document.accounting.User;
import org.gcube.application.geoportal.common.model.profile.Profile; import org.gcube.application.geoportal.common.model.profile.Profile;
@Data @Data
public class StepExecutionRequest { public class StepExecutionRequest extends BaseExecutionRequest{
public static class Steps{ public static class Steps{
@ -20,10 +20,8 @@ public class StepExecutionRequest {
} }
Profile profile;
ProfiledDocument document;
String step; String step;
Document callParameters;
User user; User user;
Context context; Context context;
} }