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.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<String> gr = resource.scopes();
Iterator<String> 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());
}
}
}