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

49 lines
1.9 KiB
Java

package org.gcube.informationsystem.registry.test;
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.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 {
message.setType(args[3]);
message.setUniqueID(args[1]);
registryFactoryPortType.removeResource(message);
} catch(Exception e) {
e.printStackTrace();
}
System.out.println("Profile with ID "+ args[1]+ "has been succesfully removed");
}
}