From 9c995cabc430896f42fefa86a2f6a123949301e1 Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Tue, 4 Aug 2015 13:16:16 +0000 Subject: [PATCH] Implemented Feature #187, remove scope operation with Report Implemented Feature #446 Show SmartGearsDistribution version instead of SmartGearsDistributionBundle version for Distro Version< git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/admin/rmp-common-library@117656 82a268e6-3cf1-43bd-a215-b396298e98cf --- distro/changelog.xml | 13 ++++++++++--- pom.xml | 2 +- .../support/client/views/ResourceTypeDecorator.java | 3 ++- .../server/gcube/queries/xquery/resources/GHN.xq | 2 +- .../managers/resources/AbstractResourceManager.java | 10 ++++++---- .../server/managers/resources/ManagementUtils.java | 9 +++++---- 6 files changed, 25 insertions(+), 14 deletions(-) diff --git a/distro/changelog.xml b/distro/changelog.xml index 234aa30..92bf833 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -1,13 +1,20 @@ + + Implemented Feature #187, remove scope operation with Report + Implemented Feature #446 Show SmartGearsDistribution version instead of SmartGearsDistributionBundle version for Distro Version + - Fix for Incident #187, remove scope operation not passing through Resource Manager + date="2015-06-09"> + Fix for Incident #187, remove scope operation not passing + through Resource Manager Fix for Incident #148, Resource Sweeper does not sweep GHN - Resources + Resources + diff --git a/pom.xml b/pom.xml index d7076ce..3ef0244 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ org.gcube.portlets.admin rmp-common-library - 2.3.0-SNAPSHOT + 2.4.0-SNAPSHOT Resource Management Library gCube Resource Management Library is a common library containing shared code for Information System Operations diff --git a/src/main/java/org/gcube/resourcemanagement/support/client/views/ResourceTypeDecorator.java b/src/main/java/org/gcube/resourcemanagement/support/client/views/ResourceTypeDecorator.java index 34c0b87..964c5a0 100644 --- a/src/main/java/org/gcube/resourcemanagement/support/client/views/ResourceTypeDecorator.java +++ b/src/main/java/org/gcube/resourcemanagement/support/client/views/ResourceTypeDecorator.java @@ -42,7 +42,8 @@ public enum ResourceTypeDecorator { InstallableSoftware("InstallableSoftware", "empty-icon",""), // In the taskbar for handlig the refresh of deployment reports DeployReport("Deploy Report", "report-big-icon",""), - AddScopeReport("Add Scope Report", "report-big-icon",""), + AddScopeReport("Add to Scope Report", "report-big-icon",""), + RemoveScopeReport("Remove from Scope Report", "report-big-icon",""), /**************************************** diff --git a/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/GHN.xq b/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/GHN.xq index 5e6e97e..8214a21 100644 --- a/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/GHN.xq +++ b/src/main/java/org/gcube/resourcemanagement/support/server/gcube/queries/xquery/resources/GHN.xq @@ -1,6 +1,6 @@ for $profiles in collection('/db/Profiles/GHN')//Resource let $gcf-version := $profiles//Resource/Profile/GHNDescription/RunTimeEnv/Variable[Key/text() = 'gCF-version']/Value/text() | $profiles//Resource/Profile/GHNDescription/RunTimeEnv/Variable[Key/text() = 'SmartGears']/Value/text() -let $ghn-version := $profiles//Resource/Profile/GHNDescription/RunTimeEnv/Variable[Key/text() = 'GHN-distribution-version']/Value/text() | $profiles//Resource/Profile/GHNDescription/RunTimeEnv/Variable[Key/text() = 'SmartGearsDistributionBundle']/Value/text() +let $ghn-version := $profiles//Resource/Profile/GHNDescription/RunTimeEnv/Variable[Key/text() = 'GHN-distribution-version']/Value/text() | $profiles//Resource/Profile/GHNDescription/RunTimeEnv/Variable[Key/text() = 'SmartGearsDistribution']/Value/text() let $scopes := string-join( $profiles/Scopes//Scope/text(), ';') let $subtype := $profiles//Resource/Profile/Site/Domain/text() diff --git a/src/main/java/org/gcube/resourcemanagement/support/server/managers/resources/AbstractResourceManager.java b/src/main/java/org/gcube/resourcemanagement/support/server/managers/resources/AbstractResourceManager.java index 383b1c1..2015b89 100644 --- a/src/main/java/org/gcube/resourcemanagement/support/server/managers/resources/AbstractResourceManager.java +++ b/src/main/java/org/gcube/resourcemanagement/support/server/managers/resources/AbstractResourceManager.java @@ -542,7 +542,7 @@ public abstract class AbstractResourceManager { * @param scope * @throws ResourceOperationException */ - public final void delete(final ScopeBean scope) throws AbstractResourceException { + public final String delete(final ScopeBean scope) throws AbstractResourceException { Assertion checker = new Assertion(); checker.validate(scope != null, new ResourceParameterException("Invalid parameter scope. null not allowed.")); checker.validate(this.getID() != null, new ResourceOperationException("Invalid ID. null not allowed.")); @@ -557,20 +557,22 @@ public abstract class AbstractResourceManager { ServerConsole.trace(LOG_PREFIX, "[DELETE] " + this.getType() + " " + this.getID() + " in scope [" + scope + "]"); ServerConsole.trace(LOG_PREFIX, "[DELETE] " + this.getType() + " " + this.getID() + " is bound to (" + boundedScopes.size() + ") scopes"); - + String toReturn = ""; if (boundedScopes.size() > 1) { ServerConsole.trace(LOG_PREFIX, "[DELETE] [DELETE-BRANCH] deleting resource is a remove from scope since more than 1 scope is present " + resStub.id()); - this.basicRemoveFromScope(scope); + toReturn = this.basicRemoveFromScope(scope); } else if (boundedScopes.size() == 1) { ServerConsole.trace(LOG_PREFIX, "[DELETE] [DELETE-BRANCH] deleting resource since is bound to 1 scope only " + resStub.id()); try { this.getRegistryPublisher().remove(resStub); + toReturn = "NO REPORT because with only one resource the RegistryPublisher().remove was called"; } catch (Exception e) { ScopeProvider.instance.set(currScope); } } - ScopeProvider.instance.set(currScope); + ScopeProvider.instance.set(currScope); + return toReturn; } } diff --git a/src/main/java/org/gcube/resourcemanagement/support/server/managers/resources/ManagementUtils.java b/src/main/java/org/gcube/resourcemanagement/support/server/managers/resources/ManagementUtils.java index 8edfe79..d92907c 100644 --- a/src/main/java/org/gcube/resourcemanagement/support/server/managers/resources/ManagementUtils.java +++ b/src/main/java/org/gcube/resourcemanagement/support/server/managers/resources/ManagementUtils.java @@ -137,17 +137,18 @@ public class ManagementUtils { if (targetScope.toString().compareTo(sourceScope.toString()) == 0) { return "You are not allowed to remove this scope. Current and Target scope are the same."; } - AbstractResourceManager resource = ResourceFactory.createResourceManager(type); + String toReturn = ""; + AbstractResourceManager manager = ResourceFactory.createResourceManager(type); for (String id : resourceIDs) { try { - resource.setID(id); - resource.delete(targetScope); + manager.setID(id); + toReturn = manager.delete(targetScope); } catch (AbstractResourceException e) { ServerConsole.error(LOG_PREFIX, e); } } - return "ACK"; + return toReturn; } /**