This commit is contained in:
andrea.manzi 2014-04-01 14:14:15 +00:00
parent 3e2d245b43
commit 886f5a2352
1 changed files with 11 additions and 14 deletions

View File

@ -3,7 +3,6 @@ package org.gcube.smartgears.utils.sweeper;
import java.io.File; import java.io.File;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException; 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.GCoreEndpoint;
import org.gcube.common.resources.gcore.HostingNode; import org.gcube.common.resources.gcore.HostingNode;
import org.gcube.common.resources.gcore.Resource; 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.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.AdvancedPublisher;
import org.gcube.informationsystem.publisher.RegistryPublisher; import org.gcube.informationsystem.publisher.RegistryPublisher;
import org.gcube.informationsystem.publisher.RegistryPublisherFactory; import org.gcube.informationsystem.publisher.RegistryPublisherFactory;
@ -130,25 +130,22 @@ public class Sweeper {
} }
public void cleanRIProfiles() throws Exception{ public void cleanRIProfiles() throws Exception{
for (GCoreEndpoint endp : this.getRunningInstanceProfiles()){ for (GCoreEndpoint endp : this.getRunningInstanceProfiles()){
forceDeleteResource(endp); forceDeleteResource(endp);
} }
} }
private void forceDeleteResource(Resource resource){ private void forceDeleteResource(Resource resource){
RegistryPublisher rp;
ScopeGroup<String> gr = resource.scopes(); AdvancedPublisher advancedPublisher;
Iterator<String> it = gr.iterator(); ScopeBean scope = new ScopeBean(resource.scopes().iterator().next());
RegistryPublisher rp; while (!(scope.is(Type.INFRASTRUCTURE)))
AdvancedPublisher advancedPublisher; scope =scope.enclosingScope();
ScopeProvider.instance.set(scope.toString());
while (it.hasNext()){
String scope = it.next();
ScopeProvider.instance.set(scope);
rp=RegistryPublisherFactory.create(); rp=RegistryPublisherFactory.create();
advancedPublisher=new AdvancedPublisher(rp); advancedPublisher=new AdvancedPublisher(rp);
advancedPublisher.forceRemove(resource); advancedPublisher.forceRemove(resource);
logger.debug("Removing resource " + resource.id() + " from scope " + scope); logger.debug("Correctly Removed resource " + resource.id());
} }
}
} }