package org.gcube.informationsystem.registry.test; import java.io.StringWriter; import org.apache.axis.message.addressing.Address; import org.apache.axis.message.addressing.EndpointReferenceType; import org.gcube.common.core.contexts.GCUBERemotePortTypeContext; import org.gcube.common.core.resources.GCUBEService; import org.gcube.common.core.scope.GCUBEScope; import org.gcube.common.core.security.GCUBESecurityManagerImpl; import org.gcube.informationsystem.registry.stubs.registryfactory.RegistryFactoryPortType; import org.gcube.informationsystem.registry.stubs.registryfactory.RemoveResourceMessage; import org.gcube.informationsystem.registry.stubs.registryfactory.service.RegistryFactoryServiceAddressingLocator; import org.gridforum.jgss.ExtendedGSSCredential; public class RegistryRemoveTest { public static void main (String[]args ) throws Exception { RegistryFactoryServiceAddressingLocator registryLocator = new RegistryFactoryServiceAddressingLocator(); GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() { public boolean isSecurityEnabled() {return true;}}; ExtendedGSSCredential cred =org.diligentproject.dvos.authentication.util.ProxyUtil.loadProxyCredentials(args[2]); EndpointReferenceType factoryEPR = new EndpointReferenceType(); RegistryFactoryPortType registryFactoryPortType= null; try { factoryEPR.setAddress(new Address(args[0])); registryFactoryPortType = registryLocator.getRegistryFactoryPortTypePort(factoryEPR); }catch(Exception e){ e.printStackTrace(); } RemoveResourceMessage message = new org.gcube.informationsystem.registry.stubs.registryfactory.RemoveResourceMessage(); managerSec.useCredentials(cred); registryFactoryPortType =GCUBERemotePortTypeContext.getProxy(registryFactoryPortType,GCUBEScope.getScope("/gcube/devsec"),managerSec); try { StringWriter writer =new StringWriter(); message.setType(GCUBEService.TYPE); message.setUniqueID(args[1]); registryFactoryPortType.removeResource(message); } catch(Exception e) { e.printStackTrace(); } System.out.println("Profile with ID "+ args[1]+ "has been succesfully removed"); } }