is-registry/src/org/gcube/informationsystem/registry/test/RegistryRemoveTest.java

55 lines
2.2 KiB
Java
Raw Normal View History

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.GCUBEHostingNode;
import org.gcube.common.core.resources.GCUBERunningInstance;
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.RegistryFactoryPortType;
import org.gcube.informationsystem.registry.stubs.RemoveResourceMessage;
import org.gcube.informationsystem.registry.stubs.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 RemoveResourceMessage();
//managerSec.useCredentials(cred);
registryFactoryPortType =GCUBERemotePortTypeContext.getProxy(registryFactoryPortType,GCUBEScope.getScope(args[2]),managerSec);
try {
StringWriter writer =new StringWriter();
message.setType(GCUBEHostingNode.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");
}
}