Porting service to smartgears 4
This commit is contained in:
parent
dcb67f357f
commit
939526d2fd
|
@ -2,6 +2,11 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
|||
|
||||
# Changelog for Resource Registry Service
|
||||
|
||||
## [v5.0.0-SNAPSHOT]
|
||||
|
||||
- Switched to gcube-smartgears-bom 3.0.0
|
||||
|
||||
|
||||
## [v4.1.0-SNAPSHOT]
|
||||
|
||||
- Relation source-target instance types are validated against Relation schema [#7355]
|
||||
|
|
15
pom.xml
15
pom.xml
|
@ -10,7 +10,7 @@
|
|||
|
||||
<groupId>org.gcube.information-system</groupId>
|
||||
<artifactId>resource-registry</artifactId>
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<version>5.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>
|
||||
|
@ -31,7 +31,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>gcube-smartgears-bom</artifactId>
|
||||
<version>2.2.0-SNAPSHOT</version>
|
||||
<version>3.0.0-SNAPSHOT</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
@ -40,19 +40,16 @@
|
|||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.information-system</groupId>
|
||||
<artifactId>resource-registry-api</artifactId>
|
||||
<scope>provided</scope>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-smartgears</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.information-system</groupId>
|
||||
<artifactId>information-system-model</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>authorization-utils</artifactId>
|
||||
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||
<groupId>org.gcube.information-system</groupId>
|
||||
<artifactId>resource-registry-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.orientechnologies</groupId>
|
||||
|
|
|
@ -5,8 +5,8 @@ import java.util.Map;
|
|||
import java.util.NoSuchElementException;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||
import org.gcube.common.scope.impl.ScopeBean;
|
||||
import org.gcube.common.security.ContextBean;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||
import org.gcube.informationsystem.contexts.reference.entities.Context;
|
||||
import org.gcube.informationsystem.contexts.reference.relations.IsParentOf;
|
||||
|
@ -222,7 +222,7 @@ public class ContextUtility {
|
|||
private OVertex getContextVertexByFullName(ODatabaseDocument oDatabaseDocument, String fullName) throws ResourceRegistryException {
|
||||
logger.trace("Going to get {} {} with full name '{}'", Context.NAME, OVertex.class.getSimpleName(), fullName);
|
||||
|
||||
ScopeBean scopeBean = new ScopeBean(fullName);
|
||||
ContextBean scopeBean = new ContextBean(fullName);
|
||||
String name = scopeBean.name();
|
||||
|
||||
// TODO Rewrite better query. This query works because all the scope parts has a different name
|
||||
|
|
|
@ -23,7 +23,6 @@ import org.gcube.com.fasterxml.jackson.databind.node.ArrayNode;
|
|||
import org.gcube.com.fasterxml.jackson.databind.node.JsonNodeType;
|
||||
import org.gcube.com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.gcube.com.fasterxml.jackson.databind.node.TextNode;
|
||||
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;
|
||||
|
@ -50,6 +49,7 @@ import org.gcube.informationsystem.resourceregistry.utils.Utility;
|
|||
import org.gcube.informationsystem.types.reference.Type;
|
||||
import org.gcube.informationsystem.types.reference.entities.ResourceType;
|
||||
import org.gcube.informationsystem.types.reference.properties.PropertyDefinition;
|
||||
import org.gcube.smartgears.utils.InnerMethodName;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -625,9 +625,9 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
|
|||
internalUpdate();
|
||||
} catch(NotFoundException e) {
|
||||
setAsEntryPoint();
|
||||
String calledMethod = CalledMethodProvider.instance.get();
|
||||
String calledMethod = InnerMethodName.instance.get();
|
||||
calledMethod = calledMethod.replace("update", "create");
|
||||
CalledMethodProvider.instance.set(calledMethod);
|
||||
InnerMethodName.instance.set(calledMethod);
|
||||
internalCreate();
|
||||
}
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@ import javax.ws.rs.core.Response;
|
|||
import javax.ws.rs.core.Response.Status;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.CalledMethodProvider;
|
||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||
import org.gcube.informationsystem.resourceregistry.ResourceInitializer;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.AvailableInAnotherContextException;
|
||||
|
@ -43,6 +42,7 @@ import org.gcube.informationsystem.resourceregistry.queries.json.JsonQuery;
|
|||
import org.gcube.informationsystem.resourceregistry.types.TypeManagement;
|
||||
import org.gcube.informationsystem.types.TypeMapper;
|
||||
import org.gcube.informationsystem.types.reference.Type;
|
||||
import org.gcube.smartgears.utils.InnerMethodName;
|
||||
|
||||
import com.orientechnologies.orient.core.record.ODirection;
|
||||
|
||||
|
@ -68,7 +68,7 @@ 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.contexts.reference.entities.Context.NAME);
|
||||
CalledMethodProvider.instance.set("listContexts");
|
||||
InnerMethodName.instance.set("listContexts");
|
||||
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
return contextManagement.all(false);
|
||||
|
@ -87,7 +87,7 @@ public class Access extends BaseRest {
|
|||
uuid = ContextUtility.getCurrentSecurityContext().getUUID().toString();
|
||||
}
|
||||
logger.info("Requested to read {} with id {} ", org.gcube.informationsystem.contexts.reference.entities.Context.NAME, uuid);
|
||||
CalledMethodProvider.instance.set("readContext");
|
||||
InnerMethodName.instance.set("readContext");
|
||||
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
contextManagement.setUUID(UUID.fromString(uuid));
|
||||
|
@ -105,7 +105,7 @@ public class Access extends BaseRest {
|
|||
@QueryParam(TypePath.POLYMORPHIC_QUERY_PARAMETER) @DefaultValue("false") Boolean polymorphic)
|
||||
throws SchemaNotFoundException, ResourceRegistryException {
|
||||
logger.info("Requested Schema for type {}", type);
|
||||
CalledMethodProvider.instance.set("readType");
|
||||
InnerMethodName.instance.set("readType");
|
||||
|
||||
TypeManagement typeManagement = new TypeManagement();
|
||||
typeManagement.setTypeName(type);
|
||||
|
@ -129,7 +129,7 @@ public class Access extends BaseRest {
|
|||
@QueryParam(InstancePath.POLYMORPHIC_QUERY_PARAMETER) @DefaultValue("true") Boolean polymorphic)
|
||||
throws NotFoundException, ResourceRegistryException {
|
||||
logger.info("Requested all {}instances of {}", polymorphic ? InstancePath.POLYMORPHIC_QUERY_PARAMETER + " " : "", type);
|
||||
CalledMethodProvider.instance.set("listInstances");
|
||||
InnerMethodName.instance.set("listInstances");
|
||||
|
||||
checkHierarchicalMode();
|
||||
checkIncludeInstancesContexts();
|
||||
|
@ -149,7 +149,7 @@ public class Access extends BaseRest {
|
|||
public Response instanceExists(@PathParam(TypeManager.TYPE_PATH_PARAMETER) String type,
|
||||
@PathParam(InstancesManager.UUID_PATH_PARAMETER) String uuid) throws NotFoundException, ResourceRegistryException {
|
||||
logger.info("Requested to check if {} with id {} exists", type, uuid);
|
||||
CalledMethodProvider.instance.set("existInstance");
|
||||
InnerMethodName.instance.set("existInstance");
|
||||
|
||||
checkHierarchicalMode();
|
||||
checkIncludeInstancesContexts();
|
||||
|
@ -186,7 +186,7 @@ public class Access extends BaseRest {
|
|||
public String getInstance(@PathParam(TypeManager.TYPE_PATH_PARAMETER) String type,
|
||||
@PathParam(InstancesManager.UUID_PATH_PARAMETER) String uuid) throws NotFoundException, ResourceRegistryException {
|
||||
logger.info("Requested to read {} with id {}", type, uuid);
|
||||
CalledMethodProvider.instance.set("readInstance");
|
||||
InnerMethodName.instance.set("readInstance");
|
||||
|
||||
checkHierarchicalMode();
|
||||
checkIncludeInstancesContexts();
|
||||
|
@ -212,7 +212,7 @@ public class Access extends BaseRest {
|
|||
public String getInstanceContexts(@PathParam(TypeManager.TYPE_PATH_PARAMETER) String type,
|
||||
@PathParam(InstancesManager.UUID_PATH_PARAMETER) String instanceId) throws NotFoundException, ResourceRegistryException {
|
||||
logger.info("Requested to get contexts of {} with UUID {}", type, instanceId);
|
||||
CalledMethodProvider.instance.set("getInstanceContexts");
|
||||
InnerMethodName.instance.set("getInstanceContexts");
|
||||
|
||||
ElementManagement<?,?> erManagement = ElementManagementUtility.getERManagement(type);
|
||||
erManagement.setUUID(UUID.fromString(instanceId));
|
||||
|
@ -243,7 +243,7 @@ public class Access extends BaseRest {
|
|||
@QueryParam(AccessPath.RAW_QUERY_PARAMETER) @DefaultValue(AccessPath.RAW_QUERY_PARAMETER_DEFAULT_VALUE) Boolean raw)
|
||||
throws InvalidQueryException {
|
||||
logger.info("Requested query (Raw {}):\n{}", raw, query);
|
||||
CalledMethodProvider.instance.set("graphQuery");
|
||||
InnerMethodName.instance.set("graphQuery");
|
||||
|
||||
checkHierarchicalMode();
|
||||
checkIncludeInstancesContexts();
|
||||
|
@ -297,7 +297,7 @@ public class Access extends BaseRest {
|
|||
@Path(AccessPath.QUERY_PATH_PART)
|
||||
public String jsonQuery(String jsonQuery) throws InvalidQueryException, ResourceRegistryException {
|
||||
logger.info("Requested json query \n{}", jsonQuery);
|
||||
CalledMethodProvider.instance.set("jsonQuery");
|
||||
InnerMethodName.instance.set("jsonQuery");
|
||||
|
||||
checkHierarchicalMode();
|
||||
checkIncludeInstancesContexts();
|
||||
|
@ -348,7 +348,7 @@ public class Access extends BaseRest {
|
|||
logger.info("Requested {} instances having a(n) {} ({}={}} with {} ({}={}). Request URI is {})", resourcetype, relationType,
|
||||
AccessPath._DIRECTION_QUERY_PARAMETER, direction, referenceType, AccessPath._POLYMORPHIC_QUERY_PARAMETER, polymorphic, uriInfo.getRequestUri());
|
||||
|
||||
CalledMethodProvider.instance.set("query");
|
||||
InnerMethodName.instance.set("query");
|
||||
|
||||
checkHierarchicalMode();
|
||||
checkIncludeInstancesContexts();
|
||||
|
|
|
@ -13,7 +13,6 @@ import javax.ws.rs.core.MediaType;
|
|||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.CalledMethodProvider;
|
||||
import org.gcube.informationsystem.contexts.reference.entities.Context;
|
||||
import org.gcube.informationsystem.resourceregistry.ResourceInitializer;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
|
@ -21,6 +20,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.Cont
|
|||
import org.gcube.informationsystem.resourceregistry.api.rest.ContextPath;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.entities.ContextManagement;
|
||||
import org.gcube.smartgears.utils.InnerMethodName;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -51,7 +51,7 @@ 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);
|
||||
CalledMethodProvider.instance.set("listContexts");
|
||||
InnerMethodName.instance.set("listContexts");
|
||||
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
return contextManagement.all(false);
|
||||
|
@ -72,7 +72,7 @@ public class ContextManager {
|
|||
uuid = ContextUtility.getCurrentSecurityContext().getUUID().toString();
|
||||
}
|
||||
logger.info("Requested to read {} with id {} ", Context.NAME, uuid);
|
||||
CalledMethodProvider.instance.set("readContext");
|
||||
InnerMethodName.instance.set("readContext");
|
||||
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
contextManagement.setUUID(UUID.fromString(uuid));
|
||||
|
@ -93,7 +93,7 @@ public class ContextManager {
|
|||
public String updateCreate(@PathParam(ContextManager.CONTEXT_UUID_PATH_PARAMETER) String uuid, String json)
|
||||
throws ResourceRegistryException {
|
||||
logger.info("Requested to update/create {} with json {} ", Context.NAME, json);
|
||||
CalledMethodProvider.instance.set("updateContext");
|
||||
InnerMethodName.instance.set("updateContext");
|
||||
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
contextManagement.setUUID(UUID.fromString(uuid));
|
||||
|
@ -111,7 +111,7 @@ public class ContextManager {
|
|||
public Response delete(@PathParam(ContextManager.CONTEXT_UUID_PATH_PARAMETER) String uuid)
|
||||
throws ContextNotFoundException, ResourceRegistryException {
|
||||
logger.info("Requested to delete {} with id {} ", Context.NAME, uuid);
|
||||
CalledMethodProvider.instance.set("deleteContext");
|
||||
InnerMethodName.instance.set("deleteContext");
|
||||
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
contextManagement.setUUID(UUID.fromString(uuid));
|
||||
|
|
|
@ -16,7 +16,6 @@ import javax.ws.rs.core.MediaType;
|
|||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
||||
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;
|
||||
|
@ -27,6 +26,7 @@ import org.gcube.informationsystem.resourceregistry.api.rest.InstancePath;
|
|||
import org.gcube.informationsystem.resourceregistry.api.rest.SharingPath;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
||||
import org.gcube.smartgears.utils.InnerMethodName;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
|
@ -53,7 +53,7 @@ public class InstancesManager extends BaseRest {
|
|||
@QueryParam(InstancePath.POLYMORPHIC_QUERY_PARAMETER) @DefaultValue("true") Boolean polymorphic)
|
||||
throws NotFoundException, ResourceRegistryException {
|
||||
logger.info("Requested all {}instances of {}", polymorphic ? InstancePath.POLYMORPHIC_QUERY_PARAMETER + " " : "", type);
|
||||
CalledMethodProvider.instance.set("listInstances");
|
||||
InnerMethodName.instance.set("listInstances");
|
||||
|
||||
checkHierarchicalMode();
|
||||
checkIncludeInstancesContexts();
|
||||
|
@ -74,7 +74,7 @@ public class InstancesManager extends BaseRest {
|
|||
public Response exists(@PathParam(TypeManager.TYPE_PATH_PARAMETER) String type,
|
||||
@PathParam(InstancesManager.UUID_PATH_PARAMETER) String uuid) throws NotFoundException, ResourceRegistryException {
|
||||
logger.info("Requested to check if {} with id {} exists", type, uuid);
|
||||
CalledMethodProvider.instance.set("existInstance");
|
||||
InnerMethodName.instance.set("existInstance");
|
||||
|
||||
checkHierarchicalMode();
|
||||
checkIncludeInstancesContexts();
|
||||
|
@ -112,7 +112,7 @@ public class InstancesManager extends BaseRest {
|
|||
public String read(@PathParam(TypeManager.TYPE_PATH_PARAMETER) String type,
|
||||
@PathParam(InstancesManager.UUID_PATH_PARAMETER) String uuid) throws NotFoundException, ResourceRegistryException {
|
||||
logger.info("Requested to read {} with id {}", type, uuid);
|
||||
CalledMethodProvider.instance.set("readInstance");
|
||||
InnerMethodName.instance.set("readInstance");
|
||||
|
||||
checkHierarchicalMode();
|
||||
checkIncludeInstancesContexts();
|
||||
|
@ -138,7 +138,7 @@ public class InstancesManager extends BaseRest {
|
|||
@PathParam(InstancesManager.UUID_PATH_PARAMETER) 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);
|
||||
CalledMethodProvider.instance.set("updateInstance");
|
||||
InnerMethodName.instance.set("updateInstance");
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
|
||||
|
@ -158,7 +158,7 @@ public class InstancesManager extends BaseRest {
|
|||
public Response delete(@PathParam(TypeManager.TYPE_PATH_PARAMETER) String type,
|
||||
@PathParam(InstancesManager.UUID_PATH_PARAMETER) String uuid) throws ResourceRegistryException {
|
||||
logger.info("Requested to delete {} with id {}", type, uuid);
|
||||
CalledMethodProvider.instance.set("deleteInstance");
|
||||
InnerMethodName.instance.set("deleteInstance");
|
||||
|
||||
ElementManagement<?,?> erManagement = ElementManagementUtility.getERManagement(type);
|
||||
erManagement.setUUID(UUID.fromString(uuid));
|
||||
|
@ -185,7 +185,7 @@ public class InstancesManager extends BaseRest {
|
|||
@PathParam(ContextManager.CONTEXT_UUID_PATH_PARAMETER) String contextId)
|
||||
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
|
||||
logger.info("Requested to get contexts of {} with UUID {}", type, instanceId);
|
||||
CalledMethodProvider.instance.set("getInstanceContexts");
|
||||
InnerMethodName.instance.set("getInstanceContexts");
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
|
||||
|
|
|
@ -12,7 +12,6 @@ import javax.ws.rs.core.MediaType;
|
|||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.CalledMethodProvider;
|
||||
import org.gcube.informationsystem.queries.templates.reference.entities.QueryTemplate;
|
||||
import org.gcube.informationsystem.resourceregistry.ResourceInitializer;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
|
||||
|
@ -20,6 +19,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegis
|
|||
import org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.rest.QueryTemplatePath;
|
||||
import org.gcube.informationsystem.resourceregistry.queries.templates.QueryTemplateManagement;
|
||||
import org.gcube.smartgears.utils.InnerMethodName;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class QueryTemplateManager {
|
|||
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
||||
public String all() throws NotFoundException, ResourceRegistryException {
|
||||
logger.info("Requested to read all {}s", QueryTemplate.NAME);
|
||||
CalledMethodProvider.instance.set("listQueryTemplates");
|
||||
InnerMethodName.instance.set("listQueryTemplates");
|
||||
|
||||
QueryTemplateManagement queryTemplateManagement = new QueryTemplateManagement();
|
||||
return queryTemplateManagement.all(false);
|
||||
|
@ -84,7 +84,7 @@ public class QueryTemplateManager {
|
|||
public Response updateCreate(@PathParam(QueryTemplateManager.QUERY_TEMPLATE_NAME_PATH_PARAMETER) String queryTemplateName, String json)
|
||||
throws InvalidQueryException, ResourceRegistryException {
|
||||
logger.info("Requested {} creation with name {} and content {}", QueryTemplate.NAME, queryTemplateName, json);
|
||||
CalledMethodProvider.instance.set("createQueryTemplate");
|
||||
InnerMethodName.instance.set("createQueryTemplate");
|
||||
|
||||
QueryTemplateManagement queryTemplateManagement = new QueryTemplateManagement();
|
||||
queryTemplateManagement.setName(queryTemplateName);
|
||||
|
@ -104,7 +104,7 @@ public class QueryTemplateManager {
|
|||
public String read(@PathParam(QueryTemplateManager.QUERY_TEMPLATE_NAME_PATH_PARAMETER) String queryTemplateName)
|
||||
throws NotFoundException, ResourceRegistryException {
|
||||
logger.info("Requested {} with name", QueryTemplate.NAME, queryTemplateName);
|
||||
CalledMethodProvider.instance.set("readQueryTemplate");
|
||||
InnerMethodName.instance.set("readQueryTemplate");
|
||||
|
||||
QueryTemplateManagement queryTemplateManagement = new QueryTemplateManagement();
|
||||
queryTemplateManagement.setName(queryTemplateName);
|
||||
|
@ -125,7 +125,7 @@ public class QueryTemplateManager {
|
|||
public String run(@PathParam(QueryTemplateManager.QUERY_TEMPLATE_NAME_PATH_PARAMETER) String queryTemplateName, String params)
|
||||
throws NotFoundException, InvalidQueryException, ResourceRegistryException {
|
||||
logger.info("Requested {} with name", QueryTemplate.NAME, queryTemplateName);
|
||||
CalledMethodProvider.instance.set("readQueryTemplate");
|
||||
InnerMethodName.instance.set("readQueryTemplate");
|
||||
|
||||
QueryTemplateManagement queryTemplateManagement = new QueryTemplateManagement();
|
||||
queryTemplateManagement.setName(queryTemplateName);
|
||||
|
@ -144,7 +144,7 @@ public class QueryTemplateManager {
|
|||
public Response delete(@PathParam(QueryTemplateManager.QUERY_TEMPLATE_NAME_PATH_PARAMETER) String queryTemplateName)
|
||||
throws NotFoundException, ResourceRegistryException {
|
||||
logger.info("Requested to delete {} with name {} ", QueryTemplate.NAME, queryTemplateName);
|
||||
CalledMethodProvider.instance.set("deleteQueryTemplate");
|
||||
InnerMethodName.instance.set("deleteQueryTemplate");
|
||||
|
||||
QueryTemplateManagement queryTemplateManagement = new QueryTemplateManagement();
|
||||
queryTemplateManagement.setName(queryTemplateName);
|
||||
|
|
|
@ -9,13 +9,6 @@ import javax.ws.rs.container.ContainerResponseFilter;
|
|||
import javax.ws.rs.container.PreMatching;
|
||||
import javax.ws.rs.ext.Provider;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.AccessTokenProvider;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.authorization.utils.manager.SecretManager;
|
||||
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||
import org.gcube.common.authorization.utils.secret.GCubeSecret;
|
||||
import org.gcube.common.authorization.utils.secret.JWTSecret;
|
||||
import org.gcube.common.authorization.utils.secret.Secret;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -31,31 +24,12 @@ public class RequestFilter implements ContainerRequestFilter, ContainerResponseF
|
|||
@Override
|
||||
public void filter(ContainerRequestContext requestContext) throws IOException {
|
||||
logger.trace("PreMatching RequestFilter");
|
||||
|
||||
SecretManagerProvider.instance.reset();
|
||||
SecretManager secretManager = new SecretManager();
|
||||
|
||||
String token = AccessTokenProvider.instance.get();
|
||||
if(token!=null) {
|
||||
Secret secret = new JWTSecret(token);
|
||||
secretManager.addSecret(secret);
|
||||
}
|
||||
|
||||
token = SecurityTokenProvider.instance.get();
|
||||
if(token!=null) {
|
||||
Secret secret = new GCubeSecret(token);
|
||||
secretManager.addSecret(secret);
|
||||
}
|
||||
|
||||
SecretManagerProvider.instance.set(secretManager);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
|
||||
throws IOException {
|
||||
logger.trace("ResponseFilter");
|
||||
SecretManagerProvider.instance.reset();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ import org.gcube.com.fasterxml.jackson.core.JsonProcessingException;
|
|||
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.gcube.com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import org.gcube.common.authorization.library.provider.CalledMethodProvider;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||
import org.gcube.informationsystem.contexts.reference.entities.Context;
|
||||
|
@ -31,6 +30,7 @@ import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
|||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.ERManagement;
|
||||
import org.gcube.smartgears.utils.InnerMethodName;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -113,7 +113,7 @@ public class SharingManager {
|
|||
calledMethod.append("RemoveFromContext");
|
||||
}
|
||||
calledMethod.append("NoPropagationConstraint");
|
||||
CalledMethodProvider.instance.set(calledMethod.toString());
|
||||
InnerMethodName.instance.set(calledMethod.toString());
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
ArrayNode arrayNode = (ArrayNode) objectMapper.readTree(body);
|
||||
|
@ -191,7 +191,7 @@ 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());
|
||||
InnerMethodName.instance.set(calledMethod.toString());
|
||||
|
||||
|
||||
ElementManagement<?,?> elementManagement = ElementManagementUtility.getERManagement(type);
|
||||
|
|
|
@ -14,7 +14,6 @@ import javax.ws.rs.core.MediaType;
|
|||
import javax.ws.rs.core.Response;
|
||||
import javax.ws.rs.core.Response.Status;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.CalledMethodProvider;
|
||||
import org.gcube.informationsystem.resourceregistry.ResourceInitializer;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException;
|
||||
|
@ -24,6 +23,7 @@ import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
|||
import org.gcube.informationsystem.resourceregistry.types.TypeManagement;
|
||||
import org.gcube.informationsystem.types.TypeMapper;
|
||||
import org.gcube.informationsystem.types.reference.Type;
|
||||
import org.gcube.smartgears.utils.InnerMethodName;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -56,7 +56,7 @@ public class TypeManager {
|
|||
public Response create(@PathParam(TypeManager.TYPE_PATH_PARAMETER) String typeName, String json)
|
||||
throws SchemaException, ResourceRegistryException {
|
||||
logger.info("Requested {} creation with schema {}", typeName, json);
|
||||
CalledMethodProvider.instance.set("createType");
|
||||
InnerMethodName.instance.set("createType");
|
||||
|
||||
TypeManagement schemaManagement = new TypeManagement();
|
||||
schemaManagement.setTypeName(typeName);
|
||||
|
@ -78,7 +78,7 @@ public class TypeManager {
|
|||
@QueryParam(TypePath.POLYMORPHIC_QUERY_PARAMETER) @DefaultValue("false") Boolean polymorphic)
|
||||
throws SchemaNotFoundException, ResourceRegistryException {
|
||||
logger.info("Requested Schema for type {}", type);
|
||||
CalledMethodProvider.instance.set("readType");
|
||||
InnerMethodName.instance.set("readType");
|
||||
|
||||
TypeManagement schemaManagement = new TypeManagement();
|
||||
schemaManagement.setTypeName(type);
|
||||
|
|
|
@ -9,7 +9,7 @@ import java.util.UUID;
|
|||
import org.gcube.com.fasterxml.jackson.core.JsonParseException;
|
||||
import org.gcube.com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
|
@ -31,7 +31,7 @@ public class HeaderUtility {
|
|||
public static String getUser() {
|
||||
String user = Header.UNKNOWN_USER;
|
||||
try {
|
||||
user = SecretManagerProvider.instance.get().getUser().getUsername();
|
||||
user = SecretManagerProvider.instance.get().getOwner().getId();
|
||||
} catch(Exception e) {
|
||||
logger.error("Unable to retrieve user. {} will be used", user);
|
||||
}
|
||||
|
|
|
@ -7,25 +7,18 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.gcube.common.authorization.utils.manager.SecretManager;
|
||||
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||
import org.gcube.common.authorization.utils.secret.Secret;
|
||||
import org.gcube.common.authorization.utils.secret.SecretUtility;
|
||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.common.security.secrets.CredentialSecret;
|
||||
import org.gcube.common.security.secrets.Secret;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class ContextTest {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ContextTest.class);
|
||||
|
||||
protected static Properties properties;
|
||||
protected static final String PROPERTIES_FILENAME = "token.properties";
|
||||
protected static final String CONFIG_INI_FILENAME = "config.ini";
|
||||
|
||||
public static final String PARENT_DEFAULT_TEST_SCOPE;
|
||||
public static final String DEFAULT_TEST_SCOPE;
|
||||
|
@ -36,18 +29,16 @@ public class ContextTest {
|
|||
public static final String NEXTNEXT;
|
||||
public static final String DEVSEC;
|
||||
public static final String DEVVRE;
|
||||
|
||||
protected static final Properties properties;
|
||||
|
||||
protected static final String CLIENT_ID_PROPERTY_KEY = "client_id";
|
||||
protected static final String CLIENT_SECRET_PROPERTY_KEY = "client_secret";
|
||||
|
||||
protected static final String clientID;
|
||||
protected static final String clientSecret;
|
||||
|
||||
static {
|
||||
properties = new Properties();
|
||||
InputStream input = ContextTest.class.getClassLoader().getResourceAsStream(PROPERTIES_FILENAME);
|
||||
|
||||
try {
|
||||
// load the properties file
|
||||
properties.load(input);
|
||||
} catch(IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
GCUBE = "/gcube";
|
||||
DEVNEXT = GCUBE + "/devNext";
|
||||
NEXTNEXT = DEVNEXT + "/NextNext";
|
||||
|
@ -58,49 +49,40 @@ public class ContextTest {
|
|||
DEFAULT_TEST_SCOPE = DEVNEXT;
|
||||
ALTERNATIVE_TEST_SCOPE = NEXTNEXT;
|
||||
|
||||
properties = new Properties();
|
||||
InputStream input = ContextTest.class.getClassLoader().getResourceAsStream(CONFIG_INI_FILENAME);
|
||||
try {
|
||||
// load the properties file
|
||||
properties.load(input);
|
||||
|
||||
clientID = properties.getProperty(CLIENT_ID_PROPERTY_KEY);
|
||||
clientSecret = properties.getProperty(CLIENT_SECRET_PROPERTY_KEY);
|
||||
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void set(Secret secret) throws Exception {
|
||||
SecretManagerProvider.instance.reset();
|
||||
SecretManager secretManager = new SecretManager();
|
||||
secretManager.addSecret(secret);
|
||||
SecretManagerProvider.instance.set(secretManager);
|
||||
SecretManagerProvider.instance.get().set();
|
||||
SecretManagerProvider.instance.set(secret);
|
||||
}
|
||||
|
||||
public static void setContext(String token) throws Exception {
|
||||
Secret secret = getSecret(token);
|
||||
set(secret);
|
||||
}
|
||||
|
||||
public static void setContextByName(String fullContextName) throws Exception {
|
||||
Secret secret = getSecretByContextName(fullContextName);
|
||||
set(secret);
|
||||
}
|
||||
|
||||
private static Secret getSecret(String token) throws Exception {
|
||||
Secret secret = SecretUtility.getSecretByTokenString(token);
|
||||
return secret;
|
||||
}
|
||||
|
||||
private static Secret getSecretByContextName(String fullContextName) throws Exception {
|
||||
String token = ContextTest.properties.getProperty(fullContextName);
|
||||
return getSecret(token);
|
||||
}
|
||||
|
||||
public static String getUser() {
|
||||
String user = Header.UNKNOWN_USER;
|
||||
try {
|
||||
user = SecretManagerProvider.instance.get().getUser().getUsername();
|
||||
} catch(Exception e) {
|
||||
logger.error("Unable to retrieve user. {} will be used", user);
|
||||
}
|
||||
return user;
|
||||
CredentialSecret credentialSecret = new CredentialSecret(clientID, clientSecret, fullContextName);
|
||||
return credentialSecret;
|
||||
}
|
||||
|
||||
@BeforeClass
|
||||
public static void beforeClass() throws Exception {
|
||||
setContextByName(DEFAULT_TEST_SCOPE);
|
||||
setContextByName(DEVVRE);
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||
import org.gcube.informationsystem.model.impl.properties.EncryptedImpl;
|
||||
|
@ -524,7 +525,7 @@ public class ERManagementTest extends ContextTest {
|
|||
Assert.assertTrue(((String) updatedCpuFacet.getAdditionalProperty(additionPropertyKey))
|
||||
.compareTo((String) readCpuFacet.getAdditionalProperty(additionPropertyKey)) == 0);
|
||||
Assert.assertTrue(uuid.compareTo(updatedCpuFacet.getHeader().getUUID()) == 0);
|
||||
String user = ContextTest.getUser();
|
||||
String user = SecretManagerProvider.instance.get().getOwner().getId();
|
||||
Assert.assertTrue(updatedCpuFacet.getHeader().getLastUpdateBy().compareTo(user) == 0);
|
||||
|
||||
facetManagement = new FacetManagement();
|
||||
|
|
|
@ -9,7 +9,7 @@ import java.util.TreeSet;
|
|||
import java.util.UUID;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.contexts.reference.entities.Context;
|
||||
import org.gcube.informationsystem.model.reference.entities.Facet;
|
||||
|
|
|
@ -10,6 +10,7 @@ import org.gcube.com.fasterxml.jackson.databind.JavaType;
|
|||
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.gcube.com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.gcube.common.security.providers.SecretManagerProvider;
|
||||
import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
||||
import org.gcube.informationsystem.model.reference.properties.Header;
|
||||
import org.gcube.informationsystem.queries.templates.impl.entities.QueryTemplateImpl;
|
||||
|
@ -44,7 +45,7 @@ public class QueryTemplateManagementTest extends ContextTest {
|
|||
Assert.assertTrue(gotHeader != null);
|
||||
Assert.assertTrue(gotHeader.getUUID() != null);
|
||||
|
||||
String user = ContextTest.getUser();
|
||||
String user = SecretManagerProvider.instance.get().getOwner().getId();
|
||||
Assert.assertTrue(gotHeader.getLastUpdateBy().compareTo(user) == 0);
|
||||
|
||||
if(previousHeader != null) {
|
||||
|
|
Loading…
Reference in New Issue