Removed old commented code to set the calledMethod

This commit is contained in:
Luca Frosini 2021-03-02 09:13:53 +01:00
parent 703a5f3b22
commit 12ade8e7de
5 changed files with 20 additions and 180 deletions

View File

@ -47,54 +47,6 @@ import com.orientechnologies.orient.core.record.ODirection;
@Path(AccessPath.ACCESS_PATH_PART)
public class Access extends BaseRest {
// private static Logger logger = LoggerFactory.getLogger(Access.class);
/*
public static void setRESTCalledMethod(HTTPMETHOD httpMethod, List<String> pathValues, Map<String,String> map) {
StringWriter stringWriter = new StringWriter();
stringWriter.append(httpMethod.name());
boolean first = true;
for(String value : pathValues) {
stringWriter.append(first ? " /" : "/");
stringWriter.append(value);
first=false;
}
first = true;
if(map != null) {
for(String key : map.keySet()) {
stringWriter.append(first ? "?" : "&");
stringWriter.append(key);
stringWriter.append("=");
stringWriter.append(map.get(key));
first=false;
}
}
CalledMethodProvider.instance.set(stringWriter.toString());
}
protected void setRESTCalledMethodLocal(HTTPMETHOD httpMethod, String path) {
setRESTCalledMethodLocal(httpMethod, path, null);
}
protected void setRESTCalledMethodLocal(HTTPMETHOD httpMethod, String path, Map<String,String> map) {
List<String> list = new ArrayList<>();
list.add(path);
setRESTCalledMethodLocal(httpMethod, list, map);
}
protected void setRESTCalledMethodLocal(HTTPMETHOD httpMethod, List<String> pathValues) {
setRESTCalledMethodLocal(httpMethod, pathValues, null);
}
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.setRESTCalledMethod(httpMethod, list, map);
}
*/
/*
* e.g. GET /access/contexts
*/
@ -103,8 +55,8 @@ public class Access extends BaseRest {
@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);
// setRESTCalledMethodLocal(HTTPMETHOD.GET, AccessPath.CONTEXTS_PATH_PART);
CalledMethodProvider.instance.set("listContexts");
ContextManagement contextManagement = new ContextManagement();
return contextManagement.all(false);
}
@ -122,13 +74,6 @@ public class Access extends BaseRest {
uuid = ContextUtility.getCurrentSecurityContext().getUUID().toString();
}
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);
setRESTCalledMethodLocal(HTTPMETHOD.GET, pathValues);
*/
CalledMethodProvider.instance.set("readContext");
ContextManagement contextManagement = new ContextManagement();
@ -147,15 +92,6 @@ public class Access extends BaseRest {
@QueryParam(AccessPath.POLYMORPHIC_PARAM) @DefaultValue("false") Boolean polymorphic)
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());
setRESTCalledMethodLocal(HTTPMETHOD.GET, pathValues, map);
*/
CalledMethodProvider.instance.set("readType");
SchemaManagement schemaManagement = new SchemaManagement();
@ -180,17 +116,10 @@ public class Access extends BaseRest {
@QueryParam(AccessPath.POLYMORPHIC_PARAM) @DefaultValue("true") Boolean polymorphic)
throws NotFoundException, ResourceRegistryException {
logger.info("Requested all {}instances of {}", polymorphic ? AccessPath.POLYMORPHIC_PARAM + " " : "", type);
CalledMethodProvider.instance.set("listInstances");
checkHierarchicalMode();
checkIncludeInstancesContexts();
/*
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());
setRESTCalledMethodLocal(HTTPMETHOD.GET, pathValues, map);
*/
CalledMethodProvider.instance.set("listInstances");
@SuppressWarnings("rawtypes")
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
@ -208,16 +137,10 @@ public class Access extends BaseRest {
public Response instanceExists(@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);
CalledMethodProvider.instance.set("existInstance");
checkHierarchicalMode();
checkIncludeInstancesContexts();
/*
List<String> pathValues = new ArrayList<>();
pathValues.add(AccessPath.INSTANCES_PATH_PART);
pathValues.add(type);
pathValues.add("{" + AccessPath.UUID_PATH_PARAM + "}");
setRESTCalledMethodLocal(HTTPMETHOD.HEAD, pathValues);
*/
CalledMethodProvider.instance.set("existInstance");
@SuppressWarnings("rawtypes")
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
@ -252,18 +175,11 @@ public class Access extends BaseRest {
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);
CalledMethodProvider.instance.set("readInstance");
checkHierarchicalMode();
checkIncludeInstancesContexts();
/*
List<String> pathValues = new ArrayList<>();
pathValues.add(AccessPath.INSTANCES_PATH_PART);
pathValues.add(type);
pathValues.add("{" + AccessPath.UUID_PATH_PARAM + "}");
setRESTCalledMethodLocal(HTTPMETHOD.GET, pathValues);
*/
CalledMethodProvider.instance.set("readInstance");
@SuppressWarnings("rawtypes")
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
@ -324,10 +240,10 @@ public class Access extends BaseRest {
@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);
CalledMethodProvider.instance.set("rawQuery");
checkHierarchicalMode();
checkIncludeInstancesContexts();
//setRESTCalledMethodLocal(HTTPMETHOD.GET, AccessPath.QUERY_PATH_PART);
CalledMethodProvider.instance.set("rawQuery");
Query queryManager = new QueryImpl();
return queryManager.query(query, limit, fetchPlan, raw);
@ -374,19 +290,11 @@ public class Access extends BaseRest {
logger.info("Requested {} instances having a(n) {} ({}={}} with {} ({}={})", resourcetype, relationType,
AccessPath.DIRECTION_PARAM, direction, referenceType, AccessPath.POLYMORPHIC_PARAM, polymorphic);
CalledMethodProvider.instance.set("query");
checkHierarchicalMode();
checkIncludeInstancesContexts();
/*
List<String> pathValues = new ArrayList<>();
pathValues.add(AccessPath.QUERY_PATH_PART);
pathValues.add(resourcetype);
pathValues.add(relationType);
pathValues.add(referenceType);
setRESTCalledMethodLocal(HTTPMETHOD.GET, pathValues);
*/
CalledMethodProvider.instance.set("query");
ElementManagement erManagement = ElementManagementUtility.getERManagement(resourcetype);
if(erManagement instanceof ResourceManagement) {

View File

@ -35,22 +35,7 @@ public class ContextManager {
* Logger
*/
private static Logger logger = LoggerFactory.getLogger(ContextManager.class);
/*
protected void setRESTCalledMethod(HTTPMETHOD httpMethod) {
setRESTCalledMethod(httpMethod, null);
}
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.setRESTCalledMethod(httpMethod, list, null);
}
*/
/*
* GET /contexts
*
@ -60,7 +45,6 @@ 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);
// setRESTCalledMethod(HTTPMETHOD.GET);
CalledMethodProvider.instance.set("listContexts");
ContextManagement contextManagement = new ContextManagement();
@ -82,7 +66,6 @@ public class ContextManager {
uuid = ContextUtility.getCurrentSecurityContext().getUUID().toString();
}
logger.info("Requested to read {} with id {} ", Context.NAME, uuid);
//setRESTCalledMethod(HTTPMETHOD.GET, uuid);
CalledMethodProvider.instance.set("readContext");
ContextManagement contextManagement = new ContextManagement();
@ -104,7 +87,6 @@ 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);
//setRESTCalledMethod(HTTPMETHOD.PUT, uuid);
CalledMethodProvider.instance.set("updateContext");
ContextManagement contextManagement = new ContextManagement();
@ -123,7 +105,6 @@ 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);
// setRESTCalledMethod(HTTPMETHOD.DELETE, uuid);
CalledMethodProvider.instance.set("deleteContext");
ContextManagement contextManagement = new ContextManagement();

View File

@ -35,28 +35,6 @@ import org.gcube.informationsystem.resourceregistry.instances.base.ElementManage
@Path(InstancePath.INSTANCES_PATH_PART)
public class InstancesManager extends BaseRest {
//private static Logger logger = LoggerFactory.getLogger(InstancesManager.class);
/*
protected void setRESTCalledMethod(HTTPMETHOD httpMethod, String type, Map<String,String> map) {
setRESTCalledMethod(httpMethod, type, false, map);
}
protected void setRESTCalledMethod(HTTPMETHOD httpMethod, String type, boolean uuid) {
setRESTCalledMethod(httpMethod, type, uuid, null);
}
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.setRESTCalledMethod(httpMethod, list, map);
}
*/
/*
* GET /instances/{TYPE_NAME}[?polymorphic=true]
* e.g. GET /instances/ContactFacet?polymorphic=true
@ -70,14 +48,10 @@ public class InstancesManager extends BaseRest {
@QueryParam(InstancePath.POLYMORPHIC_PARAM) @DefaultValue("true") Boolean polymorphic)
throws NotFoundException, ResourceRegistryException {
logger.info("Requested all {}instances of {}", polymorphic ? InstancePath.POLYMORPHIC_PARAM + " " : "", type);
CalledMethodProvider.instance.set("listInstances");
checkHierarchicalMode();
checkIncludeInstancesContexts();
/*
Map<String,String> map = new HashMap<String,String>();
map.put(InstancePath.POLYMORPHIC_PARAM, polymorphic.toString());
setRESTCalledMethod(HTTPMETHOD.GET, type, map);
*/
CalledMethodProvider.instance.set("listInstances");
@SuppressWarnings("rawtypes")
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
@ -97,10 +71,10 @@ public class InstancesManager extends BaseRest {
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);
//setRESTCalledMethod(HTTPMETHOD.HEAD, type, true);
CalledMethodProvider.instance.set("existInstance");
checkHierarchicalMode();
checkIncludeInstancesContexts();
CalledMethodProvider.instance.set("existInstance");
@SuppressWarnings("rawtypes")
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
@ -137,10 +111,10 @@ public class InstancesManager extends BaseRest {
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);
CalledMethodProvider.instance.set("readInstance");
checkHierarchicalMode();
checkIncludeInstancesContexts();
// setRESTCalledMethod(HTTPMETHOD.GET, type, true);
CalledMethodProvider.instance.set("readInstance");
@SuppressWarnings("rawtypes")
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
@ -165,7 +139,6 @@ public class InstancesManager extends BaseRest {
@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);
//setRESTCalledMethod(HTTPMETHOD.PUT, type, true);
CalledMethodProvider.instance.set("updateInstance");
@SuppressWarnings("rawtypes")
@ -188,7 +161,6 @@ public class InstancesManager extends BaseRest {
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);
// setRESTCalledMethod(HTTPMETHOD.DELETE, type, true);
CalledMethodProvider.instance.set("deleteInstance");
@SuppressWarnings("rawtypes")

View File

@ -35,26 +35,6 @@ public class SchemaManager {
private static Logger logger = LoggerFactory.getLogger(SchemaManager.class);
/*
protected void setRESTCalledMethod(HTTPMETHOD httpMethod, String type) {
setRESTCalledMethod(httpMethod, type, null);
}
protected void setRESTCalledMethod(HTTPMETHOD httpMethod, String type, Boolean polymorphic) {
List<String> list = new ArrayList<>();
list.add(TypePath.TYPES_PATH_PART);
list.add(type);
Map<String, String> map = null;
if(polymorphic!=null) {
map = new HashMap<String, String>();
map.put(InstancePath.POLYMORPHIC_PARAM, polymorphic.toString());
}
Access.setRESTCalledMethod(httpMethod, list, map);
}
*/
/*
* PUT /types/{TYPE_NAME}
* e.g. PUT /types/ContactFacet
@ -69,7 +49,6 @@ public class SchemaManager {
public Response create(@PathParam(AccessPath.TYPE_PATH_PARAM) String typeName, String json)
throws SchemaException, ResourceRegistryException {
logger.info("Requested {} creation with schema {}", typeName, json);
// setRESTCalledMethod(HTTPMETHOD.PUT, type);
CalledMethodProvider.instance.set("createType");
SchemaManagement schemaManagement = new SchemaManagement();
@ -92,8 +71,8 @@ public class SchemaManager {
@QueryParam(TypePath.POLYMORPHIC_PARAM) @DefaultValue("false") Boolean polymorphic)
throws SchemaNotFoundException, ResourceRegistryException {
logger.info("Requested Schema for type {}", type);
// setRESTCalledMethod(HTTPMETHOD.GET, type, polymorphic);
CalledMethodProvider.instance.set("readType");
SchemaManagement schemaManagement = new SchemaManagement();
schemaManagement.setTypeName(type);
List<Type> types = schemaManagement.read(polymorphic);

View File

@ -181,8 +181,8 @@ public class SharingManager {
logger.info("Requested {} {} with UUID {} from {} with UUID {}", dryRun? "a dry run for removing": "to remove", type, instanceId, Context.NAME, contextId);
calledMethod.append("RemoveFromContext");
}
CalledMethodProvider.instance.set(calledMethod.toString());
ElementManagement<?,?> elementManagement = ElementManagementUtility.getERManagement(type);
elementManagement.setEntryPoint(true);