Renaming SecurityContext in SystemEnvironment which is more clear
This commit is contained in:
parent
2360949ad3
commit
ae2ec3ca5d
|
@ -13,9 +13,10 @@ import org.gcube.informationsystem.contexts.reference.relations.IsParentOf;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.AdminSecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.AdminEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.InstanceEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.utils.OrientDBUtility;
|
import org.gcube.informationsystem.resourceregistry.utils.OrientDBUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.utils.UUIDUtility;
|
import org.gcube.informationsystem.resourceregistry.utils.UUIDUtility;
|
||||||
|
@ -36,7 +37,7 @@ public class ContextUtility {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(ContextUtility.class);
|
private static final Logger logger = LoggerFactory.getLogger(ContextUtility.class);
|
||||||
|
|
||||||
private Map<UUID,SecurityContext> contexts;
|
private Map<UUID,InstanceEnvironment> contexts;
|
||||||
|
|
||||||
private static ContextUtility contextUtility;
|
private static ContextUtility contextUtility;
|
||||||
|
|
||||||
|
@ -55,12 +56,12 @@ public class ContextUtility {
|
||||||
return SecretManagerProvider.instance.get().getContext();
|
return SecretManagerProvider.instance.get().getContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SecurityContext getCurrentSecurityContext() throws ResourceRegistryException {
|
public static SystemEnvironment getCurrentRequestEnvironment() throws ResourceRegistryException {
|
||||||
String fullName = getCurrentContextFullName();
|
String fullName = getCurrentContextFullName();
|
||||||
if(fullName == null) {
|
if(fullName == null) {
|
||||||
throw new ContextException("Null Token and Scope. Please set your token first.");
|
throw new ContextException("Null Token and Scope. Please set your token first.");
|
||||||
}
|
}
|
||||||
return ContextUtility.getInstance().getSecurityContextByFullName(fullName);
|
return ContextUtility.getInstance().getRequestEnvironmentByContextFullName(fullName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getCurrentUserUsername() {
|
public static String getCurrentUserUsername() {
|
||||||
|
@ -68,26 +69,26 @@ public class ContextUtility {
|
||||||
return sm.getUser().getUsername();
|
return sm.getUser().getUsername();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AdminSecurityContext getAdminSecurityContext() throws ResourceRegistryException {
|
public static AdminEnvironment getAdminSecurityContext() throws ResourceRegistryException {
|
||||||
AdminSecurityContext adminSecurityContext = AdminSecurityContext.getInstance();
|
AdminEnvironment adminSecurityContext = AdminEnvironment.getInstance();
|
||||||
return adminSecurityContext;
|
return adminSecurityContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void addSecurityContext(SecurityContext securityContext) {
|
public synchronized void addSecurityContext(InstanceEnvironment securityContext) {
|
||||||
contexts.put(securityContext.getUUID(), securityContext);
|
contexts.put(securityContext.getUUID(), securityContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void addSecurityContext(String fullname, SecurityContext securityContext) {
|
public synchronized void addSecurityContext(String fullname, InstanceEnvironment securityContext) {
|
||||||
contexts.put(securityContext.getUUID(), securityContext);
|
contexts.put(securityContext.getUUID(), securityContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized SecurityContext getSecurityContextByFullName(String fullName) throws ContextException {
|
public synchronized InstanceEnvironment getRequestEnvironmentByContextFullName(String fullName) throws ContextException {
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
ODatabaseDocument oDatabaseDocument = null;
|
ODatabaseDocument oDatabaseDocument = null;
|
||||||
try {
|
try {
|
||||||
SecurityContext securityContext = null;
|
InstanceEnvironment securityContext = null;
|
||||||
|
|
||||||
logger.trace("Trying to get {} for {}", SecurityContext.class.getSimpleName(), fullName);
|
logger.trace("Trying to get {} for {}", SystemEnvironment.class.getSimpleName(), fullName);
|
||||||
UUID uuid = ServerContextCache.getInstance().getUUIDByFullName(fullName);
|
UUID uuid = ServerContextCache.getInstance().getUUIDByFullName(fullName);
|
||||||
|
|
||||||
if(uuid != null) {
|
if(uuid != null) {
|
||||||
|
@ -95,7 +96,7 @@ public class ContextUtility {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(securityContext==null) {
|
if(securityContext==null) {
|
||||||
logger.trace("{} for {} is not in cache. Going to get it", SecurityContext.class.getSimpleName(),
|
logger.trace("{} for {} is not in cache. Going to get it", SystemEnvironment.class.getSimpleName(),
|
||||||
fullName);
|
fullName);
|
||||||
oDatabaseDocument = getAdminSecurityContext().getDatabaseDocument(PermissionMode.READER);
|
oDatabaseDocument = getAdminSecurityContext().getDatabaseDocument(PermissionMode.READER);
|
||||||
|
|
||||||
|
@ -103,7 +104,7 @@ public class ContextUtility {
|
||||||
|
|
||||||
uuid = UUIDUtility.getUUID(contextVertex);
|
uuid = UUIDUtility.getUUID(contextVertex);
|
||||||
|
|
||||||
securityContext = getSecurityContextByUUID(uuid, contextVertex);
|
securityContext = getEnvironmentByUUID(uuid, contextVertex);
|
||||||
|
|
||||||
addSecurityContext(fullName, securityContext);
|
addSecurityContext(fullName, securityContext);
|
||||||
|
|
||||||
|
@ -126,8 +127,8 @@ public class ContextUtility {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SecurityContext getSecurityContextByUUID(UUID uuid) throws ResourceRegistryException {
|
public InstanceEnvironment getEnvironmentByUUID(UUID uuid) throws ResourceRegistryException {
|
||||||
return getSecurityContextByUUID(uuid, null);
|
return getEnvironmentByUUID(uuid, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ODatabaseDocument getCurrentODatabaseDocumentFromThreadLocal() {
|
public static ODatabaseDocument getCurrentODatabaseDocumentFromThreadLocal() {
|
||||||
|
@ -140,24 +141,24 @@ public class ContextUtility {
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
private OVertex getContextVertexByUUID(UUID uuid) throws ResourceRegistryException {
|
// private OVertex getContextVertexByUUID(UUID uuid) throws ResourceRegistryException {
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
// ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
ODatabaseDocument oDatabaseDocument = null;
|
// ODatabaseDocument oDatabaseDocument = null;
|
||||||
try {
|
// try {
|
||||||
oDatabaseDocument = getAdminSecurityContext().getDatabaseDocument(PermissionMode.READER);
|
// oDatabaseDocument = getAdminSecurityContext().getDatabaseDocument(PermissionMode.READER);
|
||||||
OVertex oVertex = OrientDBUtility.getElementByUUID(oDatabaseDocument, Context.NAME, uuid,
|
// OVertex oVertex = OrientDBUtility.getElementByUUID(oDatabaseDocument, Context.NAME, uuid,
|
||||||
OVertex.class);
|
// OVertex.class);
|
||||||
return oVertex;
|
// return oVertex;
|
||||||
} finally {
|
// } finally {
|
||||||
if(oDatabaseDocument!=null) {
|
// if(oDatabaseDocument!=null) {
|
||||||
oDatabaseDocument.close();
|
// oDatabaseDocument.close();
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if(current!=null) {
|
// if(current!=null) {
|
||||||
current.activateOnCurrentThread();
|
// current.activateOnCurrentThread();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
// private OVertex getParentOfContextVertexByUUID(UUID uuid) throws ResourceRegistryException {
|
// private OVertex getParentOfContextVertexByUUID(UUID uuid) throws ResourceRegistryException {
|
||||||
// ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
// ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
|
@ -179,11 +180,11 @@ public class ContextUtility {
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
private SecurityContext getSecurityContextByUUID(UUID uuid, OVertex contextVertex) throws ResourceRegistryException {
|
private InstanceEnvironment getEnvironmentByUUID(UUID uuid, OVertex contextVertex) throws ResourceRegistryException {
|
||||||
SecurityContext securityContext = contexts.get(uuid);
|
InstanceEnvironment securityContext = contexts.get(uuid);
|
||||||
if(securityContext == null) {
|
if(securityContext == null) {
|
||||||
|
|
||||||
securityContext = new SecurityContext(uuid);
|
securityContext = new InstanceEnvironment(uuid);
|
||||||
|
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
ODatabaseDocument oDatabaseDocument = null;
|
ODatabaseDocument oDatabaseDocument = null;
|
||||||
|
@ -198,7 +199,7 @@ public class ContextUtility {
|
||||||
|
|
||||||
if(parentVertex != null) {
|
if(parentVertex != null) {
|
||||||
UUID parentUUID = UUIDUtility.getUUID(parentVertex);
|
UUID parentUUID = UUIDUtility.getUUID(parentVertex);
|
||||||
securityContext.setParentSecurityContext(getSecurityContextByUUID(parentUUID, parentVertex));
|
securityContext.setParentSecurityContext(getEnvironmentByUUID(parentUUID, parentVertex));
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch(NoSuchElementException e) {
|
} catch(NoSuchElementException e) {
|
||||||
|
|
|
@ -8,7 +8,6 @@ import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.ws.rs.BadRequestException;
|
|
||||||
import javax.ws.rs.ForbiddenException;
|
import javax.ws.rs.ForbiddenException;
|
||||||
import javax.ws.rs.NotAuthorizedException;
|
import javax.ws.rs.NotAuthorizedException;
|
||||||
|
|
||||||
|
@ -35,9 +34,11 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaV
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.ServerContextCache;
|
import org.gcube.informationsystem.resourceregistry.contexts.ServerContextCache;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.relations.IsParentOfManagement;
|
import org.gcube.informationsystem.resourceregistry.contexts.relations.IsParentOfManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.ContextSecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.ContextEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.InstanceEnvironment;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.entities.EntityElementManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.base.entities.EntityElementManagement;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.instances.model.Operation;
|
||||||
import org.gcube.informationsystem.resourceregistry.queries.operators.ComparisonOperator;
|
import org.gcube.informationsystem.resourceregistry.queries.operators.ComparisonOperator;
|
||||||
import org.gcube.informationsystem.resourceregistry.queries.operators.LogicalOperator;
|
import org.gcube.informationsystem.resourceregistry.queries.operators.LogicalOperator;
|
||||||
import org.gcube.informationsystem.resourceregistry.requests.RequestUtility;
|
import org.gcube.informationsystem.resourceregistry.requests.RequestUtility;
|
||||||
|
@ -94,7 +95,7 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
|
||||||
public ContextManagement(ODatabaseDocument oDatabaseDocument) throws ResourceRegistryException {
|
public ContextManagement(ODatabaseDocument oDatabaseDocument) throws ResourceRegistryException {
|
||||||
this();
|
this();
|
||||||
this.oDatabaseDocument = oDatabaseDocument;
|
this.oDatabaseDocument = oDatabaseDocument;
|
||||||
getWorkingContext();
|
getWorkingEnvironment();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -116,11 +117,11 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SecurityContext getWorkingContext() throws ResourceRegistryException {
|
protected SystemEnvironment getWorkingEnvironment() throws ResourceRegistryException {
|
||||||
if (workingContext == null) {
|
if (workingEnvironment == null) {
|
||||||
workingContext = ContextSecurityContext.getInstance();
|
workingEnvironment = ContextEnvironment.getInstance();
|
||||||
}
|
}
|
||||||
return workingContext;
|
return workingEnvironment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -266,12 +267,8 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
|
||||||
// return true;
|
// return true;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
/*
|
|
||||||
* The Context-Manager is allowed to operate in a context
|
|
||||||
* only if he is the Context-Manager of the context
|
|
||||||
*/
|
|
||||||
|
|
||||||
// TODO in subclass
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The Context-Manager is allowed to delete a context
|
* The Context-Manager is allowed to delete a context
|
||||||
|
@ -281,34 +278,34 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected OVertex reallyCreate() throws AlreadyPresentException, ResourceRegistryException {
|
protected OVertex reallyCreate() throws AlreadyPresentException, ResourceRegistryException {
|
||||||
SecurityContext securityContext = null;
|
InstanceEnvironment newInstanceEnvironment = null;
|
||||||
SecurityContext parentSecurityContext = null;
|
SystemEnvironment parentInstanceEnvironment = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
JsonNode isParentOfJsonNode = jsonNode.get(Context.PARENT_PROPERTY);
|
JsonNode isParentOfJsonNode = jsonNode.get(Context.PARENT_PROPERTY);
|
||||||
|
|
||||||
|
SystemEnvironment requestEnvironment = ContextUtility.getCurrentRequestEnvironment();
|
||||||
|
|
||||||
if (isParentOfJsonNode != null && !(isParentOfJsonNode instanceof NullNode)) {
|
if (isParentOfJsonNode != null && !(isParentOfJsonNode instanceof NullNode)) {
|
||||||
|
|
||||||
JsonNode parentJsonNode = isParentOfJsonNode.get(Relation.SOURCE_PROPERTY);
|
JsonNode parentJsonNode = isParentOfJsonNode.get(Relation.SOURCE_PROPERTY);
|
||||||
ContextManagement parentContextManagement = new ContextManagement(oDatabaseDocument);
|
ContextManagement parentContextManagement = new ContextManagement(oDatabaseDocument);
|
||||||
parentContextManagement.setJsonNode(parentJsonNode);
|
parentContextManagement.setJsonNode(parentJsonNode);
|
||||||
UUID parentUUID = parentContextManagement.uuid;
|
UUID parentUUID = parentContextManagement.uuid;
|
||||||
parentSecurityContext = ContextUtility.getInstance().getSecurityContextByUUID(parentUUID);
|
parentInstanceEnvironment = ContextUtility.getInstance().getEnvironmentByUUID(parentUUID);
|
||||||
|
|
||||||
SecurityContext requestSecurityContext = ContextUtility.getCurrentSecurityContext();
|
if(requestEnvironment.getUUID().compareTo(parentContextManagement.getUUID())==0) {
|
||||||
if(requestSecurityContext.getUUID().compareTo(parentContextManagement.getUUID())==0) {
|
Set<String> allowedRoles = requestEnvironment.getAllowedRoles();
|
||||||
Set<String> allowedRoles = SecurityContext.getAllowedRoles();
|
if(!parentInstanceEnvironment.isUserAllowed(allowedRoles)) {
|
||||||
if(!SecurityContext.isUserAllowed(allowedRoles)) {
|
throw new NotAuthorizedException("Only user with one of the following roles " + allowedRoles + " can create a child Context.");
|
||||||
throw new NotAuthorizedException("Only user with one of the following role " + allowedRoles + " can create a child Context.");
|
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
Set<String> allowedRoles = SecurityContext.getAllOperationsAllowedRoles();
|
Set<String> allowedRoles = SystemEnvironment.getAllOperationsAllowedRoles();
|
||||||
if(!SecurityContext.isUserAllowed(allowedRoles)) {
|
if(!requestEnvironment.isUserAllowed(allowedRoles)) {
|
||||||
throw new NotAuthorizedException("Only user with one of the following role " + allowedRoles + " can create a child Context requesting the operation from a Context which is not the parent.");
|
throw new NotAuthorizedException("Only user with one of the following roles " + allowedRoles + " can create a child Context requesting the operation from a Context which is not the parent.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
checkContext(parentContextManagement);
|
checkContext(parentContextManagement);
|
||||||
if (uuid == null) {
|
if (uuid == null) {
|
||||||
uuid = UUIDManager.getInstance().generateValidUUID();
|
uuid = UUIDManager.getInstance().generateValidUUID();
|
||||||
|
@ -325,7 +322,11 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
|
||||||
isParentOfManagement.internalCreate();
|
isParentOfManagement.internalCreate();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
SecurityContext.isUserAllowed(SecurityContext.getAllOperationsAllowedRoles());
|
// We are creating the root
|
||||||
|
Set<String> allowedRoles = SystemEnvironment.getAllOperationsAllowedRoles();
|
||||||
|
if(!requestEnvironment.isUserAllowed(allowedRoles)) {
|
||||||
|
throw new NotAuthorizedException("Only user with one of the following roles " + allowedRoles + " can create a root Context.");
|
||||||
|
}
|
||||||
checkContext(null);
|
checkContext(null);
|
||||||
logFullPath();
|
logFullPath();
|
||||||
createVertex();
|
createVertex();
|
||||||
|
@ -333,19 +334,20 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
|
||||||
|
|
||||||
this.element.setProperty(Context.STATE, ContextState.CREATED.getState());
|
this.element.setProperty(Context.STATE, ContextState.CREATED.getState());
|
||||||
|
|
||||||
securityContext = new SecurityContext(uuid);
|
|
||||||
securityContext.setParentSecurityContext(parentSecurityContext);
|
|
||||||
securityContext.create(oDatabaseDocument);
|
|
||||||
|
|
||||||
ContextUtility.getInstance().addSecurityContext(securityContext);
|
newInstanceEnvironment = new InstanceEnvironment(uuid);
|
||||||
|
newInstanceEnvironment.setParentSecurityContext(parentInstanceEnvironment);
|
||||||
|
newInstanceEnvironment.create(oDatabaseDocument);
|
||||||
|
|
||||||
|
ContextUtility.getInstance().addSecurityContext(newInstanceEnvironment);
|
||||||
|
|
||||||
return getElement();
|
return getElement();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
oDatabaseDocument.rollback();
|
oDatabaseDocument.rollback();
|
||||||
if (securityContext != null) {
|
if (newInstanceEnvironment != null) {
|
||||||
securityContext.delete(oDatabaseDocument);
|
newInstanceEnvironment.delete(oDatabaseDocument);
|
||||||
if (parentSecurityContext != null && securityContext != null) {
|
if (parentInstanceEnvironment != null && newInstanceEnvironment != null) {
|
||||||
parentSecurityContext.getChildren().remove(securityContext);
|
parentInstanceEnvironment.getChildren().remove(newInstanceEnvironment);
|
||||||
}
|
}
|
||||||
ServerContextCache.getInstance().cleanCache();
|
ServerContextCache.getInstance().cleanCache();
|
||||||
}
|
}
|
||||||
|
@ -458,7 +460,7 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
|
||||||
checkContext(newParentContextManagement);
|
checkContext(newParentContextManagement);
|
||||||
}
|
}
|
||||||
|
|
||||||
SecurityContext newParentSecurityContext = null;
|
SystemEnvironment newParentSecurityContext = null;
|
||||||
|
|
||||||
// Removing the old parent relationship if any
|
// Removing the old parent relationship if any
|
||||||
Iterable<OEdge> edges = getElement().getEdges(ODirection.IN, IsParentOf.NAME);
|
Iterable<OEdge> edges = getElement().getEdges(ODirection.IN, IsParentOf.NAME);
|
||||||
|
@ -483,17 +485,18 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
|
||||||
isParentOfManagement.setTargetEntityManagement(this);
|
isParentOfManagement.setTargetEntityManagement(this);
|
||||||
isParentOfManagement.internalCreate();
|
isParentOfManagement.internalCreate();
|
||||||
newParentSecurityContext = ContextUtility.getInstance()
|
newParentSecurityContext = ContextUtility.getInstance()
|
||||||
.getSecurityContextByUUID(newParentContextManagement.uuid);
|
.getEnvironmentByUUID(newParentContextManagement.uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
SecurityContext thisSecurityContext = ContextUtility.getInstance().getSecurityContextByUUID(uuid);
|
SystemEnvironment thisSecurityContext = ContextUtility.getInstance().getEnvironmentByUUID(uuid);
|
||||||
thisSecurityContext.changeParentSecurityContext(newParentSecurityContext, oDatabaseDocument);
|
thisSecurityContext.changeParentSecurityContext(newParentSecurityContext, oDatabaseDocument);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void reallyDelete() throws NotFoundException, ResourceRegistryException {
|
protected void reallyDelete() throws NotFoundException, ResourceRegistryException {
|
||||||
if(workingContext.isUserAllowed()) {
|
|
||||||
throw new ForbiddenException("You are not allowed to delete the Contexts. Allowed roles are " + SecurityContext.getAllOperationsAllowedRoles());
|
if(workingEnvironment.isUserAllowed(Operation.CREATE)) {
|
||||||
|
throw new ForbiddenException("You are not allowed to delete the Contexts. Allowed roles are " + SystemEnvironment.getAllOperationsAllowedRoles());
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterable<OEdge> iterable = getElement().getEdges(ODirection.OUT);
|
Iterable<OEdge> iterable = getElement().getEdges(ODirection.OUT);
|
||||||
|
@ -506,7 +509,7 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
|
||||||
element.delete();
|
element.delete();
|
||||||
|
|
||||||
ContextUtility contextUtility = ContextUtility.getInstance();
|
ContextUtility contextUtility = ContextUtility.getInstance();
|
||||||
SecurityContext securityContext = contextUtility.getSecurityContextByUUID(uuid);
|
SystemEnvironment securityContext = contextUtility.getEnvironmentByUUID(uuid);
|
||||||
securityContext.delete(oDatabaseDocument);
|
securityContext.delete(oDatabaseDocument);
|
||||||
|
|
||||||
ServerContextCache.getInstance().cleanCache();
|
ServerContextCache.getInstance().cleanCache();
|
||||||
|
@ -635,10 +638,10 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String createOrUpdate() throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
|
public String createOrUpdate() throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
|
||||||
if(workingContext.isUserAllowed()) {
|
if(workingEnvironment.isUserAllowed(Operation.CREATE)) {
|
||||||
return super.createOrUpdate();
|
return super.createOrUpdate();
|
||||||
}
|
}
|
||||||
throw new ForbiddenException("You are not allowed to manipulate Contexts. Allowed roles are " + SecurityContext.getAllOperationsAllowedRoles());
|
throw new ForbiddenException("You are not allowed to manipulate Contexts. Allowed roles are " + SystemEnvironment.getAllOperationsAllowedRoles());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -15,8 +15,8 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.relations.isp
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.relations.isparentof.IsParentOfNotFoundException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.relations.isparentof.IsParentOfNotFoundException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.entities.ContextManagement;
|
import org.gcube.informationsystem.resourceregistry.contexts.entities.ContextManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.ContextSecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.ContextEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.relations.RelationElementManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.base.relations.RelationElementManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.utils.OrientDBUtility;
|
import org.gcube.informationsystem.resourceregistry.utils.OrientDBUtility;
|
||||||
import org.gcube.informationsystem.types.reference.entities.EntityType;
|
import org.gcube.informationsystem.types.reference.entities.EntityType;
|
||||||
|
@ -37,7 +37,7 @@ public class IsParentOfManagement extends RelationElementManagement<ContextManag
|
||||||
public IsParentOfManagement(ODatabaseDocument oDatabaseDocument) throws ResourceRegistryException {
|
public IsParentOfManagement(ODatabaseDocument oDatabaseDocument) throws ResourceRegistryException {
|
||||||
this();
|
this();
|
||||||
this.oDatabaseDocument = oDatabaseDocument;
|
this.oDatabaseDocument = oDatabaseDocument;
|
||||||
getWorkingContext();
|
getWorkingEnvironment();
|
||||||
this.includeSource = false;
|
this.includeSource = false;
|
||||||
this.includeTarget = true;
|
this.includeTarget = true;
|
||||||
this.forceIncludeMeta = true;
|
this.forceIncludeMeta = true;
|
||||||
|
@ -50,11 +50,11 @@ public class IsParentOfManagement extends RelationElementManagement<ContextManag
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SecurityContext getWorkingContext() throws ResourceRegistryException {
|
protected SystemEnvironment getWorkingEnvironment() throws ResourceRegistryException {
|
||||||
if (workingContext == null) {
|
if (workingEnvironment == null) {
|
||||||
workingContext = ContextSecurityContext.getInstance();
|
workingEnvironment = ContextEnvironment.getInstance();
|
||||||
}
|
}
|
||||||
return workingContext;
|
return workingEnvironment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -23,11 +23,11 @@ import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||||
import org.gcube.informationsystem.model.reference.properties.Property;
|
import org.gcube.informationsystem.model.reference.properties.Property;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaAlreadyPresentException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaAlreadyPresentException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.ServerContextCache;
|
import org.gcube.informationsystem.resourceregistry.contexts.ServerContextCache;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.AdminSecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.AdminEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.ContextSecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.ContextEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.QueryTemplatesSecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.QueryTemplateEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode;
|
import org.gcube.informationsystem.resourceregistry.environments.TypeEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.TypeSecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.types.TypeManagement;
|
import org.gcube.informationsystem.resourceregistry.types.TypeManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.types.properties.PropertyTypeDefinitionManagement;
|
import org.gcube.informationsystem.resourceregistry.types.properties.PropertyTypeDefinitionManagement;
|
||||||
|
@ -178,14 +178,14 @@ public class DatabaseEnvironment {
|
||||||
ODatabasePool pool = new ODatabasePool(DatabaseEnvironment.DB_URI, CHANGED_ADMIN_USERNAME,
|
ODatabasePool pool = new ODatabasePool(DatabaseEnvironment.DB_URI, CHANGED_ADMIN_USERNAME,
|
||||||
CHANGED_ADMIN_PASSWORD);
|
CHANGED_ADMIN_PASSWORD);
|
||||||
ODatabaseDocument oDatabaseDocument = pool.acquire();
|
ODatabaseDocument oDatabaseDocument = pool.acquire();
|
||||||
AdminSecurityContext.getInstance().create(oDatabaseDocument);
|
AdminEnvironment.getInstance().create(oDatabaseDocument);
|
||||||
oDatabaseDocument.commit();
|
oDatabaseDocument.commit();
|
||||||
oDatabaseDocument.close();
|
oDatabaseDocument.close();
|
||||||
pool.close();
|
pool.close();
|
||||||
|
|
||||||
QueryTemplatesSecurityContext.getInstance().create();
|
QueryTemplateEnvironment.getInstance().create();
|
||||||
TypeSecurityContext.getInstance().create();
|
TypeEnvironment.getInstance().create();
|
||||||
ContextSecurityContext.getInstance().create();
|
ContextEnvironment.getInstance().create();
|
||||||
|
|
||||||
/* We must create only OrientDB types */
|
/* We must create only OrientDB types */
|
||||||
List<Class<? extends Element>> definitionToBeCreated = new ArrayList<>();
|
List<Class<? extends Element>> definitionToBeCreated = new ArrayList<>();
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
package org.gcube.informationsystem.resourceregistry.contexts.security;
|
package org.gcube.informationsystem.resourceregistry.environments;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
|
||||||
import org.gcube.informationsystem.resourceregistry.dbinitialization.DatabaseEnvironment;
|
import org.gcube.informationsystem.resourceregistry.dbinitialization.DatabaseEnvironment;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -15,9 +14,9 @@ import com.orientechnologies.orient.core.metadata.security.OSecurity;
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
public class AdminSecurityContext extends SecurityContext {
|
public class AdminEnvironment extends SystemEnvironment {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(SecurityContext.class);
|
private static Logger logger = LoggerFactory.getLogger(SystemEnvironment.class);
|
||||||
|
|
||||||
private static final String ADMIN_SECURITY_CONTEXT;
|
private static final String ADMIN_SECURITY_CONTEXT;
|
||||||
private static final UUID ADMIN_SECURITY_CONTEXT_UUID;
|
private static final UUID ADMIN_SECURITY_CONTEXT_UUID;
|
||||||
|
@ -27,25 +26,23 @@ public class AdminSecurityContext extends SecurityContext {
|
||||||
ADMIN_SECURITY_CONTEXT_UUID = UUID.fromString(ADMIN_SECURITY_CONTEXT);
|
ADMIN_SECURITY_CONTEXT_UUID = UUID.fromString(ADMIN_SECURITY_CONTEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static AdminSecurityContext instance;
|
private static AdminEnvironment instance;
|
||||||
|
|
||||||
public static AdminSecurityContext getInstance() throws ResourceRegistryException {
|
public static AdminEnvironment getInstance() throws ResourceRegistryException {
|
||||||
if(instance==null) {
|
if(instance==null) {
|
||||||
instance = new AdminSecurityContext();
|
instance = new AdminEnvironment();
|
||||||
ContextUtility contextUtility = ContextUtility.getInstance();
|
|
||||||
contextUtility.addSecurityContext(ADMIN_SECURITY_CONTEXT, instance);
|
|
||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private AdminSecurityContext() throws ResourceRegistryException {
|
private AdminEnvironment() throws ResourceRegistryException {
|
||||||
super(ADMIN_SECURITY_CONTEXT_UUID, false);
|
super(ADMIN_SECURITY_CONTEXT_UUID, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
protected boolean isHierarchicalMode() {
|
// protected boolean isHierarchicalMode() {
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void create() {
|
public void create() {
|
|
@ -1,9 +1,8 @@
|
||||||
package org.gcube.informationsystem.resourceregistry.contexts.security;
|
package org.gcube.informationsystem.resourceregistry.environments;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -13,9 +12,9 @@ import com.orientechnologies.orient.core.metadata.security.ORule;
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
public class ContextSecurityContext extends SecurityContext {
|
public class ContextEnvironment extends SystemEnvironment {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(SecurityContext.class);
|
private static Logger logger = LoggerFactory.getLogger(SystemEnvironment.class);
|
||||||
|
|
||||||
private static final String CONTEXT_SECURITY_CONTEXT;
|
private static final String CONTEXT_SECURITY_CONTEXT;
|
||||||
private static final UUID CONTEXT_SECURITY_CONTEXT_UUID;
|
private static final UUID CONTEXT_SECURITY_CONTEXT_UUID;
|
||||||
|
@ -25,18 +24,16 @@ public class ContextSecurityContext extends SecurityContext {
|
||||||
CONTEXT_SECURITY_CONTEXT_UUID = UUID.fromString(CONTEXT_SECURITY_CONTEXT);
|
CONTEXT_SECURITY_CONTEXT_UUID = UUID.fromString(CONTEXT_SECURITY_CONTEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ContextSecurityContext instance;
|
private static ContextEnvironment instance;
|
||||||
|
|
||||||
public static ContextSecurityContext getInstance() throws ResourceRegistryException {
|
public static ContextEnvironment getInstance() throws ResourceRegistryException {
|
||||||
if(instance==null) {
|
if(instance==null) {
|
||||||
instance = new ContextSecurityContext();
|
instance = new ContextEnvironment();
|
||||||
ContextUtility contextUtility = ContextUtility.getInstance();
|
|
||||||
contextUtility.addSecurityContext(CONTEXT_SECURITY_CONTEXT, instance);
|
|
||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ContextSecurityContext() throws ResourceRegistryException {
|
private ContextEnvironment() throws ResourceRegistryException {
|
||||||
super(CONTEXT_SECURITY_CONTEXT_UUID, false);
|
super(CONTEXT_SECURITY_CONTEXT_UUID, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
package org.gcube.informationsystem.resourceregistry.environments;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
|
*/
|
||||||
|
public class InstanceEnvironment extends SystemEnvironment {
|
||||||
|
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(InstanceEnvironment.class);
|
||||||
|
|
||||||
|
public InstanceEnvironment(UUID uuid) throws ResourceRegistryException {
|
||||||
|
super(uuid, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -1,9 +1,8 @@
|
||||||
package org.gcube.informationsystem.resourceregistry.contexts.security;
|
package org.gcube.informationsystem.resourceregistry.environments;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -13,9 +12,9 @@ import com.orientechnologies.orient.core.metadata.security.ORule;
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
public class QueryTemplatesSecurityContext extends SecurityContext {
|
public class QueryTemplateEnvironment extends SystemEnvironment {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(SecurityContext.class);
|
private static Logger logger = LoggerFactory.getLogger(SystemEnvironment.class);
|
||||||
|
|
||||||
private static final String QUERY_TEMPLATES_SECURITY_CONTEXT;
|
private static final String QUERY_TEMPLATES_SECURITY_CONTEXT;
|
||||||
private static final UUID QUERY_TEMPLATES_SECURITY_CONTEXT_UUID;
|
private static final UUID QUERY_TEMPLATES_SECURITY_CONTEXT_UUID;
|
||||||
|
@ -25,18 +24,16 @@ public class QueryTemplatesSecurityContext extends SecurityContext {
|
||||||
QUERY_TEMPLATES_SECURITY_CONTEXT_UUID = UUID.fromString(QUERY_TEMPLATES_SECURITY_CONTEXT);
|
QUERY_TEMPLATES_SECURITY_CONTEXT_UUID = UUID.fromString(QUERY_TEMPLATES_SECURITY_CONTEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static QueryTemplatesSecurityContext instance;
|
private static QueryTemplateEnvironment instance;
|
||||||
|
|
||||||
public static QueryTemplatesSecurityContext getInstance() throws ResourceRegistryException {
|
public static QueryTemplateEnvironment getInstance() throws ResourceRegistryException {
|
||||||
if(instance==null) {
|
if(instance==null) {
|
||||||
instance = new QueryTemplatesSecurityContext();
|
instance = new QueryTemplateEnvironment();
|
||||||
ContextUtility contextUtility = ContextUtility.getInstance();
|
|
||||||
contextUtility.addSecurityContext(QUERY_TEMPLATES_SECURITY_CONTEXT, instance);
|
|
||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private QueryTemplatesSecurityContext() throws ResourceRegistryException {
|
private QueryTemplateEnvironment() throws ResourceRegistryException {
|
||||||
super(QUERY_TEMPLATES_SECURITY_CONTEXT_UUID, false);
|
super(QUERY_TEMPLATES_SECURITY_CONTEXT_UUID, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
package org.gcube.informationsystem.resourceregistry.contexts.security;
|
package org.gcube.informationsystem.resourceregistry.environments;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -14,9 +13,9 @@ import com.orientechnologies.orient.core.metadata.security.ORule;
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
* Added for feature #19428
|
* Added for feature #19428
|
||||||
*/
|
*/
|
||||||
public class ShadowContextSecurityContext extends SecurityContext {
|
public class ShadowContextEnvironment extends SystemEnvironment {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(SecurityContext.class);
|
private static Logger logger = LoggerFactory.getLogger(SystemEnvironment.class);
|
||||||
|
|
||||||
private static final String SHADOW_CONTEXT_SECURITY_CONTEXT;
|
private static final String SHADOW_CONTEXT_SECURITY_CONTEXT;
|
||||||
private static final UUID SHADOW_CONTEXT_SECURITY_CONTEXT_UUID;
|
private static final UUID SHADOW_CONTEXT_SECURITY_CONTEXT_UUID;
|
||||||
|
@ -28,18 +27,16 @@ public class ShadowContextSecurityContext extends SecurityContext {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ShadowContextSecurityContext instance;
|
private static ShadowContextEnvironment instance;
|
||||||
|
|
||||||
public static ShadowContextSecurityContext getInstance() throws ResourceRegistryException {
|
public static ShadowContextEnvironment getInstance() throws ResourceRegistryException {
|
||||||
if(instance==null) {
|
if(instance==null) {
|
||||||
instance = new ShadowContextSecurityContext();
|
instance = new ShadowContextEnvironment();
|
||||||
ContextUtility contextUtility = ContextUtility.getInstance();
|
|
||||||
contextUtility.addSecurityContext(SHADOW_CONTEXT_SECURITY_CONTEXT, instance);
|
|
||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private ShadowContextSecurityContext() throws ResourceRegistryException {
|
private ShadowContextEnvironment() throws ResourceRegistryException {
|
||||||
super(SHADOW_CONTEXT_SECURITY_CONTEXT_UUID, false);
|
super(SHADOW_CONTEXT_SECURITY_CONTEXT_UUID, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.gcube.informationsystem.resourceregistry.contexts.security;
|
package org.gcube.informationsystem.resourceregistry.environments;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
@ -45,9 +45,9 @@ import com.orientechnologies.orient.core.record.impl.ODocument;
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
public class SecurityContext {
|
public abstract class SystemEnvironment {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(SecurityContext.class);
|
private static Logger logger = LoggerFactory.getLogger(SystemEnvironment.class);
|
||||||
|
|
||||||
protected static final String DEFAULT_WRITER_ROLE = "writer";
|
protected static final String DEFAULT_WRITER_ROLE = "writer";
|
||||||
protected static final String DEFAULT_READER_ROLE = "reader";
|
protected static final String DEFAULT_READER_ROLE = "reader";
|
||||||
|
@ -91,15 +91,15 @@ public class SecurityContext {
|
||||||
|
|
||||||
protected final Map<Boolean,Map<PermissionMode,ODatabasePool>> poolMap;
|
protected final Map<Boolean,Map<PermissionMode,ODatabasePool>> poolMap;
|
||||||
|
|
||||||
protected SecurityContext parentSecurityContext;
|
protected SystemEnvironment parentSecurityContext;
|
||||||
|
|
||||||
protected Set<SecurityContext> children;
|
protected Set<SystemEnvironment> children;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Roles allowed to operate on the security context
|
* Roles allowed to operate on the security context
|
||||||
*/
|
*/
|
||||||
protected static Set<String> allOperationAllowedRoles;
|
protected static Set<String> allOperationAllowedRoles;
|
||||||
//protected static Set<String> allowedRoles;
|
protected Set<String> allowedRoles;
|
||||||
|
|
||||||
public final static String INFRASTRUCTURE_MANAGER = "Infrastructure-Manager";
|
public final static String INFRASTRUCTURE_MANAGER = "Infrastructure-Manager";
|
||||||
public final static String IS_MANAGER = "IS-Manager";
|
public final static String IS_MANAGER = "IS-Manager";
|
||||||
|
@ -107,27 +107,27 @@ public class SecurityContext {
|
||||||
public final static String CONTEXT_MANAGER = "Context-Manager";
|
public final static String CONTEXT_MANAGER = "Context-Manager";
|
||||||
|
|
||||||
static {
|
static {
|
||||||
allOperationAllowedRoles = new HashSet<>();
|
SystemEnvironment.allOperationAllowedRoles = new HashSet<>();
|
||||||
allOperationAllowedRoles.add(INFRASTRUCTURE_MANAGER);
|
SystemEnvironment.allOperationAllowedRoles.add(INFRASTRUCTURE_MANAGER);
|
||||||
allOperationAllowedRoles.add(IS_MANAGER);
|
SystemEnvironment.allOperationAllowedRoles.add(IS_MANAGER);
|
||||||
|
|
||||||
// allowedRoles = new HashSet<>();
|
|
||||||
// allowedRoles.add(CONTEXT_MANAGER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Set<String> getAllOperationsAllowedRoles() {
|
public static Set<String> getAllOperationsAllowedRoles() {
|
||||||
return new HashSet<>(allOperationAllowedRoles);
|
return new HashSet<>(allOperationAllowedRoles);
|
||||||
}
|
}
|
||||||
|
|
||||||
// public static Set<String> getAllowedRoles() {
|
public Set<String> getAllowedRoles() {
|
||||||
// return new HashSet<>(allowedRoles);
|
return new HashSet<>(allowedRoles);
|
||||||
// }
|
}
|
||||||
|
|
||||||
protected SecurityContext(UUID context, boolean hierarchical) throws ResourceRegistryException {
|
protected SystemEnvironment(UUID context, boolean hierarchical) throws ResourceRegistryException {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.poolMap = new HashMap<>();
|
this.poolMap = new HashMap<>();
|
||||||
|
|
||||||
boolean hierarchicalAllowed = SecurityContext.isUserAllowed(allOperationAllowedRoles);
|
this.allowedRoles = new HashSet<>(SystemEnvironment.allOperationAllowedRoles);
|
||||||
|
this.allowedRoles.add(CONTEXT_MANAGER);
|
||||||
|
|
||||||
|
boolean hierarchicalAllowed = SystemEnvironment.isUserAllowed(allOperationAllowedRoles);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Only the Infrastructure Manager and IS Manager are entitled to use hierarchical mode.
|
* Only the Infrastructure Manager and IS Manager are entitled to use hierarchical mode.
|
||||||
|
@ -146,18 +146,13 @@ public class SecurityContext {
|
||||||
|
|
||||||
this.children = new HashSet<>();
|
this.children = new HashSet<>();
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public SecurityContext(UUID context) throws ResourceRegistryException {
|
|
||||||
this(context, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isHierarchicalMode() {
|
protected boolean isHierarchicalMode() {
|
||||||
return hierarchical || RequestUtility.getRequestInfo().get().isHierarchicalMode();
|
return hierarchical || RequestUtility.getRequestInfo().get().isHierarchicalMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParentSecurityContext(SecurityContext parentSecurityContext) {
|
public void setParentSecurityContext(SystemEnvironment parentSecurityContext) {
|
||||||
if(this.parentSecurityContext!=null) {
|
if(this.parentSecurityContext!=null) {
|
||||||
this.parentSecurityContext.getChildren().remove(this);
|
this.parentSecurityContext.getChildren().remove(this);
|
||||||
}
|
}
|
||||||
|
@ -168,15 +163,15 @@ public class SecurityContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SecurityContext getParentSecurityContext() {
|
public SystemEnvironment getParentSecurityContext() {
|
||||||
return parentSecurityContext;
|
return parentSecurityContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addChild(SecurityContext child) {
|
private void addChild(SystemEnvironment child) {
|
||||||
this.children.add(child);
|
this.children.add(child);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<SecurityContext> getChildren(){
|
public Set<SystemEnvironment> getChildren(){
|
||||||
return this.children;
|
return this.children;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,10 +183,10 @@ public class SecurityContext {
|
||||||
* @return a set containing all children and recursively
|
* @return a set containing all children and recursively
|
||||||
* all children.
|
* all children.
|
||||||
*/
|
*/
|
||||||
private Set<SecurityContext> getAllChildren(){
|
private Set<SystemEnvironment> getAllChildren(){
|
||||||
Set<SecurityContext> allChildren = new HashSet<>();
|
Set<SystemEnvironment> allChildren = new HashSet<>();
|
||||||
allChildren.add(this);
|
allChildren.add(this);
|
||||||
for(SecurityContext securityContext : getChildren()) {
|
for(SystemEnvironment securityContext : getChildren()) {
|
||||||
allChildren.addAll(securityContext.getAllChildren());
|
allChildren.addAll(securityContext.getAllChildren());
|
||||||
}
|
}
|
||||||
return allChildren;
|
return allChildren;
|
||||||
|
@ -200,9 +195,9 @@ public class SecurityContext {
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private Set<SecurityContext> getAllParents(){
|
private Set<SystemEnvironment> getAllParents(){
|
||||||
Set<SecurityContext> allParents = new HashSet<>();
|
Set<SystemEnvironment> allParents = new HashSet<>();
|
||||||
SecurityContext parent = getParentSecurityContext();
|
SystemEnvironment parent = getParentSecurityContext();
|
||||||
while(parent!=null) {
|
while(parent!=null) {
|
||||||
allParents.add(parent);
|
allParents.add(parent);
|
||||||
parent = parent.getParentSecurityContext();
|
parent = parent.getParentSecurityContext();
|
||||||
|
@ -218,13 +213,13 @@ public class SecurityContext {
|
||||||
* @param orientGraph
|
* @param orientGraph
|
||||||
* @throws ResourceRegistryException
|
* @throws ResourceRegistryException
|
||||||
*/
|
*/
|
||||||
public void changeParentSecurityContext(SecurityContext newParentSecurityContext, ODatabaseDocument orientGraph) throws ResourceRegistryException {
|
public void changeParentSecurityContext(SystemEnvironment newParentSecurityContext, ODatabaseDocument orientGraph) throws ResourceRegistryException {
|
||||||
if(!hierarchical) {
|
if(!hierarchical) {
|
||||||
StringBuilder errorMessage = new StringBuilder();
|
StringBuilder errorMessage = new StringBuilder();
|
||||||
errorMessage.append("Cannot change parent ");
|
errorMessage.append("Cannot change parent ");
|
||||||
errorMessage.append(SecurityContext.class.getSimpleName());
|
errorMessage.append(SystemEnvironment.class.getSimpleName());
|
||||||
errorMessage.append(" to non hierarchic ");
|
errorMessage.append(" to non hierarchic ");
|
||||||
errorMessage.append(SecurityContext.class.getSimpleName());
|
errorMessage.append(SystemEnvironment.class.getSimpleName());
|
||||||
errorMessage.append(". ");
|
errorMessage.append(". ");
|
||||||
errorMessage.append(OrientDBUtility.SHOULD_NOT_OCCUR_ERROR_MESSAGE);
|
errorMessage.append(OrientDBUtility.SHOULD_NOT_OCCUR_ERROR_MESSAGE);
|
||||||
final String error = errorMessage.toString();
|
final String error = errorMessage.toString();
|
||||||
|
@ -234,11 +229,11 @@ public class SecurityContext {
|
||||||
|
|
||||||
OSecurity oSecurity = getOSecurity(orientGraph);
|
OSecurity oSecurity = getOSecurity(orientGraph);
|
||||||
|
|
||||||
Set<SecurityContext> allChildren = getAllChildren();
|
Set<SystemEnvironment> allChildren = getAllChildren();
|
||||||
|
|
||||||
Set<SecurityContext> oldParents = getAllParents();
|
Set<SystemEnvironment> oldParents = getAllParents();
|
||||||
|
|
||||||
Set<SecurityContext> newParents = new HashSet<>();
|
Set<SystemEnvironment> newParents = new HashSet<>();
|
||||||
if(newParentSecurityContext!=null) {
|
if(newParentSecurityContext!=null) {
|
||||||
newParents = newParentSecurityContext.getAllParents();
|
newParents = newParentSecurityContext.getAllParents();
|
||||||
}
|
}
|
||||||
|
@ -258,7 +253,7 @@ public class SecurityContext {
|
||||||
if(newParentSecurityContext!=null){
|
if(newParentSecurityContext!=null){
|
||||||
for(PermissionMode permissionMode : PermissionMode.values()) {
|
for(PermissionMode permissionMode : PermissionMode.values()) {
|
||||||
List<ORole> roles = new ArrayList<>();
|
List<ORole> roles = new ArrayList<>();
|
||||||
for(SecurityContext child : allChildren) {
|
for(SystemEnvironment child : allChildren) {
|
||||||
String roleName = child.getSecurityRoleOrUserName(permissionMode, SecurityType.ROLE, true);
|
String roleName = child.getSecurityRoleOrUserName(permissionMode, SecurityType.ROLE, true);
|
||||||
ORole role = oSecurity.getRole(roleName);
|
ORole role = oSecurity.getRole(roleName);
|
||||||
roles.add(role);
|
roles.add(role);
|
||||||
|
@ -272,7 +267,7 @@ public class SecurityContext {
|
||||||
private synchronized ODatabasePool getPool(PermissionMode permissionMode, boolean recreate) {
|
private synchronized ODatabasePool getPool(PermissionMode permissionMode, boolean recreate) {
|
||||||
ODatabasePool pool = null;
|
ODatabasePool pool = null;
|
||||||
|
|
||||||
Boolean h = isHierarchicalMode();
|
Boolean h = hierarchical || RequestUtility.getRequestInfo().get().isHierarchicalMode();
|
||||||
|
|
||||||
Map<PermissionMode,ODatabasePool> pools = poolMap.get(h);
|
Map<PermissionMode,ODatabasePool> pools = poolMap.get(h);
|
||||||
if(pools == null) {
|
if(pools == null) {
|
||||||
|
@ -504,7 +499,7 @@ public class SecurityContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isUserAllowed() {
|
public boolean isUserAllowed(Collection<String> allowedRoles) {
|
||||||
boolean allowed = false;
|
boolean allowed = false;
|
||||||
SecretManager secretManager = SecretManagerProvider.instance.get();
|
SecretManager secretManager = SecretManagerProvider.instance.get();
|
||||||
User user = secretManager.getUser();
|
User user = secretManager.getUser();
|
||||||
|
@ -675,22 +670,22 @@ public class SecurityContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void removeChildrenHRolesFromParents(OSecurity oSecurity) {
|
protected void removeChildrenHRolesFromParents(OSecurity oSecurity) {
|
||||||
Set<SecurityContext> parents = getAllParents();
|
Set<SystemEnvironment> parents = getAllParents();
|
||||||
Set<SecurityContext> allChildren = getAllChildren();
|
Set<SystemEnvironment> allChildren = getAllChildren();
|
||||||
removeChildrenHRolesFromParents(oSecurity, parents, allChildren);
|
removeChildrenHRolesFromParents(oSecurity, parents, allChildren);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void removeChildrenHRolesFromParents(OSecurity oSecurity, Set<SecurityContext> parents, Set<SecurityContext> children) {
|
protected void removeChildrenHRolesFromParents(OSecurity oSecurity, Set<SystemEnvironment> parents, Set<SystemEnvironment> children) {
|
||||||
for(SecurityContext parent : parents) {
|
for(SystemEnvironment parent : parents) {
|
||||||
parent.removeChildrenHRolesFromMyHUsers(oSecurity, children);
|
parent.removeChildrenHRolesFromMyHUsers(oSecurity, children);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void removeChildrenHRolesFromMyHUsers(OSecurity oSecurity, Set<SecurityContext> children) {
|
protected void removeChildrenHRolesFromMyHUsers(OSecurity oSecurity, Set<SystemEnvironment> children) {
|
||||||
for(PermissionMode permissionMode : PermissionMode.values()) {
|
for(PermissionMode permissionMode : PermissionMode.values()) {
|
||||||
String userName = getSecurityRoleOrUserName(permissionMode, SecurityType.USER, true);
|
String userName = getSecurityRoleOrUserName(permissionMode, SecurityType.USER, true);
|
||||||
OUser user = oSecurity.getUser(userName);
|
OUser user = oSecurity.getUser(userName);
|
||||||
for(SecurityContext child : children) {
|
for(SystemEnvironment child : children) {
|
||||||
String roleName = child.getSecurityRoleOrUserName(permissionMode, SecurityType.ROLE, true);
|
String roleName = child.getSecurityRoleOrUserName(permissionMode, SecurityType.ROLE, true);
|
||||||
logger.debug("Going to remove {} from {}", roleName, userName);
|
logger.debug("Going to remove {} from {}", roleName, userName);
|
||||||
boolean removed = user.removeRole(roleName);
|
boolean removed = user.removeRole(roleName);
|
|
@ -1,9 +1,8 @@
|
||||||
package org.gcube.informationsystem.resourceregistry.contexts.security;
|
package org.gcube.informationsystem.resourceregistry.environments;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -13,9 +12,9 @@ import com.orientechnologies.orient.core.metadata.security.ORule;
|
||||||
/**
|
/**
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
public class TypeSecurityContext extends SecurityContext {
|
public class TypeEnvironment extends SystemEnvironment {
|
||||||
|
|
||||||
private static Logger logger = LoggerFactory.getLogger(SecurityContext.class);
|
private static Logger logger = LoggerFactory.getLogger(SystemEnvironment.class);
|
||||||
|
|
||||||
private static final String SCHEMA_SECURITY_CONTEXT;
|
private static final String SCHEMA_SECURITY_CONTEXT;
|
||||||
private static final UUID SCHEMA_SECURITY_CONTEXT_UUID;
|
private static final UUID SCHEMA_SECURITY_CONTEXT_UUID;
|
||||||
|
@ -25,18 +24,16 @@ public class TypeSecurityContext extends SecurityContext {
|
||||||
SCHEMA_SECURITY_CONTEXT_UUID = UUID.fromString(SCHEMA_SECURITY_CONTEXT);
|
SCHEMA_SECURITY_CONTEXT_UUID = UUID.fromString(SCHEMA_SECURITY_CONTEXT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TypeSecurityContext instance;
|
private static TypeEnvironment instance;
|
||||||
|
|
||||||
public static TypeSecurityContext getInstance() throws ResourceRegistryException {
|
public static TypeEnvironment getInstance() throws ResourceRegistryException {
|
||||||
if(instance==null) {
|
if(instance==null) {
|
||||||
instance = new TypeSecurityContext();
|
instance = new TypeEnvironment();
|
||||||
ContextUtility contextUtility = ContextUtility.getInstance();
|
|
||||||
contextUtility.addSecurityContext(SCHEMA_SECURITY_CONTEXT, instance);
|
|
||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TypeSecurityContext() throws ResourceRegistryException {
|
private TypeEnvironment() throws ResourceRegistryException {
|
||||||
super(SCHEMA_SECURITY_CONTEXT_UUID, false);
|
super(SCHEMA_SECURITY_CONTEXT_UUID, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,9 +47,9 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaE
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.ServerContextCache;
|
import org.gcube.informationsystem.resourceregistry.contexts.ServerContextCache;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.AdminSecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.AdminEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.properties.PropertyElementManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.base.properties.PropertyElementManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.Operation;
|
import org.gcube.informationsystem.resourceregistry.instances.model.Operation;
|
||||||
import org.gcube.informationsystem.resourceregistry.requests.RequestUtility;
|
import org.gcube.informationsystem.resourceregistry.requests.RequestUtility;
|
||||||
|
@ -254,23 +254,24 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
|
||||||
return accessType;
|
return accessType;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SecurityContext workingContext;
|
protected SystemEnvironment workingEnvironment;
|
||||||
|
|
||||||
protected SecurityContext getWorkingContext() throws ResourceRegistryException {
|
protected SystemEnvironment getWorkingEnvironment() throws ResourceRegistryException {
|
||||||
if(workingContext == null) {
|
if(workingEnvironment == null) {
|
||||||
workingContext = ContextUtility.getCurrentSecurityContext();
|
workingEnvironment = ContextUtility.getCurrentRequestEnvironment();
|
||||||
Context context = ServerContextCache.getInstance().getContextByUUID(workingContext.getUUID());
|
Context context = ServerContextCache.getInstance().getContextByUUID(workingEnvironment.getUUID());
|
||||||
if(context.getState().compareTo(ContextState.ACTIVE.getState())!=0) {
|
if(context.getState().compareTo(ContextState.ACTIVE.getState())!=0) {
|
||||||
if(!workingContext.isUserAllowed()) {
|
Set<String> allowedRoles = workingEnvironment.getAllowedRoles();
|
||||||
throw new ForbiddenException("You are not allowed to operate in non " + ContextState.ACTIVE.getState() + " Contexts. Allowed roles are " + SecurityContext.getAllOperationsAllowedRoles());
|
if(!workingEnvironment.isUserAllowed(allowedRoles)) {
|
||||||
|
throw new ForbiddenException("You are not allowed to operate in non " + ContextState.ACTIVE.getState() + " Contexts. Allowed roles are " + SystemEnvironment.getAllOperationsAllowedRoles());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return workingContext;
|
return workingEnvironment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWorkingContext(SecurityContext workingContext) {
|
public void setWorkingEnvironment(SystemEnvironment workingContext) {
|
||||||
this.workingContext = workingContext;
|
this.workingEnvironment = workingContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUUID(UUID uuid) throws ResourceRegistryException {
|
public void setUUID(UUID uuid) throws ResourceRegistryException {
|
||||||
|
@ -564,7 +565,7 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
|
||||||
|
|
||||||
MetadataUtility.addMetadata(element);
|
MetadataUtility.addMetadata(element);
|
||||||
|
|
||||||
getWorkingContext().addElement(element, oDatabaseDocument);
|
getWorkingEnvironment().addElement(element, oDatabaseDocument);
|
||||||
|
|
||||||
element.save();
|
element.save();
|
||||||
|
|
||||||
|
@ -684,7 +685,7 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
|
||||||
public String all(boolean polymorphic) throws ResourceRegistryException {
|
public String all(boolean polymorphic) throws ResourceRegistryException {
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
try {
|
try {
|
||||||
oDatabaseDocument = getWorkingContext().getDatabaseDocument(PermissionMode.READER);
|
oDatabaseDocument = getWorkingEnvironment().getDatabaseDocument(PermissionMode.READER);
|
||||||
setAsEntryPoint();
|
setAsEntryPoint();
|
||||||
setOperation(Operation.QUERY);
|
setOperation(Operation.QUERY);
|
||||||
return reallyGetAll(polymorphic);
|
return reallyGetAll(polymorphic);
|
||||||
|
@ -706,7 +707,7 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
|
||||||
public boolean exists() throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
|
public boolean exists() throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
try {
|
try {
|
||||||
oDatabaseDocument = getWorkingContext().getDatabaseDocument(PermissionMode.READER);
|
oDatabaseDocument = getWorkingEnvironment().getDatabaseDocument(PermissionMode.READER);
|
||||||
setAsEntryPoint();
|
setAsEntryPoint();
|
||||||
setOperation(Operation.EXISTS);
|
setOperation(Operation.EXISTS);
|
||||||
|
|
||||||
|
@ -734,7 +735,7 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
|
||||||
throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
|
throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
try {
|
try {
|
||||||
SecurityContext securityContext = getWorkingContext();
|
SystemEnvironment securityContext = getWorkingEnvironment();
|
||||||
oDatabaseDocument = securityContext.getDatabaseDocument(PermissionMode.WRITER);
|
oDatabaseDocument = securityContext.getDatabaseDocument(PermissionMode.WRITER);
|
||||||
oDatabaseDocument.begin();
|
oDatabaseDocument.begin();
|
||||||
boolean update = false;
|
boolean update = false;
|
||||||
|
@ -791,7 +792,7 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
|
||||||
|
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
try {
|
try {
|
||||||
SecurityContext securityContext = getWorkingContext();
|
SystemEnvironment securityContext = getWorkingEnvironment();
|
||||||
securityContext.isUserAllowed(Operation.CREATE);
|
securityContext.isUserAllowed(Operation.CREATE);
|
||||||
oDatabaseDocument = securityContext.getDatabaseDocument(PermissionMode.WRITER);
|
oDatabaseDocument = securityContext.getDatabaseDocument(PermissionMode.WRITER);
|
||||||
oDatabaseDocument.begin();
|
oDatabaseDocument.begin();
|
||||||
|
@ -832,7 +833,7 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
|
||||||
|
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
try {
|
try {
|
||||||
SecurityContext securityContext = getWorkingContext();
|
SystemEnvironment securityContext = getWorkingEnvironment();
|
||||||
setOperation(Operation.READ);
|
setOperation(Operation.READ);
|
||||||
securityContext.isUserAllowed(operation);
|
securityContext.isUserAllowed(operation);
|
||||||
oDatabaseDocument = securityContext.getDatabaseDocument(PermissionMode.READER);
|
oDatabaseDocument = securityContext.getDatabaseDocument(PermissionMode.READER);
|
||||||
|
@ -862,7 +863,7 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
|
||||||
public String update() throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
|
public String update() throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
try {
|
try {
|
||||||
SecurityContext securityContext = getWorkingContext();
|
SystemEnvironment securityContext = getWorkingEnvironment();
|
||||||
securityContext.isUserAllowed(Operation.UPDATE);
|
securityContext.isUserAllowed(Operation.UPDATE);
|
||||||
oDatabaseDocument = securityContext.getDatabaseDocument(PermissionMode.WRITER);
|
oDatabaseDocument = securityContext.getDatabaseDocument(PermissionMode.WRITER);
|
||||||
oDatabaseDocument.begin();
|
oDatabaseDocument.begin();
|
||||||
|
@ -906,7 +907,7 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
try {
|
try {
|
||||||
// oDatabaseDocument = ContextUtility.getAdminSecurityContext().getDatabaseDocument(PermissionMode.WRITER);
|
// oDatabaseDocument = ContextUtility.getAdminSecurityContext().getDatabaseDocument(PermissionMode.WRITER);
|
||||||
SecurityContext securityContext = getWorkingContext();
|
SystemEnvironment securityContext = getWorkingEnvironment();
|
||||||
setOperation(Operation.DELETE);
|
setOperation(Operation.DELETE);
|
||||||
securityContext.isUserAllowed(operation);
|
securityContext.isUserAllowed(operation);
|
||||||
oDatabaseDocument = securityContext.getDatabaseDocument(PermissionMode.WRITER);
|
oDatabaseDocument = securityContext.getDatabaseDocument(PermissionMode.WRITER);
|
||||||
|
@ -949,14 +950,14 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
ODatabaseDocument instanceDB = this.oDatabaseDocument;
|
ODatabaseDocument instanceDB = this.oDatabaseDocument;
|
||||||
try {
|
try {
|
||||||
AdminSecurityContext adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
AdminEnvironment adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
||||||
setOperation(Operation.GET_METADATA);
|
setOperation(Operation.GET_METADATA);
|
||||||
adminSecurityContext.isUserAllowed(operation);
|
adminSecurityContext.isUserAllowed(operation);
|
||||||
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.READER);
|
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.READER);
|
||||||
|
|
||||||
setAsEntryPoint();
|
setAsEntryPoint();
|
||||||
|
|
||||||
Set<String> contexts = SecurityContext.getContexts(getElement());
|
Set<String> contexts = SystemEnvironment.getContexts(getElement());
|
||||||
return contexts;
|
return contexts;
|
||||||
} catch(ResourceRegistryException e) {
|
} catch(ResourceRegistryException e) {
|
||||||
logger.error("Unable to get contexts for {} with UUID {}", typeName, uuid, e);
|
logger.error("Unable to get contexts for {} with UUID {}", typeName, uuid, e);
|
||||||
|
@ -1258,10 +1259,10 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
|
||||||
SecretManager secretManager = SecretManagerProvider.instance.get();
|
SecretManager secretManager = SecretManagerProvider.instance.get();
|
||||||
User user = secretManager.getUser();
|
User user = secretManager.getUser();
|
||||||
Collection<String> roles = new HashSet<>(user.getRoles());
|
Collection<String> roles = new HashSet<>(user.getRoles());
|
||||||
if(roles.contains(SecurityContext.CONTEXT_MANAGER)) {
|
if(roles.contains(SystemEnvironment.CONTEXT_MANAGER)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
roles.retainAll(SecurityContext.getAllOperationsAllowedRoles());
|
roles.retainAll(SystemEnvironment.getAllOperationsAllowedRoles());
|
||||||
if(roles.size()>0) {
|
if(roles.size()>0) {
|
||||||
allowed = true;
|
allowed = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
|
||||||
import org.gcube.informationsystem.model.reference.relations.Relation;
|
import org.gcube.informationsystem.model.reference.relations.Relation;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.EntityManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.model.entities.EntityManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
||||||
|
@ -68,7 +68,7 @@ public class ElementManagementUtility {
|
||||||
return erManagement;
|
return erManagement;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ElementManagement<?,?> getERManagement(SecurityContext workingContext, ODatabaseDocument orientGraph,
|
public static ElementManagement<?,?> getERManagement(SystemEnvironment workingContext, ODatabaseDocument orientGraph,
|
||||||
OElement element) throws ResourceRegistryException {
|
OElement element) throws ResourceRegistryException {
|
||||||
if(element instanceof OVertex) {
|
if(element instanceof OVertex) {
|
||||||
return getEntityManagement(workingContext, orientGraph, (OVertex) element);
|
return getEntityManagement(workingContext, orientGraph, (OVertex) element);
|
||||||
|
@ -104,7 +104,7 @@ public class ElementManagementUtility {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ElementManagement<?, ?> getERManagementFromUUID(SecurityContext workingContext, ODatabaseDocument orientGraph,
|
public static ElementManagement<?, ?> getERManagementFromUUID(SystemEnvironment workingContext, ODatabaseDocument orientGraph,
|
||||||
UUID uuid) throws ResourceRegistryException {
|
UUID uuid) throws ResourceRegistryException {
|
||||||
OElement element;
|
OElement element;
|
||||||
try {
|
try {
|
||||||
|
@ -116,7 +116,7 @@ public class ElementManagementUtility {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EntityManagement<?, ?> getEntityManagement(SecurityContext workingContext, ODatabaseDocument oDatabaseDocument,
|
public static EntityManagement<?, ?> getEntityManagement(SystemEnvironment workingContext, ODatabaseDocument oDatabaseDocument,
|
||||||
OVertex vertex) throws ResourceRegistryException {
|
OVertex vertex) throws ResourceRegistryException {
|
||||||
|
|
||||||
if(oDatabaseDocument == null) {
|
if(oDatabaseDocument == null) {
|
||||||
|
@ -150,12 +150,12 @@ public class ElementManagementUtility {
|
||||||
throw new ResourceRegistryException(error);
|
throw new ResourceRegistryException(error);
|
||||||
}
|
}
|
||||||
entityManagement.setODatabaseDocument(oDatabaseDocument);
|
entityManagement.setODatabaseDocument(oDatabaseDocument);
|
||||||
entityManagement.setWorkingContext(workingContext);
|
entityManagement.setWorkingEnvironment(workingContext);
|
||||||
entityManagement.setElement(vertex);
|
entityManagement.setElement(vertex);
|
||||||
return entityManagement;
|
return entityManagement;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RelationManagement<?,?> getRelationManagement(SecurityContext workingContext, ODatabaseDocument oDatabaseDocument,
|
public static RelationManagement<?,?> getRelationManagement(SystemEnvironment workingContext, ODatabaseDocument oDatabaseDocument,
|
||||||
OEdge edge) throws ResourceRegistryException {
|
OEdge edge) throws ResourceRegistryException {
|
||||||
|
|
||||||
if(oDatabaseDocument == null) {
|
if(oDatabaseDocument == null) {
|
||||||
|
@ -183,7 +183,7 @@ public class ElementManagementUtility {
|
||||||
|
|
||||||
|
|
||||||
relationManagement.setODatabaseDocument(oDatabaseDocument);
|
relationManagement.setODatabaseDocument(oDatabaseDocument);
|
||||||
relationManagement.setWorkingContext(workingContext);
|
relationManagement.setWorkingEnvironment(workingContext);
|
||||||
|
|
||||||
relationManagement.setElement(edge);
|
relationManagement.setElement(edge);
|
||||||
return relationManagement;
|
return relationManagement;
|
||||||
|
|
|
@ -14,7 +14,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.AvailableInAn
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entities.EntityAlreadyPresentException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.entities.EntityAlreadyPresentException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.relations.RelationElementManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.base.relations.RelationElementManagement;
|
||||||
|
@ -52,10 +52,10 @@ public abstract class EntityElementManagement<E extends EntityElement, ET extend
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected EntityElementManagement(AccessType accessType, SecurityContext workingContext, ODatabaseDocument oDatabaseDocument) {
|
protected EntityElementManagement(AccessType accessType, SystemEnvironment workingContext, ODatabaseDocument oDatabaseDocument) {
|
||||||
this(accessType);
|
this(accessType);
|
||||||
this.oDatabaseDocument = oDatabaseDocument;
|
this.oDatabaseDocument = oDatabaseDocument;
|
||||||
setWorkingContext(workingContext);
|
setWorkingEnvironment(workingContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -68,7 +68,7 @@ public abstract class EntityElementManagement<E extends EntityElement, ET extend
|
||||||
String id = edge.getIdentity().toString();
|
String id = edge.getIdentity().toString();
|
||||||
RelationElementManagement<?,?,?,?> relationManagement = relationManagements.get(id);
|
RelationElementManagement<?,?,?,?> relationManagement = relationManagements.get(id);
|
||||||
if(relationManagement == null) {
|
if(relationManagement == null) {
|
||||||
relationManagement = ElementManagementUtility.getRelationManagement(getWorkingContext(), oDatabaseDocument, edge);
|
relationManagement = ElementManagementUtility.getRelationManagement(getWorkingEnvironment(), oDatabaseDocument, edge);
|
||||||
relationManagements.put(id, relationManagement);
|
relationManagements.put(id, relationManagement);
|
||||||
}
|
}
|
||||||
return relationManagement;
|
return relationManagement;
|
||||||
|
|
|
@ -13,7 +13,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegis
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.relations.RelationNotFoundException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.relations.RelationNotFoundException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.entities.EntityElementManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.base.entities.EntityElementManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.utils.OrientDBUtility;
|
import org.gcube.informationsystem.resourceregistry.utils.OrientDBUtility;
|
||||||
|
@ -73,10 +73,10 @@ public abstract class RelationElementManagement<SEM extends EntityElementManagem
|
||||||
this.includeTarget = includeTarget;
|
this.includeTarget = includeTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected RelationElementManagement(AccessType accessType, Class<? extends EntityElement> sourceEntityClass, Class<? extends EntityElement> targetEntityClass, SecurityContext workingContext, ODatabaseDocument orientGraph) {
|
protected RelationElementManagement(AccessType accessType, Class<? extends EntityElement> sourceEntityClass, Class<? extends EntityElement> targetEntityClass, SystemEnvironment workingContext, ODatabaseDocument orientGraph) {
|
||||||
this(accessType, sourceEntityClass, targetEntityClass);
|
this(accessType, sourceEntityClass, targetEntityClass);
|
||||||
this.oDatabaseDocument = orientGraph;
|
this.oDatabaseDocument = orientGraph;
|
||||||
setWorkingContext(workingContext);
|
setWorkingEnvironment(workingContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SEM getSourceEntityManagement() throws ResourceRegistryException {
|
public SEM getSourceEntityManagement() throws ResourceRegistryException {
|
||||||
|
|
|
@ -9,7 +9,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundExcep
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
|
||||||
|
|
||||||
public interface ERManagement {
|
public interface ERManagement {
|
||||||
|
|
||||||
|
@ -23,9 +23,9 @@ public interface ERManagement {
|
||||||
* Set source security context to evaluate addToContext
|
* Set source security context to evaluate addToContext
|
||||||
* @param sourceSecurityContext the source security context
|
* @param sourceSecurityContext the source security context
|
||||||
*/
|
*/
|
||||||
public void setSourceSecurityContext(SecurityContext sourceSecurityContext);
|
public void setSourceSecurityContext(SystemEnvironment sourceSecurityContext);
|
||||||
|
|
||||||
public SecurityContext getSourceSecurityContext();
|
public SystemEnvironment getSourceSecurityContext();
|
||||||
|
|
||||||
public void internalAddToContext()
|
public void internalAddToContext()
|
||||||
throws ContextException, ResourceRegistryException;
|
throws ContextException, ResourceRegistryException;
|
||||||
|
@ -37,9 +37,9 @@ public interface ERManagement {
|
||||||
* Set target security context of addToContext/removeFromContext
|
* Set target security context of addToContext/removeFromContext
|
||||||
* @param targetSecurityContext
|
* @param targetSecurityContext
|
||||||
*/
|
*/
|
||||||
public void setTargetSecurityContext(SecurityContext targetSecurityContext);
|
public void setTargetSecurityContext(SystemEnvironment targetSecurityContext);
|
||||||
|
|
||||||
public SecurityContext getTargetSecurityContext();
|
public SystemEnvironment getTargetSecurityContext();
|
||||||
|
|
||||||
public void internalRemoveFromContext()
|
public void internalRemoveFromContext()
|
||||||
throws ContextException, ResourceRegistryException;
|
throws ContextException, ResourceRegistryException;
|
||||||
|
|
|
@ -10,9 +10,9 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundExcep
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.AdminSecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.AdminEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
||||||
import org.gcube.informationsystem.utils.TypeUtility;
|
import org.gcube.informationsystem.utils.TypeUtility;
|
||||||
|
@ -32,11 +32,11 @@ public class ERManagementUtility {
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
ODatabaseDocument oDatabaseDocument = null;
|
ODatabaseDocument oDatabaseDocument = null;
|
||||||
try {
|
try {
|
||||||
AdminSecurityContext adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
AdminEnvironment adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
||||||
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.WRITER);
|
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.WRITER);
|
||||||
oDatabaseDocument.begin();
|
oDatabaseDocument.begin();
|
||||||
|
|
||||||
SecurityContext targetSecurityContext = ContextUtility.getInstance().getSecurityContextByUUID(contextUUID);
|
SystemEnvironment targetSecurityContext = ContextUtility.getInstance().getEnvironmentByUUID(contextUUID);
|
||||||
|
|
||||||
// Map<UUID, JsonNode> enforcedInstances = new HashMap<>();
|
// Map<UUID, JsonNode> enforcedInstances = new HashMap<>();
|
||||||
|
|
||||||
|
@ -45,7 +45,7 @@ public class ERManagementUtility {
|
||||||
for(UUID uuid : uuids) {
|
for(UUID uuid : uuids) {
|
||||||
String type = TypeUtility.getTypeName(expectedInstances.get(uuid));
|
String type = TypeUtility.getTypeName(expectedInstances.get(uuid));
|
||||||
ElementManagement<?,?> elementManagement = ElementManagementUtility.getERManagement(type);
|
ElementManagement<?,?> elementManagement = ElementManagementUtility.getERManagement(type);
|
||||||
elementManagement.setWorkingContext(adminSecurityContext);
|
elementManagement.setWorkingEnvironment(adminSecurityContext);
|
||||||
elementManagement.setODatabaseDocument(oDatabaseDocument);
|
elementManagement.setODatabaseDocument(oDatabaseDocument);
|
||||||
elementManagement.setUUID(uuid);
|
elementManagement.setUUID(uuid);
|
||||||
elementManagement.setElementType(type);
|
elementManagement.setElementType(type);
|
||||||
|
@ -113,11 +113,11 @@ public class ERManagementUtility {
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
ODatabaseDocument oDatabaseDocument = null;
|
ODatabaseDocument oDatabaseDocument = null;
|
||||||
try {
|
try {
|
||||||
AdminSecurityContext adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
AdminEnvironment adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
||||||
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.WRITER);
|
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.WRITER);
|
||||||
oDatabaseDocument.begin();
|
oDatabaseDocument.begin();
|
||||||
|
|
||||||
SecurityContext targetSecurityContext = ContextUtility.getInstance().getSecurityContextByUUID(contextUUID);
|
SystemEnvironment targetSecurityContext = ContextUtility.getInstance().getEnvironmentByUUID(contextUUID);
|
||||||
|
|
||||||
//Map<UUID, JsonNode> enforcedInstances = new HashMap<>();
|
//Map<UUID, JsonNode> enforcedInstances = new HashMap<>();
|
||||||
|
|
||||||
|
@ -125,7 +125,7 @@ public class ERManagementUtility {
|
||||||
for(UUID uuid : expectedInstances.keySet()) {
|
for(UUID uuid : expectedInstances.keySet()) {
|
||||||
String type = TypeUtility.getTypeName(expectedInstances.get(uuid));
|
String type = TypeUtility.getTypeName(expectedInstances.get(uuid));
|
||||||
ElementManagement<?,?> elementManagement = ElementManagementUtility.getERManagement(type);
|
ElementManagement<?,?> elementManagement = ElementManagementUtility.getERManagement(type);
|
||||||
elementManagement.setWorkingContext(adminSecurityContext);
|
elementManagement.setWorkingEnvironment(adminSecurityContext);
|
||||||
elementManagement.setODatabaseDocument(oDatabaseDocument);
|
elementManagement.setODatabaseDocument(oDatabaseDocument);
|
||||||
elementManagement.setUUID(uuid);
|
elementManagement.setUUID(uuid);
|
||||||
((ERManagement) elementManagement).setHonourPropagationConstraintsInContextSharing(false);
|
((ERManagement) elementManagement).setHonourPropagationConstraintsInContextSharing(false);
|
||||||
|
|
|
@ -25,8 +25,8 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.queries.Inval
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.ServerContextCache;
|
import org.gcube.informationsystem.resourceregistry.contexts.ServerContextCache;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.entities.EntityElementManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.base.entities.EntityElementManagement;
|
||||||
|
@ -57,12 +57,12 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
||||||
/**
|
/**
|
||||||
* The source context of an addToContex
|
* The source context of an addToContex
|
||||||
*/
|
*/
|
||||||
protected SecurityContext sourceSecurityContext;
|
protected SystemEnvironment sourceSecurityContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The target context of an addToContex/RemoveFromContext
|
* The target context of an addToContex/RemoveFromContext
|
||||||
*/
|
*/
|
||||||
protected SecurityContext targetSecurityContext;
|
protected SystemEnvironment targetSecurityContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* By the default the system honour the propagation constraints
|
* By the default the system honour the propagation constraints
|
||||||
|
@ -97,22 +97,22 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
||||||
protected boolean honourPropagationConstraintsInContextSharing;
|
protected boolean honourPropagationConstraintsInContextSharing;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSourceSecurityContext(SecurityContext sourceSecurityContext) {
|
public void setSourceSecurityContext(SystemEnvironment sourceSecurityContext) {
|
||||||
this.sourceSecurityContext = sourceSecurityContext;
|
this.sourceSecurityContext = sourceSecurityContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SecurityContext getSourceSecurityContext() {
|
public SystemEnvironment getSourceSecurityContext() {
|
||||||
return sourceSecurityContext;
|
return sourceSecurityContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTargetSecurityContext(SecurityContext targetSecurityContext) {
|
public void setTargetSecurityContext(SystemEnvironment targetSecurityContext) {
|
||||||
this.targetSecurityContext = targetSecurityContext;
|
this.targetSecurityContext = targetSecurityContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SecurityContext getTargetSecurityContext() {
|
public SystemEnvironment getTargetSecurityContext() {
|
||||||
return sourceSecurityContext;
|
return sourceSecurityContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
||||||
String id = edge.getIdentity().toString();
|
String id = edge.getIdentity().toString();
|
||||||
RelationManagement<?,?> relationManagement = relationManagements.get(id);
|
RelationManagement<?,?> relationManagement = relationManagements.get(id);
|
||||||
if(relationManagement == null) {
|
if(relationManagement == null) {
|
||||||
relationManagement = ElementManagementUtility.getRelationManagement(getWorkingContext(), oDatabaseDocument, edge);
|
relationManagement = ElementManagementUtility.getRelationManagement(getWorkingEnvironment(), oDatabaseDocument, edge);
|
||||||
relationManagements.put(id, relationManagement);
|
relationManagements.put(id, relationManagement);
|
||||||
}
|
}
|
||||||
return relationManagement;
|
return relationManagement;
|
||||||
|
@ -349,13 +349,13 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
||||||
logger.info("Going to add {} with UUID {} to Context with UUID {} (i.e. {})", accessType.getName(), uuid, contextUUID, contextFullName);
|
logger.info("Going to add {} with UUID {} to Context with UUID {} (i.e. {})", accessType.getName(), uuid, contextUUID, contextFullName);
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
try {
|
try {
|
||||||
workingContext = ContextUtility.getAdminSecurityContext();
|
workingEnvironment = ContextUtility.getAdminSecurityContext();
|
||||||
oDatabaseDocument = workingContext.getDatabaseDocument(PermissionMode.WRITER);
|
oDatabaseDocument = workingEnvironment.getDatabaseDocument(PermissionMode.WRITER);
|
||||||
oDatabaseDocument.begin();
|
oDatabaseDocument.begin();
|
||||||
setAsEntryPoint();
|
setAsEntryPoint();
|
||||||
|
|
||||||
sourceSecurityContext = ContextUtility.getCurrentSecurityContext();
|
sourceSecurityContext = ContextUtility.getCurrentRequestEnvironment();
|
||||||
targetSecurityContext = ContextUtility.getInstance().getSecurityContextByUUID(contextUUID);
|
targetSecurityContext = ContextUtility.getInstance().getEnvironmentByUUID(contextUUID);
|
||||||
|
|
||||||
internalAddToContext();
|
internalAddToContext();
|
||||||
|
|
||||||
|
@ -446,13 +446,13 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
||||||
logger.debug("Going to remove {} with UUID {} from Context with UUID {}", typeName, uuid, contextUUID);
|
logger.debug("Going to remove {} with UUID {} from Context with UUID {}", typeName, uuid, contextUUID);
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
try {
|
try {
|
||||||
workingContext = ContextUtility.getAdminSecurityContext();
|
workingEnvironment = ContextUtility.getAdminSecurityContext();
|
||||||
oDatabaseDocument = workingContext.getDatabaseDocument(PermissionMode.WRITER);
|
oDatabaseDocument = workingEnvironment.getDatabaseDocument(PermissionMode.WRITER);
|
||||||
oDatabaseDocument.begin();
|
oDatabaseDocument.begin();
|
||||||
setAsEntryPoint();
|
setAsEntryPoint();
|
||||||
|
|
||||||
// Not needed sourceSecurityContext = ContextUtility.getCurrentSecurityContext();
|
// Not needed sourceSecurityContext = ContextUtility.getCurrentSecurityContext();
|
||||||
targetSecurityContext = ContextUtility.getInstance().getSecurityContextByUUID(contextUUID);
|
targetSecurityContext = ContextUtility.getInstance().getEnvironmentByUUID(contextUUID);
|
||||||
|
|
||||||
internalRemoveFromContext();
|
internalRemoveFromContext();
|
||||||
|
|
||||||
|
@ -504,7 +504,7 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityManagement<?,?> entityManagement = ElementManagementUtility.getEntityManagement(getWorkingContext(),
|
EntityManagement<?,?> entityManagement = ElementManagementUtility.getEntityManagement(getWorkingEnvironment(),
|
||||||
oDatabaseDocument, (OVertex) vertex);
|
oDatabaseDocument, (OVertex) vertex);
|
||||||
try {
|
try {
|
||||||
entityManagement.setAsEntryPoint();
|
entityManagement.setAsEntryPoint();
|
||||||
|
@ -620,7 +620,7 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
||||||
|
|
||||||
OVertex vertex = (OVertex) element;
|
OVertex vertex = (OVertex) element;
|
||||||
|
|
||||||
EntityManagement<?,?> entityManagement = ElementManagementUtility.getEntityManagement(getWorkingContext(),
|
EntityManagement<?,?> entityManagement = ElementManagementUtility.getEntityManagement(getWorkingEnvironment(),
|
||||||
oDatabaseDocument, vertex);
|
oDatabaseDocument, vertex);
|
||||||
try {
|
try {
|
||||||
if(constraint.containsKey(Entity.ID_PROPERTY)) {
|
if(constraint.containsKey(Entity.ID_PROPERTY)) {
|
||||||
|
@ -650,8 +650,8 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
||||||
|
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
try {
|
try {
|
||||||
workingContext = ContextUtility.getAdminSecurityContext();
|
workingEnvironment = ContextUtility.getAdminSecurityContext();
|
||||||
oDatabaseDocument = workingContext.getDatabaseDocument(PermissionMode.READER);
|
oDatabaseDocument = workingEnvironment.getDatabaseDocument(PermissionMode.READER);
|
||||||
|
|
||||||
setAsEntryPoint();
|
setAsEntryPoint();
|
||||||
setOperation(Operation.QUERY);
|
setOperation(Operation.QUERY);
|
||||||
|
|
|
@ -11,7 +11,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.entities.face
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entities.facet.FacetAvailableInAnotherContextException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.entities.facet.FacetAvailableInAnotherContextException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.entities.facet.FacetNotFoundException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.entities.facet.FacetNotFoundException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.Operation;
|
import org.gcube.informationsystem.resourceregistry.instances.model.Operation;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.relations.ConsistsOfManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.model.relations.ConsistsOfManagement;
|
||||||
import org.gcube.informationsystem.types.reference.entities.FacetType;
|
import org.gcube.informationsystem.types.reference.entities.FacetType;
|
||||||
|
@ -134,14 +134,14 @@ public class FacetManagement extends EntityManagement<Facet, FacetType> {
|
||||||
}
|
}
|
||||||
switch (operation) {
|
switch (operation) {
|
||||||
case CREATE: case DELETE:
|
case CREATE: case DELETE:
|
||||||
resourceManagement.setWorkingContext(getWorkingContext());
|
resourceManagement.setWorkingEnvironment(getWorkingEnvironment());
|
||||||
resourceManagement.setODatabaseDocument(oDatabaseDocument);
|
resourceManagement.setODatabaseDocument(oDatabaseDocument);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ADD_TO_CONTEXT:
|
case ADD_TO_CONTEXT:
|
||||||
resourceManagement.setSourceSecurityContext(sourceSecurityContext);
|
resourceManagement.setSourceSecurityContext(sourceSecurityContext);
|
||||||
resourceManagement.setTargetSecurityContext(targetSecurityContext);
|
resourceManagement.setTargetSecurityContext(targetSecurityContext);
|
||||||
resourceManagement.setWorkingContext(targetSecurityContext);
|
resourceManagement.setWorkingEnvironment(targetSecurityContext);
|
||||||
targetSecurityContextODatabaseDocument = targetSecurityContext.getDatabaseDocument(PermissionMode.READER);
|
targetSecurityContextODatabaseDocument = targetSecurityContext.getDatabaseDocument(PermissionMode.READER);
|
||||||
resourceManagement.setODatabaseDocument(targetSecurityContextODatabaseDocument);
|
resourceManagement.setODatabaseDocument(targetSecurityContextODatabaseDocument);
|
||||||
break;
|
break;
|
||||||
|
@ -149,7 +149,7 @@ public class FacetManagement extends EntityManagement<Facet, FacetType> {
|
||||||
case REMOVE_FROM_CONTEXT:
|
case REMOVE_FROM_CONTEXT:
|
||||||
// Not needed resourceManagement.setSourceSecurityContext(sourceSecurityContext);
|
// Not needed resourceManagement.setSourceSecurityContext(sourceSecurityContext);
|
||||||
resourceManagement.setTargetSecurityContext(targetSecurityContext);
|
resourceManagement.setTargetSecurityContext(targetSecurityContext);
|
||||||
resourceManagement.setWorkingContext(targetSecurityContext);
|
resourceManagement.setWorkingEnvironment(targetSecurityContext);
|
||||||
targetSecurityContextODatabaseDocument = targetSecurityContext.getDatabaseDocument(PermissionMode.READER);
|
targetSecurityContextODatabaseDocument = targetSecurityContext.getDatabaseDocument(PermissionMode.READER);
|
||||||
resourceManagement.setODatabaseDocument(targetSecurityContextODatabaseDocument);
|
resourceManagement.setODatabaseDocument(targetSecurityContextODatabaseDocument);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -24,7 +24,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.entities.reso
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.Operation;
|
import org.gcube.informationsystem.resourceregistry.instances.model.Operation;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.relations.ConsistsOfManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.model.relations.ConsistsOfManagement;
|
||||||
|
@ -155,7 +155,7 @@ public class ResourceManagement extends EntityManagement<Resource, ResourceType>
|
||||||
JsonNode jsonNodeArray = jsonNode.get(property);
|
JsonNode jsonNodeArray = jsonNode.get(property);
|
||||||
for(JsonNode consistOfJsonNode : jsonNodeArray) {
|
for(JsonNode consistOfJsonNode : jsonNodeArray) {
|
||||||
ConsistsOfManagement com = new ConsistsOfManagement();
|
ConsistsOfManagement com = new ConsistsOfManagement();
|
||||||
com.setWorkingContext(getWorkingContext());
|
com.setWorkingEnvironment(getWorkingEnvironment());
|
||||||
com.setODatabaseDocument(oDatabaseDocument);
|
com.setODatabaseDocument(oDatabaseDocument);
|
||||||
com.setJsonNode(consistOfJsonNode);
|
com.setJsonNode(consistOfJsonNode);
|
||||||
com.setSourceEntityManagement(this);
|
com.setSourceEntityManagement(this);
|
||||||
|
@ -169,7 +169,7 @@ public class ResourceManagement extends EntityManagement<Resource, ResourceType>
|
||||||
JsonNode jsonNodeArray = jsonNode.get(property);
|
JsonNode jsonNodeArray = jsonNode.get(property);
|
||||||
for(JsonNode relationJsonNode : jsonNodeArray) {
|
for(JsonNode relationJsonNode : jsonNodeArray) {
|
||||||
IsRelatedToManagement irtm = new IsRelatedToManagement();
|
IsRelatedToManagement irtm = new IsRelatedToManagement();
|
||||||
irtm.setWorkingContext(getWorkingContext());
|
irtm.setWorkingEnvironment(getWorkingEnvironment());
|
||||||
irtm.setODatabaseDocument(oDatabaseDocument);
|
irtm.setODatabaseDocument(oDatabaseDocument);
|
||||||
irtm.setJsonNode(relationJsonNode);
|
irtm.setJsonNode(relationJsonNode);
|
||||||
irtm.setSourceEntityManagement(this);
|
irtm.setSourceEntityManagement(this);
|
||||||
|
@ -191,7 +191,7 @@ public class ResourceManagement extends EntityManagement<Resource, ResourceType>
|
||||||
JsonNode jsonNodeArray = jsonNode.get(property);
|
JsonNode jsonNodeArray = jsonNode.get(property);
|
||||||
for(JsonNode relationJsonNode : jsonNodeArray) {
|
for(JsonNode relationJsonNode : jsonNodeArray) {
|
||||||
ConsistsOfManagement com = new ConsistsOfManagement();
|
ConsistsOfManagement com = new ConsistsOfManagement();
|
||||||
com.setWorkingContext(getWorkingContext());
|
com.setWorkingEnvironment(getWorkingEnvironment());
|
||||||
com.setODatabaseDocument(oDatabaseDocument);
|
com.setODatabaseDocument(oDatabaseDocument);
|
||||||
com.setJsonNode(relationJsonNode);
|
com.setJsonNode(relationJsonNode);
|
||||||
com.internalCreateOrUdate();
|
com.internalCreateOrUdate();
|
||||||
|
@ -204,7 +204,7 @@ public class ResourceManagement extends EntityManagement<Resource, ResourceType>
|
||||||
JsonNode jsonNodeArray = jsonNode.get(property);
|
JsonNode jsonNodeArray = jsonNode.get(property);
|
||||||
for(JsonNode relationJsonNode : jsonNodeArray) {
|
for(JsonNode relationJsonNode : jsonNodeArray) {
|
||||||
IsRelatedToManagement irtm = new IsRelatedToManagement();
|
IsRelatedToManagement irtm = new IsRelatedToManagement();
|
||||||
irtm.setWorkingContext(getWorkingContext());
|
irtm.setWorkingEnvironment(getWorkingEnvironment());
|
||||||
irtm.setODatabaseDocument(oDatabaseDocument);
|
irtm.setODatabaseDocument(oDatabaseDocument);
|
||||||
irtm.setJsonNode(relationJsonNode);
|
irtm.setJsonNode(relationJsonNode);
|
||||||
irtm.internalUpdate();
|
irtm.internalUpdate();
|
||||||
|
@ -238,7 +238,7 @@ public class ResourceManagement extends EntityManagement<Resource, ResourceType>
|
||||||
ConsistsOf.NAME, OrientDBUtility.SHOULD_NOT_OCCUR_ERROR_MESSAGE);
|
ConsistsOf.NAME, OrientDBUtility.SHOULD_NOT_OCCUR_ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
if(relationManagement != null) {
|
if(relationManagement != null) {
|
||||||
relationManagement.setWorkingContext(getWorkingContext());
|
relationManagement.setWorkingEnvironment(getWorkingEnvironment());
|
||||||
relationManagement.setODatabaseDocument(oDatabaseDocument);
|
relationManagement.setODatabaseDocument(oDatabaseDocument);
|
||||||
relationManagement.setElement(edge);
|
relationManagement.setElement(edge);
|
||||||
relationManagement.internalDelete();
|
relationManagement.internalDelete();
|
||||||
|
@ -317,7 +317,7 @@ public class ResourceManagement extends EntityManagement<Resource, ResourceType>
|
||||||
public String all(boolean polymorphic) throws ResourceRegistryException {
|
public String all(boolean polymorphic) throws ResourceRegistryException {
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
try {
|
try {
|
||||||
oDatabaseDocument = getWorkingContext().getDatabaseDocument(PermissionMode.READER);
|
oDatabaseDocument = getWorkingEnvironment().getDatabaseDocument(PermissionMode.READER);
|
||||||
return reallyGetAll(polymorphic);
|
return reallyGetAll(polymorphic);
|
||||||
} catch(ResourceRegistryException e) {
|
} catch(ResourceRegistryException e) {
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -483,7 +483,7 @@ public class ResourceManagement extends EntityManagement<Resource, ResourceType>
|
||||||
case CREATE: case UPDATE:
|
case CREATE: case UPDATE:
|
||||||
|
|
||||||
if(relationManagement == null) {
|
if(relationManagement == null) {
|
||||||
relationManagement = ElementManagementUtility.getRelationManagement(getWorkingContext(), oDatabaseDocument, edge);
|
relationManagement = ElementManagementUtility.getRelationManagement(getWorkingEnvironment(), oDatabaseDocument, edge);
|
||||||
relationManagements.put(id, relationManagement);
|
relationManagements.put(id, relationManagement);
|
||||||
/*
|
/*
|
||||||
* Here the AvailableInAnotherContextException should not occur because the connection to the DB is with the
|
* Here the AvailableInAnotherContextException should not occur because the connection to the DB is with the
|
||||||
|
|
|
@ -16,7 +16,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.relations.con
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.relations.consistsof.ConsistsOfAvailableInAnotherContextException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.relations.consistsof.ConsistsOfAvailableInAnotherContextException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.relations.consistsof.ConsistsOfNotFoundException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.relations.consistsof.ConsistsOfNotFoundException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.Operation;
|
import org.gcube.informationsystem.resourceregistry.instances.model.Operation;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
||||||
|
@ -65,7 +65,7 @@ public class ConsistsOfManagement extends RelationManagement<FacetManagement, Fa
|
||||||
protected FacetManagement newTargetEntityManagement() throws ResourceRegistryException {
|
protected FacetManagement newTargetEntityManagement() throws ResourceRegistryException {
|
||||||
FacetManagement facetManagement = new FacetManagement();
|
FacetManagement facetManagement = new FacetManagement();
|
||||||
facetManagement.setODatabaseDocument(oDatabaseDocument);
|
facetManagement.setODatabaseDocument(oDatabaseDocument);
|
||||||
facetManagement.setWorkingContext(getWorkingContext());
|
facetManagement.setWorkingEnvironment(getWorkingEnvironment());
|
||||||
return facetManagement;
|
return facetManagement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ public class ConsistsOfManagement extends RelationManagement<FacetManagement, Fa
|
||||||
resourceManagement.setSourceSecurityContext(sourceSecurityContext);
|
resourceManagement.setSourceSecurityContext(sourceSecurityContext);
|
||||||
}
|
}
|
||||||
resourceManagement.setTargetSecurityContext(targetSecurityContext);
|
resourceManagement.setTargetSecurityContext(targetSecurityContext);
|
||||||
resourceManagement.setWorkingContext(targetSecurityContext);
|
resourceManagement.setWorkingEnvironment(targetSecurityContext);
|
||||||
targetSecurityContextODatabaseDocument = targetSecurityContext.getDatabaseDocument(PermissionMode.READER);
|
targetSecurityContextODatabaseDocument = targetSecurityContext.getDatabaseDocument(PermissionMode.READER);
|
||||||
resourceManagement.setODatabaseDocument(targetSecurityContextODatabaseDocument);
|
resourceManagement.setODatabaseDocument(targetSecurityContextODatabaseDocument);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class IsRelatedToManagement extends RelationManagement<ResourceManagement
|
||||||
@Override
|
@Override
|
||||||
protected ResourceManagement newTargetEntityManagement() throws ResourceRegistryException {
|
protected ResourceManagement newTargetEntityManagement() throws ResourceRegistryException {
|
||||||
ResourceManagement resourceManagement = new ResourceManagement();
|
ResourceManagement resourceManagement = new ResourceManagement();
|
||||||
resourceManagement.setWorkingContext(getWorkingContext());
|
resourceManagement.setWorkingEnvironment(getWorkingEnvironment());
|
||||||
resourceManagement.setODatabaseDocument(oDatabaseDocument);
|
resourceManagement.setODatabaseDocument(oDatabaseDocument);
|
||||||
return resourceManagement;
|
return resourceManagement;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,8 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.relations.Rel
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.ServerContextCache;
|
import org.gcube.informationsystem.resourceregistry.contexts.ServerContextCache;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.relations.RelationElementManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.base.relations.RelationElementManagement;
|
||||||
|
@ -66,12 +66,12 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
/**
|
/**
|
||||||
* The source context of an addToContex
|
* The source context of an addToContex
|
||||||
*/
|
*/
|
||||||
protected SecurityContext sourceSecurityContext;
|
protected SystemEnvironment sourceSecurityContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The target context of an addToContex/RemoveFromContext
|
* The target context of an addToContex/RemoveFromContext
|
||||||
*/
|
*/
|
||||||
protected SecurityContext targetSecurityContext;
|
protected SystemEnvironment targetSecurityContext;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* By the default the system honour the propagation constraints
|
* By the default the system honour the propagation constraints
|
||||||
|
@ -106,22 +106,22 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
protected boolean honourPropagationConstraintsInContextSharing;
|
protected boolean honourPropagationConstraintsInContextSharing;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSourceSecurityContext(SecurityContext sourceSecurityContext) {
|
public void setSourceSecurityContext(SystemEnvironment sourceSecurityContext) {
|
||||||
this.sourceSecurityContext = sourceSecurityContext;
|
this.sourceSecurityContext = sourceSecurityContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SecurityContext getSourceSecurityContext() {
|
public SystemEnvironment getSourceSecurityContext() {
|
||||||
return sourceSecurityContext;
|
return sourceSecurityContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTargetSecurityContext(SecurityContext targetSecurityContext) {
|
public void setTargetSecurityContext(SystemEnvironment targetSecurityContext) {
|
||||||
this.targetSecurityContext = targetSecurityContext;
|
this.targetSecurityContext = targetSecurityContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SecurityContext getTargetSecurityContext() {
|
public SystemEnvironment getTargetSecurityContext() {
|
||||||
return sourceSecurityContext;
|
return sourceSecurityContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
|
|
||||||
public final PropagationConstraint defaultPropagationConstraint;
|
public final PropagationConstraint defaultPropagationConstraint;
|
||||||
|
|
||||||
public boolean isAvailableOnContext(SecurityContext securityContext) {
|
public boolean isAvailableOnContext(SystemEnvironment securityContext) {
|
||||||
try {
|
try {
|
||||||
return securityContext.isElementInContext(element);
|
return securityContext.isElementInContext(element);
|
||||||
} catch (ResourceRegistryException e) {
|
} catch (ResourceRegistryException e) {
|
||||||
|
@ -210,7 +210,7 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
ResourceManagement resourceManagement = null;
|
ResourceManagement resourceManagement = null;
|
||||||
|
|
||||||
if(sourceResource == null) {
|
if(sourceResource == null) {
|
||||||
resourceManagement = (ResourceManagement) ElementManagementUtility.getEntityManagement(getWorkingContext(),
|
resourceManagement = (ResourceManagement) ElementManagementUtility.getEntityManagement(getWorkingEnvironment(),
|
||||||
oDatabaseDocument, source);
|
oDatabaseDocument, source);
|
||||||
if(this instanceof IsRelatedToManagement) {
|
if(this instanceof IsRelatedToManagement) {
|
||||||
sourceResource = resourceManagement.createCompleteJsonNode();
|
sourceResource = resourceManagement.createCompleteJsonNode();
|
||||||
|
@ -324,7 +324,7 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
@Override
|
@Override
|
||||||
protected ResourceManagement newSourceEntityManagement() throws ResourceRegistryException {
|
protected ResourceManagement newSourceEntityManagement() throws ResourceRegistryException {
|
||||||
ResourceManagement resourceManagement = new ResourceManagement();
|
ResourceManagement resourceManagement = new ResourceManagement();
|
||||||
resourceManagement.setWorkingContext(getWorkingContext());
|
resourceManagement.setWorkingEnvironment(getWorkingEnvironment());
|
||||||
resourceManagement.setODatabaseDocument(oDatabaseDocument);
|
resourceManagement.setODatabaseDocument(oDatabaseDocument);
|
||||||
return resourceManagement;
|
return resourceManagement;
|
||||||
}
|
}
|
||||||
|
@ -382,7 +382,7 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
JsonNode target = jsonNode.get(Relation.TARGET_PROPERTY);
|
JsonNode target = jsonNode.get(Relation.TARGET_PROPERTY);
|
||||||
if(target != null) {
|
if(target != null) {
|
||||||
FacetManagement facetManagement = new FacetManagement();
|
FacetManagement facetManagement = new FacetManagement();
|
||||||
facetManagement.setWorkingContext(getWorkingContext());
|
facetManagement.setWorkingEnvironment(getWorkingEnvironment());
|
||||||
facetManagement.setODatabaseDocument(oDatabaseDocument);
|
facetManagement.setODatabaseDocument(oDatabaseDocument);
|
||||||
facetManagement.setJsonNode(target);
|
facetManagement.setJsonNode(target);
|
||||||
facetManagement.internalUpdate();
|
facetManagement.internalUpdate();
|
||||||
|
@ -516,12 +516,12 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
logger.debug("Going to add {} with UUID {} to Context with UUID {} (i.e {})", accessType.getName(), uuid, contextUUID, contextFullName);
|
logger.debug("Going to add {} with UUID {} to Context with UUID {} (i.e {})", accessType.getName(), uuid, contextUUID, contextFullName);
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
try {
|
try {
|
||||||
workingContext = ContextUtility.getAdminSecurityContext();
|
workingEnvironment = ContextUtility.getAdminSecurityContext();
|
||||||
oDatabaseDocument = workingContext.getDatabaseDocument(PermissionMode.WRITER);
|
oDatabaseDocument = workingEnvironment.getDatabaseDocument(PermissionMode.WRITER);
|
||||||
setAsEntryPoint();
|
setAsEntryPoint();
|
||||||
|
|
||||||
sourceSecurityContext = ContextUtility.getCurrentSecurityContext();
|
sourceSecurityContext = ContextUtility.getCurrentRequestEnvironment();
|
||||||
targetSecurityContext = ContextUtility.getInstance().getSecurityContextByUUID(contextUUID);
|
targetSecurityContext = ContextUtility.getInstance().getEnvironmentByUUID(contextUUID);
|
||||||
|
|
||||||
forcedAddToContext();
|
forcedAddToContext();
|
||||||
|
|
||||||
|
@ -669,14 +669,14 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
logger.debug("Going to remove {} with UUID {} from Context with UUID {}", typeName, uuid, contextUUID);
|
logger.debug("Going to remove {} with UUID {} from Context with UUID {}", typeName, uuid, contextUUID);
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
try {
|
try {
|
||||||
workingContext = ContextUtility.getAdminSecurityContext();
|
workingEnvironment = ContextUtility.getAdminSecurityContext();
|
||||||
oDatabaseDocument = workingContext.getDatabaseDocument(PermissionMode.WRITER);
|
oDatabaseDocument = workingEnvironment.getDatabaseDocument(PermissionMode.WRITER);
|
||||||
oDatabaseDocument.begin();
|
oDatabaseDocument.begin();
|
||||||
setAsEntryPoint();
|
setAsEntryPoint();
|
||||||
|
|
||||||
|
|
||||||
// Not needed sourceSecurityContext = ContextUtility.getCurrentSecurityContext();
|
// Not needed sourceSecurityContext = ContextUtility.getCurrentRequestEnvironment();
|
||||||
targetSecurityContext = ContextUtility.getInstance().getSecurityContextByUUID(contextUUID);
|
targetSecurityContext = ContextUtility.getInstance().getEnvironmentByUUID(contextUUID);
|
||||||
|
|
||||||
internalRemoveFromContext();
|
internalRemoveFromContext();
|
||||||
|
|
||||||
|
@ -802,7 +802,7 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
RelationManagement<?, ?> relationManagement = ElementManagementUtility.getRelationManagement(getWorkingContext(),
|
RelationManagement<?, ?> relationManagement = ElementManagementUtility.getRelationManagement(getWorkingEnvironment(),
|
||||||
oDatabaseDocument, edge);
|
oDatabaseDocument, edge);
|
||||||
// visitedSourceResources = relationManagement.fullSerialize(visitedSourceResources);
|
// visitedSourceResources = relationManagement.fullSerialize(visitedSourceResources);
|
||||||
serilizedEdges.add(relationManagement.serializeAsJsonNode());
|
serilizedEdges.add(relationManagement.serializeAsJsonNode());
|
||||||
|
|
|
@ -6,8 +6,8 @@ import org.gcube.com.fasterxml.jackson.databind.node.ArrayNode;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.utils.OrientDBUtility;
|
import org.gcube.informationsystem.resourceregistry.utils.OrientDBUtility;
|
||||||
|
@ -32,7 +32,7 @@ public class QueryImpl implements Query {
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SecurityContext securityContext = ContextUtility.getCurrentSecurityContext();
|
SystemEnvironment securityContext = ContextUtility.getCurrentRequestEnvironment();
|
||||||
|
|
||||||
oDatabaseDocument = securityContext.getDatabaseDocument(PermissionMode.READER);
|
oDatabaseDocument = securityContext.getDatabaseDocument(PermissionMode.READER);
|
||||||
oDatabaseDocument.begin();
|
oDatabaseDocument.begin();
|
||||||
|
|
|
@ -17,8 +17,8 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.queries.Inval
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.queries.json.base.JsonQueryERElement;
|
import org.gcube.informationsystem.resourceregistry.queries.json.base.JsonQueryERElement;
|
||||||
|
@ -117,7 +117,7 @@ public class JsonQuery {
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
oDatabaseDocument = null;
|
oDatabaseDocument = null;
|
||||||
try {
|
try {
|
||||||
SecurityContext securityContext = ContextUtility.getCurrentSecurityContext();
|
SystemEnvironment securityContext = ContextUtility.getCurrentRequestEnvironment();
|
||||||
|
|
||||||
oDatabaseDocument = securityContext.getDatabaseDocument(PermissionMode.READER);
|
oDatabaseDocument = securityContext.getDatabaseDocument(PermissionMode.READER);
|
||||||
oDatabaseDocument.begin();
|
oDatabaseDocument.begin();
|
||||||
|
|
|
@ -21,9 +21,9 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.queries.templ
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.queries.templates.QueryTemplateNotFoundException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.queries.templates.QueryTemplateNotFoundException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.QueryTemplatesSecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.QueryTemplateEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.entities.EntityElementManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.base.entities.EntityElementManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.model.Operation;
|
import org.gcube.informationsystem.resourceregistry.instances.model.Operation;
|
||||||
|
@ -60,7 +60,7 @@ public class QueryTemplateManagement extends EntityElementManagement<QueryTempla
|
||||||
public QueryTemplateManagement(ODatabaseDocument oDatabaseDocument) throws ResourceRegistryException {
|
public QueryTemplateManagement(ODatabaseDocument oDatabaseDocument) throws ResourceRegistryException {
|
||||||
this();
|
this();
|
||||||
this.oDatabaseDocument = oDatabaseDocument;
|
this.oDatabaseDocument = oDatabaseDocument;
|
||||||
getWorkingContext();
|
getWorkingEnvironment();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void checkERMatch() throws ResourceRegistryException {
|
protected void checkERMatch() throws ResourceRegistryException {
|
||||||
|
@ -103,11 +103,11 @@ public class QueryTemplateManagement extends EntityElementManagement<QueryTempla
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SecurityContext getWorkingContext() throws ResourceRegistryException {
|
protected SystemEnvironment getWorkingEnvironment() throws ResourceRegistryException {
|
||||||
if (workingContext == null) {
|
if (workingEnvironment == null) {
|
||||||
workingContext = QueryTemplatesSecurityContext.getInstance();
|
workingEnvironment = QueryTemplateEnvironment.getInstance();
|
||||||
}
|
}
|
||||||
return workingContext;
|
return workingEnvironment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -225,7 +225,7 @@ public class QueryTemplateManagement extends EntityElementManagement<QueryTempla
|
||||||
throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
|
throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
try {
|
try {
|
||||||
oDatabaseDocument = getWorkingContext().getDatabaseDocument(PermissionMode.WRITER);
|
oDatabaseDocument = getWorkingEnvironment().getDatabaseDocument(PermissionMode.WRITER);
|
||||||
oDatabaseDocument.begin();
|
oDatabaseDocument.begin();
|
||||||
boolean update = false;
|
boolean update = false;
|
||||||
setAsEntryPoint();
|
setAsEntryPoint();
|
||||||
|
|
|
@ -109,7 +109,7 @@ public class Access extends BaseRest {
|
||||||
public String getContext(@PathParam(InstancesManager.UUID_PATH_PARAMETER) String uuid)
|
public String getContext(@PathParam(InstancesManager.UUID_PATH_PARAMETER) String uuid)
|
||||||
throws ContextNotFoundException, ResourceRegistryException {
|
throws ContextNotFoundException, ResourceRegistryException {
|
||||||
if(uuid.compareTo(ContextPath.CURRENT_CONTEXT_PATH_PART)==0){
|
if(uuid.compareTo(ContextPath.CURRENT_CONTEXT_PATH_PART)==0){
|
||||||
uuid = ContextUtility.getCurrentSecurityContext().getUUID().toString();
|
uuid = ContextUtility.getCurrentRequestEnvironment().getUUID().toString();
|
||||||
}
|
}
|
||||||
logger.info("Requested to read {} with id {} ", org.gcube.informationsystem.contexts.reference.entities.Context.NAME, uuid);
|
logger.info("Requested to read {} with id {} ", org.gcube.informationsystem.contexts.reference.entities.Context.NAME, uuid);
|
||||||
setAccountingMethod(Method.READ, org.gcube.informationsystem.contexts.reference.entities.Context.NAME);
|
setAccountingMethod(Method.READ, org.gcube.informationsystem.contexts.reference.entities.Context.NAME);
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class ContextManager extends BaseRest {
|
||||||
public String read(@PathParam(ContextManager.CONTEXT_UUID_PATH_PARAMETER) String uuid)
|
public String read(@PathParam(ContextManager.CONTEXT_UUID_PATH_PARAMETER) String uuid)
|
||||||
throws ContextNotFoundException, ResourceRegistryException {
|
throws ContextNotFoundException, ResourceRegistryException {
|
||||||
if(uuid.compareTo(ContextPath.CURRENT_CONTEXT_PATH_PART)==0){
|
if(uuid.compareTo(ContextPath.CURRENT_CONTEXT_PATH_PART)==0){
|
||||||
uuid = ContextUtility.getCurrentSecurityContext().getUUID().toString();
|
uuid = ContextUtility.getCurrentRequestEnvironment().getUUID().toString();
|
||||||
}
|
}
|
||||||
logger.info("Requested to read {} with id {} ", Context.NAME, uuid);
|
logger.info("Requested to read {} with id {} ", Context.NAME, uuid);
|
||||||
setAccountingMethod(Method.READ, Context.NAME);
|
setAccountingMethod(Method.READ, Context.NAME);
|
||||||
|
|
|
@ -11,9 +11,9 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegis
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.AdminSecurityContext;
|
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode;
|
|
||||||
import org.gcube.informationsystem.resourceregistry.dbinitialization.DatabaseEnvironment;
|
import org.gcube.informationsystem.resourceregistry.dbinitialization.DatabaseEnvironment;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.environments.AdminEnvironment;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
||||||
import org.gcube.informationsystem.types.TypeMapper;
|
import org.gcube.informationsystem.types.TypeMapper;
|
||||||
import org.gcube.informationsystem.types.reference.Type;
|
import org.gcube.informationsystem.types.reference.Type;
|
||||||
|
@ -67,7 +67,7 @@ public class CachedType<T extends Type> {
|
||||||
ODatabaseDocument oDatabaseDocument = null;
|
ODatabaseDocument oDatabaseDocument = null;
|
||||||
try {
|
try {
|
||||||
logger.debug("GettingType {} schema", typeName);
|
logger.debug("GettingType {} schema", typeName);
|
||||||
AdminSecurityContext adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
AdminEnvironment adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
||||||
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.READER);
|
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.READER);
|
||||||
OMetadata oMetadata = oDatabaseDocument.getMetadata();
|
OMetadata oMetadata = oDatabaseDocument.getMetadata();
|
||||||
OSchema oSchema = oMetadata.getSchema();
|
OSchema oSchema = oMetadata.getSchema();
|
||||||
|
|
|
@ -32,8 +32,8 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaC
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.AdminSecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.AdminEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.types.entities.FacetTypeDefinitionManagement;
|
import org.gcube.informationsystem.resourceregistry.types.entities.FacetTypeDefinitionManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.types.entities.ResourceTypeDefinitionManagement;
|
import org.gcube.informationsystem.resourceregistry.types.entities.ResourceTypeDefinitionManagement;
|
||||||
|
@ -292,7 +292,7 @@ public class TypeManagement {
|
||||||
throw new SchemaCreationException(error);
|
throw new SchemaCreationException(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
AdminSecurityContext adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
AdminEnvironment adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
||||||
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.WRITER);
|
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.WRITER);
|
||||||
|
|
||||||
OMetadata oMetadata = oDatabaseDocument.getMetadata();
|
OMetadata oMetadata = oDatabaseDocument.getMetadata();
|
||||||
|
@ -469,7 +469,7 @@ public class TypeManagement {
|
||||||
ODatabaseDocument oDatabaseDocument = null;
|
ODatabaseDocument oDatabaseDocument = null;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
AdminSecurityContext adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
AdminEnvironment adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
||||||
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.WRITER);
|
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.WRITER);
|
||||||
|
|
||||||
OMetadata oMetadata = oDatabaseDocument.getMetadata();
|
OMetadata oMetadata = oDatabaseDocument.getMetadata();
|
||||||
|
@ -648,7 +648,7 @@ public class TypeManagement {
|
||||||
protected List<Type> getSchema(boolean includeSubtypes) throws SchemaNotFoundException, SchemaException {
|
protected List<Type> getSchema(boolean includeSubtypes) throws SchemaNotFoundException, SchemaException {
|
||||||
ODatabaseDocument oDatabaseDocument = null;
|
ODatabaseDocument oDatabaseDocument = null;
|
||||||
try {
|
try {
|
||||||
AdminSecurityContext adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
AdminEnvironment adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
||||||
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.READER);
|
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.READER);
|
||||||
|
|
||||||
OMetadata oMetadata = oDatabaseDocument.getMetadata();
|
OMetadata oMetadata = oDatabaseDocument.getMetadata();
|
||||||
|
@ -789,7 +789,7 @@ public class TypeManagement {
|
||||||
protected boolean delete(AccessType accessType) throws SchemaException, SchemaNotFoundException{
|
protected boolean delete(AccessType accessType) throws SchemaException, SchemaNotFoundException{
|
||||||
ODatabaseDocument oDatabaseDocument = null;
|
ODatabaseDocument oDatabaseDocument = null;
|
||||||
try {
|
try {
|
||||||
AdminSecurityContext adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
AdminEnvironment adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
||||||
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.READER);
|
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.READER);
|
||||||
|
|
||||||
OMetadata oMetadata = oDatabaseDocument.getMetadata();
|
OMetadata oMetadata = oDatabaseDocument.getMetadata();
|
||||||
|
|
|
@ -13,8 +13,8 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.entities.Enti
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaAlreadyPresentException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaAlreadyPresentException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.TypeSecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.TypeEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.entities.EntityElementManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.base.entities.EntityElementManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.utils.OrientDBUtility;
|
import org.gcube.informationsystem.resourceregistry.utils.OrientDBUtility;
|
||||||
|
@ -48,11 +48,11 @@ public abstract class EntityTypeDefinitionManagement<E extends EntityType> exten
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SecurityContext getWorkingContext() throws ResourceRegistryException {
|
protected SystemEnvironment getWorkingEnvironment() throws ResourceRegistryException {
|
||||||
if (workingContext == null) {
|
if (workingEnvironment == null) {
|
||||||
workingContext = TypeSecurityContext.getInstance();
|
workingEnvironment = TypeEnvironment.getInstance();
|
||||||
}
|
}
|
||||||
return workingContext;
|
return workingEnvironment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
|
|
|
@ -12,8 +12,8 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegis
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaAlreadyPresentException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaAlreadyPresentException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.TypeSecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.TypeEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.utils.OrientDBUtility;
|
import org.gcube.informationsystem.resourceregistry.utils.OrientDBUtility;
|
||||||
|
@ -42,10 +42,10 @@ public class PropertyTypeDefinitionManagement extends ElementManagement<OElement
|
||||||
this.typeName = PropertyType.NAME;
|
this.typeName = PropertyType.NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PropertyTypeDefinitionManagement(SecurityContext securityContext, ODatabaseDocument oDatabaseDocument) throws ResourceRegistryException {
|
public PropertyTypeDefinitionManagement(SystemEnvironment securityContext, ODatabaseDocument oDatabaseDocument) throws ResourceRegistryException {
|
||||||
this();
|
this();
|
||||||
this.oDatabaseDocument = oDatabaseDocument;
|
this.oDatabaseDocument = oDatabaseDocument;
|
||||||
setWorkingContext(securityContext);
|
setWorkingEnvironment(securityContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -54,11 +54,11 @@ public class PropertyTypeDefinitionManagement extends ElementManagement<OElement
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SecurityContext getWorkingContext() throws ResourceRegistryException {
|
protected SystemEnvironment getWorkingEnvironment() throws ResourceRegistryException {
|
||||||
if(workingContext == null) {
|
if(workingEnvironment == null) {
|
||||||
workingContext = TypeSecurityContext.getInstance();
|
workingEnvironment = TypeEnvironment.getInstance();
|
||||||
}
|
}
|
||||||
return workingContext;
|
return workingEnvironment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
|
|
|
@ -2,7 +2,7 @@ package org.gcube.informationsystem.resourceregistry.types.relations;
|
||||||
|
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.types.entities.FacetTypeDefinitionManagement;
|
import org.gcube.informationsystem.resourceregistry.types.entities.FacetTypeDefinitionManagement;
|
||||||
import org.gcube.informationsystem.types.reference.entities.FacetType;
|
import org.gcube.informationsystem.types.reference.entities.FacetType;
|
||||||
import org.gcube.informationsystem.types.reference.relations.ConsistsOfType;
|
import org.gcube.informationsystem.types.reference.relations.ConsistsOfType;
|
||||||
|
@ -20,7 +20,7 @@ public class ConsistsOfTypeDefinitionManagement
|
||||||
this.typeName = ConsistsOfType.NAME;
|
this.typeName = ConsistsOfType.NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConsistsOfTypeDefinitionManagement(SecurityContext securityContext, ODatabaseDocument oDatabaseDocument)
|
public ConsistsOfTypeDefinitionManagement(SystemEnvironment securityContext, ODatabaseDocument oDatabaseDocument)
|
||||||
throws ResourceRegistryException {
|
throws ResourceRegistryException {
|
||||||
super(securityContext, oDatabaseDocument, FacetType.class);
|
super(securityContext, oDatabaseDocument, FacetType.class);
|
||||||
this.typeName = ConsistsOfType.NAME;
|
this.typeName = ConsistsOfType.NAME;
|
||||||
|
@ -29,7 +29,7 @@ public class ConsistsOfTypeDefinitionManagement
|
||||||
@Override
|
@Override
|
||||||
protected FacetTypeDefinitionManagement newTargetEntityManagement() throws ResourceRegistryException {
|
protected FacetTypeDefinitionManagement newTargetEntityManagement() throws ResourceRegistryException {
|
||||||
FacetTypeDefinitionManagement ftdm = new FacetTypeDefinitionManagement();
|
FacetTypeDefinitionManagement ftdm = new FacetTypeDefinitionManagement();
|
||||||
ftdm.setWorkingContext(getWorkingContext());
|
ftdm.setWorkingEnvironment(getWorkingEnvironment());
|
||||||
ftdm.setODatabaseDocument(oDatabaseDocument);
|
ftdm.setODatabaseDocument(oDatabaseDocument);
|
||||||
return ftdm;
|
return ftdm;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package org.gcube.informationsystem.resourceregistry.types.relations;
|
||||||
|
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.types.entities.ResourceTypeDefinitionManagement;
|
import org.gcube.informationsystem.resourceregistry.types.entities.ResourceTypeDefinitionManagement;
|
||||||
import org.gcube.informationsystem.types.reference.entities.ResourceType;
|
import org.gcube.informationsystem.types.reference.entities.ResourceType;
|
||||||
import org.gcube.informationsystem.types.reference.relations.IsRelatedToType;
|
import org.gcube.informationsystem.types.reference.relations.IsRelatedToType;
|
||||||
|
@ -20,7 +20,7 @@ public class IsRelatedToTypeDefinitionManagement
|
||||||
this.typeName = IsRelatedToType.NAME;
|
this.typeName = IsRelatedToType.NAME;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IsRelatedToTypeDefinitionManagement(SecurityContext securityContext, ODatabaseDocument oDatabaseDocument)
|
public IsRelatedToTypeDefinitionManagement(SystemEnvironment securityContext, ODatabaseDocument oDatabaseDocument)
|
||||||
throws ResourceRegistryException {
|
throws ResourceRegistryException {
|
||||||
super(securityContext, oDatabaseDocument, ResourceType.class);
|
super(securityContext, oDatabaseDocument, ResourceType.class);
|
||||||
this.typeName = IsRelatedToType.NAME;
|
this.typeName = IsRelatedToType.NAME;
|
||||||
|
@ -29,7 +29,7 @@ public class IsRelatedToTypeDefinitionManagement
|
||||||
@Override
|
@Override
|
||||||
protected ResourceTypeDefinitionManagement newTargetEntityManagement() throws ResourceRegistryException {
|
protected ResourceTypeDefinitionManagement newTargetEntityManagement() throws ResourceRegistryException {
|
||||||
ResourceTypeDefinitionManagement rtdm = new ResourceTypeDefinitionManagement();
|
ResourceTypeDefinitionManagement rtdm = new ResourceTypeDefinitionManagement();
|
||||||
rtdm.setWorkingContext(getWorkingContext());
|
rtdm.setWorkingEnvironment(getWorkingEnvironment());
|
||||||
rtdm.setODatabaseDocument(oDatabaseDocument);
|
rtdm.setODatabaseDocument(oDatabaseDocument);
|
||||||
return rtdm;
|
return rtdm;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,8 +15,8 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.relations.Rel
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaAlreadyPresentException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaAlreadyPresentException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.TypeSecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.TypeEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.relations.RelationElementManagement;
|
import org.gcube.informationsystem.resourceregistry.instances.base.relations.RelationElementManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.types.entities.EntityTypeDefinitionManagement;
|
import org.gcube.informationsystem.resourceregistry.types.entities.EntityTypeDefinitionManagement;
|
||||||
|
@ -46,11 +46,11 @@ public abstract class RelationTypeDefinitionManagement<T extends EntityTypeDefin
|
||||||
this.forceIncludeAllMeta = true;
|
this.forceIncludeAllMeta = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RelationTypeDefinitionManagement(SecurityContext securityContext, ODatabaseDocument oDatabaseDocument,
|
public RelationTypeDefinitionManagement(SystemEnvironment securityContext, ODatabaseDocument oDatabaseDocument,
|
||||||
Class<TT> clz) throws ResourceRegistryException {
|
Class<TT> clz) throws ResourceRegistryException {
|
||||||
this(clz);
|
this(clz);
|
||||||
this.oDatabaseDocument = oDatabaseDocument;
|
this.oDatabaseDocument = oDatabaseDocument;
|
||||||
setWorkingContext(securityContext);
|
setWorkingEnvironment(securityContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -59,11 +59,11 @@ public abstract class RelationTypeDefinitionManagement<T extends EntityTypeDefin
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected SecurityContext getWorkingContext() throws ResourceRegistryException {
|
protected SystemEnvironment getWorkingEnvironment() throws ResourceRegistryException {
|
||||||
if (workingContext == null) {
|
if (workingEnvironment == null) {
|
||||||
this.workingContext = TypeSecurityContext.getInstance();
|
this.workingEnvironment = TypeEnvironment.getInstance();
|
||||||
}
|
}
|
||||||
return workingContext;
|
return workingEnvironment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setName(String name) {
|
public void setName(String name) {
|
||||||
|
@ -212,7 +212,7 @@ public abstract class RelationTypeDefinitionManagement<T extends EntityTypeDefin
|
||||||
@Override
|
@Override
|
||||||
protected ResourceTypeDefinitionManagement newSourceEntityManagement() throws ResourceRegistryException {
|
protected ResourceTypeDefinitionManagement newSourceEntityManagement() throws ResourceRegistryException {
|
||||||
ResourceTypeDefinitionManagement rtdm = new ResourceTypeDefinitionManagement();
|
ResourceTypeDefinitionManagement rtdm = new ResourceTypeDefinitionManagement();
|
||||||
rtdm.setWorkingContext(getWorkingContext());
|
rtdm.setWorkingEnvironment(getWorkingEnvironment());
|
||||||
rtdm.setODatabaseDocument(oDatabaseDocument);
|
rtdm.setODatabaseDocument(oDatabaseDocument);
|
||||||
return rtdm;
|
return rtdm;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,8 +14,8 @@ import org.gcube.informationsystem.model.reference.relations.Relation;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.AdminSecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.AdminEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
|
||||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
||||||
import org.gcube.informationsystem.serialization.ElementMapper;
|
import org.gcube.informationsystem.serialization.ElementMapper;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -93,7 +93,7 @@ public class OrientDBUtility {
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
try {
|
try {
|
||||||
current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
AdminSecurityContext adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
AdminEnvironment adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
||||||
adminDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.READER);
|
adminDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.READER);
|
||||||
return OrientDBUtility.getElementByUUID(adminDatabaseDocument, elementType, uuid, clz);
|
return OrientDBUtility.getElementByUUID(adminDatabaseDocument, elementType, uuid, clz);
|
||||||
} finally {
|
} finally {
|
||||||
|
|
|
@ -18,10 +18,11 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.Cont
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.entities.ContextManagement;
|
import org.gcube.informationsystem.resourceregistry.contexts.entities.ContextManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.ContextSecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.ContextEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
|
import org.gcube.informationsystem.resourceregistry.environments.InstanceEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.SecurityType;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
|
||||||
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.SecurityType;
|
||||||
import org.gcube.informationsystem.resourceregistry.utils.MetadataUtility;
|
import org.gcube.informationsystem.resourceregistry.utils.MetadataUtility;
|
||||||
import org.gcube.informationsystem.serialization.ElementMapper;
|
import org.gcube.informationsystem.serialization.ElementMapper;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
|
@ -84,26 +85,26 @@ public class ContextManagementTest extends ContextTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void roleUserAssertions(UUID uuid, UUID oldParentUUID, boolean deleted) throws ResourceRegistryException {
|
protected void roleUserAssertions(UUID uuid, UUID oldParentUUID, boolean deleted) throws ResourceRegistryException {
|
||||||
ContextSecurityContext contextSecurityContext = ContextSecurityContext.getInstance();
|
ContextEnvironment contextSecurityContext = ContextEnvironment.getInstance();
|
||||||
|
|
||||||
ODatabaseDocument oDatabaseDocument = contextSecurityContext.getDatabaseDocument(PermissionMode.READER);
|
ODatabaseDocument oDatabaseDocument = contextSecurityContext.getDatabaseDocument(PermissionMode.READER);
|
||||||
OSecurity oSecurity = oDatabaseDocument.getMetadata().getSecurity();
|
OSecurity oSecurity = oDatabaseDocument.getMetadata().getSecurity();
|
||||||
|
|
||||||
SecurityContext securityContext = null;
|
InstanceEnvironment instanceEnvironment = null;
|
||||||
if(deleted) {
|
if(deleted) {
|
||||||
securityContext = new SecurityContext(uuid);
|
instanceEnvironment = new InstanceEnvironment(uuid);
|
||||||
} else {
|
} else {
|
||||||
securityContext = ContextUtility.getInstance().getSecurityContextByUUID(uuid);
|
instanceEnvironment = ContextUtility.getInstance().getEnvironmentByUUID(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean[] booleanArray = new boolean[] {false, true};
|
boolean[] booleanArray = new boolean[] {false, true};
|
||||||
for(boolean hierarchic : booleanArray) {
|
for(boolean hierarchic : booleanArray) {
|
||||||
for(PermissionMode permissionMode : PermissionMode.values()) {
|
for(PermissionMode permissionMode : PermissionMode.values()) {
|
||||||
String role = securityContext.getSecurityRoleOrUserName(permissionMode, SecurityType.ROLE, hierarchic);
|
String role = instanceEnvironment.getSecurityRoleOrUserName(permissionMode, SecurityType.ROLE, hierarchic);
|
||||||
ORole oRole = oSecurity.getRole(role);
|
ORole oRole = oSecurity.getRole(role);
|
||||||
Assert.assertEquals(oRole == null, deleted);
|
Assert.assertEquals(oRole == null, deleted);
|
||||||
|
|
||||||
String user = securityContext.getSecurityRoleOrUserName(permissionMode, SecurityType.USER, hierarchic);
|
String user = instanceEnvironment.getSecurityRoleOrUserName(permissionMode, SecurityType.USER, hierarchic);
|
||||||
OUser oUser = oSecurity.getUser(user);
|
OUser oUser = oSecurity.getUser(user);
|
||||||
Assert.assertEquals(oUser == null, deleted);
|
Assert.assertEquals(oUser == null, deleted);
|
||||||
if(oUser != null) {
|
if(oUser != null) {
|
||||||
|
@ -111,13 +112,13 @@ public class ContextManagementTest extends ContextTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hierarchic) {
|
if(hierarchic) {
|
||||||
SecurityContext parent = null;
|
SystemEnvironment parent = null;
|
||||||
if(deleted) {
|
if(deleted) {
|
||||||
if(oldParentUUID != null) {
|
if(oldParentUUID != null) {
|
||||||
parent = ContextUtility.getInstance().getSecurityContextByUUID(oldParentUUID);
|
parent = ContextUtility.getInstance().getEnvironmentByUUID(oldParentUUID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
parent = securityContext.getParentSecurityContext();
|
parent = instanceEnvironment.getParentSecurityContext();
|
||||||
while(parent != null) {
|
while(parent != null) {
|
||||||
String parentUser = parent.getSecurityRoleOrUserName(permissionMode, SecurityType.USER,
|
String parentUser = parent.getSecurityRoleOrUserName(permissionMode, SecurityType.USER,
|
||||||
hierarchic);
|
hierarchic);
|
||||||
|
@ -167,7 +168,7 @@ public class ContextManagementTest extends ContextTest {
|
||||||
ContextManagement contextManagement = new ContextManagement();
|
ContextManagement contextManagement = new ContextManagement();
|
||||||
contextManagement.setUUID(uuid);
|
contextManagement.setUUID(uuid);
|
||||||
|
|
||||||
SecurityContext securityContext = ContextUtility.getInstance().getSecurityContextByUUID(uuid);
|
SystemEnvironment securityContext = ContextUtility.getInstance().getEnvironmentByUUID(uuid);
|
||||||
|
|
||||||
UUID oldParentUUID = null;
|
UUID oldParentUUID = null;
|
||||||
if(securityContext.getParentSecurityContext() != null) {
|
if(securityContext.getParentSecurityContext() != null) {
|
||||||
|
@ -534,7 +535,7 @@ public class ContextManagementTest extends ContextTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Context currentContext = read(ContextUtility.getCurrentSecurityContext().getUUID());
|
Context currentContext = read(ContextUtility.getCurrentRequestEnvironment().getUUID());
|
||||||
logger.debug("Current context : {}", currentContext);
|
logger.debug("Current context : {}", currentContext);
|
||||||
|
|
||||||
for(Context c : contexts) {
|
for(Context c : contexts) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ package org.gcube.informationsystem.resourceregistry.dbinitialization;
|
||||||
import org.gcube.informationsystem.base.reference.Element;
|
import org.gcube.informationsystem.base.reference.Element;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
||||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
|
@ -61,7 +61,7 @@ public class AddToContextTest extends MultiContextTest {
|
||||||
consistsOfManagement.setUUID(isIdentifiedBy.getID());
|
consistsOfManagement.setUUID(isIdentifiedBy.getID());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
consistsOfManagement.removeFromContext(ContextUtility.getCurrentSecurityContext().getUUID());
|
consistsOfManagement.removeFromContext(ContextUtility.getCurrentRequestEnvironment().getUUID());
|
||||||
throw new Exception("You should not be able to delete a mandatory ConsistsOf");
|
throw new Exception("You should not be able to delete a mandatory ConsistsOf");
|
||||||
}catch (SchemaViolationException e) {
|
}catch (SchemaViolationException e) {
|
||||||
// As expected
|
// As expected
|
||||||
|
@ -76,7 +76,7 @@ public class AddToContextTest extends MultiContextTest {
|
||||||
facetManagement.setUUID(softwareFacet.getID());
|
facetManagement.setUUID(softwareFacet.getID());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
facetManagement.removeFromContext(ContextUtility.getCurrentSecurityContext().getUUID());
|
facetManagement.removeFromContext(ContextUtility.getCurrentRequestEnvironment().getUUID());
|
||||||
throw new Exception("You should not be able to delete a mandatory Facet");
|
throw new Exception("You should not be able to delete a mandatory Facet");
|
||||||
}catch (SchemaViolationException e) {
|
}catch (SchemaViolationException e) {
|
||||||
// As expected
|
// As expected
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class MultiContextTest extends ERManagementTest {
|
||||||
|
|
||||||
ResourceManagement resourceManagement = getResourceManagement(r);
|
ResourceManagement resourceManagement = getResourceManagement(r);
|
||||||
resourceManagement.setDryRun(dryRun);
|
resourceManagement.setDryRun(dryRun);
|
||||||
UUID contextUUID = ContextUtility.getCurrentSecurityContext().getUUID();
|
UUID contextUUID = ContextUtility.getCurrentRequestEnvironment().getUUID();
|
||||||
resourceManagement.removeFromContext(contextUUID);
|
resourceManagement.removeFromContext(contextUUID);
|
||||||
// Map<UUID, JsonNode> affectedInstances = resourceManagement.getAffectedInstances();
|
// Map<UUID, JsonNode> affectedInstances = resourceManagement.getAffectedInstances();
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ public class MultiContextTest extends ERManagementTest {
|
||||||
|
|
||||||
ResourceManagement resourceManagement = getResourceManagement(r);
|
ResourceManagement resourceManagement = getResourceManagement(r);
|
||||||
resourceManagement.setDryRun(dryRun);
|
resourceManagement.setDryRun(dryRun);
|
||||||
UUID contextUUID = ContextUtility.getInstance().getSecurityContextByFullName(targetContextFullName).getUUID();
|
UUID contextUUID = ContextUtility.getInstance().getRequestEnvironmentByContextFullName(targetContextFullName).getUUID();
|
||||||
resourceManagement.addToContext(contextUUID);
|
resourceManagement.addToContext(contextUUID);
|
||||||
// Map<UUID, JsonNode> affectedInstances = resourceManagement.getAffectedInstances();
|
// Map<UUID, JsonNode> affectedInstances = resourceManagement.getAffectedInstances();
|
||||||
//
|
//
|
||||||
|
@ -279,7 +279,7 @@ public class MultiContextTest extends ERManagementTest {
|
||||||
|
|
||||||
IsRelatedToManagement isRelatedToManagement = getIsRelatedToManagement(isRelatedTo);
|
IsRelatedToManagement isRelatedToManagement = getIsRelatedToManagement(isRelatedTo);
|
||||||
isRelatedToManagement.setDryRun(dryRun);
|
isRelatedToManagement.setDryRun(dryRun);
|
||||||
UUID contextUUID = ContextUtility.getInstance().getSecurityContextByFullName(targetContextFullName).getUUID();
|
UUID contextUUID = ContextUtility.getInstance().getRequestEnvironmentByContextFullName(targetContextFullName).getUUID();
|
||||||
isRelatedToManagement.addToContext(contextUUID);
|
isRelatedToManagement.addToContext(contextUUID);
|
||||||
// Map<UUID, JsonNode> affectedInstances = isRelatedToManagement.getAffectedInstances();
|
// Map<UUID, JsonNode> affectedInstances = isRelatedToManagement.getAffectedInstances();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue