Added Context UUID cache
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@148299 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
e559991510
commit
ed6f906c7e
|
@ -191,8 +191,6 @@ public class ContextManagementImpl implements ContextManagement {
|
|||
logger.info("Trying to rename {} with UUID {} to {}", Context.NAME,
|
||||
contextUUID, newName);
|
||||
|
||||
ContextUtility.invalidCurrentContextUUIDCache();
|
||||
|
||||
orientGraph = SecurityContextMapper.getSecurityContextFactory(
|
||||
SecurityContextMapper.ADMIN_SECURITY_CONTEXT_UUID,
|
||||
PermissionMode.WRITER).getTx();
|
||||
|
@ -221,6 +219,8 @@ public class ContextManagementImpl implements ContextManagement {
|
|||
context.setProperty(Context.NAME_PROPERTY, newName);
|
||||
|
||||
orientGraph.commit();
|
||||
|
||||
ContextUtility.invalidContextUUIDCache(contextUUID);
|
||||
|
||||
String contextJsonString = Utility.toJsonString(context, true);
|
||||
logger.info("Context renamed {}", contextJsonString);
|
||||
|
@ -253,8 +253,6 @@ public class ContextManagementImpl implements ContextManagement {
|
|||
"Trying to move {} with UUID {} as child of {} with UUID {}",
|
||||
Context.NAME, contextToMoveUUID, Context.NAME, newParentUUID);
|
||||
|
||||
ContextUtility.invalidCurrentContextUUIDCache();
|
||||
|
||||
orientGraph = SecurityContextMapper.getSecurityContextFactory(
|
||||
SecurityContextMapper.ADMIN_SECURITY_CONTEXT_UUID,
|
||||
PermissionMode.WRITER).getTx();
|
||||
|
@ -288,6 +286,9 @@ public class ContextManagementImpl implements ContextManagement {
|
|||
|
||||
orientGraph.commit();
|
||||
|
||||
ContextUtility.invalidContextUUIDCache(contextToMoveUUID);
|
||||
|
||||
|
||||
context = getContext(orientGraph, contextToMoveUUID);
|
||||
String contextJsonString = Utility.toJsonString(context, true);
|
||||
logger.info("Context moved {}", contextJsonString);
|
||||
|
@ -320,7 +321,7 @@ public class ContextManagementImpl implements ContextManagement {
|
|||
try {
|
||||
logger.info("Trying to remove {} with UUID {}", Context.NAME, uuid);
|
||||
|
||||
ContextUtility.invalidCurrentContextUUIDCache();
|
||||
|
||||
|
||||
orientGraph = SecurityContextMapper.getSecurityContextFactory(
|
||||
SecurityContextMapper.ADMIN_SECURITY_CONTEXT_UUID,
|
||||
|
@ -342,6 +343,8 @@ public class ContextManagementImpl implements ContextManagement {
|
|||
context.remove();
|
||||
|
||||
orientGraph.commit();
|
||||
ContextUtility.invalidContextUUIDCache(uuid);
|
||||
|
||||
logger.info("{} with UUID {} successfully removed", Context.NAME,
|
||||
uuid);
|
||||
return true;
|
||||
|
|
|
@ -51,9 +51,15 @@ public class ContextUtility {
|
|||
contextUUIDCache = new HashMap<>();
|
||||
}
|
||||
|
||||
protected static void invalidCurrentContextUUIDCache(){
|
||||
String scope = getCurrentContext();
|
||||
contextUUIDCache.remove(scope);
|
||||
protected static void invalidContextUUIDCache(UUID uuid){
|
||||
for(String scope : contextUUIDCache.keySet()){
|
||||
UUID gotUUID = contextUUIDCache.get(scope);
|
||||
if(gotUUID.compareTo(uuid)==0){
|
||||
contextUUIDCache.remove(scope);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static UUID addToActualContext(OrientGraph orientGraph, Element element)
|
||||
|
|
Loading…
Reference in New Issue