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:
Luca Frosini 2017-05-04 15:43:36 +00:00
parent e559991510
commit ed6f906c7e
2 changed files with 17 additions and 8 deletions

View File

@ -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();
@ -222,6 +220,8 @@ public class ContextManagementImpl implements ContextManagement {
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;

View File

@ -51,9 +51,15 @@ public class ContextUtility {
contextUUIDCache = new HashMap<>();
}
protected static void invalidCurrentContextUUIDCache(){
String scope = getCurrentContext();
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)