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