Added explicit invocation of addEserviceToContext

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/Common/resource-registry-handlers@148246 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2017-05-02 15:55:29 +00:00
parent 2f56c934df
commit 7453f3239d
1 changed files with 18 additions and 12 deletions

View File

@ -335,16 +335,6 @@ public class EServiceManager extends ApplicationLifecycleHandler {
try {
eService = resourceRegistryPublisher.createResource(EService.class,
eService);
try {
createHostsRelation(eService, resourceRegistryPublisher);
} catch (Exception ex) {
String error = String.format(
"Unable to Create %s relation from % to % (%s : %s)",
Hosts.NAME, HostingNode.NAME, EService.NAME,
applicationContext.name(), eService.getHeader().getUUID());
logger.error(error, ex);
throw new ResourceRegistryException(error, ex);
}
} catch (ResourceAlreadyPresentException e) {
ResourceRegistryClient registryClient = ResourceRegistryClientFactory.create();
eService = registryClient.getInstance(EService.class, eService.getHeader().getUUID());
@ -352,11 +342,27 @@ public class EServiceManager extends ApplicationLifecycleHandler {
logger.debug("Moving app {} to {}", applicationContext.name(), state);
createOrUpdateServiceStateFacet(eService, state);
} catch (ResourceAvailableInAnotherContextException e) {
// Adding the HostingNode I also add the EService thanks to propagationConstraint
// Adding the HostingNode I also add the EService thanks to propagationConstraint
String token = SecurityTokenProvider.instance.get();
// If hosts was not created we need to add eService and HostingNode, otherwise
// addHostingnode is sufficient. Because we cannot be sure of it we invoke both
addToContext(eService, token);
addHostingNodeToCurrentContext();
ResourceRegistryClient registryClient = ResourceRegistryClientFactory.create();
eService = registryClient.getInstance(EService.class, eService.getHeader().getUUID());
}
try {
createHostsRelation(eService, resourceRegistryPublisher);
} catch (Exception ex) {
String error = String.format(
"Unable to Create %s relation from % to % (%s : %s)",
Hosts.NAME, HostingNode.NAME, EService.NAME,
applicationContext.name(), eService.getHeader().getUUID());
logger.error(error, ex);
throw new ResourceRegistryException(error, ex);
}
return eService;
}
@ -540,6 +546,7 @@ public class EServiceManager extends ApplicationLifecycleHandler {
Thread.currentThread().setContextClassLoader(contextCL);
}
}
*/
private void addToContext(EService eService, String token) {
ClassLoader contextCL = Thread.currentThread().getContextClassLoader();
@ -574,7 +581,6 @@ public class EServiceManager extends ApplicationLifecycleHandler {
Thread.currentThread().setContextClassLoader(contextCL);
}
}
*/
@SuppressWarnings("unchecked")