Reorganizing classes

This commit is contained in:
Luca Frosini 2024-10-29 16:39:29 +01:00
parent 281285761f
commit 8902f6b17b
37 changed files with 149 additions and 149 deletions

View File

@ -49,8 +49,8 @@ import org.gcube.informationsystem.resourceregistry.base.properties.PropertyElem
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
import org.gcube.informationsystem.resourceregistry.contexts.ServerContextCache;
import org.gcube.informationsystem.resourceregistry.environments.AdminEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
import org.gcube.informationsystem.resourceregistry.environments.Environment;
import org.gcube.informationsystem.resourceregistry.environments.Environment.PermissionMode;
import org.gcube.informationsystem.resourceregistry.environments.instances.InstanceEnvironment;
import org.gcube.informationsystem.resourceregistry.instances.model.Operation;
import org.gcube.informationsystem.resourceregistry.rest.requests.RequestUtility;
@ -255,23 +255,23 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
return accessType;
}
protected SystemEnvironment workingEnvironment;
protected Environment workingEnvironment;
protected SystemEnvironment getWorkingEnvironment() throws ResourceRegistryException {
protected Environment getWorkingEnvironment() throws ResourceRegistryException {
if(workingEnvironment == null) {
workingEnvironment = ContextUtility.getCurrentRequestEnvironment();
Context context = ServerContextCache.getInstance().getContextByUUID(workingEnvironment.getUUID());
if(context.getState().compareTo(ContextState.ACTIVE.getState())!=0) {
Set<String> allowedRoles = workingEnvironment.getAllowedRoles();
if(!workingEnvironment.isUserAllowed(allowedRoles)) {
throw new ForbiddenException("You are not allowed to operate in non " + ContextState.ACTIVE.getState() + " Contexts. Allowed roles are " + SystemEnvironment.getAllOperationsAllowedRoles());
throw new ForbiddenException("You are not allowed to operate in non " + ContextState.ACTIVE.getState() + " Contexts. Allowed roles are " + Environment.getAllOperationsAllowedRoles());
}
}
}
return workingEnvironment;
}
public void setWorkingEnvironment(SystemEnvironment workingContext) {
public void setWorkingEnvironment(Environment workingContext) {
this.workingEnvironment = workingContext;
}
@ -736,7 +736,7 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
try {
SystemEnvironment securityContext = getWorkingEnvironment();
Environment securityContext = getWorkingEnvironment();
oDatabaseDocument = securityContext.getDatabaseDocument(PermissionMode.WRITER);
oDatabaseDocument.begin();
boolean update = false;
@ -793,7 +793,7 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
try {
SystemEnvironment securityContext = getWorkingEnvironment();
Environment securityContext = getWorkingEnvironment();
securityContext.isUserAllowed(Operation.CREATE);
oDatabaseDocument = securityContext.getDatabaseDocument(PermissionMode.WRITER);
oDatabaseDocument.begin();
@ -834,7 +834,7 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
try {
SystemEnvironment securityContext = getWorkingEnvironment();
Environment securityContext = getWorkingEnvironment();
setOperation(Operation.READ);
securityContext.isUserAllowed(operation);
oDatabaseDocument = securityContext.getDatabaseDocument(PermissionMode.READER);
@ -864,7 +864,7 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
public String update() throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
try {
SystemEnvironment securityContext = getWorkingEnvironment();
Environment securityContext = getWorkingEnvironment();
securityContext.isUserAllowed(Operation.UPDATE);
oDatabaseDocument = securityContext.getDatabaseDocument(PermissionMode.WRITER);
oDatabaseDocument.begin();
@ -908,7 +908,7 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
try {
// oDatabaseDocument = ContextUtility.getAdminSecurityContext().getDatabaseDocument(PermissionMode.WRITER);
SystemEnvironment securityContext = getWorkingEnvironment();
Environment securityContext = getWorkingEnvironment();
setOperation(Operation.DELETE);
securityContext.isUserAllowed(operation);
oDatabaseDocument = securityContext.getDatabaseDocument(PermissionMode.WRITER);
@ -1260,10 +1260,10 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
SecretManager secretManager = SecretManagerProvider.instance.get();
User user = secretManager.getUser();
Collection<String> roles = new HashSet<>(user.getRoles());
if(roles.contains(SystemEnvironment.CONTEXT_MANAGER)) {
if(roles.contains(Environment.CONTEXT_MANAGER)) {
return true;
}
roles.retainAll(SystemEnvironment.getAllOperationsAllowedRoles());
roles.retainAll(Environment.getAllOperationsAllowedRoles());
if(roles.size()>0) {
allowed = true;
}

View File

@ -12,7 +12,7 @@ import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
import org.gcube.informationsystem.model.reference.relations.Relation;
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.Environment;
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.ResourceManagement;
@ -68,7 +68,7 @@ public class ElementManagementUtility {
return erManagement;
}
public static ElementManagement<?,?> getERManagement(SystemEnvironment workingContext, ODatabaseDocument orientGraph,
public static ElementManagement<?,?> getERManagement(Environment workingContext, ODatabaseDocument orientGraph,
OElement element) throws ResourceRegistryException {
if(element instanceof OVertex) {
return getEntityManagement(workingContext, orientGraph, (OVertex) element);
@ -104,7 +104,7 @@ public class ElementManagementUtility {
}
}
public static ElementManagement<?, ?> getERManagementFromUUID(SystemEnvironment workingContext, ODatabaseDocument orientGraph,
public static ElementManagement<?, ?> getERManagementFromUUID(Environment workingContext, ODatabaseDocument orientGraph,
UUID uuid) throws ResourceRegistryException {
OElement element;
try {
@ -116,7 +116,7 @@ public class ElementManagementUtility {
}
}
public static EntityManagement<?, ?> getEntityManagement(SystemEnvironment workingContext, ODatabaseDocument oDatabaseDocument,
public static EntityManagement<?, ?> getEntityManagement(Environment workingContext, ODatabaseDocument oDatabaseDocument,
OVertex vertex) throws ResourceRegistryException {
if(oDatabaseDocument == null) {
@ -155,7 +155,7 @@ public class ElementManagementUtility {
return entityManagement;
}
public static RelationManagement<?,?> getRelationManagement(SystemEnvironment workingContext, ODatabaseDocument oDatabaseDocument,
public static RelationManagement<?,?> getRelationManagement(Environment workingContext, ODatabaseDocument oDatabaseDocument,
OEdge edge) throws ResourceRegistryException {
if(oDatabaseDocument == null) {

View File

@ -17,7 +17,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.entities.Enti
import org.gcube.informationsystem.resourceregistry.base.ElementManagement;
import org.gcube.informationsystem.resourceregistry.base.ElementManagementUtility;
import org.gcube.informationsystem.resourceregistry.base.relations.RelationElementManagement;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.Environment;
import org.gcube.informationsystem.resourceregistry.utils.OrientDBUtility;
import org.gcube.informationsystem.types.reference.entities.EntityType;
@ -52,7 +52,7 @@ public abstract class EntityElementManagement<E extends EntityElement, ET extend
}
protected EntityElementManagement(AccessType accessType, SystemEnvironment workingContext, ODatabaseDocument oDatabaseDocument) {
protected EntityElementManagement(AccessType accessType, Environment workingContext, ODatabaseDocument oDatabaseDocument) {
this(accessType);
this.oDatabaseDocument = oDatabaseDocument;
setWorkingEnvironment(workingContext);

View File

@ -15,7 +15,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaE
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
import org.gcube.informationsystem.resourceregistry.base.ElementManagement;
import org.gcube.informationsystem.resourceregistry.base.entities.EntityElementManagement;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.Environment;
import org.gcube.informationsystem.resourceregistry.utils.OrientDBUtility;
import org.gcube.informationsystem.types.reference.entities.EntityType;
import org.gcube.informationsystem.types.reference.relations.RelationType;
@ -73,7 +73,7 @@ public abstract class RelationElementManagement<SEM extends EntityElementManagem
this.includeTarget = includeTarget;
}
protected RelationElementManagement(AccessType accessType, Class<? extends EntityElement> sourceEntityClass, Class<? extends EntityElement> targetEntityClass, SystemEnvironment workingContext, ODatabaseDocument orientGraph) {
protected RelationElementManagement(AccessType accessType, Class<? extends EntityElement> sourceEntityClass, Class<? extends EntityElement> targetEntityClass, Environment workingContext, ODatabaseDocument orientGraph) {
this(accessType, sourceEntityClass, targetEntityClass);
this.oDatabaseDocument = orientGraph;
setWorkingEnvironment(workingContext);

View File

@ -15,8 +15,8 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.Cont
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException;
import org.gcube.informationsystem.resourceregistry.base.ElementManagementUtility;
import org.gcube.informationsystem.resourceregistry.environments.AdminEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
import org.gcube.informationsystem.resourceregistry.environments.Environment;
import org.gcube.informationsystem.resourceregistry.environments.Environment.PermissionMode;
import org.gcube.informationsystem.resourceregistry.environments.instances.InstanceEnvironment;
import org.gcube.informationsystem.resourceregistry.utils.OrientDBUtility;
import org.gcube.informationsystem.resourceregistry.utils.UUIDUtility;
@ -56,7 +56,7 @@ public class ContextUtility {
return SecretManagerProvider.instance.get().getContext();
}
public static SystemEnvironment getCurrentRequestEnvironment() throws ResourceRegistryException {
public static Environment getCurrentRequestEnvironment() throws ResourceRegistryException {
String fullName = getCurrentContextFullName();
if(fullName == null) {
throw new ContextException("Null Token and Scope. Please set your token first.");
@ -83,7 +83,7 @@ public class ContextUtility {
try {
InstanceEnvironment securityContext = null;
logger.trace("Trying to get {} for {}", SystemEnvironment.class.getSimpleName(), fullName);
logger.trace("Trying to get {} for {}", Environment.class.getSimpleName(), fullName);
UUID uuid = ServerContextCache.getInstance().getUUIDByFullName(fullName);
if(uuid != null) {
@ -91,7 +91,7 @@ public class ContextUtility {
}
if(securityContext==null) {
logger.trace("{} for {} is not in cache. Going to get it", SystemEnvironment.class.getSimpleName(),
logger.trace("{} for {} is not in cache. Going to get it", Environment.class.getSimpleName(),
fullName);
oDatabaseDocument = AdminEnvironment.getInstance().getDatabaseDocument(PermissionMode.READER);

View File

@ -35,7 +35,7 @@ import org.gcube.informationsystem.resourceregistry.base.entities.EntityElementM
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
import org.gcube.informationsystem.resourceregistry.contexts.ServerContextCache;
import org.gcube.informationsystem.resourceregistry.contexts.relations.IsParentOfManagement;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.Environment;
import org.gcube.informationsystem.resourceregistry.environments.contexts.ContextEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.instances.InstanceEnvironment;
import org.gcube.informationsystem.resourceregistry.instances.model.Operation;
@ -117,7 +117,7 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
}
@Override
protected SystemEnvironment getWorkingEnvironment() throws ResourceRegistryException {
protected Environment getWorkingEnvironment() throws ResourceRegistryException {
if (workingEnvironment == null) {
workingEnvironment = ContextEnvironment.getInstance();
}
@ -284,7 +284,7 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
try {
JsonNode isParentOfJsonNode = jsonNode.get(Context.PARENT_PROPERTY);
SystemEnvironment requestEnvironment = ContextUtility.getCurrentRequestEnvironment();
Environment requestEnvironment = ContextUtility.getCurrentRequestEnvironment();
if (isParentOfJsonNode != null && !(isParentOfJsonNode instanceof NullNode)) {
@ -300,7 +300,7 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
throw new NotAuthorizedException("Only user with one of the following roles " + allowedRoles + " can create a child Context.");
}
}else {
Set<String> allowedRoles = SystemEnvironment.getAllOperationsAllowedRoles();
Set<String> allowedRoles = Environment.getAllOperationsAllowedRoles();
if(!requestEnvironment.isUserAllowed(allowedRoles)) {
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.");
}
@ -323,7 +323,7 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
} else {
// We are creating the root
Set<String> allowedRoles = SystemEnvironment.getAllOperationsAllowedRoles();
Set<String> allowedRoles = Environment.getAllOperationsAllowedRoles();
if(!requestEnvironment.isUserAllowed(allowedRoles)) {
throw new NotAuthorizedException("Only user with one of the following roles " + allowedRoles + " can create a root Context.");
}
@ -496,7 +496,7 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
protected void reallyDelete() throws NotFoundException, ResourceRegistryException {
if(workingEnvironment.isUserAllowed(Operation.CREATE)) {
throw new ForbiddenException("You are not allowed to delete the Contexts. Allowed roles are " + SystemEnvironment.getAllOperationsAllowedRoles());
throw new ForbiddenException("You are not allowed to delete the Contexts. Allowed roles are " + Environment.getAllOperationsAllowedRoles());
}
Iterable<OEdge> iterable = getElement().getEdges(ODirection.OUT);
@ -509,7 +509,7 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
element.delete();
ContextUtility contextUtility = ContextUtility.getInstance();
SystemEnvironment securityContext = contextUtility.getEnvironmentByUUID(uuid);
Environment securityContext = contextUtility.getEnvironmentByUUID(uuid);
securityContext.delete(oDatabaseDocument);
ServerContextCache.getInstance().cleanCache();
@ -641,7 +641,7 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
if(workingEnvironment.isUserAllowed(Operation.CREATE)) {
return super.createOrUpdate();
}
throw new ForbiddenException("You are not allowed to manipulate Contexts. Allowed roles are " + SystemEnvironment.getAllOperationsAllowedRoles());
throw new ForbiddenException("You are not allowed to manipulate Contexts. Allowed roles are " + Environment.getAllOperationsAllowedRoles());
}
@Override

View File

@ -16,7 +16,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.relations.isp
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
import org.gcube.informationsystem.resourceregistry.base.relations.RelationElementManagement;
import org.gcube.informationsystem.resourceregistry.contexts.entities.ContextManagement;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.Environment;
import org.gcube.informationsystem.resourceregistry.environments.contexts.ContextEnvironment;
import org.gcube.informationsystem.resourceregistry.utils.OrientDBUtility;
import org.gcube.informationsystem.types.reference.entities.EntityType;
@ -50,7 +50,7 @@ public class IsParentOfManagement extends RelationElementManagement<ContextManag
}
@Override
protected SystemEnvironment getWorkingEnvironment() throws ResourceRegistryException {
protected Environment getWorkingEnvironment() throws ResourceRegistryException {
if (workingEnvironment == null) {
workingEnvironment = ContextEnvironment.getInstance();
}

View File

@ -25,7 +25,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaA
import org.gcube.informationsystem.resourceregistry.base.ElementManagement;
import org.gcube.informationsystem.resourceregistry.contexts.ServerContextCache;
import org.gcube.informationsystem.resourceregistry.environments.AdminEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
import org.gcube.informationsystem.resourceregistry.environments.Environment.PermissionMode;
import org.gcube.informationsystem.resourceregistry.environments.contexts.ContextEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.queries.templates.QueryTemplateEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.types.TypeEnvironment;

View File

@ -16,9 +16,9 @@ import com.orientechnologies.orient.core.metadata.security.OSecurity;
* This SystemEnvironment is used in all the case the
* operation must be done by an administrator
*/
public class AdminEnvironment extends SystemEnvironment {
public class AdminEnvironment extends Environment {
private static Logger logger = LoggerFactory.getLogger(SystemEnvironment.class);
private static Logger logger = LoggerFactory.getLogger(Environment.class);
private static final String ADMIN_SECURITY_CONTEXT;
private static final UUID ADMIN_SECURITY_CONTEXT_UUID;

View File

@ -40,9 +40,9 @@ import com.orientechnologies.orient.core.record.impl.ODocument;
* partion of a graph which in OrientDB is implemented
* via security.
*/
public abstract class SystemEnvironment {
public abstract class Environment {
private static Logger logger = LoggerFactory.getLogger(SystemEnvironment.class);
private static Logger logger = LoggerFactory.getLogger(Environment.class);
protected static final String DEFAULT_WRITER_ROLE = "writer";
protected static final String DEFAULT_READER_ROLE = "reader";
@ -91,9 +91,9 @@ public abstract class SystemEnvironment {
public final static String CONTEXT_MANAGER = "Context-Manager";
static {
SystemEnvironment.allOperationAllowedRoles = new HashSet<>();
SystemEnvironment.allOperationAllowedRoles.add(INFRASTRUCTURE_MANAGER);
SystemEnvironment.allOperationAllowedRoles.add(IS_MANAGER);
Environment.allOperationAllowedRoles = new HashSet<>();
Environment.allOperationAllowedRoles.add(INFRASTRUCTURE_MANAGER);
Environment.allOperationAllowedRoles.add(IS_MANAGER);
}
public static Set<String> getAllOperationsAllowedRoles() {
@ -104,11 +104,11 @@ public abstract class SystemEnvironment {
return new HashSet<>(allowedRoles);
}
protected SystemEnvironment(UUID context) throws ResourceRegistryException {
protected Environment(UUID context) throws ResourceRegistryException {
this.environmentUUID = context;
this.poolMap = new HashMap<>();
this.allowedRoles = new HashSet<>(SystemEnvironment.allOperationAllowedRoles);
this.allowedRoles = new HashSet<>(Environment.allOperationAllowedRoles);
this.allowedRoles.add(CONTEXT_MANAGER);
}

View File

@ -40,9 +40,9 @@ import com.orientechnologies.orient.core.record.impl.ODocument;
* belonging to a context must be visible from parent
* context if the requesting client has enough privileges
*/
public abstract class HierarchicalSystemEnvironment extends SystemEnvironment {
public abstract class HierarchicalEnvironment extends Environment {
private static Logger logger = LoggerFactory.getLogger(HierarchicalSystemEnvironment.class);
private static Logger logger = LoggerFactory.getLogger(HierarchicalEnvironment.class);
/*
* H stand for Hierarchical
@ -53,11 +53,11 @@ public abstract class HierarchicalSystemEnvironment extends SystemEnvironment {
protected final Map<PermissionMode,ODatabasePool> hierarchicPoolMap;
protected HierarchicalSystemEnvironment parentEnvironment;
protected HierarchicalEnvironment parentEnvironment;
protected Set<HierarchicalSystemEnvironment> children;
protected Set<HierarchicalEnvironment> children;
public HierarchicalSystemEnvironment(UUID uuid) throws ResourceRegistryException {
public HierarchicalEnvironment(UUID uuid) throws ResourceRegistryException {
super(uuid);
this.hierarchicPoolMap = new HashMap<>();
@ -65,7 +65,7 @@ public abstract class HierarchicalSystemEnvironment extends SystemEnvironment {
boolean hierarchicalModeRequested = RequestUtility.getRequestInfo().get().isHierarchicalMode();
logger.trace("HierarchicalMode {}requested", hierarchicalModeRequested ? "" : "not ");
boolean hierarchicalAllowed = isUserAllowed(SystemEnvironment.getAllOperationsAllowedRoles());
boolean hierarchicalAllowed = isUserAllowed(Environment.getAllOperationsAllowedRoles());
logger.trace("{} is {}to request the ", ContextUtility.getCurrentUserUsername(), hierarchicalAllowed ? "" : "not ");
/*
@ -92,7 +92,7 @@ public abstract class HierarchicalSystemEnvironment extends SystemEnvironment {
return hierarchical;
}
public void setParentEnvironment(HierarchicalSystemEnvironment parentEnvironment) {
public void setParentEnvironment(HierarchicalEnvironment parentEnvironment) {
if(this.parentEnvironment!=null) {
this.parentEnvironment.getChildren().remove(this);
}
@ -103,15 +103,15 @@ public abstract class HierarchicalSystemEnvironment extends SystemEnvironment {
}
}
public HierarchicalSystemEnvironment getParentEnvironment() {
public HierarchicalEnvironment getParentEnvironment() {
return parentEnvironment;
}
private void addChild(HierarchicalSystemEnvironment child) {
private void addChild(HierarchicalEnvironment child) {
this.children.add(child);
}
public Set<HierarchicalSystemEnvironment> getChildren(){
public Set<HierarchicalEnvironment> getChildren(){
return this.children;
}
@ -119,10 +119,10 @@ public abstract class HierarchicalSystemEnvironment extends SystemEnvironment {
* @return a set containing all children and recursively
* all children.
*/
private Set<HierarchicalSystemEnvironment> getAllChildren(){
Set<HierarchicalSystemEnvironment> allChildren = new HashSet<>();
private Set<HierarchicalEnvironment> getAllChildren(){
Set<HierarchicalEnvironment> allChildren = new HashSet<>();
allChildren.add(this);
for(HierarchicalSystemEnvironment securityContext : getChildren()) {
for(HierarchicalEnvironment securityContext : getChildren()) {
allChildren.addAll(securityContext.getAllChildren());
}
return allChildren;
@ -131,9 +131,9 @@ public abstract class HierarchicalSystemEnvironment extends SystemEnvironment {
/**
* @return
*/
private Set<HierarchicalSystemEnvironment> getAllParents(){
Set<HierarchicalSystemEnvironment> allParents = new HashSet<>();
HierarchicalSystemEnvironment parent = getParentEnvironment();
private Set<HierarchicalEnvironment> getAllParents(){
Set<HierarchicalEnvironment> allParents = new HashSet<>();
HierarchicalEnvironment parent = getParentEnvironment();
while(parent!=null) {
allParents.add(parent);
parent = parent.getParentEnvironment();
@ -149,13 +149,13 @@ public abstract class HierarchicalSystemEnvironment extends SystemEnvironment {
* @param orientGraph
* @throws ResourceRegistryException
*/
public void changeParentEnvironment(HierarchicalSystemEnvironment newParentSecurityContext, ODatabaseDocument orientGraph) throws ResourceRegistryException {
public void changeParentEnvironment(HierarchicalEnvironment newParentSecurityContext, ODatabaseDocument orientGraph) throws ResourceRegistryException {
if(!hierarchical) {
StringBuilder errorMessage = new StringBuilder();
errorMessage.append("Cannot change parent ");
errorMessage.append(HierarchicalSystemEnvironment.class.getSimpleName());
errorMessage.append(HierarchicalEnvironment.class.getSimpleName());
errorMessage.append(" to non hierarchic ");
errorMessage.append(HierarchicalSystemEnvironment.class.getSimpleName());
errorMessage.append(HierarchicalEnvironment.class.getSimpleName());
errorMessage.append(". ");
errorMessage.append(OrientDBUtility.SHOULD_NOT_OCCUR_ERROR_MESSAGE);
final String error = errorMessage.toString();
@ -165,11 +165,11 @@ public abstract class HierarchicalSystemEnvironment extends SystemEnvironment {
OSecurity oSecurity = getOSecurity(orientGraph);
Set<HierarchicalSystemEnvironment> allChildren = getAllChildren();
Set<HierarchicalEnvironment> allChildren = getAllChildren();
Set<HierarchicalSystemEnvironment> oldParents = getAllParents();
Set<HierarchicalEnvironment> oldParents = getAllParents();
Set<HierarchicalSystemEnvironment> newParents = new HashSet<>();
Set<HierarchicalEnvironment> newParents = new HashSet<>();
if(newParentSecurityContext!=null) {
newParents = newParentSecurityContext.getAllParents();
}
@ -189,7 +189,7 @@ public abstract class HierarchicalSystemEnvironment extends SystemEnvironment {
if(newParentSecurityContext!=null){
for(PermissionMode permissionMode : PermissionMode.values()) {
List<ORole> roles = new ArrayList<>();
for(HierarchicalSystemEnvironment child : allChildren) {
for(HierarchicalEnvironment child : allChildren) {
String roleName = child.getSecurityRoleOrUserName(permissionMode, SecurityType.ROLE, true);
ORole role = oSecurity.getRole(roleName);
roles.add(role);
@ -385,22 +385,22 @@ public abstract class HierarchicalSystemEnvironment extends SystemEnvironment {
}
protected void removeChildrenHRolesFromParents(OSecurity oSecurity) {
Set<HierarchicalSystemEnvironment> parents = getAllParents();
Set<HierarchicalSystemEnvironment> allChildren = getAllChildren();
Set<HierarchicalEnvironment> parents = getAllParents();
Set<HierarchicalEnvironment> allChildren = getAllChildren();
removeChildrenHRolesFromParents(oSecurity, parents, allChildren);
}
protected void removeChildrenHRolesFromParents(OSecurity oSecurity, Set<HierarchicalSystemEnvironment> parents, Set<HierarchicalSystemEnvironment> children) {
for(HierarchicalSystemEnvironment parent : parents) {
protected void removeChildrenHRolesFromParents(OSecurity oSecurity, Set<HierarchicalEnvironment> parents, Set<HierarchicalEnvironment> children) {
for(HierarchicalEnvironment parent : parents) {
parent.removeChildrenHRolesFromMyHUsers(oSecurity, children);
}
}
protected void removeChildrenHRolesFromMyHUsers(OSecurity oSecurity, Set<HierarchicalSystemEnvironment> children) {
protected void removeChildrenHRolesFromMyHUsers(OSecurity oSecurity, Set<HierarchicalEnvironment> children) {
for(PermissionMode permissionMode : PermissionMode.values()) {
String userName = getSecurityRoleOrUserName(permissionMode, SecurityType.USER, true);
OUser user = oSecurity.getUser(userName);
for(HierarchicalSystemEnvironment child : children) {
for(HierarchicalEnvironment child : children) {
String roleName = child.getSecurityRoleOrUserName(permissionMode, SecurityType.ROLE, true);
logger.debug("Going to remove {} from {}", roleName, userName);
boolean removed = user.removeRole(roleName);

View File

@ -3,7 +3,7 @@ package org.gcube.informationsystem.resourceregistry.environments.contexts;
import java.util.UUID;
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.Environment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -16,9 +16,9 @@ import com.orientechnologies.orient.core.metadata.security.ORule;
* Contexts information and their relations among
* others, e.g. a Context is parent of another.
*/
public class ContextEnvironment extends SystemEnvironment {
public class ContextEnvironment extends Environment {
private static Logger logger = LoggerFactory.getLogger(SystemEnvironment.class);
private static Logger logger = LoggerFactory.getLogger(Environment.class);
private static final String CONTEXT_SECURITY_CONTEXT;
private static final UUID CONTEXT_SECURITY_CONTEXT_UUID;

View File

@ -3,7 +3,7 @@ package org.gcube.informationsystem.resourceregistry.environments.contexts;
import java.util.UUID;
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.Environment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -19,9 +19,9 @@ import com.orientechnologies.orient.core.metadata.security.ORule;
* ah historical information and to provide a minimal support for
* Context reborn.
*/
public class ShadowContextEnvironment extends SystemEnvironment {
public class ShadowContextEnvironment extends Environment {
private static Logger logger = LoggerFactory.getLogger(SystemEnvironment.class);
private static Logger logger = LoggerFactory.getLogger(Environment.class);
private static final String SHADOW_CONTEXT_SECURITY_CONTEXT;
private static final UUID SHADOW_CONTEXT_SECURITY_CONTEXT_UUID;

View File

@ -3,13 +3,13 @@ package org.gcube.informationsystem.resourceregistry.environments.instances;
import java.util.UUID;
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
import org.gcube.informationsystem.resourceregistry.environments.HierarchicalSystemEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.HierarchicalEnvironment;
/**
* @author Luca Frosini (ISTI - CNR)
* Contains all the instances belonging to a context.
*/
public class InstanceEnvironment extends HierarchicalSystemEnvironment {
public class InstanceEnvironment extends HierarchicalEnvironment {
public InstanceEnvironment(UUID uuid) throws ResourceRegistryException {
super(uuid);

View File

@ -3,7 +3,7 @@ package org.gcube.informationsystem.resourceregistry.environments.queries.templa
import java.util.UUID;
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.Environment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -14,9 +14,9 @@ import com.orientechnologies.orient.core.metadata.security.ORule;
* @author Luca Frosini (ISTI - CNR)
* Contains all the query templates
*/
public class QueryTemplateEnvironment extends SystemEnvironment {
public class QueryTemplateEnvironment extends Environment {
private static Logger logger = LoggerFactory.getLogger(SystemEnvironment.class);
private static Logger logger = LoggerFactory.getLogger(Environment.class);
private static final String QUERY_TEMPLATES_SECURITY_CONTEXT;
private static final UUID QUERY_TEMPLATES_SECURITY_CONTEXT_UUID;

View File

@ -3,7 +3,7 @@ package org.gcube.informationsystem.resourceregistry.environments.types;
import java.util.UUID;
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.Environment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -16,9 +16,9 @@ import com.orientechnologies.orient.core.metadata.security.ORule;
* plus all the types defined on top of the
* information-system-model (e.g the gcube-model)
*/
public class TypeEnvironment extends SystemEnvironment {
public class TypeEnvironment extends Environment {
private static Logger logger = LoggerFactory.getLogger(SystemEnvironment.class);
private static Logger logger = LoggerFactory.getLogger(Environment.class);
private static final String SCHEMA_SECURITY_CONTEXT;
private static final UUID SCHEMA_SECURITY_CONTEXT_UUID;

View File

@ -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.contexts.ContextException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.Environment;
public interface ERManagement {
@ -23,9 +23,9 @@ public interface ERManagement {
* Set source security context to evaluate addToContext
* @param sourceSecurityContext the source security context
*/
public void setSourceSecurityContext(SystemEnvironment sourceSecurityContext);
public void setSourceSecurityContext(Environment sourceSecurityContext);
public SystemEnvironment getSourceSecurityContext();
public Environment getSourceSecurityContext();
public void internalAddToContext()
throws ContextException, ResourceRegistryException;
@ -37,9 +37,9 @@ public interface ERManagement {
* Set target security context of addToContext/removeFromContext
* @param targetSecurityContext
*/
public void setTargetSecurityContext(SystemEnvironment targetSecurityContext);
public void setTargetSecurityContext(Environment targetSecurityContext);
public SystemEnvironment getTargetSecurityContext();
public Environment getTargetSecurityContext();
public void internalRemoveFromContext()
throws ContextException, ResourceRegistryException;

View File

@ -13,8 +13,8 @@ import org.gcube.informationsystem.resourceregistry.base.ElementManagement;
import org.gcube.informationsystem.resourceregistry.base.ElementManagementUtility;
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
import org.gcube.informationsystem.resourceregistry.environments.AdminEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
import org.gcube.informationsystem.resourceregistry.environments.Environment;
import org.gcube.informationsystem.resourceregistry.environments.Environment.PermissionMode;
import org.gcube.informationsystem.utils.TypeUtility;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -36,7 +36,7 @@ public class ERManagementUtility {
oDatabaseDocument = adminEnvironment.getDatabaseDocument(PermissionMode.WRITER);
oDatabaseDocument.begin();
SystemEnvironment targetSecurityContext = ContextUtility.getInstance().getEnvironmentByUUID(contextUUID);
Environment targetSecurityContext = ContextUtility.getInstance().getEnvironmentByUUID(contextUUID);
// Map<UUID, JsonNode> enforcedInstances = new HashMap<>();
@ -117,7 +117,7 @@ public class ERManagementUtility {
oDatabaseDocument = adminEnvironment.getDatabaseDocument(PermissionMode.WRITER);
oDatabaseDocument.begin();
SystemEnvironment targetSecurityContext = ContextUtility.getInstance().getEnvironmentByUUID(contextUUID);
Environment targetSecurityContext = ContextUtility.getInstance().getEnvironmentByUUID(contextUUID);
//Map<UUID, JsonNode> enforcedInstances = new HashMap<>();

View File

@ -29,8 +29,8 @@ import org.gcube.informationsystem.resourceregistry.base.entities.EntityElementM
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
import org.gcube.informationsystem.resourceregistry.contexts.ServerContextCache;
import org.gcube.informationsystem.resourceregistry.environments.AdminEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
import org.gcube.informationsystem.resourceregistry.environments.Environment;
import org.gcube.informationsystem.resourceregistry.environments.Environment.PermissionMode;
import org.gcube.informationsystem.resourceregistry.instances.model.ERManagement;
import org.gcube.informationsystem.resourceregistry.instances.model.Operation;
import org.gcube.informationsystem.resourceregistry.instances.model.relations.RelationManagement;
@ -58,12 +58,12 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
/**
* The source context of an addToContex
*/
protected SystemEnvironment sourceSecurityContext;
protected Environment sourceSecurityContext;
/**
* The target context of an addToContex/RemoveFromContext
*/
protected SystemEnvironment targetSecurityContext;
protected Environment targetSecurityContext;
/**
* By the default the system honour the propagation constraints
@ -98,22 +98,22 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
protected boolean honourPropagationConstraintsInContextSharing;
@Override
public void setSourceSecurityContext(SystemEnvironment sourceSecurityContext) {
public void setSourceSecurityContext(Environment sourceSecurityContext) {
this.sourceSecurityContext = sourceSecurityContext;
}
@Override
public SystemEnvironment getSourceSecurityContext() {
public Environment getSourceSecurityContext() {
return sourceSecurityContext;
}
@Override
public void setTargetSecurityContext(SystemEnvironment targetSecurityContext) {
public void setTargetSecurityContext(Environment targetSecurityContext) {
this.targetSecurityContext = targetSecurityContext;
}
@Override
public SystemEnvironment getTargetSecurityContext() {
public Environment getTargetSecurityContext() {
return sourceSecurityContext;
}

View File

@ -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.FacetNotFoundException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
import org.gcube.informationsystem.resourceregistry.environments.Environment.PermissionMode;
import org.gcube.informationsystem.resourceregistry.instances.model.Operation;
import org.gcube.informationsystem.resourceregistry.instances.model.relations.ConsistsOfManagement;
import org.gcube.informationsystem.types.reference.entities.FacetType;

View File

@ -25,7 +25,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaE
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
import org.gcube.informationsystem.resourceregistry.base.ElementManagementUtility;
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
import org.gcube.informationsystem.resourceregistry.environments.Environment.PermissionMode;
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.IsRelatedToManagement;

View File

@ -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.ConsistsOfNotFoundException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
import org.gcube.informationsystem.resourceregistry.environments.Environment.PermissionMode;
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.ResourceManagement;

View File

@ -33,8 +33,8 @@ import org.gcube.informationsystem.resourceregistry.base.relations.RelationEleme
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
import org.gcube.informationsystem.resourceregistry.contexts.ServerContextCache;
import org.gcube.informationsystem.resourceregistry.environments.AdminEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
import org.gcube.informationsystem.resourceregistry.environments.Environment;
import org.gcube.informationsystem.resourceregistry.environments.Environment.PermissionMode;
import org.gcube.informationsystem.resourceregistry.instances.model.ERManagement;
import org.gcube.informationsystem.resourceregistry.instances.model.Operation;
import org.gcube.informationsystem.resourceregistry.instances.model.entities.EntityManagement;
@ -67,12 +67,12 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
/**
* The source context of an addToContex
*/
protected SystemEnvironment sourceSecurityContext;
protected Environment sourceSecurityContext;
/**
* The target context of an addToContex/RemoveFromContext
*/
protected SystemEnvironment targetSecurityContext;
protected Environment targetSecurityContext;
/**
* By the default the system honour the propagation constraints
@ -107,22 +107,22 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
protected boolean honourPropagationConstraintsInContextSharing;
@Override
public void setSourceSecurityContext(SystemEnvironment sourceSecurityContext) {
public void setSourceSecurityContext(Environment sourceSecurityContext) {
this.sourceSecurityContext = sourceSecurityContext;
}
@Override
public SystemEnvironment getSourceSecurityContext() {
public Environment getSourceSecurityContext() {
return sourceSecurityContext;
}
@Override
public void setTargetSecurityContext(SystemEnvironment targetSecurityContext) {
public void setTargetSecurityContext(Environment targetSecurityContext) {
this.targetSecurityContext = targetSecurityContext;
}
@Override
public SystemEnvironment getTargetSecurityContext() {
public Environment getTargetSecurityContext() {
return sourceSecurityContext;
}
@ -138,7 +138,7 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
public final PropagationConstraint defaultPropagationConstraint;
public boolean isAvailableOnContext(SystemEnvironment securityContext) {
public boolean isAvailableOnContext(Environment securityContext) {
try {
return securityContext.isElementInContext(element);
} catch (ResourceRegistryException e) {

View File

@ -8,8 +8,8 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.queries.Inval
import org.gcube.informationsystem.resourceregistry.base.ElementManagement;
import org.gcube.informationsystem.resourceregistry.base.ElementManagementUtility;
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
import org.gcube.informationsystem.resourceregistry.environments.Environment;
import org.gcube.informationsystem.resourceregistry.environments.Environment.PermissionMode;
import org.gcube.informationsystem.resourceregistry.utils.OrientDBUtility;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -32,7 +32,7 @@ public class QueryImpl implements Query {
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
try {
SystemEnvironment securityContext = ContextUtility.getCurrentRequestEnvironment();
Environment securityContext = ContextUtility.getCurrentRequestEnvironment();
oDatabaseDocument = securityContext.getDatabaseDocument(PermissionMode.READER);
oDatabaseDocument.begin();

View File

@ -19,8 +19,8 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaN
import org.gcube.informationsystem.resourceregistry.base.ElementManagement;
import org.gcube.informationsystem.resourceregistry.base.ElementManagementUtility;
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
import org.gcube.informationsystem.resourceregistry.environments.Environment;
import org.gcube.informationsystem.resourceregistry.environments.Environment.PermissionMode;
import org.gcube.informationsystem.resourceregistry.queries.json.base.JsonQueryERElement;
import org.gcube.informationsystem.resourceregistry.queries.json.base.entities.JsonQueryFacet;
import org.gcube.informationsystem.resourceregistry.queries.json.base.entities.JsonQueryResource;
@ -117,7 +117,7 @@ public class JsonQuery {
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
oDatabaseDocument = null;
try {
SystemEnvironment securityContext = ContextUtility.getCurrentRequestEnvironment();
Environment securityContext = ContextUtility.getCurrentRequestEnvironment();
oDatabaseDocument = securityContext.getDatabaseDocument(PermissionMode.READER);
oDatabaseDocument.begin();

View File

@ -23,8 +23,8 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaV
import org.gcube.informationsystem.resourceregistry.base.ElementManagementUtility;
import org.gcube.informationsystem.resourceregistry.base.entities.EntityElementManagement;
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
import org.gcube.informationsystem.resourceregistry.environments.Environment;
import org.gcube.informationsystem.resourceregistry.environments.Environment.PermissionMode;
import org.gcube.informationsystem.resourceregistry.environments.queries.templates.QueryTemplateEnvironment;
import org.gcube.informationsystem.resourceregistry.instances.model.Operation;
import org.gcube.informationsystem.resourceregistry.queries.json.JsonQuery;
@ -103,7 +103,7 @@ public class QueryTemplateManagement extends EntityElementManagement<QueryTempla
}
@Override
protected SystemEnvironment getWorkingEnvironment() throws ResourceRegistryException {
protected Environment getWorkingEnvironment() throws ResourceRegistryException {
if (workingEnvironment == null) {
workingEnvironment = QueryTemplateEnvironment.getInstance();
}

View File

@ -14,7 +14,7 @@ import org.gcube.informationsystem.resourceregistry.base.ElementManagement;
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
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.environments.Environment.PermissionMode;
import org.gcube.informationsystem.types.TypeMapper;
import org.gcube.informationsystem.types.reference.Type;
import org.gcube.informationsystem.types.reference.properties.LinkedEntity;

View File

@ -33,7 +33,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaE
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException;
import org.gcube.informationsystem.resourceregistry.base.ElementManagement;
import org.gcube.informationsystem.resourceregistry.environments.AdminEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
import org.gcube.informationsystem.resourceregistry.environments.Environment.PermissionMode;
import org.gcube.informationsystem.resourceregistry.types.entities.FacetTypeDefinitionManagement;
import org.gcube.informationsystem.resourceregistry.types.entities.ResourceTypeDefinitionManagement;
import org.gcube.informationsystem.resourceregistry.types.properties.PropertyTypeDefinitionManagement;

View File

@ -15,7 +15,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaN
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
import org.gcube.informationsystem.resourceregistry.base.ElementManagementUtility;
import org.gcube.informationsystem.resourceregistry.base.entities.EntityElementManagement;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.Environment;
import org.gcube.informationsystem.resourceregistry.environments.types.TypeEnvironment;
import org.gcube.informationsystem.resourceregistry.utils.OrientDBUtility;
import org.gcube.informationsystem.types.TypeMapper;
@ -48,7 +48,7 @@ public abstract class EntityTypeDefinitionManagement<E extends EntityType> exten
}
@Override
protected SystemEnvironment getWorkingEnvironment() throws ResourceRegistryException {
protected Environment getWorkingEnvironment() throws ResourceRegistryException {
if (workingEnvironment == null) {
workingEnvironment = TypeEnvironment.getInstance();
}

View File

@ -14,7 +14,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaN
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
import org.gcube.informationsystem.resourceregistry.base.ElementManagement;
import org.gcube.informationsystem.resourceregistry.base.ElementManagementUtility;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.Environment;
import org.gcube.informationsystem.resourceregistry.environments.types.TypeEnvironment;
import org.gcube.informationsystem.resourceregistry.utils.OrientDBUtility;
import org.gcube.informationsystem.types.reference.entities.EntityType;
@ -42,7 +42,7 @@ public class PropertyTypeDefinitionManagement extends ElementManagement<OElement
this.typeName = PropertyType.NAME;
}
public PropertyTypeDefinitionManagement(SystemEnvironment securityContext, ODatabaseDocument oDatabaseDocument) throws ResourceRegistryException {
public PropertyTypeDefinitionManagement(Environment securityContext, ODatabaseDocument oDatabaseDocument) throws ResourceRegistryException {
this();
this.oDatabaseDocument = oDatabaseDocument;
setWorkingEnvironment(securityContext);
@ -54,7 +54,7 @@ public class PropertyTypeDefinitionManagement extends ElementManagement<OElement
}
@Override
protected SystemEnvironment getWorkingEnvironment() throws ResourceRegistryException {
protected Environment getWorkingEnvironment() throws ResourceRegistryException {
if(workingEnvironment == null) {
workingEnvironment = TypeEnvironment.getInstance();
}

View File

@ -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.types.SchemaViolationException;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.Environment;
import org.gcube.informationsystem.resourceregistry.types.entities.FacetTypeDefinitionManagement;
import org.gcube.informationsystem.types.reference.entities.FacetType;
import org.gcube.informationsystem.types.reference.relations.ConsistsOfType;
@ -20,7 +20,7 @@ public class ConsistsOfTypeDefinitionManagement
this.typeName = ConsistsOfType.NAME;
}
public ConsistsOfTypeDefinitionManagement(SystemEnvironment securityContext, ODatabaseDocument oDatabaseDocument)
public ConsistsOfTypeDefinitionManagement(Environment securityContext, ODatabaseDocument oDatabaseDocument)
throws ResourceRegistryException {
super(securityContext, oDatabaseDocument, FacetType.class);
this.typeName = ConsistsOfType.NAME;

View File

@ -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.types.SchemaViolationException;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.Environment;
import org.gcube.informationsystem.resourceregistry.types.entities.ResourceTypeDefinitionManagement;
import org.gcube.informationsystem.types.reference.entities.ResourceType;
import org.gcube.informationsystem.types.reference.relations.IsRelatedToType;
@ -20,7 +20,7 @@ public class IsRelatedToTypeDefinitionManagement
this.typeName = IsRelatedToType.NAME;
}
public IsRelatedToTypeDefinitionManagement(SystemEnvironment securityContext, ODatabaseDocument oDatabaseDocument)
public IsRelatedToTypeDefinitionManagement(Environment securityContext, ODatabaseDocument oDatabaseDocument)
throws ResourceRegistryException {
super(securityContext, oDatabaseDocument, ResourceType.class);
this.typeName = IsRelatedToType.NAME;

View File

@ -17,7 +17,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaN
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
import org.gcube.informationsystem.resourceregistry.base.ElementManagementUtility;
import org.gcube.informationsystem.resourceregistry.base.relations.RelationElementManagement;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.Environment;
import org.gcube.informationsystem.resourceregistry.environments.types.TypeEnvironment;
import org.gcube.informationsystem.resourceregistry.types.entities.EntityTypeDefinitionManagement;
import org.gcube.informationsystem.resourceregistry.types.entities.ResourceTypeDefinitionManagement;
@ -46,7 +46,7 @@ public abstract class RelationTypeDefinitionManagement<T extends EntityTypeDefin
this.forceIncludeAllMeta = true;
}
public RelationTypeDefinitionManagement(SystemEnvironment securityContext, ODatabaseDocument oDatabaseDocument,
public RelationTypeDefinitionManagement(Environment securityContext, ODatabaseDocument oDatabaseDocument,
Class<TT> clz) throws ResourceRegistryException {
this(clz);
this.oDatabaseDocument = oDatabaseDocument;
@ -59,7 +59,7 @@ public abstract class RelationTypeDefinitionManagement<T extends EntityTypeDefin
}
@Override
protected SystemEnvironment getWorkingEnvironment() throws ResourceRegistryException {
protected Environment getWorkingEnvironment() throws ResourceRegistryException {
if (workingEnvironment == null) {
this.workingEnvironment = TypeEnvironment.getInstance();
}

View File

@ -16,7 +16,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegis
import org.gcube.informationsystem.resourceregistry.base.ElementManagementUtility;
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
import org.gcube.informationsystem.resourceregistry.environments.AdminEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
import org.gcube.informationsystem.resourceregistry.environments.Environment.PermissionMode;
import org.gcube.informationsystem.serialization.ElementMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

View File

@ -3,7 +3,7 @@ package org.gcube.informationsystem.resourceregistry;
import java.util.Collection;
import org.gcube.common.iam.OIDCBearerAuth;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.Environment;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
@ -26,12 +26,12 @@ public class TestTokenRoles extends ContextTest {
OIDCBearerAuth auth = OIDCBearerAuth.fromAccessTokenString(accessToken);
Collection<String> roles = auth.getRoles();
logger.debug("{} All roles are {}", context, roles);
Assert.assertTrue(roles.contains(SystemEnvironment.IS_MANAGER));
Assert.assertTrue(roles.contains(Environment.IS_MANAGER));
Collection<String> contextRoles = auth.getContextRoles();
logger.debug("{} Context roles are {}", context, contextRoles);
Collection<String> globalRoles = auth.getGlobalRoles();
logger.debug("{} Global roles are {}", context, globalRoles);
Assert.assertTrue(globalRoles.contains(SystemEnvironment.IS_MANAGER));
Assert.assertTrue(globalRoles.contains(Environment.IS_MANAGER));
Assert.assertTrue(roles.size()==(contextRoles.size() + globalRoles.size()));
Assert.assertTrue(roles.containsAll(contextRoles));
Assert.assertTrue(roles.containsAll(globalRoles));

View File

@ -18,8 +18,8 @@ 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.ContextNotFoundException;
import org.gcube.informationsystem.resourceregistry.contexts.entities.ContextManagement;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.SecurityType;
import org.gcube.informationsystem.resourceregistry.environments.Environment.PermissionMode;
import org.gcube.informationsystem.resourceregistry.environments.Environment.SecurityType;
import org.gcube.informationsystem.resourceregistry.environments.contexts.ContextEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.instances.InstanceEnvironment;
import org.gcube.informationsystem.resourceregistry.utils.MetadataUtility;

View File

@ -3,7 +3,7 @@ package org.gcube.informationsystem.resourceregistry.dbinitialization;
import org.gcube.informationsystem.base.reference.Element;
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
import org.gcube.informationsystem.resourceregistry.environments.AdminEnvironment;
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
import org.gcube.informationsystem.resourceregistry.environments.Environment.PermissionMode;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;