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
This commit is contained in:
Costantino Perciante 2016-07-08 13:50:22 +00:00
parent 63a129ab5b
commit 98def5426d
1 changed files with 12 additions and 18 deletions

View File

@ -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<ServiceEndpoint> 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
*/