Fixing issues
This commit is contained in:
parent
4fe825cbfb
commit
0ead00f884
|
@ -259,7 +259,7 @@ public abstract class ElementManagement<El extends OElement, T extends Type> {
|
|||
protected Environment getWorkingEnvironment() throws ResourceRegistryException {
|
||||
if(workingEnvironment == null) {
|
||||
workingEnvironment = ContextUtility.getCurrentRequestEnvironment();
|
||||
Context context = ServerContextCache.getInstance().getContextByUUID(workingEnvironment.getUUID());
|
||||
Context context = ServerContextCache.getInstance().getFullInfoContextByUUID(workingEnvironment.getUUID());
|
||||
String state = context.getState();
|
||||
if(state.compareTo(ContextState.ACTIVE.getState())!=0) {
|
||||
Set<String> allowedRoles = workingEnvironment.getAllowedRoles();
|
||||
|
|
|
@ -10,6 +10,8 @@ import java.util.SortedSet;
|
|||
import java.util.TreeSet;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.ws.rs.InternalServerErrorException;
|
||||
|
||||
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;
|
||||
|
@ -117,6 +119,11 @@ public class ServerContextCache extends ContextCache {
|
|||
}
|
||||
}
|
||||
|
||||
public synchronized Context getFullInfoContextByUUID(UUID uuid) throws ResourceRegistryException {
|
||||
refreshContextsIfNeeded();
|
||||
return uuidToContext.get(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized Context getContextByUUID(UUID uuid) throws ResourceRegistryException {
|
||||
refreshContextsIfNeeded();
|
||||
|
@ -171,25 +178,42 @@ public class ServerContextCache extends ContextCache {
|
|||
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());
|
||||
contextNoMeta.setMetadata(null);
|
||||
contextNoMeta.setID(uuid);
|
||||
this.contextsBasicInfo.add(contextNoMeta);
|
||||
this.uuidToContextBasicInfo.put(uuid, contextNoMeta);
|
||||
|
||||
try {
|
||||
String contextString = ElementMapper.marshal(c);
|
||||
|
||||
Context contextWithMeta = ElementMapper.unmarshal(Context.class, contextString);
|
||||
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());
|
||||
contextNoMeta.setMetadata(null);
|
||||
contextNoMeta.setID(uuid);
|
||||
this.contextsBasicInfo.add(contextNoMeta);
|
||||
this.uuidToContextBasicInfo.put(uuid, contextNoMeta);
|
||||
|
||||
/*
|
||||
Context contextMetaPrivacy = ElementMapper.unmarshal(Context.class, contextString);
|
||||
Metadata metadataWithPrivacy = getMetadataForPrivacy(objectMapper, c.getMetadata());
|
||||
contextMetaPrivacy.setMetadata(metadataWithPrivacy);
|
||||
this.contextsMetaPrivacy.add(contextMetaPrivacy);
|
||||
this.uuidToContextMetaPrivacy.put(uuid, contextMetaPrivacy);
|
||||
|
||||
Context contextNoMeta = ElementMapper.unmarshal(Context.class, contextString);
|
||||
contextNoMeta.setMetadata(null);
|
||||
this.contextsBasicInfo.add(contextNoMeta);
|
||||
this.uuidToContextBasicInfo.put(uuid, contextNoMeta);
|
||||
*/
|
||||
|
||||
}catch (Exception e) {
|
||||
throw new InternalServerErrorException("Error while creating context Cache", e);
|
||||
}
|
||||
}
|
||||
|
||||
for(Context c : contexts) {
|
||||
|
|
Loading…
Reference in New Issue