diff --git a/distro/changelog.xml b/distro/changelog.xml index a023ae3..672c246 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -1,7 +1,10 @@ - + + + + Reorganize URLs to be REST compliant #10810 diff --git a/pom.xml b/pom.xml index 556fd93..1d9b56d 100644 --- a/pom.xml +++ b/pom.xml @@ -9,7 +9,7 @@ org.gcube.accounting accounting-service - 1.2.0-SNAPSHOT + 1.3.0-SNAPSHOT accounting-service Service Accounting Manger war @@ -50,7 +50,6 @@ org.gcube.core common-smartgears-app - provided org.gcube.common diff --git a/src/main/java/org/gcube/accounting/service/resources/RecordManagement.java b/src/main/java/org/gcube/accounting/service/resources/RecordManagement.java index edaaac3..8f0d0cd 100644 --- a/src/main/java/org/gcube/accounting/service/resources/RecordManagement.java +++ b/src/main/java/org/gcube/accounting/service/resources/RecordManagement.java @@ -19,12 +19,15 @@ import org.gcube.accounting.persistence.AccountingPersistence; import org.gcube.accounting.persistence.AccountingPersistenceFactory; import org.gcube.accounting.service.AccountingResource; import org.gcube.accounting.service.AccountingServiceInitializer; +import org.gcube.common.authorization.library.provider.CalledMethodProvider; import org.gcube.documentstore.records.DSMapper; import org.gcube.documentstore.records.Record; import org.gcube.smartgears.annotations.ManagedBy; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.sun.research.ws.wadl.HTTPMethods; + /** * @author Luca Frosini (ISTI - CNR) */ @@ -41,6 +44,8 @@ public class RecordManagement { @POST @Consumes({MediaType.TEXT_PLAIN, AccountingResource.APPLICATION_JSON_CHARSET_UTF_8}) public Response add(String json) throws Exception { + CalledMethodProvider.instance + .set(HTTPMethods.POST.name() + " /" + RecordManagement.RECORD_PATH_PART); log.trace("Going to account : {}", json); @@ -62,11 +67,14 @@ public class RecordManagement { public Response get(@NotNull @PathParam(TYPE_PATH_PART) String type, @NotNull @PathParam(RECORD_ID_PATH_PART) String recordId) throws Exception { + CalledMethodProvider.instance + .set(HTTPMethods.GET.name() + " /" + TYPE_PATH_PART + "/" + RECORD_ID_PATH_PART); + log.debug("Requested {} having ID {}", type, recordId); AccountingPersistenceQuery accountingPersistenceQuery = AccountingPersistenceQueryFactory.getInstance(); String record = accountingPersistenceQuery.getRecord(recordId, type); - return Response.status(200).entity(record).type(AccountingResource.APPLICATION_JSON_CHARSET_UTF_8).build(); + return Response.status(Status.OK).entity(record).type(AccountingResource.APPLICATION_JSON_CHARSET_UTF_8).build(); } diff --git a/src/main/java/org/gcube/accounting/service/resources/ServiceState.java b/src/main/java/org/gcube/accounting/service/resources/ServiceState.java index 08470df..599b52d 100644 --- a/src/main/java/org/gcube/accounting/service/resources/ServiceState.java +++ b/src/main/java/org/gcube/accounting/service/resources/ServiceState.java @@ -12,12 +12,15 @@ import org.gcube.accounting.persistence.AccountingPersistence; import org.gcube.accounting.persistence.AccountingPersistenceFactory; import org.gcube.accounting.service.AccountingResource; import org.gcube.accounting.service.AccountingServiceInitializer; +import org.gcube.common.authorization.library.provider.CalledMethodProvider; import org.gcube.smartgears.annotations.ManagedBy; import org.json.JSONException; import org.json.JSONObject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.sun.research.ws.wadl.HTTPMethods; + /** * @author Alessandro Pieve (alessandro.pieve@isti.cnr.it) * @author Luca Frosini (ISTI - CNR) @@ -39,6 +42,10 @@ public class ServiceState { @GET @Produces(AccountingResource.APPLICATION_JSON_CHARSET_UTF_8) public Response getState() throws JSONException { + + CalledMethodProvider.instance + .set(HTTPMethods.GET.name() + " /" + STATE_PATH_PART); + String context = AccountingServiceInitializer.getCurrentContext(); logger.debug("Getting Service Status for context {}", context); @@ -46,8 +53,6 @@ public class ServiceState { jsonObject.append(SERVICE, RUNNING); jsonObject.append(CONTEXT, context); - Status responseStatus = Status.SERVICE_UNAVAILABLE; - AccountingPersistence accountingPersistence = AccountingPersistenceFactory.getPersistence(); try { jsonObject.append(INSERT_CONNECTION_UP, accountingPersistence.isConnectionActive()); @@ -62,7 +67,7 @@ public class ServiceState { jsonObject.append(QUERY_CONNECTION_UP, false); } - return Response.status(responseStatus).entity(jsonObject.toString()).build(); + return Response.status(Status.OK).entity(jsonObject.toString()).build(); }