Fixing cache

This commit is contained in:
Luca Frosini 2023-05-10 17:57:10 +02:00
parent a21b1d9173
commit a8fb9de301
1 changed files with 17 additions and 0 deletions

View File

@ -102,6 +102,7 @@ public class ServerContextCache extends ContextCache {
return ElementManagement.isUserAllowedToGetPrivacyMeta();
}
@Override
public synchronized List<Context> 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<Context> contexts) {
this.contexts = new ArrayList<>();
this.contextsNoMeta = new ArrayList<>();