From 5da45277c437d81752a5e0fe287b84ba7881b61c Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Tue, 28 May 2024 18:01:59 +0200 Subject: [PATCH] Implementing service --- .../extra-resources}/WEB-INF/web.xml | 13 ++++++++--- pom.xml | 1 + .../resourcemanagement/RMInitializer.java | 22 ------------------- .../rest/administration/Administration.java | 12 ++++++++++ .../rest/administration/Configuration.java | 14 ++++++------ 5 files changed, 30 insertions(+), 32 deletions(-) rename {src/main/webapp => gcube/extra-resources}/WEB-INF/web.xml (56%) delete mode 100644 src/main/java/org/gcube/resourcemanagement/RMInitializer.java create mode 100644 src/main/java/org/gcube/resourcemanagement/rest/administration/Administration.java diff --git a/src/main/webapp/WEB-INF/web.xml b/gcube/extra-resources/WEB-INF/web.xml similarity index 56% rename from src/main/webapp/WEB-INF/web.xml rename to gcube/extra-resources/WEB-INF/web.xml index 996a73d..2f3166d 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/gcube/extra-resources/WEB-INF/web.xml @@ -3,9 +3,16 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0"> + ${project.name} + ${project.description} - org.gcube.resourcemanagement.RMInitializer - + resourcemanager + org.glassfish.jersey.servlet.ServletContainer + + jersey.config.server.provider.packages + org.gcube.resourcemanagement.rest + + default /docs/* @@ -15,7 +22,7 @@ /api-docs/* - org.gcube.resourcemanagement.RMInitializer + resourcemanager /* \ No newline at end of file diff --git a/pom.xml b/pom.xml index 26563ae..7562439 100644 --- a/pom.xml +++ b/pom.xml @@ -12,6 +12,7 @@ 1.0.0-SNAPSHOT war Resource Manager + Resource Manager gCube System diff --git a/src/main/java/org/gcube/resourcemanagement/RMInitializer.java b/src/main/java/org/gcube/resourcemanagement/RMInitializer.java deleted file mode 100644 index 4954e03..0000000 --- a/src/main/java/org/gcube/resourcemanagement/RMInitializer.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.gcube.resourcemanagement; - -import org.gcube.resourcemanagement.rest.BaseREST; -import org.gcube.resourcemanagement.rest.administration.Configuration; -import org.gcube.smartgears.annotations.ManagedBy; -import org.glassfish.jersey.server.ResourceConfig; - -import jakarta.ws.rs.ApplicationPath; - -/** - * @author Luca Frosini (ISTI - CNR) - */ -@ApplicationPath("/") -@ManagedBy(ResourceManager.class) -public class RMInitializer extends ResourceConfig { - - public RMInitializer() { - packages(BaseREST.class.getPackage().toString()); - packages(Configuration.class.getPackage().toString()); - } - -} diff --git a/src/main/java/org/gcube/resourcemanagement/rest/administration/Administration.java b/src/main/java/org/gcube/resourcemanagement/rest/administration/Administration.java new file mode 100644 index 0000000..825283c --- /dev/null +++ b/src/main/java/org/gcube/resourcemanagement/rest/administration/Administration.java @@ -0,0 +1,12 @@ +package org.gcube.resourcemanagement.rest.administration; + +import org.gcube.resourcemanagement.rest.BaseREST; + +/** + * @author Luca Frosini (ISTI - CNR) + */ +public class Administration extends BaseREST { + + public static final String ADMIN_PATH = "admin"; + +} diff --git a/src/main/java/org/gcube/resourcemanagement/rest/administration/Configuration.java b/src/main/java/org/gcube/resourcemanagement/rest/administration/Configuration.java index 0317415..df7c5f3 100644 --- a/src/main/java/org/gcube/resourcemanagement/rest/administration/Configuration.java +++ b/src/main/java/org/gcube/resourcemanagement/rest/administration/Configuration.java @@ -39,14 +39,14 @@ import jakarta.xml.ws.WebServiceException; * * @author Luca Frosini (ISTI - CNR) */ -@Path(Configuration.CONFIGURATIONS) +@Path(Administration.ADMIN_PATH + "/" + Configuration.CONFIGURATIONS_PATH) @ResourceGroup("Administration APIs") @ResourceLabel("Configuration APIs") -public class Configuration extends BaseREST { +public class Configuration extends Administration { private static Logger logger = LoggerFactory.getLogger(Configuration.class); - public static final String CONFIGURATIONS = "configurations"; + public static final String CONFIGURATIONS_PATH = "configurations"; public static final String CURRENT_CONTEXT_PATH_PARAMETER = "CURRENT_CONTEXT"; public static final String CONTEXT_FULLNAME_PARAMETER = "CONTEXT_FULLNAME_PARAMETER"; @@ -130,7 +130,7 @@ public class Configuration extends BaseREST { public Response read() throws WebServiceException { try { - String configuration = ""; + String configuration = "{}"; logger.debug("Configuration in context {} is {}", "", configuration); ResponseBuilder responseBuilder = Response.status(Status.OK); if(configuration!=null) { @@ -161,7 +161,7 @@ public class Configuration extends BaseREST { @OperationId("Create or Update") public String createOrUpdate(@PathParam(CONTEXT_FULLNAME_PARAMETER) String context, String json) throws WebServiceException { try { - return null; + return "{}"; }catch (WebApplicationException e) { throw e; }catch (Exception e) { @@ -171,7 +171,7 @@ public class Configuration extends BaseREST { public Response update(String json) throws WebServiceException { try { - String configuration = ""; + String configuration = "{}"; logger.debug("Configuration in context {} has been updated to {}", "", configuration); ResponseBuilder responseBuilder = Response.status(Status.OK); if(configuration!=null) { @@ -212,7 +212,7 @@ public class Configuration extends BaseREST { public Response patch(String json) throws WebServiceException { try { - String ret = ""; + String ret = "{}"; logger.debug("Configuration in context {} has been patched to {}", "", ret); ResponseBuilder responseBuilder = Response.status(Status.OK); if(ret!=null) {