diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/contexts/ServerContextCache.java b/src/main/java/org/gcube/informationsystem/resourceregistry/contexts/ServerContextCache.java index fa9258d..4a76258 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/contexts/ServerContextCache.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/contexts/ServerContextCache.java @@ -102,6 +102,7 @@ public class ServerContextCache extends ContextCache { return ElementManagement.isUserAllowedToGetPrivacyMeta(); } + @Override public synchronized List getContexts() throws ResourceRegistryException { refreshContextsIfNeeded(); ServerRequestInfo requestInfo = RequestUtility.getRequestInfo().get(); @@ -115,6 +116,21 @@ public class ServerContextCache extends ContextCache { } } + @Override + public synchronized Context getContextByUUID(UUID uuid) throws ResourceRegistryException { + refreshContextsIfNeeded(); + ServerRequestInfo requestInfo = RequestUtility.getRequestInfo().get(); + if(requestInfo.getUriInfo()!=null && !requestInfo.includeMeta()){ + return uuidToContextNoMeta.get(uuid); + } + if(isUserAllowedToGetPrivacyMeta()) { + return uuidToContext.get(uuid); + }else { + return uuidToContextMetaPrivacy.get(uuid); + } + } + + protected Metadata getMetadataForPrivacy(ObjectMapper objectMapper, Metadata metadata) { ObjectNode objectNode = objectMapper.valueToTree(metadata); objectNode.replace(Metadata.CREATED_BY_PROPERTY, new TextNode(Metadata.HIDDEN_FOR_PRIVACY_USER)); @@ -127,6 +143,7 @@ public class ServerContextCache extends ContextCache { } } + @Override protected void setContexts(List contexts) { this.contexts = new ArrayList<>(); this.contextsNoMeta = new ArrayList<>();