Managing Context Cache
This commit is contained in:
parent
024af70188
commit
f4600172e2
|
@ -9,7 +9,6 @@ import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
|||
import org.gcube.common.scope.impl.ScopeBean;
|
||||
import org.gcube.informationsystem.contexts.reference.entities.Context;
|
||||
import org.gcube.informationsystem.contexts.reference.relations.IsParentOf;
|
||||
import org.gcube.informationsystem.resourceregistry.api.contexts.ContextCache;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException;
|
||||
|
@ -83,7 +82,7 @@ public class ContextUtility {
|
|||
SecurityContext securityContext = null;
|
||||
|
||||
logger.trace("Trying to get {} for {}", SecurityContext.class.getSimpleName(), fullName);
|
||||
UUID uuid = ContextCache.getInstance().getUUIDByFullName(fullName);
|
||||
UUID uuid = ServerContextCache.getInstance().getUUIDByFullName(fullName);
|
||||
|
||||
if(uuid != null) {
|
||||
securityContext = contexts.get(uuid);
|
||||
|
|
|
@ -0,0 +1,205 @@
|
|||
package org.gcube.informationsystem.resourceregistry.contexts;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.gcube.com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.gcube.com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.gcube.com.fasterxml.jackson.databind.node.TextNode;
|
||||
import org.gcube.informationsystem.contexts.impl.entities.ContextImpl;
|
||||
import org.gcube.informationsystem.contexts.impl.relations.IsParentOfImpl;
|
||||
import org.gcube.informationsystem.contexts.reference.entities.Context;
|
||||
import org.gcube.informationsystem.contexts.reference.relations.IsParentOf;
|
||||
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||
import org.gcube.informationsystem.resourceregistry.api.contexts.ContextCache;
|
||||
import org.gcube.informationsystem.resourceregistry.api.contexts.ContextCacheRenewal;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.entities.ContextManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.requests.RequestUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.requests.ServerRequestInfo;
|
||||
import org.gcube.informationsystem.serialization.ElementMapper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
*/
|
||||
public class ServerContextCache extends ContextCache {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(ServerContextCache.class);
|
||||
|
||||
protected List<Context> contextsNoMeta;
|
||||
protected Map<UUID, Context> uuidToContextNoMeta;
|
||||
|
||||
protected List<Context> contextsMetaPrivacy;
|
||||
protected Map<UUID, Context> uuidToContextMetaPrivacy;
|
||||
|
||||
protected boolean includeMeta;
|
||||
|
||||
protected static ServerContextCache singleton;
|
||||
|
||||
public synchronized static ServerContextCache getInstance() {
|
||||
if(singleton==null) {
|
||||
singleton = new ServerContextCache();
|
||||
}
|
||||
return singleton;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cleanCache() {
|
||||
cleanCache(Calendar.getInstance());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void cleanCache(Calendar now) {
|
||||
super.cleanCache(now);
|
||||
contextsNoMeta = null;
|
||||
uuidToContextNoMeta = new LinkedHashMap<>();
|
||||
contextsMetaPrivacy = null;
|
||||
uuidToContextMetaPrivacy = new LinkedHashMap<>();
|
||||
}
|
||||
|
||||
public ServerContextCache() {
|
||||
super();
|
||||
cleanCache();
|
||||
initContextCacheRenewal();
|
||||
}
|
||||
|
||||
public boolean isIncludeMeta() {
|
||||
return includeMeta;
|
||||
}
|
||||
|
||||
public void setIncludeMeta(boolean includeMeta) {
|
||||
this.includeMeta = includeMeta;
|
||||
}
|
||||
|
||||
public void initContextCacheRenewal() {
|
||||
ContextCacheRenewal contextCacheRenewal = new ContextCacheRenewal() {
|
||||
@Override
|
||||
public List<Context> renew() throws ResourceRegistryException {
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
String contextsJsonString = contextManagement.allFromServer(false);
|
||||
List<Context> contexts = null;
|
||||
try {
|
||||
contexts = ElementMapper.unmarshalList(contextsJsonString);
|
||||
} catch (IOException e) {
|
||||
logger.error("Unable to read contexts from DB", e);
|
||||
}
|
||||
return contexts;
|
||||
}
|
||||
};
|
||||
setContextCacheRenewal(contextCacheRenewal);
|
||||
}
|
||||
|
||||
protected boolean isUserAllowedToGetPrivacyMeta() {
|
||||
// TODO
|
||||
return true;
|
||||
}
|
||||
|
||||
public synchronized List<Context> getContexts() throws ResourceRegistryException {
|
||||
refreshContextsIfNeeded();
|
||||
ServerRequestInfo requestInfo = RequestUtility.getRequestInfo().get();
|
||||
if(requestInfo.getUriInfo()!=null && !requestInfo.includeMeta()){
|
||||
return contextsNoMeta;
|
||||
}
|
||||
if(isUserAllowedToGetPrivacyMeta()) {
|
||||
return contexts;
|
||||
}else {
|
||||
return contextsMetaPrivacy;
|
||||
}
|
||||
}
|
||||
|
||||
protected Metadata getMetadataForPrivacy(ObjectMapper objectMapper, Metadata metadata) {
|
||||
ObjectNode objectNode = objectMapper.valueToTree(metadata);
|
||||
objectNode.set(Metadata.CREATED_BY_PROPERTY, new TextNode(Metadata.HIDDEN_FOR_PRIVACY_USER));
|
||||
objectNode.set(Metadata.LAST_UPDATE_BY_PROPERTY, new TextNode(Metadata.HIDDEN_FOR_PRIVACY_USER));
|
||||
try {
|
||||
Metadata metadataWithPrivacy = objectMapper.treeToValue(objectNode, Metadata.class);
|
||||
return metadataWithPrivacy;
|
||||
} catch (JsonProcessingException e) {
|
||||
return metadata;
|
||||
}
|
||||
}
|
||||
|
||||
protected void setContexts(List<Context> contexts) {
|
||||
this.contexts = new ArrayList<>();
|
||||
this.contextsNoMeta = new ArrayList<>();
|
||||
this.contextsMetaPrivacy = new ArrayList<>();
|
||||
|
||||
ObjectMapper objectMapper = ElementMapper.getObjectMapper();
|
||||
|
||||
for(Context c : contexts) {
|
||||
UUID uuid = c.getID();
|
||||
|
||||
Context contextWithMeta = new ContextImpl(c.getName());
|
||||
contextWithMeta.setMetadata(c.getMetadata());
|
||||
contextWithMeta.setID(uuid);
|
||||
this.contexts.add(contextWithMeta);
|
||||
this.uuidToContext.put(uuid, contextWithMeta);
|
||||
|
||||
Context contextMetaPrivacy = new ContextImpl(c.getName());
|
||||
Metadata metadataWithPrivacy = getMetadataForPrivacy(objectMapper, c.getMetadata());
|
||||
contextMetaPrivacy.setMetadata(metadataWithPrivacy);
|
||||
contextMetaPrivacy.setID(uuid);
|
||||
this.contextsMetaPrivacy.add(contextMetaPrivacy);
|
||||
this.uuidToContextMetaPrivacy.put(uuid, contextMetaPrivacy);
|
||||
|
||||
Context contextNoMeta = new ContextImpl(c.getName());
|
||||
contextWithMeta.setID(uuid);
|
||||
this.contextsNoMeta.add(contextNoMeta);
|
||||
this.uuidToContextNoMeta.put(uuid, contextNoMeta);
|
||||
|
||||
}
|
||||
|
||||
for(Context c : contexts) {
|
||||
UUID uuid = c.getID();
|
||||
|
||||
Context contextMeta = this.uuidToContext.get(uuid);
|
||||
Context contextMetaPrivacy = this.uuidToContextMetaPrivacy.get(uuid);
|
||||
Context contextNoMeta = this.uuidToContextNoMeta.get(uuid);
|
||||
|
||||
|
||||
if(c.getParent()!=null) {
|
||||
IsParentOf ipo = c.getParent();
|
||||
UUID parentUUID = ipo.getSource().getID();
|
||||
|
||||
Context parentWithMeta = this.uuidToContext.get(parentUUID);
|
||||
IsParentOf isParentOf = new IsParentOfImpl(parentWithMeta, contextMeta);
|
||||
isParentOf.setID(parentUUID);
|
||||
isParentOf.setMetadata(ipo.getMetadata());
|
||||
parentWithMeta.addChild(isParentOf);
|
||||
contextMeta.setParent(isParentOf);
|
||||
|
||||
Context parentWithMetaPrivacy = this.uuidToContextMetaPrivacy.get(parentUUID);
|
||||
IsParentOf isParentOfMetaPrivacy = new IsParentOfImpl(parentWithMetaPrivacy, contextMetaPrivacy);
|
||||
isParentOfMetaPrivacy.setID(parentUUID);
|
||||
Metadata metadataWithPrivacy = getMetadataForPrivacy(objectMapper, ipo.getMetadata());
|
||||
isParentOfMetaPrivacy.setMetadata(metadataWithPrivacy);
|
||||
parentWithMetaPrivacy.addChild(isParentOfMetaPrivacy);
|
||||
contextMetaPrivacy.setParent(isParentOfMetaPrivacy);
|
||||
|
||||
Context parentNoMeta = this.uuidToContextNoMeta.get(parentUUID);
|
||||
IsParentOf isParentOfNoMeta = new IsParentOfImpl(parentNoMeta, contextNoMeta);
|
||||
isParentOfNoMeta.setID(parentUUID);
|
||||
parentNoMeta.addChild(isParentOfNoMeta);
|
||||
contextNoMeta.setParent(isParentOfNoMeta);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for(Context context : contexts) {
|
||||
UUID uuid = context.getID();
|
||||
String fullName = getContextFullName(context);
|
||||
this.uuidToContextFullName.put(uuid, fullName);
|
||||
this.contextFullNameToUUID.put(fullName, uuid);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -17,7 +17,6 @@ import org.gcube.informationsystem.base.reference.IdentifiableElement;
|
|||
import org.gcube.informationsystem.contexts.reference.entities.Context;
|
||||
import org.gcube.informationsystem.contexts.reference.relations.IsParentOf;
|
||||
import org.gcube.informationsystem.model.reference.relations.Relation;
|
||||
import org.gcube.informationsystem.resourceregistry.api.contexts.ContextCache;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.AlreadyPresentException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.AvailableInAnotherContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
|
||||
|
@ -27,6 +26,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.Cont
|
|||
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.ServerContextCache;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.relations.IsParentOfManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.security.ContextSecurityContext;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
|
||||
|
@ -61,6 +61,8 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
|
|||
this.ignoreStartWithKeys.add(Context.PARENT_PROPERTY);
|
||||
this.ignoreStartWithKeys.add(Context.CHILDREN_PROPERTY);
|
||||
this.typeName = Context.NAME;
|
||||
this.forceIncludeMeta = true;
|
||||
this.forceIncludeAllMeta = true;
|
||||
}
|
||||
|
||||
public ContextManagement() {
|
||||
|
@ -267,7 +269,7 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
|
|||
if (parentSecurityContext != null && securityContext != null) {
|
||||
parentSecurityContext.getChildren().remove(securityContext);
|
||||
}
|
||||
ContextCache.getInstance().cleanCache();
|
||||
ServerContextCache.getInstance().cleanCache();
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
@ -346,7 +348,7 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
|
|||
|
||||
element = (OVertex) updateProperties(oClass, getElement(), jsonNode, ignoreKeys, ignoreStartWithKeys);
|
||||
|
||||
ContextCache.getInstance().cleanCache();
|
||||
ServerContextCache.getInstance().cleanCache();
|
||||
|
||||
return element;
|
||||
}
|
||||
|
@ -403,7 +405,7 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
|
|||
SecurityContext securityContext = contextUtility.getSecurityContextByUUID(uuid);
|
||||
securityContext.delete(oDatabaseDocument);
|
||||
|
||||
ContextCache.getInstance().cleanCache();
|
||||
ServerContextCache.getInstance().cleanCache();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -413,6 +415,8 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
|
|||
Iterable<ODocument> iterable = oDatabaseDocument.browseClass(typeName, polymorphic);
|
||||
for (ODocument vertex : iterable) {
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
contextManagement.setForceIncludeMeta(forceIncludeMeta);
|
||||
contextManagement.setForceIncludeAllMeta(forceIncludeAllMeta);
|
||||
contextManagement.setElement((OVertex) vertex);
|
||||
try {
|
||||
JsonNode jsonObject = contextManagement.serializeAsJsonNode();
|
||||
|
@ -436,11 +440,8 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
|
|||
@Override
|
||||
public String all(boolean polymorphic) throws ResourceRegistryException {
|
||||
try {
|
||||
ContextCache contextCache = ContextCache.getInstance();
|
||||
ServerContextCache contextCache = ServerContextCache.getInstance();
|
||||
List<Context> contexts = contextCache.getContexts();
|
||||
if(contexts==null) {
|
||||
return allFromServer(polymorphic);
|
||||
}
|
||||
return ElementMapper.marshal(contexts);
|
||||
} catch (JsonProcessingException | ResourceRegistryException e) {
|
||||
return allFromServer(polymorphic);
|
||||
|
@ -455,7 +456,7 @@ public class ContextManagement extends EntityElementManagement<Context, EntityTy
|
|||
public String readAsString()
|
||||
throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
|
||||
try {
|
||||
ContextCache contextCache = ContextCache.getInstance();
|
||||
ServerContextCache contextCache = ServerContextCache.getInstance();
|
||||
return ElementMapper.marshal(contextCache.getContextByUUID(uuid));
|
||||
} catch (JsonProcessingException | ResourceRegistryException e) {
|
||||
return readFromServer();
|
||||
|
|
|
@ -38,8 +38,10 @@ public class IsParentOfManagement extends RelationElementManagement<ContextManag
|
|||
this();
|
||||
this.oDatabaseDocument = oDatabaseDocument;
|
||||
getWorkingContext();
|
||||
includeSource = false;
|
||||
includeTarget = true;
|
||||
this.includeSource = false;
|
||||
this.includeTarget = true;
|
||||
this.forceIncludeMeta = true;
|
||||
this.forceIncludeAllMeta = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.gcube.informationsystem.resourceregistry.dbinitialization;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.security.Key;
|
||||
|
@ -18,16 +17,12 @@ import org.gcube.informationsystem.base.reference.Element;
|
|||
import org.gcube.informationsystem.base.reference.entities.EntityElement;
|
||||
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
|
||||
import org.gcube.informationsystem.base.reference.relations.RelationElement;
|
||||
import org.gcube.informationsystem.contexts.reference.entities.Context;
|
||||
import org.gcube.informationsystem.discovery.Discovery;
|
||||
import org.gcube.informationsystem.discovery.RegistrationProvider;
|
||||
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||
import org.gcube.informationsystem.model.reference.properties.Property;
|
||||
import org.gcube.informationsystem.resourceregistry.api.contexts.ContextCache;
|
||||
import org.gcube.informationsystem.resourceregistry.api.contexts.ContextCacheRenewal;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaAlreadyPresentException;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.entities.ContextManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.ServerContextCache;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.security.AdminSecurityContext;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.security.ContextSecurityContext;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.security.QueryTemplatesSecurityContext;
|
||||
|
@ -36,7 +31,6 @@ import org.gcube.informationsystem.resourceregistry.contexts.security.TypeSecuri
|
|||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.types.TypeManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.types.properties.PropertyTypeDefinitionManagement;
|
||||
import org.gcube.informationsystem.serialization.ElementMapper;
|
||||
import org.gcube.informationsystem.types.TypeMapper;
|
||||
import org.gcube.informationsystem.types.reference.Type;
|
||||
import org.gcube.informationsystem.types.reference.entities.EntityType;
|
||||
|
@ -292,8 +286,8 @@ public class DatabaseEnvironment {
|
|||
|
||||
KEY = initDbKey(properties);
|
||||
|
||||
initContextCacheRenewal();
|
||||
|
||||
// Initializing ServerContextCache instance
|
||||
ServerContextCache.getInstance();
|
||||
}
|
||||
|
||||
protected static Key initDbKey(Properties properties) {
|
||||
|
@ -381,26 +375,6 @@ public class DatabaseEnvironment {
|
|||
}
|
||||
}
|
||||
|
||||
public static void initContextCacheRenewal() {
|
||||
ContextCacheRenewal contextCacheRenewal = new ContextCacheRenewal() {
|
||||
|
||||
@Override
|
||||
public List<Context> renew() throws ResourceRegistryException {
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
String contextsJsonString = contextManagement.allFromServer(false);
|
||||
List<Context> contexts = null;
|
||||
try {
|
||||
contexts = ElementMapper.unmarshalList(contextsJsonString);
|
||||
} catch (IOException e) {
|
||||
logger.error("Unable to read contexts from DB", e);
|
||||
}
|
||||
return contexts;
|
||||
}
|
||||
};
|
||||
ContextCache.getInstance().setContextCacheRenewal(contextCacheRenewal);
|
||||
}
|
||||
|
||||
|
||||
public static Key getDatabaseKey() {
|
||||
return KEY;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,6 @@ import org.gcube.informationsystem.model.reference.ERElement;
|
|||
import org.gcube.informationsystem.model.reference.properties.Metadata;
|
||||
import org.gcube.informationsystem.model.reference.properties.Property;
|
||||
import org.gcube.informationsystem.model.reference.relations.Relation;
|
||||
import org.gcube.informationsystem.resourceregistry.api.contexts.ContextCache;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.AlreadyPresentException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.AvailableInAnotherContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
|
||||
|
@ -41,13 +40,14 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.Cont
|
|||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.ServerContextCache;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.security.AdminSecurityContext;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.base.properties.PropertyElementManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.Operation;
|
||||
import org.gcube.informationsystem.resourceregistry.requests.ServerRequestInfo;
|
||||
import org.gcube.informationsystem.resourceregistry.requests.RequestUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.requests.ServerRequestInfo;
|
||||
import org.gcube.informationsystem.resourceregistry.types.CachedType;
|
||||
import org.gcube.informationsystem.resourceregistry.types.TypesCache;
|
||||
import org.gcube.informationsystem.resourceregistry.utils.MetadataOrient;
|
||||
|
@ -104,6 +104,19 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
|
|||
protected El element;
|
||||
protected boolean reload;
|
||||
|
||||
/**
|
||||
* Used to force Meta inclusion.
|
||||
* It is use for example to request to include meta
|
||||
* by the context cache manager.
|
||||
*/
|
||||
protected boolean forceIncludeMeta;
|
||||
/**
|
||||
* Used to force Meta inclusion in all instances.
|
||||
* It is use for example to request to include meta
|
||||
* by the context cache manager.
|
||||
*/
|
||||
protected boolean forceIncludeAllMeta;
|
||||
|
||||
/**
|
||||
* Some operation, e.g. delete has a cascade impact which is not know a priori by the client.
|
||||
* Setting this variable to false the system just simulate the operation so an interested client
|
||||
|
@ -165,9 +178,30 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
|
|||
this.dryRun = false;
|
||||
|
||||
this.affectedInstances = new HashMap<>();
|
||||
|
||||
this.forceIncludeMeta = false;
|
||||
this.forceIncludeAllMeta = false;
|
||||
}
|
||||
|
||||
public boolean isForceIncludeMeta() {
|
||||
return forceIncludeMeta;
|
||||
}
|
||||
|
||||
|
||||
public void setForceIncludeMeta(boolean forceIncludeMeta) {
|
||||
this.forceIncludeMeta = forceIncludeMeta;
|
||||
}
|
||||
|
||||
|
||||
public boolean isForceIncludeAllMeta() {
|
||||
return forceIncludeAllMeta;
|
||||
}
|
||||
|
||||
|
||||
public void setForceIncludeAllMeta(boolean forceIncludeAllMeta) {
|
||||
this.forceIncludeAllMeta = forceIncludeAllMeta;
|
||||
}
|
||||
|
||||
|
||||
public Map<UUID,JsonNode> getAffectedInstances() {
|
||||
return affectedInstances;
|
||||
}
|
||||
|
@ -406,9 +440,9 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
|
|||
ServerRequestInfo requestInfo = RequestUtility.getRequestInfo().get();
|
||||
|
||||
List<String> keysToAddFirst = new ArrayList<>();
|
||||
keysToAddFirst.add(IdentifiableElement.ID_PROPERTY);
|
||||
keysToAddFirst.add(Element.TYPE_PROPERTY);
|
||||
keysToAddFirst.add(Element.SUPERTYPES_PROPERTY);
|
||||
keysToAddFirst.add(IdentifiableElement.ID_PROPERTY);
|
||||
keysToAddFirst.add(IdentifiableElement.METADATA_PROPERTY);
|
||||
keysToAddFirst.add(ERElement.CONTEXTS_PROPERTY);
|
||||
keysToAddFirst.add(Relation.PROPAGATION_CONSTRAINT_PROPERTY);
|
||||
|
@ -426,8 +460,8 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
|
|||
break;
|
||||
|
||||
case IdentifiableElement.METADATA_PROPERTY:
|
||||
if(requestInfo.includeMeta()) {
|
||||
if(requestInfo.allMeta() || entryPoint) {
|
||||
if(requestInfo.includeMeta() || forceIncludeMeta) {
|
||||
if(requestInfo.allMeta() || entryPoint || forceIncludeAllMeta) {
|
||||
analizeProperty(element, key, objectNode);
|
||||
}
|
||||
}
|
||||
|
@ -922,7 +956,7 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
|
|||
private ObjectNode getContextsAsObjectNode(ObjectMapper objectMapper) throws NotFoundException, ContextException, ResourceRegistryException {
|
||||
try {
|
||||
Set<String> contexts = getContextsSet();
|
||||
ContextCache contextCache = ContextCache.getInstance();
|
||||
ServerContextCache contextCache = ServerContextCache.getInstance();
|
||||
ObjectNode objectNode = objectMapper.createObjectNode();
|
||||
for(String contextUUID : contexts) {
|
||||
String contextFullName = contextCache.getContextFullNameByUUID(contextUUID);
|
||||
|
|
|
@ -20,7 +20,6 @@ import org.gcube.informationsystem.model.reference.entities.Facet;
|
|||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||
import org.gcube.informationsystem.model.reference.relations.ConsistsOf;
|
||||
import org.gcube.informationsystem.model.reference.relations.Relation;
|
||||
import org.gcube.informationsystem.resourceregistry.api.contexts.ContextCache;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.AvailableInAnotherContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
|
@ -30,6 +29,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.queries.Inval
|
|||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.ServerContextCache;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
||||
|
@ -350,7 +350,7 @@ public abstract class EntityManagement<E extends Entity, ET extends EntityType>
|
|||
|
||||
@Override
|
||||
public void addToContext(UUID contextUUID) throws SchemaViolationException, NotFoundException, ContextException, ResourceRegistryException {
|
||||
String contextFullName = ContextCache.getInstance().getContextFullNameByUUID(contextUUID);
|
||||
String contextFullName = ServerContextCache.getInstance().getContextFullNameByUUID(contextUUID);
|
||||
logger.info("Going to add {} with UUID {} to Context with UUID {} (i.e. {})", accessType.getName(), uuid, contextUUID, contextFullName);
|
||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||
try {
|
||||
|
|
|
@ -21,7 +21,6 @@ import org.gcube.informationsystem.model.reference.properties.PropagationConstra
|
|||
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.RemoveConstraint;
|
||||
import org.gcube.informationsystem.model.reference.relations.ConsistsOf;
|
||||
import org.gcube.informationsystem.model.reference.relations.Relation;
|
||||
import org.gcube.informationsystem.resourceregistry.api.contexts.ContextCache;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.AvailableInAnotherContextException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
|
@ -29,6 +28,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.Cont
|
|||
import org.gcube.informationsystem.resourceregistry.api.exceptions.relations.RelationNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.ServerContextCache;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
||||
|
@ -41,8 +41,8 @@ import org.gcube.informationsystem.resourceregistry.instances.model.entities.Fac
|
|||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.types.TypesCache;
|
||||
import org.gcube.informationsystem.resourceregistry.utils.MetadataUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.utils.PropagationConstraintOrient;
|
||||
import org.gcube.informationsystem.resourceregistry.utils.OrientDBUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.utils.PropagationConstraintOrient;
|
||||
import org.gcube.informationsystem.serialization.ElementMapper;
|
||||
import org.gcube.informationsystem.types.reference.entities.EntityType;
|
||||
import org.gcube.informationsystem.types.reference.entities.ResourceType;
|
||||
|
@ -510,7 +510,7 @@ public abstract class RelationManagement<T extends EntityManagement<? extends En
|
|||
|
||||
@Override
|
||||
public void addToContext(UUID contextUUID) throws SchemaViolationException, NotFoundException, ContextException, ResourceRegistryException {
|
||||
String contextFullName = ContextCache.getInstance().getContextFullNameByUUID(contextUUID);
|
||||
String contextFullName = ServerContextCache.getInstance().getContextFullNameByUUID(contextUUID);
|
||||
logger.debug("Going to add {} with UUID {} to Context with UUID {} (i.e {})", accessType.getName(), uuid, contextUUID, contextFullName);
|
||||
ODatabaseDocument current = ContextUtility.getCurrentODatabaseDocumentFromThreadLocal();
|
||||
try {
|
||||
|
|
|
@ -47,8 +47,13 @@ public class ServerRequestInfo implements RequestInfo {
|
|||
this.allMeta = false;
|
||||
this.hierarchicalMode = false;
|
||||
this.includeContexts = false;
|
||||
this.uriInfo = null;
|
||||
}
|
||||
|
||||
public UriInfo getUriInfo() {
|
||||
return uriInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* -check if the user is allowed to set such a request
|
||||
* @param queryParameterKey requested query parameter
|
||||
|
@ -136,11 +141,11 @@ public class ServerRequestInfo implements RequestInfo {
|
|||
}
|
||||
|
||||
public void checkIncludeQueryParameters() {
|
||||
checkIncludeMetaQueryParameters();
|
||||
checkIncludeAllMetaQueryParameters();
|
||||
checkQueryParameter(InstancePath.INCLUDE_CONTEXTS_QUERY_PARAMETER);
|
||||
}
|
||||
|
||||
public void checkIncludeMetaQueryParameters() {
|
||||
public void checkIncludeAllMetaQueryParameters() {
|
||||
checkQueryParameter(InstancePath.INCLUDE_META_QUERY_PARAMETER);
|
||||
checkQueryParameter(InstancePath.INCLUDE_META_IN_ALL_INSTANCES_QUERY_PARAMETER);
|
||||
}
|
||||
|
|
|
@ -72,7 +72,7 @@ public class Access extends BaseRest {
|
|||
CalledMethodProvider.instance.set("listContexts");
|
||||
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkIncludeMetaQueryParameters();
|
||||
serverRequestInfo.checkIncludeAllMetaQueryParameters();
|
||||
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
return contextManagement.all(false);
|
||||
|
@ -94,7 +94,7 @@ public class Access extends BaseRest {
|
|||
CalledMethodProvider.instance.set("readContext");
|
||||
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkIncludeMetaQueryParameters();
|
||||
serverRequestInfo.checkIncludeAllMetaQueryParameters();
|
||||
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
contextManagement.setUUID(UUID.fromString(uuid));
|
||||
|
@ -115,7 +115,7 @@ public class Access extends BaseRest {
|
|||
CalledMethodProvider.instance.set("readType");
|
||||
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkIncludeMetaQueryParameters();
|
||||
serverRequestInfo.checkIncludeAllMetaQueryParameters();
|
||||
|
||||
TypeManagement typeManagement = new TypeManagement();
|
||||
typeManagement.setTypeName(type);
|
||||
|
|
|
@ -47,7 +47,8 @@ public class ContextManager extends BaseRest {
|
|||
CalledMethodProvider.instance.set("listContexts");
|
||||
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkIncludeMetaQueryParameters();
|
||||
serverRequestInfo.setAllMeta(true);
|
||||
serverRequestInfo.checkQueryParameter(ContextPath.INCLUDE_META_QUERY_PARAMETER);
|
||||
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
return contextManagement.all(false);
|
||||
|
@ -71,7 +72,8 @@ public class ContextManager extends BaseRest {
|
|||
CalledMethodProvider.instance.set("readContext");
|
||||
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkIncludeMetaQueryParameters();
|
||||
serverRequestInfo.setAllMeta(true);
|
||||
serverRequestInfo.checkQueryParameter(ContextPath.INCLUDE_META_QUERY_PARAMETER);
|
||||
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
contextManagement.setUUID(UUID.fromString(uuid));
|
||||
|
@ -95,7 +97,8 @@ public class ContextManager extends BaseRest {
|
|||
CalledMethodProvider.instance.set("updateContext");
|
||||
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkIncludeMetaQueryParameters();
|
||||
serverRequestInfo.setAllMeta(true);
|
||||
serverRequestInfo.checkQueryParameter(ContextPath.INCLUDE_META_QUERY_PARAMETER);
|
||||
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
contextManagement.setUUID(UUID.fromString(uuid));
|
||||
|
|
|
@ -45,7 +45,7 @@ public class QueryTemplateManager extends BaseRest {
|
|||
CalledMethodProvider.instance.set("listQueryTemplates");
|
||||
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkIncludeMetaQueryParameters();
|
||||
serverRequestInfo.checkIncludeAllMetaQueryParameters();
|
||||
|
||||
QueryTemplateManagement queryTemplateManagement = new QueryTemplateManagement();
|
||||
return queryTemplateManagement.all(false);
|
||||
|
@ -91,7 +91,7 @@ public class QueryTemplateManager extends BaseRest {
|
|||
CalledMethodProvider.instance.set("createQueryTemplate");
|
||||
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkIncludeMetaQueryParameters();
|
||||
serverRequestInfo.checkIncludeAllMetaQueryParameters();
|
||||
|
||||
QueryTemplateManagement queryTemplateManagement = new QueryTemplateManagement();
|
||||
queryTemplateManagement.setName(queryTemplateName);
|
||||
|
@ -114,7 +114,7 @@ public class QueryTemplateManager extends BaseRest {
|
|||
CalledMethodProvider.instance.set("readQueryTemplate");
|
||||
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkIncludeMetaQueryParameters();
|
||||
serverRequestInfo.checkIncludeAllMetaQueryParameters();
|
||||
|
||||
QueryTemplateManagement queryTemplateManagement = new QueryTemplateManagement();
|
||||
queryTemplateManagement.setName(queryTemplateName);
|
||||
|
@ -138,7 +138,7 @@ public class QueryTemplateManager extends BaseRest {
|
|||
CalledMethodProvider.instance.set("readQueryTemplate");
|
||||
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkIncludeMetaQueryParameters();
|
||||
serverRequestInfo.checkIncludeAllMetaQueryParameters();
|
||||
|
||||
QueryTemplateManagement queryTemplateManagement = new QueryTemplateManagement();
|
||||
queryTemplateManagement.setName(queryTemplateName);
|
||||
|
|
|
@ -54,7 +54,8 @@ public class TypeManager extends BaseRest {
|
|||
CalledMethodProvider.instance.set("createType");
|
||||
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkIncludeMetaQueryParameters();
|
||||
serverRequestInfo.setAllMeta(true);
|
||||
serverRequestInfo.checkQueryParameter(TypePath.INCLUDE_META_QUERY_PARAMETER);
|
||||
|
||||
TypeManagement schemaManagement = new TypeManagement();
|
||||
schemaManagement.setTypeName(typeName);
|
||||
|
@ -79,7 +80,8 @@ public class TypeManager extends BaseRest {
|
|||
CalledMethodProvider.instance.set("readType");
|
||||
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkIncludeMetaQueryParameters();
|
||||
serverRequestInfo.setAllMeta(true);
|
||||
serverRequestInfo.checkQueryParameter(TypePath.INCLUDE_META_QUERY_PARAMETER);
|
||||
|
||||
TypeManagement schemaManagement = new TypeManagement();
|
||||
schemaManagement.setTypeName(type);
|
||||
|
|
|
@ -39,6 +39,7 @@ public abstract class EntityTypeDefinitionManagement<E extends EntityType> exten
|
|||
protected EntityTypeDefinitionManagement(Class<E> clz) {
|
||||
super(AccessType.ENTITY_TYPE);
|
||||
this.typeName = TypeMapper.getType(clz);
|
||||
this.forceIncludeAllMeta = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -43,6 +43,7 @@ public abstract class RelationTypeDefinitionManagement<T extends EntityTypeDefin
|
|||
public RelationTypeDefinitionManagement(Class<TT> clz) {
|
||||
super(AccessType.RELATION_TYPE, ResourceType.class, clz);
|
||||
this.typeName = RelationType.NAME;
|
||||
this.forceIncludeAllMeta = true;
|
||||
}
|
||||
|
||||
public RelationTypeDefinitionManagement(SecurityContext securityContext, ODatabaseDocument oDatabaseDocument,
|
||||
|
|
|
@ -11,7 +11,6 @@ import org.gcube.informationsystem.contexts.impl.entities.ContextImpl;
|
|||
import org.gcube.informationsystem.contexts.reference.entities.Context;
|
||||
import org.gcube.informationsystem.contexts.reference.relations.IsParentOf;
|
||||
import org.gcube.informationsystem.resourceregistry.ContextTest;
|
||||
import org.gcube.informationsystem.resourceregistry.api.contexts.ContextCache;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextAlreadyPresentException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.ContextException;
|
||||
|
@ -21,7 +20,6 @@ import org.gcube.informationsystem.resourceregistry.contexts.security.ContextSec
|
|||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.PermissionMode;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.security.SecurityContext.SecurityType;
|
||||
import org.gcube.informationsystem.resourceregistry.dbinitialization.DatabaseEnvironment;
|
||||
import org.gcube.informationsystem.resourceregistry.utils.MetadataUtility;
|
||||
import org.gcube.informationsystem.serialization.ElementMapper;
|
||||
import org.junit.Assert;
|
||||
|
@ -471,7 +469,7 @@ public class ContextManagementTest extends ContextTest {
|
|||
@Test
|
||||
public void testGetAll() throws Exception {
|
||||
List<Context> contexts = getAll();
|
||||
contexts = ContextCache.getInstance().getContexts();
|
||||
contexts = ServerContextCache.getInstance().getContexts();
|
||||
for(Context context : contexts) {
|
||||
logger.info(ElementMapper.marshal(context));
|
||||
List<IsParentOf> children = context.getChildren();
|
||||
|
@ -499,11 +497,10 @@ public class ContextManagementTest extends ContextTest {
|
|||
|
||||
@Test
|
||||
public void testContextCache() throws Exception {
|
||||
DatabaseEnvironment.initContextCacheRenewal();
|
||||
List<Context> contexts = getAll();
|
||||
logger.debug("{}", contexts);
|
||||
|
||||
ContextCache contextCache = ContextCache.getInstance();
|
||||
ServerContextCache contextCache = ServerContextCache.getInstance();
|
||||
Map<UUID, String> uuidToContextFullName = contextCache.getUUIDToContextFullNameAssociation();
|
||||
logger.debug("{}", uuidToContextFullName);
|
||||
|
||||
|
@ -536,7 +533,7 @@ public class ContextManagementTest extends ContextTest {
|
|||
for(Context c : contexts) {
|
||||
UUID uuid = c.getID();
|
||||
Context context = read(uuid);
|
||||
String fullName = ContextCache.getInstance().getContextFullNameByUUID(uuid);
|
||||
String fullName = ServerContextCache.getInstance().getContextFullNameByUUID(uuid);
|
||||
logger.debug("{} - {} : {}", uuid, fullName, context);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,8 +10,8 @@ import org.gcube.informationsystem.model.reference.properties.PropagationConstra
|
|||
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.AddConstraint;
|
||||
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.RemoveConstraint;
|
||||
import org.gcube.informationsystem.resourceregistry.ContextTest;
|
||||
import org.gcube.informationsystem.resourceregistry.api.contexts.ContextCache;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.ServerContextCache;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.FacetManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.relations.IsRelatedToManagement;
|
||||
|
@ -34,9 +34,6 @@ public class ComplexTest extends MultiContextTest {
|
|||
public void testGetInstancesContexts() throws ResourceRegistryException, Exception {
|
||||
ContextTest.setContextByName(DEVNEXT);
|
||||
|
||||
ContextCache contextCache = ContextCache.getInstance();
|
||||
contextCache.setContextCacheRenewal(contextCacheRenewal);
|
||||
|
||||
/* Creating HostingNode */
|
||||
HostingNode hostingNode = createHostingNode();
|
||||
|
||||
|
@ -116,7 +113,7 @@ public class ComplexTest extends MultiContextTest {
|
|||
Assert.assertTrue(eServiceContextsUUID.size()==1);
|
||||
Assert.assertFalse(eServiceContextsUUID.containsAll(hostingNodeContextUUID));
|
||||
Assert.assertTrue(hostingNodeContextUUID.containsAll(eServiceContextsUUID));
|
||||
Set<String> eServiceContextFullNames = org.gcube.informationsystem.resourceregistry.api.contexts.ContextUtility.getContextFullNameSet(eServiceContextsUUID);
|
||||
Set<String> eServiceContextFullNames = org.gcube.informationsystem.resourceregistry.api.contexts.ContextUtility.getContextFullNameSet(ServerContextCache.getInstance(), eServiceContextsUUID);
|
||||
Assert.assertTrue(eServiceContextFullNames.size()==1);
|
||||
logger.debug("Contexts of {} with UUID {} are {}", EService.NAME, eServiceManagement.getUUID(), eServiceContextFullNames);
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.gcube.informationsystem.resourceregistry.instances.multicontext;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -11,7 +10,6 @@ import java.util.UUID;
|
|||
import org.gcube.com.fasterxml.jackson.databind.JsonNode;
|
||||
import org.gcube.common.authorization.utils.manager.SecretManagerProvider;
|
||||
import org.gcube.informationsystem.base.reference.Element;
|
||||
import org.gcube.informationsystem.contexts.reference.entities.Context;
|
||||
import org.gcube.informationsystem.model.reference.entities.Facet;
|
||||
import org.gcube.informationsystem.model.reference.entities.Resource;
|
||||
import org.gcube.informationsystem.model.reference.properties.PropagationConstraint.AddConstraint;
|
||||
|
@ -20,10 +18,8 @@ import org.gcube.informationsystem.model.reference.relations.ConsistsOf;
|
|||
import org.gcube.informationsystem.model.reference.relations.IsRelatedTo;
|
||||
import org.gcube.informationsystem.model.reference.relations.Relation;
|
||||
import org.gcube.informationsystem.resourceregistry.ContextTest;
|
||||
import org.gcube.informationsystem.resourceregistry.api.contexts.ContextCacheRenewal;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.entities.ContextManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.ERManagementTest;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.entities.ResourceManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.relations.IsRelatedToManagement;
|
||||
|
@ -323,20 +319,4 @@ public class MultiContextTest extends ERManagementTest {
|
|||
addToContextThenTestIfBehaveProperly(isRelatedTo, false, targetContextFullName);
|
||||
}
|
||||
|
||||
protected ContextCacheRenewal contextCacheRenewal = new ContextCacheRenewal() {
|
||||
|
||||
@Override
|
||||
public List<Context> renew() throws ResourceRegistryException {
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
String contextsJsonString = contextManagement.allFromServer(false);
|
||||
List<Context> contexts = null;
|
||||
try {
|
||||
contexts = ElementMapper.unmarshalList(contextsJsonString);
|
||||
} catch (IOException e) {
|
||||
logger.error("Unable to read context from server", e);
|
||||
}
|
||||
return contexts;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue