Redesigning REST interface

This commit is contained in:
Luca Frosini 2019-08-02 18:29:38 +02:00
parent 8fdda4e3e8
commit 72db4cbf53
2 changed files with 11 additions and 4 deletions

View File

@ -79,7 +79,7 @@ public abstract class SmartExecutorPersistenceConnector extends PluginStateNotif
try {
SmartExecutor smartExecutor = SmartExecutorClientFactory.create(pluginName, address);
smartExecutor.getPluginStateEvolution(uuid, null);
smartExecutor.getPluginStateEvolution(pluginName, uuid.toString(), null);
logger.trace("{} is not orphan.", SEMapper
.getObjectMapper().writeValueAsString(scheduledTask));
return false;

View File

@ -20,6 +20,7 @@ import org.gcube.common.authorization.library.provider.CalledMethodProvider;
import org.gcube.vremanagement.executor.ResourceInitializer;
import org.gcube.vremanagement.executor.annotation.PURGE;
import org.gcube.vremanagement.executor.api.rest.RestConstants;
import org.gcube.vremanagement.executor.api.rest.SmartExecutor;
import org.gcube.vremanagement.executor.api.types.LaunchParameter;
import org.gcube.vremanagement.executor.exception.ExecutorException;
import org.gcube.vremanagement.executor.exception.InputsNullException;
@ -39,7 +40,7 @@ import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.JsonProcessingException;
@Path(RestConstants.PLUGINS_PATH_PART)
public class RestSmartExecutor {
public class RestSmartExecutor implements SmartExecutor {
private static Logger logger = LoggerFactory.getLogger(RestSmartExecutor.class);
@ -65,7 +66,8 @@ public class RestSmartExecutor {
@GET
@Path("")
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
public String listPlugins() throws ExecutorException {
@Override
public String getAvailablePlugins() throws ExecutorException {
setCalledMethod(HttpMethod.GET.getClass().getSimpleName() + " /" + RestConstants.PLUGINS_PATH_PART);
return "[]";
}
@ -73,7 +75,8 @@ public class RestSmartExecutor {
@GET
@Path("/{" + PLUGIN_NAME_PATH_PARAM + "}/" + RestConstants.EXECUTIONS_PATH_PART)
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
public String listExecutions(@PathParam(PLUGIN_NAME_PATH_PARAM) String pluginName) throws ExecutorException {
@Override
public String getLaunches(@PathParam(PLUGIN_NAME_PATH_PARAM) String pluginName) throws ExecutorException {
setCalledMethod(HttpMethod.GET.getClass().getSimpleName() + " /" + RestConstants.PLUGINS_PATH_PART + "/"
+ pluginName + "/" + RestConstants.EXECUTIONS_PATH_PART);
return "[]";
@ -83,6 +86,7 @@ public class RestSmartExecutor {
@Path("/{" + PLUGIN_NAME_PATH_PARAM + "}/" + RestConstants.EXECUTIONS_PATH_PART)
@Consumes({MediaType.TEXT_PLAIN, ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8})
@Produces(MediaType.TEXT_PLAIN)
@Override
public String launch(@PathParam(PLUGIN_NAME_PATH_PARAM) String pluginName, String launchParameterString)
throws ExecutorException {
setCalledMethod(HttpMethod.POST.getClass().getSimpleName() + " /" + RestConstants.PLUGINS_PATH_PART + "/"
@ -120,6 +124,7 @@ public class RestSmartExecutor {
@GET
@Path("/{" + PLUGIN_NAME_PATH_PARAM + "}/" + RestConstants.EXECUTIONS_PATH_PART + "/" + "{" + UUID_PATH_PARAM + "}")
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
@Override
public String getPluginStateEvolution(@PathParam(PLUGIN_NAME_PATH_PARAM) String pluginName,
@PathParam(UUID_PATH_PARAM) String executionIdentifier,
@QueryParam(RestConstants.ITERATION_PARAM) Integer iteration) throws ExecutorException {
@ -157,6 +162,7 @@ public class RestSmartExecutor {
@DELETE
@Path("/{" + PLUGIN_NAME_PATH_PARAM + "}/" + RestConstants.EXECUTIONS_PATH_PART + "/" + "{" + UUID_PATH_PARAM + "}")
@Override
public boolean delete(@PathParam(PLUGIN_NAME_PATH_PARAM) String pluginName,
@PathParam(UUID_PATH_PARAM) String executionIdentifier,
@QueryParam(RestConstants.UNSCHEDULE_PARAM) Boolean unschedule) throws ExecutorException {
@ -212,6 +218,7 @@ public class RestSmartExecutor {
@PURGE
@Path("/{" + PLUGIN_NAME_PATH_PARAM + "}/" + RestConstants.EXECUTIONS_PATH_PART + "/" + "{" + UUID_PATH_PARAM + "}")
@Override
public boolean purge(@PathParam(PLUGIN_NAME_PATH_PARAM) String pluginName,
@PathParam(UUID_PATH_PARAM) String executionIdentifier) throws ExecutorException {
return delete(pluginName, executionIdentifier, true);