Implementing service

This commit is contained in:
Luca Frosini 2024-05-28 18:01:59 +02:00
parent a04088e37b
commit 5da45277c4
5 changed files with 30 additions and 32 deletions

View File

@ -3,8 +3,15 @@
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">
<display-name>${project.name}</display-name>
<description>${project.description}</description>
<servlet>
<servlet-name>org.gcube.resourcemanagement.RMInitializer</servlet-name>
<servlet-name>resourcemanager</servlet-name>
<servlet-class>org.glassfish.jersey.servlet.ServletContainer</servlet-class>
<init-param>
<param-name>jersey.config.server.provider.packages</param-name>
<param-value>org.gcube.resourcemanagement.rest</param-value>
</init-param>
</servlet>
<servlet-mapping>
<servlet-name>default</servlet-name>
@ -15,7 +22,7 @@
<url-pattern>/api-docs/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>org.gcube.resourcemanagement.RMInitializer</servlet-name>
<servlet-name>resourcemanager</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>

View File

@ -12,6 +12,7 @@
<version>1.0.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>Resource Manager</name>
<description>Resource Manager</description>
<organization>
<name>gCube System</name>

View File

@ -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());
}
}

View File

@ -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";
}

View File

@ -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) {