From 09afc9d110c7ac957e589b0b9737bb66c5ca9e43 Mon Sep 17 00:00:00 2001 From: felmer <felmer> Date: Thu, 17 Dec 2015 10:52:14 +0000 Subject: [PATCH] SSDM-2718: Introducing ExecutionOptions replacing parameters map. SVN: 35358 --- .../server/api/v3/ApplicationServerApi.java | 5 +- .../api/v3/ApplicationServerApiLogger.java | 7 +-- .../method/ExecuteServiceMethodExecutor.java | 9 ++-- .../method/IExecuteServiceMethodExecutor.java | 4 +- .../v3/executor/method/IServiceProvider.java | 2 +- .../v3/executor/method/ServiceProvider.java | 2 +- .../helper/service/IScriptRunnerFactory.java | 2 +- .../helper/service/IServiceScriptRunner.java | 5 +- .../service/JythonBasedServiceExecutor.java | 11 +++-- .../helper/service/ScriptRunnerFactory.java | 8 ++-- .../as/api/v3/IApplicationServerApi.java | 3 +- .../api/v3/dto/service/ExecutionOptions.java | 47 +++++++++++++++++++ .../{ => service}/IServiceExecutor.java | 8 ++-- .../{ => service}/context/ServiceContext.java | 2 +- 14 files changed, 84 insertions(+), 31 deletions(-) create mode 100644 openbis_api/source/java/ch/ethz/sis/openbis/generic/as/api/v3/dto/service/ExecutionOptions.java rename openbis_api/source/java/ch/ethz/sis/openbis/generic/as/api/v3/plugin/{ => service}/IServiceExecutor.java (72%) rename openbis_api/source/java/ch/ethz/sis/openbis/generic/as/api/v3/plugin/{ => service}/context/ServiceContext.java (92%) diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/ApplicationServerApi.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/ApplicationServerApi.java index ba49249c15e..39de67312ed 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/ApplicationServerApi.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/ApplicationServerApi.java @@ -69,6 +69,7 @@ import ch.ethz.sis.openbis.generic.as.api.v3.dto.sample.id.ISampleId; import ch.ethz.sis.openbis.generic.as.api.v3.dto.sample.id.SamplePermId; import ch.ethz.sis.openbis.generic.as.api.v3.dto.sample.search.SampleSearchCriteria; import ch.ethz.sis.openbis.generic.as.api.v3.dto.sample.update.SampleUpdate; +import ch.ethz.sis.openbis.generic.as.api.v3.dto.service.ExecutionOptions; import ch.ethz.sis.openbis.generic.as.api.v3.dto.service.Service; import ch.ethz.sis.openbis.generic.as.api.v3.dto.service.fetchoptions.ServiceFetchOptions; import ch.ethz.sis.openbis.generic.as.api.v3.dto.service.id.IServiceId; @@ -608,9 +609,9 @@ public class ApplicationServerApi extends AbstractServer<IApplicationServerApi> @Override @RolesAllowed({ RoleWithHierarchy.SPACE_OBSERVER, RoleWithHierarchy.SPACE_ETL_SERVER }) @Capability("EXECUTE_SERVICE") - public Serializable executeService(String sessionToken, IServiceId serviceId, Map<String, Serializable> parameters) + public Serializable executeService(String sessionToken, IServiceId serviceId, ExecutionOptions options) { - return executeServiceExecutor.executeService(sessionToken, serviceId, parameters); + return executeServiceExecutor.executeService(sessionToken, serviceId, options); } @Override diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/ApplicationServerApiLogger.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/ApplicationServerApiLogger.java index 899273b421a..2d313da5903 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/ApplicationServerApiLogger.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/ApplicationServerApiLogger.java @@ -65,6 +65,7 @@ import ch.ethz.sis.openbis.generic.as.api.v3.dto.sample.id.ISampleId; import ch.ethz.sis.openbis.generic.as.api.v3.dto.sample.id.SamplePermId; import ch.ethz.sis.openbis.generic.as.api.v3.dto.sample.search.SampleSearchCriteria; import ch.ethz.sis.openbis.generic.as.api.v3.dto.sample.update.SampleUpdate; +import ch.ethz.sis.openbis.generic.as.api.v3.dto.service.ExecutionOptions; import ch.ethz.sis.openbis.generic.as.api.v3.dto.service.Service; import ch.ethz.sis.openbis.generic.as.api.v3.dto.service.fetchoptions.ServiceFetchOptions; import ch.ethz.sis.openbis.generic.as.api.v3.dto.service.id.IServiceId; @@ -350,14 +351,14 @@ public class ApplicationServerApiLogger extends AbstractServerLogger implements @Override public SearchResult<Service> searchServices(String sessionToken, ServiceSearchCriteria searchCriteria, ServiceFetchOptions fetchOptions) { - logAccess(sessionToken, "search-services", "SEARCH_CRITERIA(%s) FETCH_OPTIONS(%s)", searchCriteria, fetchOptions); + logAccess(sessionToken, "search-services", "SEARCH_CRITERIA:\n%s\nFETCH_OPTIONS:\n%s\n", searchCriteria, fetchOptions); return null; } @Override - public Serializable executeService(String sessionToken, IServiceId serviceId, Map<String, Serializable> parameters) + public Serializable executeService(String sessionToken, IServiceId serviceId, ExecutionOptions options) { - logAccess(sessionToken, "execute-service", "SERVICE_ID(%s) PARAMETERS(%s)", serviceId, parameters); + logAccess(sessionToken, "execute-service", "SERVICE_ID(%s) EXECUTION_OPTIONS(%s)", serviceId, options); return null; } diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/method/ExecuteServiceMethodExecutor.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/method/ExecuteServiceMethodExecutor.java index 930d06911c0..90bbb598118 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/method/ExecuteServiceMethodExecutor.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/method/ExecuteServiceMethodExecutor.java @@ -22,12 +22,13 @@ import java.util.Map; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import ch.ethz.sis.openbis.generic.as.api.v3.dto.service.ExecutionOptions; import ch.ethz.sis.openbis.generic.as.api.v3.dto.service.id.IServiceId; import ch.ethz.sis.openbis.generic.as.api.v3.dto.service.id.ServiceCode; import ch.ethz.sis.openbis.generic.as.api.v3.exceptions.ObjectNotFoundException; import ch.ethz.sis.openbis.generic.as.api.v3.exceptions.UnsupportedObjectIdException; -import ch.ethz.sis.openbis.generic.as.api.v3.plugin.IServiceExecutor; -import ch.ethz.sis.openbis.generic.as.api.v3.plugin.context.ServiceContext; +import ch.ethz.sis.openbis.generic.as.api.v3.plugin.service.IServiceExecutor; +import ch.ethz.sis.openbis.generic.as.api.v3.plugin.service.context.ServiceContext; /** * @@ -41,7 +42,7 @@ public class ExecuteServiceMethodExecutor implements IExecuteServiceMethodExecut private IServiceProvider serviceProvider; @Override - public Serializable executeService(String sessionToken, IServiceId serviceId, Map<String, Serializable> parameters) + public Serializable executeService(String sessionToken, IServiceId serviceId, ExecutionOptions options) { if (serviceId instanceof ServiceCode == false) { @@ -55,7 +56,7 @@ public class ExecuteServiceMethodExecutor implements IExecuteServiceMethodExecut } ServiceContext serviceContext = new ServiceContext(); serviceContext.setSessionToken(sessionToken); - return serviceExecutor.executeService(parameters, serviceContext); + return serviceExecutor.executeService(serviceContext, options); } } diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/method/IExecuteServiceMethodExecutor.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/method/IExecuteServiceMethodExecutor.java index 13b137f37d3..1fbed030446 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/method/IExecuteServiceMethodExecutor.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/method/IExecuteServiceMethodExecutor.java @@ -17,8 +17,8 @@ package ch.ethz.sis.openbis.generic.server.api.v3.executor.method; import java.io.Serializable; -import java.util.Map; +import ch.ethz.sis.openbis.generic.as.api.v3.dto.service.ExecutionOptions; import ch.ethz.sis.openbis.generic.as.api.v3.dto.service.id.IServiceId; /** @@ -28,5 +28,5 @@ import ch.ethz.sis.openbis.generic.as.api.v3.dto.service.id.IServiceId; */ public interface IExecuteServiceMethodExecutor { - public Serializable executeService(String sessionToken, IServiceId serviceId, Map<String, Serializable> parameters); + public Serializable executeService(String sessionToken, IServiceId serviceId, ExecutionOptions options); } diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/method/IServiceProvider.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/method/IServiceProvider.java index bb6313daf4c..2ad226d753b 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/method/IServiceProvider.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/method/IServiceProvider.java @@ -19,7 +19,7 @@ package ch.ethz.sis.openbis.generic.server.api.v3.executor.method; import java.util.List; import ch.ethz.sis.openbis.generic.as.api.v3.dto.service.Service; -import ch.ethz.sis.openbis.generic.as.api.v3.plugin.IServiceExecutor; +import ch.ethz.sis.openbis.generic.as.api.v3.plugin.service.IServiceExecutor; /** * diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/method/ServiceProvider.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/method/ServiceProvider.java index f9a04b81ece..163ffd241ad 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/method/ServiceProvider.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/executor/method/ServiceProvider.java @@ -30,7 +30,7 @@ import org.springframework.stereotype.Component; import ch.ethz.sis.openbis.generic.as.api.v3.dto.service.Service; import ch.ethz.sis.openbis.generic.as.api.v3.dto.service.id.ServiceCode; -import ch.ethz.sis.openbis.generic.as.api.v3.plugin.IServiceExecutor; +import ch.ethz.sis.openbis.generic.as.api.v3.plugin.service.IServiceExecutor; import ch.systemsx.cisd.common.properties.PropertyParametersUtil; import ch.systemsx.cisd.common.properties.PropertyParametersUtil.SectionProperties; import ch.systemsx.cisd.common.properties.PropertyUtils; diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/helper/service/IScriptRunnerFactory.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/helper/service/IScriptRunnerFactory.java index b5248d84826..4ac293d95c0 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/helper/service/IScriptRunnerFactory.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/helper/service/IScriptRunnerFactory.java @@ -16,7 +16,7 @@ package ch.ethz.sis.openbis.generic.server.api.v3.helper.service; -import ch.ethz.sis.openbis.generic.as.api.v3.plugin.context.ServiceContext; +import ch.ethz.sis.openbis.generic.as.api.v3.plugin.service.context.ServiceContext; /** * diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/helper/service/IServiceScriptRunner.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/helper/service/IServiceScriptRunner.java index 42560c14150..2af901652c2 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/helper/service/IServiceScriptRunner.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/helper/service/IServiceScriptRunner.java @@ -17,7 +17,8 @@ package ch.ethz.sis.openbis.generic.server.api.v3.helper.service; import java.io.Serializable; -import java.util.Map; + +import ch.ethz.sis.openbis.generic.as.api.v3.dto.service.ExecutionOptions; /** * @@ -26,5 +27,5 @@ import java.util.Map; */ public interface IServiceScriptRunner { - public Serializable process(Map<String, Serializable> parameters); + public Serializable process(ExecutionOptions options); } diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/helper/service/JythonBasedServiceExecutor.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/helper/service/JythonBasedServiceExecutor.java index b233a6707c5..a7d62b358ef 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/helper/service/JythonBasedServiceExecutor.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/helper/service/JythonBasedServiceExecutor.java @@ -1,4 +1,5 @@ /* + * Copyright 2015 ETH Zuerich, SIS * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -17,12 +18,12 @@ package ch.ethz.sis.openbis.generic.server.api.v3.helper.service; import java.io.Serializable; -import java.util.Map; import java.util.Properties; import ch.ethz.sis.openbis.generic.as.api.v3.IApplicationServerApi; -import ch.ethz.sis.openbis.generic.as.api.v3.plugin.IServiceExecutor; -import ch.ethz.sis.openbis.generic.as.api.v3.plugin.context.ServiceContext; +import ch.ethz.sis.openbis.generic.as.api.v3.dto.service.ExecutionOptions; +import ch.ethz.sis.openbis.generic.as.api.v3.plugin.service.IServiceExecutor; +import ch.ethz.sis.openbis.generic.as.api.v3.plugin.service.context.ServiceContext; import ch.systemsx.cisd.common.properties.PropertyUtils; import ch.systemsx.cisd.openbis.generic.server.CommonServiceProvider; @@ -48,9 +49,9 @@ public class JythonBasedServiceExecutor implements IServiceExecutor } @Override - public Serializable executeService(Map<String, Serializable> parameters, ServiceContext context) + public Serializable executeService(ServiceContext context, ExecutionOptions options) { - return factory.createServiceRunner(context).process(parameters); + return factory.createServiceRunner(context).process(options); } } diff --git a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/helper/service/ScriptRunnerFactory.java b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/helper/service/ScriptRunnerFactory.java index b56cf07faf5..90b296c6e99 100644 --- a/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/helper/service/ScriptRunnerFactory.java +++ b/openbis/source/java/ch/ethz/sis/openbis/generic/server/api/v3/helper/service/ScriptRunnerFactory.java @@ -17,10 +17,10 @@ package ch.ethz.sis.openbis.generic.server.api.v3.helper.service; import java.io.Serializable; -import java.util.Map; import ch.ethz.sis.openbis.generic.as.api.v3.IApplicationServerApi; -import ch.ethz.sis.openbis.generic.as.api.v3.plugin.context.ServiceContext; +import ch.ethz.sis.openbis.generic.as.api.v3.dto.service.ExecutionOptions; +import ch.ethz.sis.openbis.generic.as.api.v3.plugin.service.context.ServiceContext; import ch.systemsx.cisd.common.jython.JythonUtils; import ch.systemsx.cisd.common.jython.evaluator.Evaluator; import ch.systemsx.cisd.common.jython.evaluator.EvaluatorException; @@ -84,9 +84,9 @@ class ScriptRunnerFactory implements IScriptRunnerFactory } @Override - public Serializable process(Map<String, Serializable> parameters) + public Serializable process(ExecutionOptions options) { - Object result = evaluator.evalFunction(PROCESS_FUNCTION_NAME, parameters); + Object result = evaluator.evalFunction(PROCESS_FUNCTION_NAME, options.getParameters()); if (result == null || result instanceof Serializable) { return (Serializable) result; diff --git a/openbis_api/source/java/ch/ethz/sis/openbis/generic/as/api/v3/IApplicationServerApi.java b/openbis_api/source/java/ch/ethz/sis/openbis/generic/as/api/v3/IApplicationServerApi.java index 29dff898981..8bc69606805 100644 --- a/openbis_api/source/java/ch/ethz/sis/openbis/generic/as/api/v3/IApplicationServerApi.java +++ b/openbis_api/source/java/ch/ethz/sis/openbis/generic/as/api/v3/IApplicationServerApi.java @@ -64,6 +64,7 @@ import ch.ethz.sis.openbis.generic.as.api.v3.dto.sample.id.ISampleId; import ch.ethz.sis.openbis.generic.as.api.v3.dto.sample.id.SamplePermId; import ch.ethz.sis.openbis.generic.as.api.v3.dto.sample.search.SampleSearchCriteria; import ch.ethz.sis.openbis.generic.as.api.v3.dto.sample.update.SampleUpdate; +import ch.ethz.sis.openbis.generic.as.api.v3.dto.service.ExecutionOptions; import ch.ethz.sis.openbis.generic.as.api.v3.dto.service.Service; import ch.ethz.sis.openbis.generic.as.api.v3.dto.service.fetchoptions.ServiceFetchOptions; import ch.ethz.sis.openbis.generic.as.api.v3.dto.service.id.IServiceId; @@ -175,6 +176,6 @@ public interface IApplicationServerApi extends IRpcService public void confirmDeletions(String sessionToken, List<? extends IDeletionId> deletionIds); - public Serializable executeService(String sessionToken, IServiceId serviceId, Map<String, Serializable> parameters); + public Serializable executeService(String sessionToken, IServiceId serviceId, ExecutionOptions options); } diff --git a/openbis_api/source/java/ch/ethz/sis/openbis/generic/as/api/v3/dto/service/ExecutionOptions.java b/openbis_api/source/java/ch/ethz/sis/openbis/generic/as/api/v3/dto/service/ExecutionOptions.java new file mode 100644 index 00000000000..c4678531f6a --- /dev/null +++ b/openbis_api/source/java/ch/ethz/sis/openbis/generic/as/api/v3/dto/service/ExecutionOptions.java @@ -0,0 +1,47 @@ +/* + * Copyright 2015 ETH Zuerich, SIS + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.ethz.sis.openbis.generic.as.api.v3.dto.service; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + +import ch.systemsx.cisd.base.annotation.JsonObject; + +/** + * + * + * @author Franz-Josef Elmer + */ +@JsonObject("dto.service.ExecutionOptions") +public class ExecutionOptions implements Serializable +{ + private static final long serialVersionUID = 1L; + + private final Map<String, Serializable> parameters = new HashMap<String, Serializable>(); + + public ExecutionOptions withParameter(String parameterName, Serializable value) + { + parameters.put(parameterName, value); + return this; + } + + public Map<String, Serializable> getParameters() + { + return parameters; + } +} diff --git a/openbis_api/source/java/ch/ethz/sis/openbis/generic/as/api/v3/plugin/IServiceExecutor.java b/openbis_api/source/java/ch/ethz/sis/openbis/generic/as/api/v3/plugin/service/IServiceExecutor.java similarity index 72% rename from openbis_api/source/java/ch/ethz/sis/openbis/generic/as/api/v3/plugin/IServiceExecutor.java rename to openbis_api/source/java/ch/ethz/sis/openbis/generic/as/api/v3/plugin/service/IServiceExecutor.java index a4e6cd8c0c8..5f20d9cb7f6 100644 --- a/openbis_api/source/java/ch/ethz/sis/openbis/generic/as/api/v3/plugin/IServiceExecutor.java +++ b/openbis_api/source/java/ch/ethz/sis/openbis/generic/as/api/v3/plugin/service/IServiceExecutor.java @@ -14,13 +14,13 @@ * limitations under the License. */ -package ch.ethz.sis.openbis.generic.as.api.v3.plugin; +package ch.ethz.sis.openbis.generic.as.api.v3.plugin.service; import java.io.Serializable; -import java.util.Map; +import ch.ethz.sis.openbis.generic.as.api.v3.dto.service.ExecutionOptions; import ch.ethz.sis.openbis.generic.as.api.v3.dto.service.Service; -import ch.ethz.sis.openbis.generic.as.api.v3.plugin.context.ServiceContext; +import ch.ethz.sis.openbis.generic.as.api.v3.plugin.service.context.ServiceContext; /** * Executor of a {@link Service}. @@ -29,5 +29,5 @@ import ch.ethz.sis.openbis.generic.as.api.v3.plugin.context.ServiceContext; */ public interface IServiceExecutor { - public Serializable executeService(Map<String, Serializable> parameters, ServiceContext context); + public Serializable executeService(ServiceContext context, ExecutionOptions options); } diff --git a/openbis_api/source/java/ch/ethz/sis/openbis/generic/as/api/v3/plugin/context/ServiceContext.java b/openbis_api/source/java/ch/ethz/sis/openbis/generic/as/api/v3/plugin/service/context/ServiceContext.java similarity index 92% rename from openbis_api/source/java/ch/ethz/sis/openbis/generic/as/api/v3/plugin/context/ServiceContext.java rename to openbis_api/source/java/ch/ethz/sis/openbis/generic/as/api/v3/plugin/service/context/ServiceContext.java index a39f2a009ac..f49217c7d0c 100644 --- a/openbis_api/source/java/ch/ethz/sis/openbis/generic/as/api/v3/plugin/context/ServiceContext.java +++ b/openbis_api/source/java/ch/ethz/sis/openbis/generic/as/api/v3/plugin/service/context/ServiceContext.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package ch.ethz.sis.openbis.generic.as.api.v3.plugin.context; +package ch.ethz.sis.openbis.generic.as.api.v3.plugin.service.context; /** * -- GitLab