This commit is contained in:
Manuele Simi 2008-06-30 22:31:35 +00:00
parent 20fd26f374
commit ffd9cda8f9
1 changed files with 38 additions and 18 deletions

View File

@ -7,52 +7,72 @@ import org.apache.axis.message.addressing.Address;
import org.apache.axis.message.addressing.EndpointReferenceType; import org.apache.axis.message.addressing.EndpointReferenceType;
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext; import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
import org.gcube.common.core.contexts.GHNContext; import org.gcube.common.core.contexts.GHNContext;
import org.gcube.common.core.resources.GCUBEResource;
import org.gcube.common.core.resources.GCUBEService; import org.gcube.common.core.resources.GCUBEService;
import org.gcube.common.core.scope.GCUBEScope; import org.gcube.common.core.scope.GCUBEScope;
import org.gcube.common.core.security.GCUBESecurityManager; import org.gcube.common.core.scope.ServiceMap.ServiceType;
import org.gcube.common.core.security.GCUBESecurityManagerImpl; import org.gcube.common.core.security.GCUBESecurityManagerImpl;
import org.gcube.informationsystem.registry.stubs.CreateResourceMessage; import org.gcube.informationsystem.registry.stubs.CreateResourceMessage;
import org.gcube.informationsystem.registry.stubs.RegistryFactoryPortType; import org.gcube.informationsystem.registry.stubs.RegistryFactoryPortType;
import org.gcube.informationsystem.registry.stubs.service.RegistryFactoryServiceAddressingLocator; import org.gcube.informationsystem.registry.stubs.service.RegistryFactoryServiceAddressingLocator;
import org.gridforum.jgss.ExtendedGSSCredential; import org.gridforum.jgss.ExtendedGSSCredential;
public class RegistryTest { public class RegistryRegistrationTest {
public static void main (String[]args ) throws Exception { public static void main (String[]args ) throws Exception {
if (args.length != 3) {
printUsage();
}
//get the scope and the factory URI
GCUBEScope scope = GCUBEScope.getScope(args[2]);
EndpointReferenceType factoryEPR = scope.getServiceMap().getEndpoint(ServiceType.ISRegistry);
RegistryFactoryServiceAddressingLocator registryLocator = new RegistryFactoryServiceAddressingLocator(); RegistryFactoryServiceAddressingLocator registryLocator = new RegistryFactoryServiceAddressingLocator();
GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() { public boolean isSecurityEnabled() {return true;}}; GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() { public boolean isSecurityEnabled() {return false;}};
ExtendedGSSCredential cred =org.diligentproject.dvos.authentication.util.ProxyUtil.loadProxyCredentials(args[2]); //ExtendedGSSCredential cred =org.diligentproject.dvos.authentication.util.ProxyUtil.loadProxyCredentials(args[2]);
//managerSec.useCredentials(cred);
FileReader fis = new FileReader (args[1]); //load the resource
// GHNContext.getImplementation(GCUBEService.class); GCUBEResource resource = null;
GCUBEService resource =GHNContext.getImplementation(GCUBEService.class); if (args[1].compareTo("Service") == 0) {
EndpointReferenceType factoryEPR = new EndpointReferenceType(); GCUBEService service =GHNContext.getImplementation(GCUBEService.class);
resource.load(fis); service.load(new FileReader (args[0]));
//resource.store(fir); resource = (GCUBEResource)service;
}
RegistryFactoryPortType registryFactoryPortType= null; RegistryFactoryPortType registryFactoryPortType= null;
try { try {
factoryEPR.setAddress(new Address(args[0]));
registryFactoryPortType = registryLocator.getRegistryFactoryPortTypePort(factoryEPR); registryFactoryPortType = registryLocator.getRegistryFactoryPortTypePort(factoryEPR);
}catch(Exception e){ }catch(Exception e){
e.printStackTrace(); e.printStackTrace();
} System.exit(1);
}
CreateResourceMessage message = new CreateResourceMessage(); CreateResourceMessage message = new CreateResourceMessage();
String profile ="";
managerSec.useCredentials(cred); registryFactoryPortType = GCUBERemotePortTypeContext.getProxy(registryFactoryPortType,scope,managerSec);
registryFactoryPortType =GCUBERemotePortTypeContext.getProxy(registryFactoryPortType,GCUBEScope.getScope("/gcube/devsec"),managerSec);
try { try {
StringWriter writer =new StringWriter(); StringWriter writer =new StringWriter();
resource.store(writer); resource.store(writer);
message.setProfile(writer.toString()); message.setProfile(writer.toString());
message.setType(resource.getType()); message.setType(resource.getType());
profile =registryFactoryPortType.createResource(message); System.out.println(registryFactoryPortType.createResource(message));
} catch(Exception e) { } catch(Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
System.out.println(profile);
}
static void printUsage() {
System.out.println("RegistryRegistrationTest <resource file> <resource type> <caller scope>");
System.out.println("allowed types are: RunningInstance/Service/GHN/GenericResource");
System.exit(1);
} }
} }