Reorganizing naming
This commit is contained in:
parent
ae2ec3ca5d
commit
924b370a81
|
@ -69,11 +69,6 @@ public class ContextUtility {
|
||||||
return sm.getUser().getUsername();
|
return sm.getUser().getUsername();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AdminEnvironment getAdminSecurityContext() throws ResourceRegistryException {
|
|
||||||
AdminEnvironment adminSecurityContext = AdminEnvironment.getInstance();
|
|
||||||
return adminSecurityContext;
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized void addSecurityContext(InstanceEnvironment securityContext) {
|
public synchronized void addSecurityContext(InstanceEnvironment securityContext) {
|
||||||
contexts.put(securityContext.getUUID(), securityContext);
|
contexts.put(securityContext.getUUID(), securityContext);
|
||||||
}
|
}
|
||||||
|
@ -98,7 +93,7 @@ public class ContextUtility {
|
||||||
if(securityContext==null) {
|
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", SystemEnvironment.class.getSimpleName(),
|
||||||
fullName);
|
fullName);
|
||||||
oDatabaseDocument = getAdminSecurityContext().getDatabaseDocument(PermissionMode.READER);
|
oDatabaseDocument = AdminEnvironment.getInstance().getDatabaseDocument(PermissionMode.READER);
|
||||||
|
|
||||||
OVertex contextVertex = getContextVertexByFullName(oDatabaseDocument, fullName);
|
OVertex contextVertex = getContextVertexByFullName(oDatabaseDocument, fullName);
|
||||||
|
|
||||||
|
@ -191,7 +186,7 @@ public class ContextUtility {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if(contextVertex == null) {
|
if(contextVertex == null) {
|
||||||
oDatabaseDocument = getAdminSecurityContext().getDatabaseDocument(PermissionMode.READER);
|
oDatabaseDocument = AdminEnvironment.getInstance().getDatabaseDocument(PermissionMode.READER);
|
||||||
contextVertex = OrientDBUtility.getElementByUUID(oDatabaseDocument, Context.NAME, uuid, OVertex.class);
|
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;
|
protected final Map<Boolean,Map<PermissionMode,ODatabasePool>> poolMap;
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ public abstract class SystemEnvironment {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SystemEnvironment(UUID context, boolean hierarchical) throws ResourceRegistryException {
|
protected SystemEnvironment(UUID context, boolean hierarchical) throws ResourceRegistryException {
|
||||||
this.context = context;
|
this.environmentId = context;
|
||||||
this.poolMap = new HashMap<>();
|
this.poolMap = new HashMap<>();
|
||||||
|
|
||||||
this.allowedRoles = new HashSet<>(SystemEnvironment.allOperationAllowedRoles);
|
this.allowedRoles = new HashSet<>(SystemEnvironment.allOperationAllowedRoles);
|
||||||
|
@ -176,7 +176,7 @@ public abstract class SystemEnvironment {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ODatabaseDocument getAdminDatabaseDocument() throws ResourceRegistryException {
|
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() {
|
public UUID getUUID() {
|
||||||
return context;
|
return environmentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getRoleOrUserName(PermissionMode permissionMode, SecurityType securityType) {
|
public static String getRoleOrUserName(PermissionMode permissionMode, SecurityType securityType) {
|
||||||
|
@ -322,7 +322,7 @@ public abstract class SystemEnvironment {
|
||||||
StringBuilder stringBuilder = new StringBuilder();
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
stringBuilder.append(getRoleOrUserName(permissionMode, securityType, hierarchic));
|
stringBuilder.append(getRoleOrUserName(permissionMode, securityType, hierarchic));
|
||||||
stringBuilder.append("_");
|
stringBuilder.append("_");
|
||||||
stringBuilder.append(context.toString());
|
stringBuilder.append(environmentId.toString());
|
||||||
return stringBuilder.toString();
|
return stringBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -624,7 +624,7 @@ public abstract class SystemEnvironment {
|
||||||
public void create(ODatabaseDocument oDatabaseDocument) {
|
public void create(ODatabaseDocument oDatabaseDocument) {
|
||||||
OSecurity oSecurity = getOSecurity(oDatabaseDocument);
|
OSecurity oSecurity = getOSecurity(oDatabaseDocument);
|
||||||
createRolesAndUsers(oSecurity);
|
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) {
|
private void drop(OSecurity oSecurity, String name, SecurityType securityType) {
|
||||||
|
@ -731,9 +731,9 @@ public abstract class SystemEnvironment {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void delete(OSecurity oSecurity) {
|
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);
|
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 {
|
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 current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
ODatabaseDocument instanceDB = this.oDatabaseDocument;
|
ODatabaseDocument instanceDB = this.oDatabaseDocument;
|
||||||
try {
|
try {
|
||||||
AdminEnvironment adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
AdminEnvironment adminSecurityContext = AdminEnvironment.getInstance();
|
||||||
setOperation(Operation.GET_METADATA);
|
setOperation(Operation.GET_METADATA);
|
||||||
adminSecurityContext.isUserAllowed(operation);
|
adminSecurityContext.isUserAllowed(operation);
|
||||||
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.READER);
|
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.READER);
|
||||||
|
|
|
@ -32,8 +32,8 @@ public class ERManagementUtility {
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
ODatabaseDocument oDatabaseDocument = null;
|
ODatabaseDocument oDatabaseDocument = null;
|
||||||
try {
|
try {
|
||||||
AdminEnvironment adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
AdminEnvironment adminEnvironment = AdminEnvironment.getInstance();
|
||||||
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.WRITER);
|
oDatabaseDocument = adminEnvironment.getDatabaseDocument(PermissionMode.WRITER);
|
||||||
oDatabaseDocument.begin();
|
oDatabaseDocument.begin();
|
||||||
|
|
||||||
SystemEnvironment targetSecurityContext = ContextUtility.getInstance().getEnvironmentByUUID(contextUUID);
|
SystemEnvironment targetSecurityContext = ContextUtility.getInstance().getEnvironmentByUUID(contextUUID);
|
||||||
|
@ -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.setWorkingEnvironment(adminSecurityContext);
|
elementManagement.setWorkingEnvironment(adminEnvironment);
|
||||||
elementManagement.setODatabaseDocument(oDatabaseDocument);
|
elementManagement.setODatabaseDocument(oDatabaseDocument);
|
||||||
elementManagement.setUUID(uuid);
|
elementManagement.setUUID(uuid);
|
||||||
elementManagement.setElementType(type);
|
elementManagement.setElementType(type);
|
||||||
|
@ -113,8 +113,8 @@ public class ERManagementUtility {
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
ODatabaseDocument oDatabaseDocument = null;
|
ODatabaseDocument oDatabaseDocument = null;
|
||||||
try {
|
try {
|
||||||
AdminEnvironment adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
AdminEnvironment adminEnvironment = AdminEnvironment.getInstance();
|
||||||
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.WRITER);
|
oDatabaseDocument = adminEnvironment.getDatabaseDocument(PermissionMode.WRITER);
|
||||||
oDatabaseDocument.begin();
|
oDatabaseDocument.begin();
|
||||||
|
|
||||||
SystemEnvironment targetSecurityContext = ContextUtility.getInstance().getEnvironmentByUUID(contextUUID);
|
SystemEnvironment targetSecurityContext = ContextUtility.getInstance().getEnvironmentByUUID(contextUUID);
|
||||||
|
@ -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.setWorkingEnvironment(adminSecurityContext);
|
elementManagement.setWorkingEnvironment(adminEnvironment);
|
||||||
elementManagement.setODatabaseDocument(oDatabaseDocument);
|
elementManagement.setODatabaseDocument(oDatabaseDocument);
|
||||||
elementManagement.setUUID(uuid);
|
elementManagement.setUUID(uuid);
|
||||||
((ERManagement) elementManagement).setHonourPropagationConstraintsInContextSharing(false);
|
((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.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.environments.AdminEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.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;
|
||||||
|
@ -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);
|
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 {
|
||||||
workingEnvironment = ContextUtility.getAdminSecurityContext();
|
workingEnvironment = AdminEnvironment.getInstance();
|
||||||
oDatabaseDocument = workingEnvironment.getDatabaseDocument(PermissionMode.WRITER);
|
oDatabaseDocument = workingEnvironment.getDatabaseDocument(PermissionMode.WRITER);
|
||||||
oDatabaseDocument.begin();
|
oDatabaseDocument.begin();
|
||||||
setAsEntryPoint();
|
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);
|
logger.debug("Going to remove {} with UUID {} from Context with UUID {}", typeName, uuid, contextUUID);
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
try {
|
try {
|
||||||
workingEnvironment = ContextUtility.getAdminSecurityContext();
|
workingEnvironment = AdminEnvironment.getInstance();
|
||||||
oDatabaseDocument = workingEnvironment.getDatabaseDocument(PermissionMode.WRITER);
|
oDatabaseDocument = workingEnvironment.getDatabaseDocument(PermissionMode.WRITER);
|
||||||
oDatabaseDocument.begin();
|
oDatabaseDocument.begin();
|
||||||
setAsEntryPoint();
|
setAsEntryPoint();
|
||||||
|
@ -650,7 +651,7 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
||||||
|
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
try {
|
try {
|
||||||
workingEnvironment = ContextUtility.getAdminSecurityContext();
|
workingEnvironment = AdminEnvironment.getInstance();
|
||||||
oDatabaseDocument = workingEnvironment.getDatabaseDocument(PermissionMode.READER);
|
oDatabaseDocument = workingEnvironment.getDatabaseDocument(PermissionMode.READER);
|
||||||
|
|
||||||
setAsEntryPoint();
|
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.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.environments.AdminEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
|
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.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;
|
||||||
|
@ -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);
|
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 {
|
||||||
workingEnvironment = ContextUtility.getAdminSecurityContext();
|
workingEnvironment = AdminEnvironment.getInstance();
|
||||||
oDatabaseDocument = workingEnvironment.getDatabaseDocument(PermissionMode.WRITER);
|
oDatabaseDocument = workingEnvironment.getDatabaseDocument(PermissionMode.WRITER);
|
||||||
setAsEntryPoint();
|
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);
|
logger.debug("Going to remove {} with UUID {} from Context with UUID {}", typeName, uuid, contextUUID);
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
try {
|
try {
|
||||||
workingEnvironment = ContextUtility.getAdminSecurityContext();
|
workingEnvironment = AdminEnvironment.getInstance();
|
||||||
oDatabaseDocument = workingEnvironment.getDatabaseDocument(PermissionMode.WRITER);
|
oDatabaseDocument = workingEnvironment.getDatabaseDocument(PermissionMode.WRITER);
|
||||||
oDatabaseDocument.begin();
|
oDatabaseDocument.begin();
|
||||||
setAsEntryPoint();
|
setAsEntryPoint();
|
||||||
|
|
|
@ -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);
|
||||||
AdminEnvironment adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
AdminEnvironment adminSecurityContext = AdminEnvironment.getInstance();
|
||||||
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();
|
||||||
|
|
|
@ -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.SchemaCreationException;
|
||||||
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.environments.AdminEnvironment;
|
import org.gcube.informationsystem.resourceregistry.environments.AdminEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.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;
|
||||||
|
@ -292,8 +291,8 @@ public class TypeManagement {
|
||||||
throw new SchemaCreationException(error);
|
throw new SchemaCreationException(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
AdminEnvironment adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
AdminEnvironment adminEnvironment = AdminEnvironment.getInstance();
|
||||||
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.WRITER);
|
oDatabaseDocument = adminEnvironment.getDatabaseDocument(PermissionMode.WRITER);
|
||||||
|
|
||||||
OMetadata oMetadata = oDatabaseDocument.getMetadata();
|
OMetadata oMetadata = oDatabaseDocument.getMetadata();
|
||||||
OSchema oSchema = oMetadata.getSchema();
|
OSchema oSchema = oMetadata.getSchema();
|
||||||
|
@ -469,8 +468,8 @@ public class TypeManagement {
|
||||||
ODatabaseDocument oDatabaseDocument = null;
|
ODatabaseDocument oDatabaseDocument = null;
|
||||||
try {
|
try {
|
||||||
|
|
||||||
AdminEnvironment adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
AdminEnvironment adminEnvironment = AdminEnvironment.getInstance();
|
||||||
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.WRITER);
|
oDatabaseDocument = adminEnvironment.getDatabaseDocument(PermissionMode.WRITER);
|
||||||
|
|
||||||
OMetadata oMetadata = oDatabaseDocument.getMetadata();
|
OMetadata oMetadata = oDatabaseDocument.getMetadata();
|
||||||
OSchema oSchema = oMetadata.getSchema();
|
OSchema oSchema = oMetadata.getSchema();
|
||||||
|
@ -648,8 +647,8 @@ 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 {
|
||||||
AdminEnvironment adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
AdminEnvironment adminEnvironment = AdminEnvironment.getInstance();
|
||||||
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.READER);
|
oDatabaseDocument = adminEnvironment.getDatabaseDocument(PermissionMode.READER);
|
||||||
|
|
||||||
OMetadata oMetadata = oDatabaseDocument.getMetadata();
|
OMetadata oMetadata = oDatabaseDocument.getMetadata();
|
||||||
OSchema oSchema = oMetadata.getSchema();
|
OSchema oSchema = oMetadata.getSchema();
|
||||||
|
@ -789,8 +788,8 @@ 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 {
|
||||||
AdminEnvironment adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
AdminEnvironment adminEnvironment = AdminEnvironment.getInstance();
|
||||||
oDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.READER);
|
oDatabaseDocument = adminEnvironment.getDatabaseDocument(PermissionMode.READER);
|
||||||
|
|
||||||
OMetadata oMetadata = oDatabaseDocument.getMetadata();
|
OMetadata oMetadata = oDatabaseDocument.getMetadata();
|
||||||
OSchema oSchema = oMetadata.getSchema();
|
OSchema oSchema = oMetadata.getSchema();
|
||||||
|
|
|
@ -93,8 +93,8 @@ public class OrientDBUtility {
|
||||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
try {
|
try {
|
||||||
current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||||
AdminEnvironment adminSecurityContext = ContextUtility.getAdminSecurityContext();
|
AdminEnvironment adminEnvironment = AdminEnvironment.getInstance();
|
||||||
adminDatabaseDocument = adminSecurityContext.getDatabaseDocument(PermissionMode.READER);
|
adminDatabaseDocument = adminEnvironment.getDatabaseDocument(PermissionMode.READER);
|
||||||
return OrientDBUtility.getElementByUUID(adminDatabaseDocument, elementType, uuid, clz);
|
return OrientDBUtility.getElementByUUID(adminDatabaseDocument, elementType, uuid, clz);
|
||||||
} finally {
|
} finally {
|
||||||
if(adminDatabaseDocument != null) {
|
if(adminDatabaseDocument != null) {
|
||||||
|
|
|
@ -2,7 +2,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.environments.AdminEnvironment;
|
||||||
import org.gcube.informationsystem.resourceregistry.environments.SystemEnvironment.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;
|
||||||
|
@ -27,7 +27,7 @@ public class DatabaseEnvironmentTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testDateTimeFormat() throws ResourceRegistryException {
|
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();
|
String dateTime = oDatabaseDocument.get(ATTRIBUTES.DATETIMEFORMAT).toString();
|
||||||
Assert.assertTrue(dateTime.compareTo(Element.DATETIME_PATTERN)==0);
|
Assert.assertTrue(dateTime.compareTo(Element.DATETIME_PATTERN)==0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue