Changed the way to account requests.
The accounted called Methods are summarized in file ISMethods.txt in src/test/resources
This commit is contained in:
parent
f3b3c038db
commit
64177d1c85
2
pom.xml
2
pom.xml
|
@ -10,7 +10,7 @@
|
|||
|
||||
<groupId>org.gcube.information-system</groupId>
|
||||
<artifactId>resource-registry</artifactId>
|
||||
<version>3.0.0</version>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
<name>Resource Registry Service</name>
|
||||
<description>The Resource Registry is a web-service which represent the core component of the gCube Information System</description>
|
||||
<packaging>war</packaging>
|
||||
|
|
|
@ -17,6 +17,7 @@ import java.util.UUID;
|
|||
|
||||
import javax.activation.UnsupportedDataTypeException;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.CalledMethodProvider;
|
||||
import org.gcube.informationsystem.base.reference.AccessType;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||
|
@ -496,6 +497,9 @@ public abstract class ElementManagement<El extends OElement> {
|
|||
update = true;
|
||||
element = internalUpdate();
|
||||
} catch(NotFoundException e) {
|
||||
String calledMethod = CalledMethodProvider.instance.get();
|
||||
calledMethod = calledMethod.replace("update", "create");
|
||||
CalledMethodProvider.instance.set(calledMethod);
|
||||
element = internalCreate();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
package org.gcube.informationsystem.resourceregistry.rest;
|
||||
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -23,7 +20,6 @@ import javax.ws.rs.core.Response.Status;
|
|||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.CalledMethodProvider;
|
||||
import org.gcube.common.gxhttp.reference.GXConnection.HTTPMETHOD;
|
||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||
import org.gcube.informationsystem.resourceregistry.ResourceInitializer;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.AvailableInAnotherContextException;
|
||||
|
@ -56,7 +52,8 @@ public class Access {
|
|||
|
||||
private static Logger logger = LoggerFactory.getLogger(Access.class);
|
||||
|
||||
public static void setCalledMethod(HTTPMETHOD httpMethod, List<String> pathValues, Map<String,String> map) {
|
||||
/*
|
||||
public static void setRESTCalledMethod(HTTPMETHOD httpMethod, List<String> pathValues, Map<String,String> map) {
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
stringWriter.append(httpMethod.name());
|
||||
boolean first = true;
|
||||
|
@ -78,27 +75,28 @@ public class Access {
|
|||
CalledMethodProvider.instance.set(stringWriter.toString());
|
||||
}
|
||||
|
||||
protected void setCalledMethodLocal(HTTPMETHOD httpMethod, String path) {
|
||||
setCalledMethodLocal(httpMethod, path, null);
|
||||
protected void setRESTCalledMethodLocal(HTTPMETHOD httpMethod, String path) {
|
||||
setRESTCalledMethodLocal(httpMethod, path, null);
|
||||
}
|
||||
|
||||
protected void setCalledMethodLocal(HTTPMETHOD httpMethod, String path, Map<String,String> map) {
|
||||
protected void setRESTCalledMethodLocal(HTTPMETHOD httpMethod, String path, Map<String,String> map) {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add(path);
|
||||
setCalledMethodLocal(httpMethod, list, map);
|
||||
setRESTCalledMethodLocal(httpMethod, list, map);
|
||||
}
|
||||
|
||||
protected void setCalledMethodLocal(HTTPMETHOD httpMethod, List<String> pathValues) {
|
||||
setCalledMethodLocal(httpMethod, pathValues, null);
|
||||
protected void setRESTCalledMethodLocal(HTTPMETHOD httpMethod, List<String> pathValues) {
|
||||
setRESTCalledMethodLocal(httpMethod, pathValues, null);
|
||||
|
||||
}
|
||||
|
||||
protected void setCalledMethodLocal(HTTPMETHOD httpMethod, List<String> pathValues, Map<String,String> map) {
|
||||
protected void setRESTCalledMethodLocal(HTTPMETHOD httpMethod, List<String> pathValues, Map<String,String> map) {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add(AccessPath.ACCESS_PATH_PART);
|
||||
list.addAll(pathValues);
|
||||
Access.setCalledMethod(httpMethod, list, map);
|
||||
Access.setRESTCalledMethod(httpMethod, list, map);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* e.g. GET /access/contexts
|
||||
|
@ -108,7 +106,8 @@ public class Access {
|
|||
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
||||
public String getAllContexts() throws ResourceRegistryException {
|
||||
logger.info("Requested to read all {}s", org.gcube.informationsystem.context.reference.entities.Context.NAME);
|
||||
setCalledMethodLocal(HTTPMETHOD.GET, AccessPath.CONTEXTS_PATH_PART);
|
||||
// setRESTCalledMethodLocal(HTTPMETHOD.GET, AccessPath.CONTEXTS_PATH_PART);
|
||||
CalledMethodProvider.instance.set("listContexts");
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
return contextManagement.all(false);
|
||||
}
|
||||
|
@ -128,10 +127,13 @@ public class Access {
|
|||
}
|
||||
logger.info("Requested to read {} with id {} ", org.gcube.informationsystem.context.reference.entities.Context.NAME, uuid);
|
||||
|
||||
/*
|
||||
List<String> pathValues = new ArrayList<>();
|
||||
pathValues.add(AccessPath.CONTEXTS_PATH_PART);
|
||||
pathValues.add(uuid);
|
||||
setCalledMethodLocal(HTTPMETHOD.GET, pathValues);
|
||||
setRESTCalledMethodLocal(HTTPMETHOD.GET, pathValues);
|
||||
*/
|
||||
CalledMethodProvider.instance.set("readContext");
|
||||
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
contextManagement.setUUID(UUID.fromString(uuid));
|
||||
|
@ -151,12 +153,15 @@ public class Access {
|
|||
throws SchemaNotFoundException, ResourceRegistryException {
|
||||
logger.info("Requested Schema for type {}", type);
|
||||
|
||||
/*
|
||||
List<String> pathValues = new ArrayList<>();
|
||||
pathValues.add(AccessPath.TYPES_PATH_PART);
|
||||
pathValues.add(type);
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
map.put(AccessPath.POLYMORPHIC_PARAM, polymorphic.toString());
|
||||
setCalledMethodLocal(HTTPMETHOD.GET, pathValues, map);
|
||||
setRESTCalledMethodLocal(HTTPMETHOD.GET, pathValues, map);
|
||||
*/
|
||||
CalledMethodProvider.instance.set("readType");
|
||||
|
||||
SchemaManagement schemaManagement = new SchemaManagementImpl();
|
||||
return schemaManagement.read(type, polymorphic);
|
||||
|
@ -176,12 +181,15 @@ public class Access {
|
|||
throws NotFoundException, ResourceRegistryException {
|
||||
logger.info("Requested all {}instances of {}", polymorphic ? AccessPath.POLYMORPHIC_PARAM + " " : "", type);
|
||||
|
||||
/*
|
||||
List<String> pathValues = new ArrayList<>();
|
||||
pathValues.add(AccessPath.INSTANCES_PATH_PART);
|
||||
pathValues.add(type);
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
map.put(AccessPath.POLYMORPHIC_PARAM, polymorphic.toString());
|
||||
setCalledMethodLocal(HTTPMETHOD.GET, pathValues, map);
|
||||
setRESTCalledMethodLocal(HTTPMETHOD.GET, pathValues, map);
|
||||
*/
|
||||
CalledMethodProvider.instance.set("listInstances");
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
|
||||
|
@ -201,11 +209,14 @@ public class Access {
|
|||
@PathParam(AccessPath.UUID_PATH_PARAM) String uuid) throws NotFoundException, ResourceRegistryException {
|
||||
|
||||
logger.info("Requested to check if {} with id {} exists", type, uuid);
|
||||
/*
|
||||
List<String> pathValues = new ArrayList<>();
|
||||
pathValues.add(AccessPath.INSTANCES_PATH_PART);
|
||||
pathValues.add(type);
|
||||
pathValues.add("{" + AccessPath.UUID_PATH_PARAM + "}");
|
||||
setCalledMethodLocal(HTTPMETHOD.HEAD, pathValues);
|
||||
setRESTCalledMethodLocal(HTTPMETHOD.HEAD, pathValues);
|
||||
*/
|
||||
CalledMethodProvider.instance.set("existInstance");
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
|
||||
|
@ -241,11 +252,14 @@ public class Access {
|
|||
public String getInstance(@PathParam(AccessPath.TYPE_PATH_PARAM) String type,
|
||||
@PathParam(AccessPath.UUID_PATH_PARAM) String uuid) throws NotFoundException, ResourceRegistryException {
|
||||
logger.info("Requested to read {} with id {}", type, uuid);
|
||||
/*
|
||||
List<String> pathValues = new ArrayList<>();
|
||||
pathValues.add(AccessPath.INSTANCES_PATH_PART);
|
||||
pathValues.add(type);
|
||||
pathValues.add("{" + AccessPath.UUID_PATH_PARAM + "}");
|
||||
setCalledMethodLocal(HTTPMETHOD.GET, pathValues);
|
||||
setRESTCalledMethodLocal(HTTPMETHOD.GET, pathValues);
|
||||
*/
|
||||
CalledMethodProvider.instance.set("readInstance");
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
|
||||
|
@ -286,7 +300,8 @@ public class Access {
|
|||
@QueryParam(AccessPath.RAW_PARAM) @DefaultValue(AccessPath.DEFAULT_RAW_PARAM) Boolean raw)
|
||||
throws InvalidQueryException {
|
||||
logger.info("Requested query (fetch plan {}, limit : {}, Raw : raw):\n{}", fetchPlan, limit, query, raw);
|
||||
setCalledMethodLocal(HTTPMETHOD.GET, AccessPath.QUERY_PATH_PART);
|
||||
//setRESTCalledMethodLocal(HTTPMETHOD.GET, AccessPath.QUERY_PATH_PART);
|
||||
CalledMethodProvider.instance.set("rawQuery");
|
||||
|
||||
Query queryManager = new QueryImpl();
|
||||
return queryManager.query(query, limit, fetchPlan, raw);
|
||||
|
@ -333,12 +348,15 @@ public class Access {
|
|||
logger.info("Requested {} instances having a(n) {} ({}={}} with {} ({}={})", resourcetype, relationType,
|
||||
AccessPath.DIRECTION_PARAM, direction, referenceType, AccessPath.POLYMORPHIC_PARAM, polymorphic);
|
||||
|
||||
/*
|
||||
List<String> pathValues = new ArrayList<>();
|
||||
pathValues.add(AccessPath.QUERY_PATH_PART);
|
||||
pathValues.add(resourcetype);
|
||||
pathValues.add(relationType);
|
||||
pathValues.add(referenceType);
|
||||
setCalledMethodLocal(HTTPMETHOD.GET, pathValues);
|
||||
setRESTCalledMethodLocal(HTTPMETHOD.GET, pathValues);
|
||||
*/
|
||||
CalledMethodProvider.instance.set("query");
|
||||
|
||||
ElementManagement erManagement = ElementManagementUtility.getERManagement(resourcetype);
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package org.gcube.informationsystem.resourceregistry.rest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
|
@ -15,7 +13,7 @@ import javax.ws.rs.core.MediaType;
|
|||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
||||
import org.gcube.common.gxhttp.reference.GXConnection.HTTPMETHOD;
|
||||
import org.gcube.common.authorization.library.provider.CalledMethodProvider;
|
||||
import org.gcube.informationsystem.context.reference.entities.Context;
|
||||
import org.gcube.informationsystem.resourceregistry.ResourceInitializer;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
|
@ -38,18 +36,20 @@ public class ContextManager {
|
|||
*/
|
||||
private static Logger logger = LoggerFactory.getLogger(ContextManager.class);
|
||||
|
||||
protected void setCalledMethod(HTTPMETHOD httpMethod) {
|
||||
setCalledMethod(httpMethod, null);
|
||||
/*
|
||||
protected void setRESTCalledMethod(HTTPMETHOD httpMethod) {
|
||||
setRESTCalledMethod(httpMethod, null);
|
||||
}
|
||||
|
||||
protected void setCalledMethod(HTTPMETHOD httpMethod, String uuid) {
|
||||
protected void setRESTCalledMethod(HTTPMETHOD httpMethod, String uuid) {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add(ContextPath.CONTEXTS_PATH_PART);
|
||||
if(uuid != null) {
|
||||
list.add(uuid);
|
||||
}
|
||||
Access.setCalledMethod(httpMethod, list, null);
|
||||
Access.setRESTCalledMethod(httpMethod, list, null);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* GET /contexts
|
||||
|
@ -60,7 +60,8 @@ public class ContextManager {
|
|||
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
||||
public String all() throws ContextNotFoundException, ResourceRegistryException {
|
||||
logger.info("Requested to read all {}s", Context.NAME);
|
||||
setCalledMethod(HTTPMETHOD.GET);
|
||||
// setRESTCalledMethod(HTTPMETHOD.GET);
|
||||
CalledMethodProvider.instance.set("listContexts");
|
||||
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
return contextManagement.all(false);
|
||||
|
@ -81,7 +82,8 @@ public class ContextManager {
|
|||
uuid = ContextUtility.getCurrentSecurityContext().getUUID().toString();
|
||||
}
|
||||
logger.info("Requested to read {} with id {} ", Context.NAME, uuid);
|
||||
setCalledMethod(HTTPMETHOD.GET, uuid);
|
||||
//setRESTCalledMethod(HTTPMETHOD.GET, uuid);
|
||||
CalledMethodProvider.instance.set("readContext");
|
||||
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
contextManagement.setUUID(UUID.fromString(uuid));
|
||||
|
@ -102,7 +104,8 @@ public class ContextManager {
|
|||
public String updateCreate(@PathParam(AccessPath.CONTEXT_UUID_PATH_PARAM) String uuid, String json)
|
||||
throws ResourceRegistryException {
|
||||
logger.info("Requested to update/create {} with json {} ", Context.NAME, json);
|
||||
setCalledMethod(HTTPMETHOD.PUT, uuid);
|
||||
//setRESTCalledMethod(HTTPMETHOD.PUT, uuid);
|
||||
CalledMethodProvider.instance.set("updateContext");
|
||||
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
contextManagement.setUUID(UUID.fromString(uuid));
|
||||
|
@ -120,7 +123,8 @@ public class ContextManager {
|
|||
public Response delete(@PathParam(AccessPath.CONTEXT_UUID_PATH_PARAM) String uuid)
|
||||
throws ContextNotFoundException, ResourceRegistryException {
|
||||
logger.info("Requested to delete {} with id {} ", Context.NAME, uuid);
|
||||
setCalledMethod(HTTPMETHOD.DELETE, uuid);
|
||||
// setRESTCalledMethod(HTTPMETHOD.DELETE, uuid);
|
||||
CalledMethodProvider.instance.set("deleteContext");
|
||||
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
contextManagement.setUUID(UUID.fromString(uuid));
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
package org.gcube.informationsystem.resourceregistry.rest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
|
@ -20,7 +16,7 @@ import javax.ws.rs.core.MediaType;
|
|||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
||||
import org.gcube.common.gxhttp.reference.GXConnection.HTTPMETHOD;
|
||||
import org.gcube.common.authorization.library.provider.CalledMethodProvider;
|
||||
import org.gcube.informationsystem.resourceregistry.ResourceInitializer;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.AvailableInAnotherContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
|
||||
|
@ -40,23 +36,25 @@ public class InstancesManager {
|
|||
|
||||
private static Logger logger = LoggerFactory.getLogger(InstancesManager.class);
|
||||
|
||||
protected void setCalledMethod(HTTPMETHOD httpMethod, String type, Map<String,String> map) {
|
||||
setCalledMethod(httpMethod, type, false, map);
|
||||
/*
|
||||
protected void setRESTCalledMethod(HTTPMETHOD httpMethod, String type, Map<String,String> map) {
|
||||
setRESTCalledMethod(httpMethod, type, false, map);
|
||||
}
|
||||
|
||||
protected void setCalledMethod(HTTPMETHOD httpMethod, String type, boolean uuid) {
|
||||
setCalledMethod(httpMethod, type, uuid, null);
|
||||
protected void setRESTCalledMethod(HTTPMETHOD httpMethod, String type, boolean uuid) {
|
||||
setRESTCalledMethod(httpMethod, type, uuid, null);
|
||||
}
|
||||
|
||||
protected void setCalledMethod(HTTPMETHOD httpMethod, String type, boolean uuid, Map<String,String> map) {
|
||||
protected void setRESTCalledMethod(HTTPMETHOD httpMethod, String type, boolean uuid, Map<String,String> map) {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add(InstancePath.INSTANCES_PATH_PART);
|
||||
list.add(type);
|
||||
if(uuid) {
|
||||
list.add("{" + AccessPath.UUID_PATH_PARAM + "}");
|
||||
}
|
||||
Access.setCalledMethod(httpMethod, list, map);
|
||||
Access.setRESTCalledMethod(httpMethod, list, map);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* GET /instances/{TYPE_NAME}[?polymorphic=true]
|
||||
|
@ -71,9 +69,12 @@ public class InstancesManager {
|
|||
@QueryParam(InstancePath.POLYMORPHIC_PARAM) @DefaultValue("true") Boolean polymorphic)
|
||||
throws NotFoundException, ResourceRegistryException {
|
||||
logger.info("Requested all {}instances of {}", polymorphic ? InstancePath.POLYMORPHIC_PARAM + " " : "", type);
|
||||
/*
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
map.put(InstancePath.POLYMORPHIC_PARAM, polymorphic.toString());
|
||||
setCalledMethod(HTTPMETHOD.GET, type, map);
|
||||
setRESTCalledMethod(HTTPMETHOD.GET, type, map);
|
||||
*/
|
||||
CalledMethodProvider.instance.set("listInstances");
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
|
||||
|
@ -92,7 +93,8 @@ public class InstancesManager {
|
|||
public Response exists(@PathParam(AccessPath.TYPE_PATH_PARAM) String type,
|
||||
@PathParam(AccessPath.UUID_PATH_PARAM) String uuid) throws NotFoundException, ResourceRegistryException {
|
||||
logger.info("Requested to check if {} with id {} exists", type, uuid);
|
||||
setCalledMethod(HTTPMETHOD.HEAD, type, true);
|
||||
//setRESTCalledMethod(HTTPMETHOD.HEAD, type, true);
|
||||
CalledMethodProvider.instance.set("existInstance");
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
|
||||
|
@ -128,7 +130,8 @@ public class InstancesManager {
|
|||
public String read(@PathParam(AccessPath.TYPE_PATH_PARAM) String type,
|
||||
@PathParam(AccessPath.UUID_PATH_PARAM) String uuid) throws NotFoundException, ResourceRegistryException {
|
||||
logger.info("Requested to read {} with id {}", type, uuid);
|
||||
setCalledMethod(HTTPMETHOD.GET, type, true);
|
||||
// setRESTCalledMethod(HTTPMETHOD.GET, type, true);
|
||||
CalledMethodProvider.instance.set("readInstance");
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
|
||||
|
@ -153,7 +156,8 @@ public class InstancesManager {
|
|||
@PathParam(AccessPath.UUID_PATH_PARAM) String uuid, String json) throws ResourceRegistryException {
|
||||
logger.info("Requested to update/create {} with id {}", type, uuid);
|
||||
logger.trace("Requested to update/create {} with id {} with json {}", type, uuid, json);
|
||||
setCalledMethod(HTTPMETHOD.PUT, type, true);
|
||||
//setRESTCalledMethod(HTTPMETHOD.PUT, type, true);
|
||||
CalledMethodProvider.instance.set("updateInstance");
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
|
||||
|
@ -174,7 +178,8 @@ public class InstancesManager {
|
|||
public Response delete(@PathParam(AccessPath.TYPE_PATH_PARAM) String type,
|
||||
@PathParam(AccessPath.UUID_PATH_PARAM) String uuid) throws ResourceRegistryException {
|
||||
logger.info("Requested to delete {} with id {}", type, uuid);
|
||||
setCalledMethod(HTTPMETHOD.DELETE, type, true);
|
||||
// setRESTCalledMethod(HTTPMETHOD.DELETE, type, true);
|
||||
CalledMethodProvider.instance.set("deleteInstance");
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
package org.gcube.informationsystem.resourceregistry.rest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
|
@ -18,14 +14,13 @@ import javax.ws.rs.core.MediaType;
|
|||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
||||
import org.gcube.common.gxhttp.reference.GXConnection.HTTPMETHOD;
|
||||
import org.gcube.common.authorization.library.provider.CalledMethodProvider;
|
||||
import org.gcube.informationsystem.base.reference.AccessType;
|
||||
import org.gcube.informationsystem.resourceregistry.ResourceInitializer;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.rest.AccessPath;
|
||||
import org.gcube.informationsystem.resourceregistry.api.rest.InstancePath;
|
||||
import org.gcube.informationsystem.resourceregistry.api.rest.TypePath;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.types.SchemaManagement;
|
||||
|
@ -42,11 +37,12 @@ public class SchemaManager {
|
|||
|
||||
private static Logger logger = LoggerFactory.getLogger(SchemaManager.class);
|
||||
|
||||
protected void setCalledMethod(HTTPMETHOD httpMethod, String type) {
|
||||
setCalledMethod(httpMethod, type, null);
|
||||
/*
|
||||
protected void setRESTCalledMethod(HTTPMETHOD httpMethod, String type) {
|
||||
setRESTCalledMethod(httpMethod, type, null);
|
||||
}
|
||||
|
||||
protected void setCalledMethod(HTTPMETHOD httpMethod, String type, Boolean polymorphic) {
|
||||
protected void setRESTCalledMethod(HTTPMETHOD httpMethod, String type, Boolean polymorphic) {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add(TypePath.TYPES_PATH_PART);
|
||||
list.add(type);
|
||||
|
@ -57,8 +53,9 @@ public class SchemaManager {
|
|||
map.put(InstancePath.POLYMORPHIC_PARAM, polymorphic.toString());
|
||||
}
|
||||
|
||||
Access.setCalledMethod(httpMethod, list, map);
|
||||
Access.setRESTCalledMethod(httpMethod, list, map);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* PUT /types/{TYPE_NAME}
|
||||
|
@ -74,8 +71,8 @@ public class SchemaManager {
|
|||
public Response create(@PathParam(AccessPath.TYPE_PATH_PARAM) String type, String json)
|
||||
throws SchemaException, ResourceRegistryException {
|
||||
logger.info("Requested {} creation with schema {}", type, json);
|
||||
setCalledMethod(HTTPMETHOD.PUT, type);
|
||||
|
||||
// setRESTCalledMethod(HTTPMETHOD.PUT, type);
|
||||
CalledMethodProvider.instance.set("createType");
|
||||
|
||||
AccessType accessType = null;
|
||||
String firstGotType = null;
|
||||
|
@ -114,7 +111,8 @@ public class SchemaManager {
|
|||
@QueryParam(TypePath.POLYMORPHIC_PARAM) @DefaultValue("false") Boolean polymorphic)
|
||||
throws SchemaNotFoundException, ResourceRegistryException {
|
||||
logger.info("Requested Schema for type {}", type);
|
||||
setCalledMethod(HTTPMETHOD.PUT, type, polymorphic);
|
||||
// setRESTCalledMethod(HTTPMETHOD.GET, type, polymorphic);
|
||||
CalledMethodProvider.instance.set("readType");
|
||||
SchemaManagement schemaManagement = new SchemaManagementImpl();
|
||||
return schemaManagement.read(type, polymorphic);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package org.gcube.informationsystem.resourceregistry.rest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.ws.rs.DELETE;
|
||||
|
@ -11,7 +9,7 @@ import javax.ws.rs.PathParam;
|
|||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
||||
import org.gcube.common.gxhttp.reference.GXConnection.HTTPMETHOD;
|
||||
import org.gcube.common.authorization.library.provider.CalledMethodProvider;
|
||||
import org.gcube.informationsystem.context.reference.entities.Context;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextNotFoundException;
|
||||
|
@ -28,15 +26,17 @@ public class SharingManagement {
|
|||
|
||||
private static Logger logger = LoggerFactory.getLogger(SharingManagement.class);
|
||||
|
||||
protected void setCalledMethod(HTTPMETHOD httpMethod, String type) {
|
||||
/*
|
||||
protected void setRESTCalledMethod(HTTPMETHOD httpMethod, String type) {
|
||||
List<String> list = new ArrayList<>();
|
||||
list.add(SharingPath.SHARING_PATH_PART);
|
||||
list.add(SharingPath.CONTEXTS_PATH_PART);
|
||||
list.add("{" + AccessPath.CONTEXT_UUID_PATH_PARAM + "}");
|
||||
list.add(type);
|
||||
list.add("{" + AccessPath.UUID_PATH_PARAM + "}");
|
||||
Access.setCalledMethod(httpMethod, list, null);
|
||||
Access.setRESTCalledMethod(httpMethod, list, null);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* PUT /sharing/{CONTEXT_UUID}/{TYPE_NAME}/{UUID}
|
||||
|
@ -54,7 +54,8 @@ public class SharingManagement {
|
|||
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
|
||||
|
||||
logger.info("Requested to add {} with UUID {} to {} with UUID {}", type, id, Context.NAME, contextId);
|
||||
setCalledMethod(HTTPMETHOD.PUT, type);
|
||||
// setRESTCalledMethod(HTTPMETHOD.PUT, type);
|
||||
CalledMethodProvider.instance.set("addToContext");
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
|
||||
|
@ -91,7 +92,8 @@ public class SharingManagement {
|
|||
@PathParam(AccessPath.TYPE_PATH_PARAM) String type, @PathParam(AccessPath.UUID_PATH_PARAM) String id)
|
||||
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
|
||||
logger.info("Requested to remove {} with UUID {} to {} with UUID {}", type, id, Context.NAME, contextId);
|
||||
setCalledMethod(HTTPMETHOD.DELETE, type);
|
||||
// setRESTCalledMethod(HTTPMETHOD.DELETE, type);
|
||||
CalledMethodProvider.instance.set("removeFromContext");
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
Access Port Type
|
||||
|
||||
- listContexts
|
||||
- readContext
|
||||
|
||||
- readType (type definition)
|
||||
|
||||
- listInstances (all type instances and eventually all subtypes instances)
|
||||
- existInstance (an instance with a certain UUID of a certain type exists)
|
||||
- readInstance (read an instance with a certain UUID of a certain type)
|
||||
|
||||
- rawQuery (Graph Query)
|
||||
- query (e.g. All the EService identified By a SoftwareFacet : GET /access/query/EService/isIdentifiedBy/SoftwareFacet?polymorphic=true&direction=out)
|
||||
|
||||
________________________________________________________________________________
|
||||
|
||||
Context Management Port Type
|
||||
|
||||
- listContexts
|
||||
- createContext
|
||||
- readContext
|
||||
- updateContext (quando ancora non si sa se è una create o una update viene usato update. Solo se qualcosa va storto prima che si capisca viene accountato come update)
|
||||
- deleteContext
|
||||
|
||||
________________________________________________________________________________
|
||||
|
||||
Instances Management Port Type
|
||||
|
||||
- listInstances (all type instances and eventually all subtypes instances)
|
||||
- existInstance (an instance with a certain UUID of a certain type exists)
|
||||
- createInstance (create an instance with a certain UUID of a certain type)
|
||||
- readInstance (read an instance with a certain UUID of a certain type)
|
||||
- updateInstance (update an instance with a certain UUID of a certain type)
|
||||
(quando ancora non si sa se è una create o una update viene usato update. Solo se qualcosa va storto prima che si capisca viene accountato come update)
|
||||
- deleteInstance (delete an instance with a certain UUID of a certain type)
|
||||
|
||||
________________________________________________________________________________
|
||||
|
||||
Types Management Port Type
|
||||
|
||||
- createType
|
||||
- readType (type definition)
|
||||
|
||||
________________________________________________________________________________
|
||||
|
||||
Sharing Management Port Type
|
||||
|
||||
- addToContext
|
||||
- removeFromContext
|
||||
|
||||
________________________________________________________________________________
|
||||
|
Loading…
Reference in New Issue