From 98def5426d4bcf3be23c70e3d985ab0d58ab122a Mon Sep 17 00:00:00 2001 From: Costantino Perciante Date: Fri, 8 Jul 2016 13:50:22 +0000 Subject: [PATCH] if more than one resources with the same name is found, just take the information from the first one git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/ckan-util-library@130175 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../ckanutillibrary/CKanRunningCluster.java | 30 ++++++++----------- 1 file changed, 12 insertions(+), 18 deletions(-) diff --git a/src/main/java/org/gcube/datacatalogue/ckanutillibrary/CKanRunningCluster.java b/src/main/java/org/gcube/datacatalogue/ckanutillibrary/CKanRunningCluster.java index 15450ef..f93f42a 100644 --- a/src/main/java/org/gcube/datacatalogue/ckanutillibrary/CKanRunningCluster.java +++ b/src/main/java/org/gcube/datacatalogue/ckanutillibrary/CKanRunningCluster.java @@ -20,7 +20,6 @@ import org.gcube.common.scope.api.ScopeProvider; import org.gcube.datacatalogue.ckanutillibrary.exceptions.ApplicationProfileNotFoundException; import org.gcube.datacatalogue.ckanutillibrary.exceptions.NoCKanRuntimeResourceException; import org.gcube.datacatalogue.ckanutillibrary.exceptions.ServiceEndPointException; -import org.gcube.datacatalogue.ckanutillibrary.exceptions.TooManyRunningClustersException; import org.gcube.resources.discovery.client.api.DiscoveryClient; import org.gcube.resources.discovery.client.queries.api.Query; import org.gcube.resources.discovery.client.queries.api.SimpleQuery; @@ -79,17 +78,15 @@ public class CKanRunningCluster { List resources = getConfigurationFromISFORDB(); - if (resources.size() > 1) { - logger.error("Too many Runtime Resource having name " + RUNTIME_DB_RESOURCE_NAME +" in this scope"); - throw new TooManyRunningClustersException("There exist more than 1 Runtime Resource in this scope having name " - + RUNTIME_DB_RESOURCE_NAME + " and Platform " + PLATFORM_DB_NAME + ". Only one allowed per infrasrtucture."); - } - else if (resources.size() == 0){ + if (resources.size() == 0){ logger.error("There is no Runtime Resource having name " + RUNTIME_DB_RESOURCE_NAME +" and Platform " + PLATFORM_DB_NAME + " in this scope."); throw new NoCKanRuntimeResourceException(); } else { + if(resources.size() > 1) + logger.warn("Too many Runtime Resource having name " + RUNTIME_DB_RESOURCE_NAME +" in this scope"); + try{ logger.debug(resources.toString()); @@ -129,17 +126,14 @@ public class CKanRunningCluster { logger.debug("Retrieving ckan data catalogue service end point information and sysadmin token."); resources = getConfigurationFromISFORCatalogueUrl(); - if (resources.size() > 1) { - logger.error("Too many Runtime Resource having name " + RUNTIME_CATALOGUE_RESOURCE_NAME +" in this scope"); - throw new TooManyRunningClustersException("There exist more than 1 Runtime Resource in this scope having name " - + RUNTIME_CATALOGUE_RESOURCE_NAME + " and Platform " + PLATFORM_CATALOGUE_NAME + ". Only one allowed per infrasrtucture."); - } - else if (resources.size() == 0){ + if (resources.size() == 0){ logger.error("There is no Runtime Resource having name " + RUNTIME_CATALOGUE_RESOURCE_NAME +" and Platform " + PLATFORM_CATALOGUE_NAME + " in this scope."); throw new NoCKanRuntimeResourceException(); } else { + if(resources.size() > 1) + logger.warn("Too many Runtime Resource having name " + RUNTIME_CATALOGUE_RESOURCE_NAME +" in this scope"); try{ logger.debug(resources.toString()); @@ -168,12 +162,12 @@ public class CKanRunningCluster { throw new ServiceEndPointException(); } } - - + + // finally get the url in which the ckan portlet is deployed logger.debug("Looking for portlet url in " + ScopeProvider.instance.get() + " scope" ); portletUrl = getPortletUrlFromInfrastrucure(); - + }catch(Exception e) { logger.error(e.toString()); throw e; @@ -256,11 +250,11 @@ public class CKanRunningCluster { } catch (Exception e) { logger.error("Error while trying to fetch applicationProfile profile from the infrastructure", e); } - + return null; } - + /** Retrieve the ckan portlet url * @return the portletUrl */