fixing corner cases
This commit is contained in:
parent
5947a095f8
commit
c09eba8a57
|
@ -1,5 +1,7 @@
|
||||||
package org.gcube.smartgears.handler.resourceregistry;
|
package org.gcube.smartgears.handler.resourceregistry;
|
||||||
|
|
||||||
|
import org.gcube.smartgears.handler.resourceregistry.resourcemanager.HostingNodeManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Library-wide constants.
|
* Library-wide constants.
|
||||||
* @author Luca Frosini
|
* @author Luca Frosini
|
||||||
|
@ -7,8 +9,8 @@ package org.gcube.smartgears.handler.resourceregistry;
|
||||||
*/
|
*/
|
||||||
public class Constants {
|
public class Constants {
|
||||||
|
|
||||||
// public static final String HOSTING_NODE_MANAGER_PROPERT = HostingNodeManager.class.getSimpleName();
|
public static final String HOSTING_NODE_MANAGER_PROPERTY = HostingNodeManager.class.getSimpleName();
|
||||||
//
|
|
||||||
// /**
|
// /**
|
||||||
// * The name of the context property that contains the EService Resource.
|
// * The name of the context property that contains the EService Resource.
|
||||||
// */
|
// */
|
||||||
|
|
|
@ -31,6 +31,7 @@ import org.gcube.informationsystem.resourceregistry.api.contexts.ContextCache;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||||
import org.gcube.resourcemanagement.model.reference.entities.facets.StateFacet;
|
import org.gcube.resourcemanagement.model.reference.entities.facets.StateFacet;
|
||||||
import org.gcube.resourcemanagement.model.reference.entities.resources.HostingNode;
|
import org.gcube.resourcemanagement.model.reference.entities.resources.HostingNode;
|
||||||
|
import org.gcube.smartgears.context.Property;
|
||||||
import org.gcube.smartgears.context.container.ContainerContext;
|
import org.gcube.smartgears.context.container.ContainerContext;
|
||||||
import org.gcube.smartgears.handler.resourceregistry.resourcemanager.HostingNodeManager;
|
import org.gcube.smartgears.handler.resourceregistry.resourcemanager.HostingNodeManager;
|
||||||
import org.gcube.smartgears.handlers.container.ContainerHandler;
|
import org.gcube.smartgears.handlers.container.ContainerHandler;
|
||||||
|
@ -110,6 +111,8 @@ public class HostingNodeHandler extends ContainerHandler {
|
||||||
ContextUtility.setContextFromToken(token);
|
ContextUtility.setContextFromToken(token);
|
||||||
hostingNodeManager = new HostingNodeManager(containerContext);
|
hostingNodeManager = new HostingNodeManager(containerContext);
|
||||||
hostingNodeManager.createHostingNode();
|
hostingNodeManager.createHostingNode();
|
||||||
|
containerContext.properties().add(new Property(Constants.HOSTING_NODE_MANAGER_PROPERTY, hostingNodeManager));
|
||||||
|
|
||||||
create = false;
|
create = false;
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -4,7 +4,6 @@ import java.net.URI;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
@ -34,7 +33,6 @@ import org.gcube.resourcemanagement.model.impl.entities.facets.EventFacetImpl;
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.facets.SoftwareFacetImpl;
|
import org.gcube.resourcemanagement.model.impl.entities.facets.SoftwareFacetImpl;
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.facets.StateFacetImpl;
|
import org.gcube.resourcemanagement.model.impl.entities.facets.StateFacetImpl;
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.resources.EServiceImpl;
|
import org.gcube.resourcemanagement.model.impl.entities.resources.EServiceImpl;
|
||||||
import org.gcube.resourcemanagement.model.impl.entities.resources.HostingNodeImpl;
|
|
||||||
import org.gcube.resourcemanagement.model.impl.properties.ValueSchemaImpl;
|
import org.gcube.resourcemanagement.model.impl.properties.ValueSchemaImpl;
|
||||||
import org.gcube.resourcemanagement.model.impl.relations.consistsof.IsIdentifiedByImpl;
|
import org.gcube.resourcemanagement.model.impl.relations.consistsof.IsIdentifiedByImpl;
|
||||||
import org.gcube.resourcemanagement.model.impl.relations.isrelatedto.ActivatesImpl;
|
import org.gcube.resourcemanagement.model.impl.relations.isrelatedto.ActivatesImpl;
|
||||||
|
@ -50,6 +48,7 @@ import org.gcube.resourcemanagement.model.reference.relations.isrelatedto.Activa
|
||||||
import org.gcube.smartgears.configuration.application.ApplicationConfiguration;
|
import org.gcube.smartgears.configuration.application.ApplicationConfiguration;
|
||||||
import org.gcube.smartgears.configuration.container.ContainerConfiguration;
|
import org.gcube.smartgears.configuration.container.ContainerConfiguration;
|
||||||
import org.gcube.smartgears.context.application.ApplicationContext;
|
import org.gcube.smartgears.context.application.ApplicationContext;
|
||||||
|
import org.gcube.smartgears.handler.resourceregistry.Constants;
|
||||||
import org.gcube.smartgears.handler.resourceregistry.ContextUtility;
|
import org.gcube.smartgears.handler.resourceregistry.ContextUtility;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -247,8 +246,8 @@ public class EServiceManager {
|
||||||
stateFacet = new StateFacetImpl();
|
stateFacet = new StateFacetImpl();
|
||||||
String state = getState();
|
String state = getState();
|
||||||
stateFacet.setValue(state);
|
stateFacet.setValue(state);
|
||||||
eService.addFacet(stateFacet);
|
|
||||||
stateFacet.setAdditionalProperty("date", date);
|
stateFacet.setAdditionalProperty("date", date);
|
||||||
|
eService.addFacet(stateFacet);
|
||||||
|
|
||||||
EventFacet eventFacet = new EventFacetImpl();
|
EventFacet eventFacet = new EventFacetImpl();
|
||||||
eventFacet.setEvent(state);
|
eventFacet.setEvent(state);
|
||||||
|
@ -269,7 +268,6 @@ public class EServiceManager {
|
||||||
} catch (NotFoundException e) {
|
} catch (NotFoundException e) {
|
||||||
eService = instantiateEService();
|
eService = instantiateEService();
|
||||||
createActivatesRelation(eService);
|
createActivatesRelation(eService);
|
||||||
stateFacet = eService.getFacets(StateFacet.class).get(0);
|
|
||||||
} catch (AvailableInAnotherContextException e) {
|
} catch (AvailableInAnotherContextException e) {
|
||||||
addHostingNodeToCurrentContext();
|
addHostingNodeToCurrentContext();
|
||||||
try {
|
try {
|
||||||
|
@ -320,10 +318,7 @@ public class EServiceManager {
|
||||||
private Activates<HostingNode, EService> createActivatesRelation(EService eService)
|
private Activates<HostingNode, EService> createActivatesRelation(EService eService)
|
||||||
throws ResourceRegistryException {
|
throws ResourceRegistryException {
|
||||||
|
|
||||||
UUID hostingNodeUUID = UUID.fromString(applicationContext.container().id());
|
HostingNode hostingNode = ((HostingNodeManager) applicationContext.container().properties().lookup(Constants.HOSTING_NODE_MANAGER_PROPERTY).value()).getHostingNode();
|
||||||
HostingNode hostingNode = new HostingNodeImpl();
|
|
||||||
Header header = new HeaderImpl(hostingNodeUUID);
|
|
||||||
hostingNode.setHeader(header);
|
|
||||||
|
|
||||||
PropagationConstraint propagationConstraint = new PropagationConstraintImpl();
|
PropagationConstraint propagationConstraint = new PropagationConstraintImpl();
|
||||||
propagationConstraint.setRemoveConstraint(RemoveConstraint.cascade);
|
propagationConstraint.setRemoveConstraint(RemoveConstraint.cascade);
|
||||||
|
@ -332,7 +327,7 @@ public class EServiceManager {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
activates = resourceRegistryPublisher.createIsRelatedTo(activates);
|
activates = resourceRegistryPublisher.createIsRelatedTo(activates);
|
||||||
this.eService = activates.getTarget();
|
hostingNode.attachResource(activates);
|
||||||
} catch (NotFoundException e) {
|
} catch (NotFoundException e) {
|
||||||
logger.error("THIS IS REALLY STRANGE. YOU SHOULD NOT BE HERE. Error while creating {}.", activates, e);
|
logger.error("THIS IS REALLY STRANGE. YOU SHOULD NOT BE HERE. Error while creating {}.", activates, e);
|
||||||
throw e;
|
throw e;
|
||||||
|
@ -341,8 +336,6 @@ public class EServiceManager {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
hostingNode.attachResource(activates);
|
|
||||||
|
|
||||||
return activates;
|
return activates;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue