From 886f5a2352ce42403d23a0b07987e478c4a68bb0 Mon Sep 17 00:00:00 2001 From: "andrea.manzi" Date: Tue, 1 Apr 2014 14:14:15 +0000 Subject: [PATCH] git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/Common/common-smartgears-utils@93991 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../smartgears/utils/sweeper/Sweeper.java | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/gcube/smartgears/utils/sweeper/Sweeper.java b/src/main/java/org/gcube/smartgears/utils/sweeper/Sweeper.java index 78a9d7e..b114860 100644 --- a/src/main/java/org/gcube/smartgears/utils/sweeper/Sweeper.java +++ b/src/main/java/org/gcube/smartgears/utils/sweeper/Sweeper.java @@ -3,7 +3,6 @@ package org.gcube.smartgears.utils.sweeper; import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; -import java.util.Iterator; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; @@ -12,8 +11,9 @@ import javax.xml.bind.Unmarshaller; import org.gcube.common.resources.gcore.GCoreEndpoint; import org.gcube.common.resources.gcore.HostingNode; import org.gcube.common.resources.gcore.Resource; -import org.gcube.common.resources.gcore.ScopeGroup; import org.gcube.common.scope.api.ScopeProvider; +import org.gcube.common.scope.impl.ScopeBean; +import org.gcube.common.scope.impl.ScopeBean.Type; import org.gcube.informationsystem.publisher.AdvancedPublisher; import org.gcube.informationsystem.publisher.RegistryPublisher; import org.gcube.informationsystem.publisher.RegistryPublisherFactory; @@ -130,25 +130,22 @@ public class Sweeper { } public void cleanRIProfiles() throws Exception{ - for (GCoreEndpoint endp : this.getRunningInstanceProfiles()){ + for (GCoreEndpoint endp : this.getRunningInstanceProfiles()){ forceDeleteResource(endp); } } private void forceDeleteResource(Resource resource){ - - ScopeGroup gr = resource.scopes(); - Iterator it = gr.iterator(); - RegistryPublisher rp; - AdvancedPublisher advancedPublisher; - - while (it.hasNext()){ - String scope = it.next(); - ScopeProvider.instance.set(scope); + RegistryPublisher rp; + AdvancedPublisher advancedPublisher; + ScopeBean scope = new ScopeBean(resource.scopes().iterator().next()); + while (!(scope.is(Type.INFRASTRUCTURE))) + scope =scope.enclosingScope(); + ScopeProvider.instance.set(scope.toString()); rp=RegistryPublisherFactory.create(); advancedPublisher=new AdvancedPublisher(rp); advancedPublisher.forceRemove(resource); - logger.debug("Removing resource " + resource.id() + " from scope " + scope); + logger.debug("Correctly Removed resource " + resource.id()); + } - } }