Reorganizing naming
This commit is contained in:
parent
ae2ec3ca5d
commit
924b370a81
|
@ -69,11 +69,6 @@ public class ContextUtility {
|
|||
return sm.getUser().getUsername();
|
||||
}
|
||||
|
||||
public static AdminEnvironment getAdminSecurityContext() throws ResourceRegistryException {
|
||||
AdminEnvironment adminSecurityContext = AdminEnvironment.getInstance();
|
||||
return adminSecurityContext;
|
||||
}
|
||||
|
||||
public synchronized void addSecurityContext(InstanceEnvironment securityContext) {
|
||||
contexts.put(securityContext.getUUID(), securityContext);
|
||||
}
|
||||
|
@ -98,7 +93,7 @@ public class ContextUtility {
|
|||
if(securityContext==null) {
|
||||
logger.trace("{} for {} is not in cache. Going to get it", SystemEnvironment.class.getSimpleName(),
|
||||
fullName);
|
||||
oDatabaseDocument = getAdminSecurityContext().getDatabaseDocument(PermissionMode.READER);
|
||||
oDatabaseDocument = AdminEnvironment.getInstance().getDatabaseDocument(PermissionMode.READER);
|
||||
|
||||
OVertex contextVertex = getContextVertexByFullName(oDatabaseDocument, fullName);
|
||||
|
||||
|
@ -191,7 +186,7 @@ public class ContextUtility {
|
|||
|
||||
try {
|
||||
if(contextVertex == null) {
|
||||
oDatabaseDocument = getAdminSecurityContext().getDatabaseDocument(PermissionMode.READER);
|
||||
oDatabaseDocument = AdminEnvironment.getInstance().getDatabaseDocument(PermissionMode.READER);
|
||||
contextVertex = OrientDBUtility.getElementByUUID(oDatabaseDocument, Context.NAME, uuid, OVertex.class);
|
||||
}
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ public abstract class SystemEnvironment {
|
|||
}
|
||||
}
|
||||
|
||||
protected final UUID context;
|
||||
protected final UUID environmentId;
|
||||
|
||||
protected final Map<Boolean,Map<PermissionMode,ODatabasePool>> poolMap;
|
||||
|
||||
|
@ -121,7 +121,7 @@ public abstract class SystemEnvironment {
|
|||
}
|
||||
|
||||
protected SystemEnvironment(UUID context, boolean hierarchical) throws ResourceRegistryException {
|
||||
this.context = context;
|
||||
this.environmentId = context;
|
||||
this.poolMap = new HashMap<>();
|
||||
|
||||
this.allowedRoles = new HashSet<>(SystemEnvironment.allOperationAllowedRoles);
|
||||
|
@ -176,7 +176,7 @@ public abstract class SystemEnvironment {
|
|||
}
|
||||
|
||||
protected ODatabaseDocument getAdminDatabaseDocument() throws ResourceRegistryException {
|
||||
return ContextUtility.getAdminSecurityContext().getDatabaseDocument(PermissionMode.WRITER);
|
||||
return AdminEnvironment.getInstance().getDatabaseDocument(PermissionMode.WRITER);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -299,7 +299,7 @@ public abstract class SystemEnvironment {
|
|||
}
|
||||
|
||||
public UUID getUUID() {
|
||||
return context;
|
||||
return environmentId;
|
||||
}
|
||||
|
||||
public static String getRoleOrUserName(PermissionMode permissionMode, SecurityType securityType) {
|
||||
|
@ -322,7 +322,7 @@ public abstract class SystemEnvironment {
|
|||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.append(getRoleOrUserName(permissionMode, securityType, hierarchic));
|
||||
stringBuilder.append("_");
|
||||
stringBuilder.append(context.toString());
|
||||
stringBuilder.append(environmentId.toString());
|
||||
return stringBuilder.toString();
|
||||
}
|
||||
|
||||
|
@ -624,7 +624,7 @@ public abstract class SystemEnvironment {
|
|||
public void create(ODatabaseDocument oDatabaseDocument) {
|
||||
OSecurity oSecurity = getOSecurity(oDatabaseDocument);
|
||||
createRolesAndUsers(oSecurity);
|
||||
logger.trace("Security Context (roles and users) with UUID {} successfully created", context.toString());
|
||||
logger.trace("Security Context (roles and users) with UUID {} successfully created", environmentId.toString());
|
||||
}
|
||||
|
||||
private void drop(OSecurity oSecurity, String name, SecurityType securityType) {
|
||||
|
@ -731,9 +731,9 @@ public abstract class SystemEnvironment {
|
|||
}
|
||||
|
||||
private void delete(OSecurity oSecurity) {
|
||||
logger.trace("Going to remove Security Context (roles and users) with UUID {}", context.toString());
|
||||
logger.trace("Going to remove Security Context (roles and users) with UUID {}", environmentId.toString());
|
||||
deleteRolesAndUsers(oSecurity);
|
||||
logger.trace("Security Context (roles and users) with UUID {} successfully removed", context.toString());
|
||||
logger.trace("Security Context (roles and users) with UUID {} successfully removed", environmentId.toString());
|
||||
}
|
||||
|
||||
public ODatabaseDocument getDatabaseDocument(PermissionMode permissionMode) throws ResourceRegistryException {
|
||||
|
|
|
@ -950,7 +950,7 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
|
|||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||
ODatabaseDocument instanceDB = this.oDatabaseDocument;
|
||||
try {
|
||||
AdminEnvironment adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
||||
AdminEnvironment adminSecurityContext = AdminEnvironment.getInstance();
|
||||
setOperation(Operation.GET_METADATA);
|
||||
adminSecurityContext.isUserAllowed(operation);
|
||||
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.READER);
|
||||
|
|
|
@ -32,8 +32,8 @@ public class ERManagementUtility {
|
|||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||
ODatabaseDocument oDatabaseDocument = null;
|
||||
try {
|
||||
AdminEnvironment adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
||||
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.WRITER);
|
||||
AdminEnvironment adminEnvironment = AdminEnvironment.getInstance();
|
||||
oDatabaseDocument = adminEnvironment.getDatabaseDocument(PermissionMode.WRITER);
|
||||
oDatabaseDocument.begin();
|
||||
|
||||
SystemEnvironment targetSecurityContext = ContextUtility.getInstance().getEnvironmentByUUID(contextUUID);
|
||||
|
@ -45,7 +45,7 @@ public class ERManagementUtility {
|
|||
for(UUID uuid : uuids) {
|
||||
String type = TypeUtility.getTypeName(expectedInstances.get(uuid));
|
||||
ElementManagement<?,?> elementManagement = ElementManagementUtility.getERManagement(type);
|
||||
elementManagement.setWorkingEnvironment(adminSecurityContext);
|
||||
elementManagement.setWorkingEnvironment(adminEnvironment);
|
||||
elementManagement.setODatabaseDocument(oDatabaseDocument);
|
||||
elementManagement.setUUID(uuid);
|
||||
elementManagement.setElementType(type);
|
||||
|
@ -113,8 +113,8 @@ public class ERManagementUtility {
|
|||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||
ODatabaseDocument oDatabaseDocument = null;
|
||||
try {
|
||||
AdminEnvironment adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
||||
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.WRITER);
|
||||
AdminEnvironment adminEnvironment = AdminEnvironment.getInstance();
|
||||
oDatabaseDocument = adminEnvironment.getDatabaseDocument(PermissionMode.WRITER);
|
||||
oDatabaseDocument.begin();
|
||||
|
||||
SystemEnvironment targetSecurityContext = ContextUtility.getInstance().getEnvironmentByUUID(contextUUID);
|
||||
|
@ -125,7 +125,7 @@ public class ERManagementUtility {
|
|||
for(UUID uuid : expectedInstances.keySet()) {
|
||||
String type = TypeUtility.getTypeName(expectedInstances.get(uuid));
|
||||
ElementManagement<?,?> elementManagement = ElementManagementUtility.getERManagement(type);
|
||||
elementManagement.setWorkingEnvironment(adminSecurityContext);
|
||||
elementManagement.setWorkingEnvironment(adminEnvironment);
|
||||
elementManagement.setODatabaseDocument(oDatabaseDocument);
|
||||
elementManagement.setUUID(uuid);
|
||||
((ERManagement) elementManagement).setHonourPropagationConstraintsInContextSharing(false);
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.queries.Inval
|
|||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
||||
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.instances.base.ElementManagement;
|
||||
|
@ -349,7 +350,7 @@ 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);
|
||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||
try {
|
||||
workingEnvironment = ContextUtility.getAdminSecurityContext();
|
||||
workingEnvironment = AdminEnvironment.getInstance();
|
||||
oDatabaseDocument = workingEnvironment.getDatabaseDocument(PermissionMode.WRITER);
|
||||
oDatabaseDocument.begin();
|
||||
setAsEntryPoint();
|
||||
|
@ -446,7 +447,7 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
|||
logger.debug("Going to remove {} with UUID {} from Context with UUID {}", typeName, uuid, contextUUID);
|
||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||
try {
|
||||
workingEnvironment = ContextUtility.getAdminSecurityContext();
|
||||
workingEnvironment = AdminEnvironment.getInstance();
|
||||
oDatabaseDocument = workingEnvironment.getDatabaseDocument(PermissionMode.WRITER);
|
||||
oDatabaseDocument.begin();
|
||||
setAsEntryPoint();
|
||||
|
@ -650,7 +651,7 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
|||
|
||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||
try {
|
||||
workingEnvironment = ContextUtility.getAdminSecurityContext();
|
||||
workingEnvironment = AdminEnvironment.getInstance();
|
||||
oDatabaseDocument = workingEnvironment.getDatabaseDocument(PermissionMode.READER);
|
||||
|
||||
setAsEntryPoint();
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.relations.Rel
|
|||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
||||
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.instances.base.ElementManagement;
|
||||
|
@ -516,7 +517,7 @@ 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);
|
||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||
try {
|
||||
workingEnvironment = ContextUtility.getAdminSecurityContext();
|
||||
workingEnvironment = AdminEnvironment.getInstance();
|
||||
oDatabaseDocument = workingEnvironment.getDatabaseDocument(PermissionMode.WRITER);
|
||||
setAsEntryPoint();
|
||||
|
||||
|
@ -669,7 +670,7 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
|||
logger.debug("Going to remove {} with UUID {} from Context with UUID {}", typeName, uuid, contextUUID);
|
||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||
try {
|
||||
workingEnvironment = ContextUtility.getAdminSecurityContext();
|
||||
workingEnvironment = AdminEnvironment.getInstance();
|
||||
oDatabaseDocument = workingEnvironment.getDatabaseDocument(PermissionMode.WRITER);
|
||||
oDatabaseDocument.begin();
|
||||
setAsEntryPoint();
|
||||
|
|
|
@ -67,7 +67,7 @@ public class CachedType<T extends Type> {
|
|||
ODatabaseDocument oDatabaseDocument = null;
|
||||
try {
|
||||
logger.debug("GettingType {} schema", typeName);
|
||||
AdminEnvironment adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
||||
AdminEnvironment adminSecurityContext = AdminEnvironment.getInstance();
|
||||
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.READER);
|
||||
OMetadata oMetadata = oDatabaseDocument.getMetadata();
|
||||
OSchema oSchema = oMetadata.getSchema();
|
||||
|
|
|
@ -31,7 +31,6 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaA
|
|||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaCreationException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException;
|
||||
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.instances.base.ElementManagement;
|
||||
|
@ -292,8 +291,8 @@ public class TypeManagement {
|
|||
throw new SchemaCreationException(error);
|
||||
}
|
||||
|
||||
AdminEnvironment adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
||||
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.WRITER);
|
||||
AdminEnvironment adminEnvironment = AdminEnvironment.getInstance();
|
||||
oDatabaseDocument = adminEnvironment.getDatabaseDocument(PermissionMode.WRITER);
|
||||
|
||||
OMetadata oMetadata = oDatabaseDocument.getMetadata();
|
||||
OSchema oSchema = oMetadata.getSchema();
|
||||
|
@ -469,8 +468,8 @@ public class TypeManagement {
|
|||
ODatabaseDocument oDatabaseDocument = null;
|
||||
try {
|
||||
|
||||
AdminEnvironment adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
||||
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.WRITER);
|
||||
AdminEnvironment adminEnvironment = AdminEnvironment.getInstance();
|
||||
oDatabaseDocument = adminEnvironment.getDatabaseDocument(PermissionMode.WRITER);
|
||||
|
||||
OMetadata oMetadata = oDatabaseDocument.getMetadata();
|
||||
OSchema oSchema = oMetadata.getSchema();
|
||||
|
@ -648,8 +647,8 @@ public class TypeManagement {
|
|||
protected List<Type> getSchema(boolean includeSubtypes) throws SchemaNotFoundException, SchemaException {
|
||||
ODatabaseDocument oDatabaseDocument = null;
|
||||
try {
|
||||
AdminEnvironment adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
||||
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.READER);
|
||||
AdminEnvironment adminEnvironment = AdminEnvironment.getInstance();
|
||||
oDatabaseDocument = adminEnvironment.getDatabaseDocument(PermissionMode.READER);
|
||||
|
||||
OMetadata oMetadata = oDatabaseDocument.getMetadata();
|
||||
OSchema oSchema = oMetadata.getSchema();
|
||||
|
@ -789,8 +788,8 @@ public class TypeManagement {
|
|||
protected boolean delete(AccessType accessType) throws SchemaException, SchemaNotFoundException{
|
||||
ODatabaseDocument oDatabaseDocument = null;
|
||||
try {
|
||||
AdminEnvironment adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
||||
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.READER);
|
||||
AdminEnvironment adminEnvironment = AdminEnvironment.getInstance();
|
||||
oDatabaseDocument = adminEnvironment.getDatabaseDocument(PermissionMode.READER);
|
||||
|
||||
OMetadata oMetadata = oDatabaseDocument.getMetadata();
|
||||
OSchema oSchema = oMetadata.getSchema();
|
||||
|
|
|
@ -93,8 +93,8 @@ public class OrientDBUtility {
|
|||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||
try {
|
||||
current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||
AdminEnvironment adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
||||
adminDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.READER);
|
||||
AdminEnvironment adminEnvironment = AdminEnvironment.getInstance();
|
||||
adminDatabaseDocument = adminEnvironment.getDatabaseDocument(PermissionMode.READER);
|
||||
return OrientDBUtility.getElementByUUID(adminDatabaseDocument, elementType, uuid, clz);
|
||||
} finally {
|
||||
if(adminDatabaseDocument != null) {
|
||||
|
|
|
@ -2,7 +2,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.contexts.ContextUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.environments.AdminEnvironment;
|
||||
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.PermissionMode;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
@ -27,7 +27,7 @@ public class DatabaseEnvironmentTest {
|
|||
|
||||
@Test
|
||||
public void testDateTimeFormat() throws ResourceRegistryException {
|
||||
ODatabaseDocument oDatabaseDocument = ContextUtility.getAdminSecurityContext().getDatabaseDocument(PermissionMode.WRITER);
|
||||
ODatabaseDocument oDatabaseDocument = AdminEnvironment.getInstance().getDatabaseDocument(PermissionMode.WRITER);
|
||||
String dateTime = oDatabaseDocument.get(ATTRIBUTES.DATETIMEFORMAT).toString();
|
||||
Assert.assertTrue(dateTime.compareTo(Element.DATETIME_PATTERN)==0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue