fixing removing compute resource preference
Project: http://git-wip-us.apache.org/repos/asf/airavata/repo Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/3ad52055 Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/3ad52055 Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/3ad52055 Branch: refs/heads/gfac-storm Commit: 3ad52055362aac1693a1629bc18131527c668061 Parents: 42f77ed Author: Chathuri Wimalasena <[email protected]> Authored: Thu Jan 29 15:36:26 2015 -0500 Committer: Chathuri Wimalasena <[email protected]> Committed: Thu Jan 29 15:36:26 2015 -0500 ---------------------------------------------------------------------- .../api/server/handler/AiravataServerHandler.java | 16 +--------------- .../appcatalog/cpi/GwyResourceProfile.java | 1 + .../catalog/data/impl/GwyResourceProfileImpl.java | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 15 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/airavata/blob/3ad52055/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java ---------------------------------------------------------------------- diff --git a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java index 612fc8e..8e2ca17 100644 --- a/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java +++ b/airavata-api/airavata-api-server/src/main/java/org/apache/airavata/api/server/handler/AiravataServerHandler.java @@ -2651,21 +2651,7 @@ public class AiravataServerHandler implements Airavata.Iface { try { appCatalog = AppCatalogFactory.getAppCatalog(); GwyResourceProfile gatewayProfile = appCatalog.getGatewayProfile(); - GatewayResourceProfile profile = gatewayProfile.getGatewayProfile(gatewayID); - List<ComputeResourcePreference> computeResourcePreferences = profile.getComputeResourcePreferences(); - ComputeResourcePreference preferenceToRemove = null; - for (ComputeResourcePreference preference : computeResourcePreferences) { - if (preference.getComputeResourceId().equals(computeResourceId)){ - preferenceToRemove=preference; - break; - } - } - if (preferenceToRemove!=null) { - profile.getComputeResourcePreferences().remove( - preferenceToRemove); - } - gatewayProfile.updateGatewayResourceProfile(gatewayID, profile); - return true; + return gatewayProfile.removeComputeResourcePreferenceFromGateway(gatewayID, computeResourceId); } catch (AppCatalogException e) { logger.errorId(gatewayID, "Error while reading gateway compute resource preference...", e); AiravataSystemException exception = new AiravataSystemException(); http://git-wip-us.apache.org/repos/asf/airavata/blob/3ad52055/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/GwyResourceProfile.java ---------------------------------------------------------------------- diff --git a/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/GwyResourceProfile.java b/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/GwyResourceProfile.java index ef491d5..d6d04fc 100644 --- a/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/GwyResourceProfile.java +++ b/modules/app-catalog/app-catalog-cpi/src/main/java/org/airavata/appcatalog/cpi/GwyResourceProfile.java @@ -52,6 +52,7 @@ public interface GwyResourceProfile { * @return true or false */ boolean removeGatewayResourceProfile(String gatewayId) throws AppCatalogException; + boolean removeComputeResourcePreferenceFromGateway(String gatewayId, String preferenceId) throws AppCatalogException; /** * This method will check whether gateway profile exists http://git-wip-us.apache.org/repos/asf/airavata/blob/3ad52055/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/GwyResourceProfileImpl.java ---------------------------------------------------------------------- diff --git a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/GwyResourceProfileImpl.java b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/GwyResourceProfileImpl.java index 393b446..c3a3a62 100644 --- a/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/GwyResourceProfileImpl.java +++ b/modules/app-catalog/app-catalog-data/src/main/java/org/apache/aiaravata/application/catalog/data/impl/GwyResourceProfileImpl.java @@ -22,7 +22,9 @@ package org.apache.aiaravata.application.catalog.data.impl; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.airavata.appcatalog.cpi.AppCatalogException; import org.airavata.appcatalog.cpi.GwyResourceProfile; @@ -153,6 +155,21 @@ public class GwyResourceProfileImpl implements GwyResourceProfile { } @Override + public boolean removeComputeResourcePreferenceFromGateway(String gatewayId, String preferenceId) throws AppCatalogException { + try { + ComputeHostPreferenceResource resource = new ComputeHostPreferenceResource(); + Map<String, String> ids = new HashMap<String, String>(); + ids.put(AbstractResource.ComputeResourcePreferenceConstants.GATEWAY_ID, gatewayId); + ids.put(AbstractResource.ComputeResourcePreferenceConstants.RESOURCE_ID, preferenceId); + resource.remove(ids); + return true; + }catch (Exception e) { + logger.error("Error while deleting gateway profile...", e); + throw new AppCatalogException(e); + } + } + + @Override public boolean isGatewayResourceProfileExists(String gatewayId) throws AppCatalogException { try { GatewayProfileResource resource = new GatewayProfileResource();
