Refs #10810: Reorganize URLs to be REST compliant

Task-Url: https://support.d4science.org/issues/10810

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/accounting/accounting-service@161873 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2017-12-22 15:21:00 +00:00
parent 66e39e36b2
commit e7015876f5
1 changed files with 0 additions and 47 deletions

View File

@ -1,47 +0,0 @@
package org.gcube.accounting.service.resources;
import javax.validation.constraints.NotNull;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Response;
import org.gcube.accounting.analytics.persistence.AccountingPersistenceQuery;
import org.gcube.accounting.analytics.persistence.AccountingPersistenceQueryFactory;
import org.gcube.accounting.service.AccountingResource;
import org.gcube.accounting.service.AccountingServiceInitializer;
import org.gcube.smartgears.annotations.ManagedBy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @author Alessandro Pieve (alessandro.pieve@isti.cnr.it)
* @author Luca Frosini (ISTI - CNR)
*/
@ManagedBy(AccountingServiceInitializer.class)
@Path(ResourceQuery.QUERY_PATH_PART)
public class ResourceQuery {
private static final Logger log = LoggerFactory.getLogger(ResourceQuery.class);
public static final String QUERY_PATH_PART = "query";
public static final String TYPE_PATH_PART = "type";
public static final String RECORD_ID_PATH_PART = "recordID";
@GET
@Path("/{" + TYPE_PATH_PART + "}/{" + RECORD_ID_PATH_PART + "}/")
@Produces(AccountingResource.APPLICATION_JSON_CHARSET_UTF_8)
public Response get(@NotNull @PathParam(TYPE_PATH_PART) String type,
@NotNull @PathParam(RECORD_ID_PATH_PART) String recordId) throws Exception {
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();
}
}