Fixed add/remove to/from context return
This commit is contained in:
parent
676e90dcc9
commit
122cdb8288
|
@ -81,37 +81,34 @@ public class EServiceManager {
|
||||||
public void addToContext() throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
|
public void addToContext() throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
|
||||||
HostingNode hostingNode = applicationContext.container().properties()
|
HostingNode hostingNode = applicationContext.container().properties()
|
||||||
.lookup(Constants.HOSTING_NODE_MANAGER_PROPERTY).value(HostingNodeManager.class).getHostingNode();
|
.lookup(Constants.HOSTING_NODE_MANAGER_PROPERTY).value(HostingNodeManager.class).getHostingNode();
|
||||||
boolean added = resourceRegistryPublisher.addResourceToCurrentContext(hostingNode);
|
try {
|
||||||
if (added) {
|
resourceRegistryPublisher.addResourceToCurrentContext(hostingNode);
|
||||||
logger.info("{} successfully added to current context ({})", eService,
|
logger.info("{} successfully added to current context ({})", eService, ContextUtility.getCurrentContextName());
|
||||||
ContextUtility.getCurrentContextName());
|
} catch (Exception e) {
|
||||||
} else {
|
logger.error("Unable to add {} to current context ({})", eService, ContextUtility.getCurrentContextName(), e);
|
||||||
logger.error("Unable to add {} to current context ({})", eService, ContextUtility.getCurrentContextName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeFromContext()
|
public void removeFromContext()
|
||||||
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
|
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
|
||||||
boolean removed = false;
|
try {
|
||||||
removed = resourceRegistryPublisher.removeResourceFromCurrentContext(eService);
|
resourceRegistryPublisher.removeResourceFromCurrentContext(eService);
|
||||||
if (removed) {
|
|
||||||
logger.info("{} successfully removed from current context ({})", eService,
|
logger.info("{} successfully removed from current context ({})", eService,
|
||||||
ContextUtility.getCurrentContextName());
|
ContextUtility.getCurrentContextName());
|
||||||
} else {
|
} catch (Exception e) {
|
||||||
logger.error("Unable to remove {} from current context ({})", eService,
|
logger.error("Unable to remove {} from current context ({})", eService,
|
||||||
ContextUtility.getCurrentContextName());
|
ContextUtility.getCurrentContextName(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeFromContext(UUID contextUUID)
|
public void removeFromContext(UUID contextUUID)
|
||||||
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
|
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
|
||||||
boolean removed = false;
|
|
||||||
String contextFullName = ContextCache.getInstance().getContextFullNameByUUID(contextUUID);
|
String contextFullName = ContextCache.getInstance().getContextFullNameByUUID(contextUUID);
|
||||||
removed = resourceRegistryPublisher.removeResourceFromContext(eService, contextUUID);
|
try {
|
||||||
if (removed) {
|
resourceRegistryPublisher.removeResourceFromContext(eService, contextUUID);
|
||||||
logger.info("{} successfully removed from context ({})", eService, contextFullName);
|
logger.info("{} successfully removed from context ({})", eService, contextFullName);
|
||||||
} else {
|
} catch (Exception e) {
|
||||||
logger.error("Unable to remove {} from current context ({})", eService, contextFullName);
|
logger.error("Unable to remove {} from current context ({})", eService, contextFullName, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,7 +185,7 @@ public class EServiceManager {
|
||||||
|
|
||||||
return eService;
|
return eService;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EService createEService() throws ResourceRegistryException {
|
public EService createEService() throws ResourceRegistryException {
|
||||||
ResourceRegistryClient resourceRegistryClient = ResourceRegistryClientFactory.create();
|
ResourceRegistryClient resourceRegistryClient = ResourceRegistryClientFactory.create();
|
||||||
UUID eServiceUUID = UUID.fromString(applicationContext.id());
|
UUID eServiceUUID = UUID.fromString(applicationContext.id());
|
||||||
|
@ -196,13 +193,13 @@ public class EServiceManager {
|
||||||
ResourceRegistryClientFactory.includeContextsInInstanceHeader(true);
|
ResourceRegistryClientFactory.includeContextsInInstanceHeader(true);
|
||||||
eService = resourceRegistryClient.getInstance(EService.class, eServiceUUID);
|
eService = resourceRegistryClient.getInstance(EService.class, eServiceUUID);
|
||||||
stateFacet = eService.getFacets(StateFacet.class).get(0);
|
stateFacet = eService.getFacets(StateFacet.class).get(0);
|
||||||
if(stateFacet==null) {
|
if (stateFacet == null) {
|
||||||
stateFacet = new StateFacetImpl();
|
stateFacet = new StateFacetImpl();
|
||||||
String state = getState();
|
String state = getState();
|
||||||
stateFacet.setValue(state);
|
stateFacet.setValue(state);
|
||||||
eService.addFacet(stateFacet);
|
eService.addFacet(stateFacet);
|
||||||
resourceRegistryPublisher.update(eService);
|
resourceRegistryPublisher.update(eService);
|
||||||
}else{
|
} else {
|
||||||
updateServiceStateFacet();
|
updateServiceStateFacet();
|
||||||
}
|
}
|
||||||
} catch (NotFoundException e) {
|
} catch (NotFoundException e) {
|
||||||
|
@ -222,13 +219,13 @@ public class EServiceManager {
|
||||||
createActivatesRelation(eService);
|
createActivatesRelation(eService);
|
||||||
}
|
}
|
||||||
stateFacet = eService.getFacets(StateFacet.class).get(0);
|
stateFacet = eService.getFacets(StateFacet.class).get(0);
|
||||||
if(stateFacet==null) {
|
if (stateFacet == null) {
|
||||||
stateFacet = new StateFacetImpl();
|
stateFacet = new StateFacetImpl();
|
||||||
String state = getState();
|
String state = getState();
|
||||||
stateFacet.setValue(state);
|
stateFacet.setValue(state);
|
||||||
eService.addFacet(stateFacet);
|
eService.addFacet(stateFacet);
|
||||||
resourceRegistryPublisher.update(eService);
|
resourceRegistryPublisher.update(eService);
|
||||||
}else{
|
} else {
|
||||||
updateServiceStateFacet();
|
updateServiceStateFacet();
|
||||||
}
|
}
|
||||||
} catch (ResourceRegistryException e) {
|
} catch (ResourceRegistryException e) {
|
||||||
|
@ -279,7 +276,7 @@ public class EServiceManager {
|
||||||
updateServiceStateFacet();
|
updateServiceStateFacet();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<UUID> getContextsUUID() throws Exception {
|
public Set<UUID> getContextsUUID() throws Exception {
|
||||||
return resourceRegistryPublisher.getResourceContexts(eService);
|
return resourceRegistryPublisher.getResourceContexts(eService);
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,38 +100,33 @@ public class HostingNodeManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addToContext() throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
|
public void addToContext() throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
|
||||||
boolean added = resourceRegistryPublisher.addResourceToCurrentContext(hostingNode);
|
try {
|
||||||
if (added) {
|
resourceRegistryPublisher.addResourceToCurrentContext(hostingNode);
|
||||||
logger.info("{} successfully added to current context ({})", hostingNode,
|
logger.info("{} successfully added to current context ({})", hostingNode, ContextUtility.getCurrentContextName());
|
||||||
ContextUtility.getCurrentContextName());
|
} catch (Exception e) {
|
||||||
} else {
|
logger.error("Unable to add {} to current context ({})", hostingNode, ContextUtility.getCurrentContextName(), e);
|
||||||
logger.error("Unable to add {} to current context ({})", hostingNode,
|
|
||||||
ContextUtility.getCurrentContextName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeFromContext()
|
public void removeFromContext()
|
||||||
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
|
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
|
||||||
boolean removed = false;
|
try {
|
||||||
removed = resourceRegistryPublisher.removeResourceFromCurrentContext(hostingNode);
|
resourceRegistryPublisher.removeResourceFromCurrentContext(hostingNode);
|
||||||
if (removed) {
|
|
||||||
logger.info("{} successfully removed from current context ({})", hostingNode,
|
logger.info("{} successfully removed from current context ({})", hostingNode,
|
||||||
ContextUtility.getCurrentContextName());
|
ContextUtility.getCurrentContextName());
|
||||||
} else {
|
} catch (Exception e) {
|
||||||
logger.error("Unable to remove {} from current context ({})", hostingNode,
|
logger.error("Unable to remove {} from current context ({})", hostingNode, ContextUtility.getCurrentContextName(), e);
|
||||||
ContextUtility.getCurrentContextName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeFromContext(UUID contextUUID)
|
public void removeFromContext(UUID contextUUID)
|
||||||
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
|
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
|
||||||
boolean removed = false;
|
|
||||||
String contextFullName = ContextCache.getInstance().getContextFullNameByUUID(contextUUID);
|
String contextFullName = ContextCache.getInstance().getContextFullNameByUUID(contextUUID);
|
||||||
removed = resourceRegistryPublisher.removeResourceFromContext(hostingNode, contextUUID);
|
try {
|
||||||
if (removed) {
|
resourceRegistryPublisher.removeResourceFromContext(hostingNode, contextUUID);
|
||||||
logger.info("{} successfully removed from context ({})", hostingNode, contextFullName);
|
logger.info("{} successfully removed from context ({})", hostingNode, contextFullName);
|
||||||
} else {
|
} catch (Exception e) {
|
||||||
logger.error("Unable to remove {} from current context ({})", hostingNode, contextFullName);
|
logger.error("Unable to remove {} from current context ({})", hostingNode, contextFullName, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue