From ffd9cda8f99b15c427b0ad3a46f115b7f184e310 Mon Sep 17 00:00:00 2001 From: Manuele Simi Date: Mon, 30 Jun 2008 22:31:35 +0000 Subject: [PATCH] git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@1974 82a268e6-3cf1-43bd-a215-b396298e98cf --- ...est.java => RegistryRegistrationTest.java} | 56 +++++++++++++------ 1 file changed, 38 insertions(+), 18 deletions(-) rename src/org/gcube/informationsystem/registry/test/{RegistryTest.java => RegistryRegistrationTest.java} (53%) diff --git a/src/org/gcube/informationsystem/registry/test/RegistryTest.java b/src/org/gcube/informationsystem/registry/test/RegistryRegistrationTest.java similarity index 53% rename from src/org/gcube/informationsystem/registry/test/RegistryTest.java rename to src/org/gcube/informationsystem/registry/test/RegistryRegistrationTest.java index d299ab3..0ab8764 100644 --- a/src/org/gcube/informationsystem/registry/test/RegistryTest.java +++ b/src/org/gcube/informationsystem/registry/test/RegistryRegistrationTest.java @@ -7,52 +7,72 @@ 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.contexts.GHNContext; +import org.gcube.common.core.resources.GCUBEResource; import org.gcube.common.core.resources.GCUBEService; 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.informationsystem.registry.stubs.CreateResourceMessage; import org.gcube.informationsystem.registry.stubs.RegistryFactoryPortType; import org.gcube.informationsystem.registry.stubs.service.RegistryFactoryServiceAddressingLocator; import org.gridforum.jgss.ExtendedGSSCredential; -public class RegistryTest { +public class RegistryRegistrationTest { 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(); - 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]); -// GHNContext.getImplementation(GCUBEService.class); - GCUBEService resource =GHNContext.getImplementation(GCUBEService.class); - EndpointReferenceType factoryEPR = new EndpointReferenceType(); - resource.load(fis); - //resource.store(fir); + //load the resource + GCUBEResource resource = null; + if (args[1].compareTo("Service") == 0) { + GCUBEService service =GHNContext.getImplementation(GCUBEService.class); + service.load(new FileReader (args[0])); + resource = (GCUBEResource)service; + } + + RegistryFactoryPortType registryFactoryPortType= null; - try { - factoryEPR.setAddress(new Address(args[0])); + try { registryFactoryPortType = registryLocator.getRegistryFactoryPortTypePort(factoryEPR); }catch(Exception e){ e.printStackTrace(); - } + System.exit(1); + } CreateResourceMessage message = new CreateResourceMessage(); - String profile =""; - managerSec.useCredentials(cred); - registryFactoryPortType =GCUBERemotePortTypeContext.getProxy(registryFactoryPortType,GCUBEScope.getScope("/gcube/devsec"),managerSec); + + registryFactoryPortType = GCUBERemotePortTypeContext.getProxy(registryFactoryPortType,scope,managerSec); try { StringWriter writer =new StringWriter(); resource.store(writer); message.setProfile(writer.toString()); message.setType(resource.getType()); - profile =registryFactoryPortType.createResource(message); + System.out.println(registryFactoryPortType.createResource(message)); } catch(Exception e) { e.printStackTrace(); } - System.out.println(profile); + + } + + + + static void printUsage() { + System.out.println("RegistryRegistrationTest "); + System.out.println("allowed types are: RunningInstance/Service/GHN/GenericResource"); + System.exit(1); } }