Updated setCalledMethod #26707
This commit is contained in:
parent
b32f2d1680
commit
fdead3cb7d
|
@ -12,5 +12,12 @@ public class CalledMethodHandler {
|
|||
logger.debug("setCalledMethod as {}", method);
|
||||
CalledMethodProvider.instance.set(method);
|
||||
}
|
||||
|
||||
public static String buildCalledResource(String httpMethod, String path) {
|
||||
if(!path.startsWith("/"))
|
||||
path = "/"+path;
|
||||
|
||||
return String.format("%s %s", httpMethod.toString(), path);
|
||||
}
|
||||
|
||||
}
|
|
@ -4,6 +4,7 @@ import javax.ws.rs.Consumes;
|
|||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.HttpMethod;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
|
@ -89,6 +90,11 @@ public class ProfiledDocuments {
|
|||
@Path(InterfaceConstants.Methods.CONFIGURATION_PATH)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Configuration getConfiguration(@PathParam(InterfaceConstants.Parameters.UCID) String profileID) {
|
||||
|
||||
String path = CalledMethodHandler.buildCalledResource(HttpMethod.GET,
|
||||
"/" + InterfaceConstants.Methods.PROJECTS + "/" + profileID);
|
||||
CalledMethodHandler.setCalledMethod(path + "/getConfiguration");
|
||||
|
||||
return new GuardedMethod<Configuration>() {
|
||||
|
||||
@Override
|
||||
|
@ -109,9 +115,11 @@ public class ProfiledDocuments {
|
|||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Project createNew(Document d) {
|
||||
|
||||
CalledMethodHandler.setCalledMethod("POST /createNew");
|
||||
|
||||
|
||||
String path = CalledMethodHandler.buildCalledResource(HttpMethod.POST,
|
||||
"/" + InterfaceConstants.Methods.PROJECTS + "/" + manager.getUseCaseDescriptor().getId());
|
||||
CalledMethodHandler.setCalledMethod(path + "/createNew");
|
||||
|
||||
Project theNewProject = new GuardedMethod<Project>() {
|
||||
@Override
|
||||
protected Project run() throws Exception, WebApplicationException {
|
||||
|
@ -154,9 +162,11 @@ public class ProfiledDocuments {
|
|||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Project update(@PathParam(InterfaceConstants.Parameters.PROJECT_ID) String documentId, Document d) {
|
||||
|
||||
CalledMethodHandler.setCalledMethod("PUT /update/{" + InterfaceConstants.Parameters.PROJECT_ID + "}");
|
||||
|
||||
|
||||
String path = CalledMethodHandler.buildCalledResource(HttpMethod.PUT,
|
||||
"/" + InterfaceConstants.Methods.PROJECTS + "/" + manager.getUseCaseDescriptor().getId());
|
||||
CalledMethodHandler.setCalledMethod(path + "/update/{" + InterfaceConstants.Parameters.PROJECT_ID + "}");
|
||||
|
||||
Project theUpdatedProject = new GuardedMethod<Project>() {
|
||||
@Override
|
||||
protected Project run() throws Exception, WebApplicationException {
|
||||
|
@ -197,8 +207,11 @@ public class ProfiledDocuments {
|
|||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Project patch(@PathParam(InterfaceConstants.Parameters.PROJECT_ID) String documentId, Document d) {
|
||||
CalledMethodHandler.setCalledMethod("PATCH /patch/{" + InterfaceConstants.Parameters.PROJECT_ID + "}");
|
||||
|
||||
|
||||
String path = CalledMethodHandler.buildCalledResource("PATCH",
|
||||
"/" + InterfaceConstants.Methods.PROJECTS + "/" + manager.getUseCaseDescriptor().getId());
|
||||
CalledMethodHandler.setCalledMethod(path + "/patch/{" + InterfaceConstants.Parameters.PROJECT_ID + "}");
|
||||
|
||||
return new GuardedMethod<Project>() {
|
||||
@Override
|
||||
protected Project run() throws Exception, WebApplicationException {
|
||||
|
@ -221,9 +234,11 @@ public class ProfiledDocuments {
|
|||
@Path("{" + InterfaceConstants.Parameters.PROJECT_ID + "}")
|
||||
public Boolean delete(@PathParam(InterfaceConstants.Parameters.PROJECT_ID) String id,
|
||||
@DefaultValue("false") @QueryParam(InterfaceConstants.Parameters.FORCE) Boolean force) {
|
||||
|
||||
CalledMethodHandler.setCalledMethod("POST /delete/{" + InterfaceConstants.Parameters.PROJECT_ID + "}");
|
||||
|
||||
|
||||
String path = CalledMethodHandler.buildCalledResource(HttpMethod.DELETE,
|
||||
"/" + InterfaceConstants.Methods.PROJECTS + "/" + manager.getUseCaseDescriptor().getId());
|
||||
CalledMethodHandler.setCalledMethod(path + "/delete/{" + InterfaceConstants.Parameters.PROJECT_ID + "}");
|
||||
|
||||
Boolean deleted = new GuardedMethod<Boolean>() {
|
||||
@Override
|
||||
protected Boolean run() throws Exception, WebApplicationException {
|
||||
|
@ -268,10 +283,12 @@ public class ProfiledDocuments {
|
|||
@Path("/" + InterfaceConstants.Methods.REGISTER_FILES_PATH + "/{" + InterfaceConstants.Parameters.PROJECT_ID + "}")
|
||||
public Project registerFileSet(@PathParam(InterfaceConstants.Parameters.PROJECT_ID) String id,
|
||||
RegisterFileSetRequest request) {
|
||||
|
||||
CalledMethodHandler.setCalledMethod("POST /" + InterfaceConstants.Methods.REGISTER_FILES_PATH + "/{"
|
||||
|
||||
String path = CalledMethodHandler.buildCalledResource(HttpMethod.POST,
|
||||
"/" + InterfaceConstants.Methods.PROJECTS + "/" + manager.getUseCaseDescriptor().getId());
|
||||
CalledMethodHandler.setCalledMethod(path + "/" + InterfaceConstants.Methods.REGISTER_FILES_PATH + "/{"
|
||||
+ InterfaceConstants.Parameters.PROJECT_ID + "}");
|
||||
|
||||
|
||||
return new GuardedMethod<Project>() {
|
||||
@Override
|
||||
protected Project run() throws Exception, WebApplicationException {
|
||||
|
@ -302,10 +319,12 @@ public class ProfiledDocuments {
|
|||
@DefaultValue("false") @QueryParam(InterfaceConstants.Parameters.FORCE) Boolean force,
|
||||
@DefaultValue("false") @QueryParam(InterfaceConstants.Parameters.IGNORE_ERRORS) Boolean ignore_errors,
|
||||
String path) {
|
||||
|
||||
CalledMethodHandler.setCalledMethod("POST /" + InterfaceConstants.Methods.DELETE_FILES_PATH + "/{"
|
||||
+ InterfaceConstants.Parameters.PROJECT_ID + "}");
|
||||
|
||||
|
||||
String pathCalledResource = CalledMethodHandler.buildCalledResource(HttpMethod.POST,
|
||||
"/" + InterfaceConstants.Methods.PROJECTS + "/" + manager.getUseCaseDescriptor().getId());
|
||||
CalledMethodHandler.setCalledMethod(pathCalledResource + "/" + InterfaceConstants.Methods.DELETE_FILES_PATH
|
||||
+ "/{" + InterfaceConstants.Parameters.PROJECT_ID + "}");
|
||||
|
||||
return new GuardedMethod<Project>() {
|
||||
@Override
|
||||
protected Project run() throws Exception, WebApplicationException {
|
||||
|
@ -329,10 +348,12 @@ public class ProfiledDocuments {
|
|||
@Path("/" + InterfaceConstants.Methods.STEP + "/{" + InterfaceConstants.Parameters.PROJECT_ID + "}")
|
||||
public Project performStep(@PathParam(InterfaceConstants.Parameters.PROJECT_ID) String id,
|
||||
PerformStepRequest performStepRequest) {
|
||||
|
||||
CalledMethodHandler.setCalledMethod(
|
||||
"POST /" + InterfaceConstants.Methods.STEP + "/{" + InterfaceConstants.Parameters.PROJECT_ID + "}");
|
||||
|
||||
|
||||
String pathCalledResource = CalledMethodHandler.buildCalledResource(HttpMethod.POST,
|
||||
"/" + InterfaceConstants.Methods.PROJECTS + "/" + manager.getUseCaseDescriptor().getId());
|
||||
CalledMethodHandler.setCalledMethod(pathCalledResource + "/" + InterfaceConstants.Methods.STEP + "/{"
|
||||
+ InterfaceConstants.Parameters.PROJECT_ID + "}");
|
||||
|
||||
Project theProject = new GuardedMethod<Project>() {
|
||||
@Override
|
||||
protected Project run() throws Exception, WebApplicationException {
|
||||
|
@ -373,10 +394,12 @@ public class ProfiledDocuments {
|
|||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/" + InterfaceConstants.Methods.FORCE_UNLOCK + "/{" + InterfaceConstants.Parameters.PROJECT_ID + "}")
|
||||
public Project forceUnlock(@PathParam(InterfaceConstants.Parameters.PROJECT_ID) String id) {
|
||||
|
||||
CalledMethodHandler.setCalledMethod("PUT /" + InterfaceConstants.Methods.FORCE_UNLOCK + "/{"
|
||||
|
||||
String pathCalledResource = CalledMethodHandler.buildCalledResource(HttpMethod.PUT,
|
||||
"/" + InterfaceConstants.Methods.PROJECTS + "/" + manager.getUseCaseDescriptor().getId());
|
||||
CalledMethodHandler.setCalledMethod(pathCalledResource + "/" + InterfaceConstants.Methods.FORCE_UNLOCK + "/{"
|
||||
+ InterfaceConstants.Parameters.PROJECT_ID + "}");
|
||||
|
||||
|
||||
return new GuardedMethod<Project>() {
|
||||
|
||||
@Override
|
||||
|
@ -400,10 +423,13 @@ public class ProfiledDocuments {
|
|||
@Path("/" + InterfaceConstants.Methods.SET_PROJECT_ACCESS_POLICY + "/{" + InterfaceConstants.Parameters.PROJECT_ID
|
||||
+ "}")
|
||||
public Project setAccessPolicy(@PathParam(InterfaceConstants.Parameters.PROJECT_ID) String id, Access toSet) {
|
||||
|
||||
CalledMethodHandler.setCalledMethod("PUT /" + InterfaceConstants.Methods.SET_PROJECT_ACCESS_POLICY + "/{"
|
||||
+ InterfaceConstants.Parameters.PROJECT_ID + "}");
|
||||
|
||||
|
||||
String pathCalledResource = CalledMethodHandler.buildCalledResource(HttpMethod.PUT,
|
||||
"/" + InterfaceConstants.Methods.PROJECTS + "/" + manager.getUseCaseDescriptor().getId());
|
||||
CalledMethodHandler
|
||||
.setCalledMethod(pathCalledResource + "/" + InterfaceConstants.Methods.SET_PROJECT_ACCESS_POLICY + "/{"
|
||||
+ InterfaceConstants.Parameters.PROJECT_ID + "}");
|
||||
|
||||
return new GuardedMethod<Project>() {
|
||||
|
||||
@Override
|
||||
|
@ -424,6 +450,11 @@ public class ProfiledDocuments {
|
|||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Iterable<?> list() {
|
||||
|
||||
String pathCalledResource = CalledMethodHandler.buildCalledResource(HttpMethod.GET,
|
||||
"/" + InterfaceConstants.Methods.PROJECTS + "/" + manager.getUseCaseDescriptor().getId());
|
||||
CalledMethodHandler.setCalledMethod(pathCalledResource + "/list");
|
||||
|
||||
return new GuardedMethod<Iterable<?>>() {
|
||||
protected Iterable<?> run() throws Exception, WebApplicationException {
|
||||
return manager.query(new QueryRequest());
|
||||
|
@ -442,9 +473,12 @@ public class ProfiledDocuments {
|
|||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("{" + InterfaceConstants.Parameters.PROJECT_ID + "}")
|
||||
public Project getById(@PathParam(InterfaceConstants.Parameters.PROJECT_ID) String id) {
|
||||
|
||||
CalledMethodHandler.setCalledMethod("GET /getById/{" + InterfaceConstants.Parameters.PROJECT_ID + "}");
|
||||
|
||||
|
||||
String pathCalledResource = CalledMethodHandler.buildCalledResource(HttpMethod.GET,
|
||||
"/" + InterfaceConstants.Methods.PROJECTS + "/" + manager.getUseCaseDescriptor().getId());
|
||||
CalledMethodHandler
|
||||
.setCalledMethod(pathCalledResource + "/getById/{" + InterfaceConstants.Parameters.PROJECT_ID + "}");
|
||||
|
||||
return new GuardedMethod<Project>() {
|
||||
@Override
|
||||
protected Project run() throws Exception, WebApplicationException {
|
||||
|
@ -464,9 +498,11 @@ public class ProfiledDocuments {
|
|||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/" + InterfaceConstants.Methods.SEARCH_PATH)
|
||||
public String search(String filter) {
|
||||
|
||||
CalledMethodHandler.setCalledMethod("POST /search");
|
||||
|
||||
|
||||
String pathCalledResource = CalledMethodHandler.buildCalledResource(HttpMethod.POST,
|
||||
"/" + InterfaceConstants.Methods.PROJECTS + "/" + manager.getUseCaseDescriptor().getId());
|
||||
CalledMethodHandler.setCalledMethod(pathCalledResource + "/" + InterfaceConstants.Methods.SEARCH_PATH);
|
||||
|
||||
return new GuardedMethod<String>() {
|
||||
@Override
|
||||
protected String run() throws Exception, WebApplicationException {
|
||||
|
@ -488,6 +524,11 @@ public class ProfiledDocuments {
|
|||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/" + InterfaceConstants.Methods.QUERY_PATH)
|
||||
public Iterable<?> query(String queryString) {
|
||||
|
||||
String pathCalledResource = CalledMethodHandler.buildCalledResource(HttpMethod.POST,
|
||||
"/" + InterfaceConstants.Methods.PROJECTS + "/" + manager.getUseCaseDescriptor().getId());
|
||||
CalledMethodHandler.setCalledMethod(pathCalledResource + "/" + InterfaceConstants.Methods.QUERY_PATH);
|
||||
|
||||
return new GuardedMethod<Iterable<?>>() {
|
||||
@Override
|
||||
protected Iterable<?> run() throws Exception, WebApplicationException {
|
||||
|
@ -513,11 +554,13 @@ public class ProfiledDocuments {
|
|||
public String getRelationshipChain(@PathParam(InterfaceConstants.Parameters.PROJECT_ID) String id,
|
||||
@PathParam(InterfaceConstants.Parameters.RELATIONSHIP_ID) String relationshipId,
|
||||
@DefaultValue("false") @QueryParam(InterfaceConstants.Parameters.DEEP) Boolean deep) {
|
||||
|
||||
CalledMethodHandler.setCalledMethod("GET /getRelationshipChain/{" + "{"
|
||||
|
||||
String pathCalledResource = CalledMethodHandler.buildCalledResource(HttpMethod.GET,
|
||||
"/" + InterfaceConstants.Methods.PROJECTS + "/" + manager.getUseCaseDescriptor().getId());
|
||||
CalledMethodHandler.setCalledMethod(pathCalledResource + "/getRelationshipChain/" + "{"
|
||||
+ InterfaceConstants.Methods.RELATIONSHIP + "}/{" + InterfaceConstants.Parameters.PROJECT_ID + "}"
|
||||
+ "/{" + InterfaceConstants.Parameters.RELATIONSHIP_ID + "}");
|
||||
|
||||
|
||||
return new GuardedMethod<String>() {
|
||||
@Override
|
||||
protected String run() throws Exception, WebApplicationException {
|
||||
|
@ -544,11 +587,13 @@ public class ProfiledDocuments {
|
|||
@PathParam(InterfaceConstants.Parameters.RELATIONSHIP_ID) String relationshipId,
|
||||
@QueryParam(InterfaceConstants.Parameters.TARGET_ID) String targetId,
|
||||
@QueryParam(InterfaceConstants.Parameters.TARGET_UCD) String targetUCD) {
|
||||
|
||||
CalledMethodHandler.setCalledMethod("PUT /setRelation/{" + InterfaceConstants.Methods.RELATIONSHIP + "}/{"
|
||||
+ InterfaceConstants.Parameters.PROJECT_ID + "}" + "/{" + InterfaceConstants.Parameters.RELATIONSHIP_ID
|
||||
+ "}");
|
||||
|
||||
|
||||
String pathCalledResource = CalledMethodHandler.buildCalledResource(HttpMethod.PUT,
|
||||
"/" + InterfaceConstants.Methods.PROJECTS + "/" + manager.getUseCaseDescriptor().getId());
|
||||
CalledMethodHandler.setCalledMethod(pathCalledResource + "/setRelation/" + "{"
|
||||
+ InterfaceConstants.Methods.RELATIONSHIP + "}/{" + InterfaceConstants.Parameters.PROJECT_ID + "}"
|
||||
+ "/{" + InterfaceConstants.Parameters.RELATIONSHIP_ID + "}");
|
||||
|
||||
return new GuardedMethod<Project>() {
|
||||
@Override
|
||||
protected Project run() throws Exception, WebApplicationException {
|
||||
|
@ -582,11 +627,13 @@ public class ProfiledDocuments {
|
|||
@PathParam(InterfaceConstants.Parameters.RELATIONSHIP_ID) String relationshipId,
|
||||
@QueryParam(InterfaceConstants.Parameters.TARGET_ID) String targetId,
|
||||
@QueryParam(InterfaceConstants.Parameters.TARGET_UCD) String targetUCD) {
|
||||
|
||||
CalledMethodHandler.setCalledMethod("PUT /deleteRelation/{" + InterfaceConstants.Methods.RELATIONSHIP + "}/{"
|
||||
+ InterfaceConstants.Parameters.PROJECT_ID + "}" + "/{" + InterfaceConstants.Parameters.RELATIONSHIP_ID
|
||||
+ "}");
|
||||
|
||||
|
||||
String pathCalledResource = CalledMethodHandler.buildCalledResource(HttpMethod.DELETE,
|
||||
"/" + InterfaceConstants.Methods.PROJECTS + "/" + manager.getUseCaseDescriptor().getId());
|
||||
CalledMethodHandler.setCalledMethod(pathCalledResource + "/deleteRelation/" + "{"
|
||||
+ InterfaceConstants.Methods.RELATIONSHIP + "}/{" + InterfaceConstants.Parameters.PROJECT_ID + "}"
|
||||
+ "/{" + InterfaceConstants.Parameters.RELATIONSHIP_ID + "}");
|
||||
|
||||
return new GuardedMethod<Project>() {
|
||||
@Override
|
||||
protected Project run() throws Exception, WebApplicationException {
|
||||
|
|
|
@ -4,6 +4,7 @@ import javax.ws.rs.Consumes;
|
|||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.DefaultValue;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.HttpMethod;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
|
@ -29,118 +30,121 @@ import lombok.extern.slf4j.Slf4j;
|
|||
@Path(InterfaceConstants.Methods.UCD)
|
||||
@Slf4j
|
||||
@RequestHeaders({
|
||||
@RequestHeader( name = "Authorization", description = "Bearer token, see https://dev.d4science.org/how-to-access-resources"),
|
||||
@RequestHeader( name = "Content-Type", description = "application/json")
|
||||
})
|
||||
@RequestHeader(name = "Authorization", description = "Bearer token, see https://dev.d4science.org/how-to-access-resources"),
|
||||
@RequestHeader(name = "Content-Type", description = "application/json") })
|
||||
public class UseCaseDescriptors {
|
||||
|
||||
private UCDManagerI getManager() {
|
||||
try {
|
||||
return ImplementationProvider.get().getProvidedObjectByClass(UCDManagerI.class);
|
||||
} catch (Throwable t) {
|
||||
log.error("Unable to get UCD Engine", t);
|
||||
throw new WebApplicationException("Unable to access UC Engine", Response.Status.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
private UCDManagerI getManager(){
|
||||
try{
|
||||
return ImplementationProvider.get().getProvidedObjectByClass(UCDManagerI.class);
|
||||
}catch(Throwable t){
|
||||
log.error("Unable to get UCD Engine",t);
|
||||
throw new WebApplicationException("Unable to access UC Engine", Response.Status.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
@POST
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public UseCaseDescriptor createNew(UseCaseDescriptor toCreate) {
|
||||
|
||||
String path = CalledMethodHandler.buildCalledResource(HttpMethod.POST, "/" + InterfaceConstants.Methods.UCD);
|
||||
CalledMethodHandler.setCalledMethod(path + "/createNew");
|
||||
|
||||
return new GuardedMethod<UseCaseDescriptor>() {
|
||||
@Override
|
||||
protected UseCaseDescriptor run() throws Exception, WebApplicationException {
|
||||
log.info("Creating new UseCaseDescriptor ({})", toCreate);
|
||||
if (toCreate.getMongoId() != null)
|
||||
throw new WebApplicationException("Cannot register Use Case Descriptor with mongo ID",
|
||||
Response.Status.BAD_REQUEST);
|
||||
if (toCreate.getId() == null)
|
||||
throw new WebApplicationException("Missing mandatory field ID", Response.Status.BAD_REQUEST);
|
||||
UseCaseDescriptor toReturn = getManager().put(toCreate);
|
||||
if (toReturn == null) {
|
||||
log.warn("NB Cached backend implementation is slow beware of that");
|
||||
}
|
||||
log.info("Created new UseCaseDescriptor (ID {})", toReturn.getId());
|
||||
return toReturn;
|
||||
}
|
||||
}.execute().getResult();
|
||||
}
|
||||
|
||||
@PUT
|
||||
@Path("{" + InterfaceConstants.Parameters.UCID + "}")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public UseCaseDescriptor update(@PathParam(InterfaceConstants.Parameters.UCID) String profileId,
|
||||
UseCaseDescriptor d) {
|
||||
|
||||
@POST
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public UseCaseDescriptor createNew(UseCaseDescriptor toCreate) {
|
||||
|
||||
CalledMethodHandler.setCalledMethod("POST /createNew");
|
||||
|
||||
return new GuardedMethod<UseCaseDescriptor>() {
|
||||
@Override
|
||||
protected UseCaseDescriptor run() throws Exception, WebApplicationException {
|
||||
log.info("Creating new UseCaseDescriptor ({})",toCreate);
|
||||
if(toCreate.getMongoId()!=null) throw new WebApplicationException("Cannot register Use Case Descriptor with mongo ID", Response.Status.BAD_REQUEST);
|
||||
if(toCreate.getId()==null) throw new WebApplicationException("Missing mandatory field ID", Response.Status.BAD_REQUEST);
|
||||
UseCaseDescriptor toReturn = getManager().put(toCreate);
|
||||
if(toReturn == null){
|
||||
log.warn("NB Cached backend implementation is slow beware of that");
|
||||
}
|
||||
log.info("Created new UseCaseDescriptor (ID {})",toReturn.getId());
|
||||
return toReturn;
|
||||
}
|
||||
}.execute().getResult();
|
||||
}
|
||||
String path = CalledMethodHandler.buildCalledResource(HttpMethod.PUT, "/" + InterfaceConstants.Methods.UCD);
|
||||
CalledMethodHandler.setCalledMethod(path + "/update/" + profileId);
|
||||
|
||||
@PUT
|
||||
@Path("{"+InterfaceConstants.Parameters.UCID +"}")
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public UseCaseDescriptor update(@PathParam(InterfaceConstants.Parameters.UCID) String profileId, UseCaseDescriptor d) {
|
||||
|
||||
CalledMethodHandler.setCalledMethod("PUT /update/" + "{" + InterfaceConstants.Parameters.UCID + "}");
|
||||
|
||||
return new GuardedMethod<UseCaseDescriptor>() {
|
||||
@Override
|
||||
protected UseCaseDescriptor run() throws Exception, WebApplicationException {
|
||||
log.warn("Updating UseCaseDescriptor ({})",profileId);
|
||||
d.setId(profileId);
|
||||
return getManager().put(d);
|
||||
}
|
||||
}.execute().getResult();
|
||||
}
|
||||
return new GuardedMethod<UseCaseDescriptor>() {
|
||||
@Override
|
||||
protected UseCaseDescriptor run() throws Exception, WebApplicationException {
|
||||
log.warn("Updating UseCaseDescriptor ({})", profileId);
|
||||
d.setId(profileId);
|
||||
return getManager().put(d);
|
||||
}
|
||||
}.execute().getResult();
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("{" + InterfaceConstants.Parameters.UCID + "}")
|
||||
public Boolean delete(@PathParam(InterfaceConstants.Parameters.UCID) String id,
|
||||
@DefaultValue("false") @QueryParam(InterfaceConstants.Parameters.FORCE) Boolean force) {
|
||||
|
||||
String path = CalledMethodHandler.buildCalledResource(HttpMethod.DELETE, "/" + InterfaceConstants.Methods.UCD);
|
||||
CalledMethodHandler.setCalledMethod(path + "/delete/"+id);
|
||||
|
||||
@DELETE
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("{"+InterfaceConstants.Parameters.UCID +"}")
|
||||
public Boolean delete(@PathParam(InterfaceConstants.Parameters.UCID) String id,
|
||||
@DefaultValue("false")
|
||||
@QueryParam(InterfaceConstants.Parameters.FORCE) Boolean force) {
|
||||
|
||||
CalledMethodHandler.setCalledMethod("DELETE /delete/" + "{" + InterfaceConstants.Parameters.UCID + "}");
|
||||
|
||||
return new GuardedMethod<Boolean>() {
|
||||
@Override
|
||||
protected Boolean run() throws Exception, WebApplicationException {
|
||||
log.warn("Deleting UseCaseDescriptor (ID {}). Force is {}",id,force);
|
||||
getManager().deleteById(id,force);
|
||||
return true;
|
||||
}
|
||||
}.execute().getResult();
|
||||
}
|
||||
return new GuardedMethod<Boolean>() {
|
||||
@Override
|
||||
protected Boolean run() throws Exception, WebApplicationException {
|
||||
log.warn("Deleting UseCaseDescriptor (ID {}). Force is {}", id, force);
|
||||
getManager().deleteById(id, force);
|
||||
return true;
|
||||
}
|
||||
}.execute().getResult();
|
||||
}
|
||||
|
||||
// BY ID
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("{" + InterfaceConstants.Parameters.UCID + "}")
|
||||
public UseCaseDescriptor getById(@PathParam(InterfaceConstants.Parameters.UCID) String id) {
|
||||
|
||||
// BY ID
|
||||
@GET
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("{"+InterfaceConstants.Parameters.UCID +"}")
|
||||
public UseCaseDescriptor getById(@PathParam(InterfaceConstants.Parameters.UCID) String id) {
|
||||
|
||||
CalledMethodHandler.setCalledMethod("GET /getById/" + "{" + InterfaceConstants.Parameters.UCID + "}");
|
||||
|
||||
return new GuardedMethod<UseCaseDescriptor>() {
|
||||
@Override
|
||||
protected UseCaseDescriptor run() throws Exception, WebApplicationException {
|
||||
UseCaseDescriptor toReturn = getManager().getById(id);
|
||||
if(toReturn == null ) throw new WebApplicationException("No UCD Matching ID "+id, Response.Status.NOT_FOUND);
|
||||
else return toReturn;
|
||||
}
|
||||
}.execute().getResult();
|
||||
}
|
||||
String path = CalledMethodHandler.buildCalledResource(HttpMethod.GET, "/" + InterfaceConstants.Methods.UCD);
|
||||
CalledMethodHandler.setCalledMethod(path + "/getById/" + id);
|
||||
|
||||
@POST
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/"+InterfaceConstants.Methods.QUERY_PATH)
|
||||
public Iterable<?> query(String queryString){
|
||||
|
||||
CalledMethodHandler.setCalledMethod("POST /" + InterfaceConstants.Methods.QUERY_PATH);
|
||||
|
||||
return new GuardedMethod<Iterable<?>>() {
|
||||
@Override
|
||||
protected Iterable<?> run() throws Exception, WebApplicationException {
|
||||
return getManager().query(Serialization.parseQuery(queryString));
|
||||
}
|
||||
}.execute().getResult();
|
||||
}
|
||||
return new GuardedMethod<UseCaseDescriptor>() {
|
||||
@Override
|
||||
protected UseCaseDescriptor run() throws Exception, WebApplicationException {
|
||||
UseCaseDescriptor toReturn = getManager().getById(id);
|
||||
if (toReturn == null)
|
||||
throw new WebApplicationException("No UCD Matching ID " + id, Response.Status.NOT_FOUND);
|
||||
else
|
||||
return toReturn;
|
||||
}
|
||||
}.execute().getResult();
|
||||
}
|
||||
|
||||
@POST
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Path("/" + InterfaceConstants.Methods.QUERY_PATH)
|
||||
public Iterable<?> query(String queryString) {
|
||||
|
||||
String path = CalledMethodHandler.buildCalledResource(HttpMethod.POST, "/" + InterfaceConstants.Methods.UCD);
|
||||
CalledMethodHandler.setCalledMethod(path + "/"+ InterfaceConstants.Methods.QUERY_PATH);
|
||||
|
||||
return new GuardedMethod<Iterable<?>>() {
|
||||
@Override
|
||||
protected Iterable<?> run() throws Exception, WebApplicationException {
|
||||
return getManager().query(Serialization.parseQuery(queryString));
|
||||
}
|
||||
}.execute().getResult();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue