git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@1975 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
ffd9cda8f9
commit
7c0839a979
|
@ -3,11 +3,13 @@ package org.gcube.informationsystem.registry.test;
|
|||
import java.io.FileReader;
|
||||
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.contexts.GHNContext;
|
||||
import org.gcube.common.core.resources.GCUBEGenericResource;
|
||||
import org.gcube.common.core.resources.GCUBEHostingNode;
|
||||
import org.gcube.common.core.resources.GCUBEResource;
|
||||
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.scope.ServiceMap.ServiceType;
|
||||
|
@ -17,6 +19,12 @@ import org.gcube.informationsystem.registry.stubs.RegistryFactoryPortType;
|
|||
import org.gcube.informationsystem.registry.stubs.service.RegistryFactoryServiceAddressingLocator;
|
||||
import org.gridforum.jgss.ExtendedGSSCredential;
|
||||
|
||||
/**
|
||||
* GCUBE resource registration tester
|
||||
*
|
||||
* @author Manuele Simi (CNR-ISTI)
|
||||
*
|
||||
*/
|
||||
public class RegistryRegistrationTest {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
@ -27,34 +35,35 @@ public class RegistryRegistrationTest {
|
|||
|
||||
// get the scope and the factory URI
|
||||
GCUBEScope scope = GCUBEScope.getScope(args[2]);
|
||||
EndpointReferenceType factoryEPR = scope.getServiceMap().getEndpoint(ServiceType.ISRegistry);
|
||||
EndpointReferenceType factoryEPR = scope.getServiceMap().getEndpoint(
|
||||
ServiceType.ISRegistry);
|
||||
|
||||
RegistryFactoryServiceAddressingLocator registryLocator = new RegistryFactoryServiceAddressingLocator();
|
||||
|
||||
GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() { public boolean isSecurityEnabled() {return false;}};
|
||||
GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() {
|
||||
public boolean isSecurityEnabled() {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
// ExtendedGSSCredential cred = org.diligentproject.dvos.authentication.util.ProxyUtil.loadProxyCredentials(args[2]);
|
||||
// managerSec.useCredentials(cred);
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
GCUBEResource resource = getResource(args[1], new FileReader(args[0]));
|
||||
|
||||
RegistryFactoryPortType registryFactoryPortType = null;
|
||||
try {
|
||||
registryFactoryPortType = registryLocator.getRegistryFactoryPortTypePort(factoryEPR);
|
||||
registryFactoryPortType = registryLocator
|
||||
.getRegistryFactoryPortTypePort(factoryEPR);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
CreateResourceMessage message = new CreateResourceMessage();
|
||||
|
||||
registryFactoryPortType = GCUBERemotePortTypeContext.getProxy(registryFactoryPortType,scope,managerSec);
|
||||
registryFactoryPortType = GCUBERemotePortTypeContext.getProxy(
|
||||
registryFactoryPortType, scope, managerSec);
|
||||
try {
|
||||
StringWriter writer = new StringWriter();
|
||||
resource.store(writer);
|
||||
|
@ -68,8 +77,40 @@ public class RegistryRegistrationTest {
|
|||
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads the specific GCUBEResource class
|
||||
* @param type the resource type
|
||||
* @param file the file representation of the profile
|
||||
* @return the resource class
|
||||
* @throws Exception if the loading fails
|
||||
*/
|
||||
static GCUBEResource getResource(String type, FileReader file) throws Exception {
|
||||
if (type.compareTo("Service") == 0) {
|
||||
GCUBEService service = GHNContext.getImplementation(GCUBEService.class);
|
||||
service.load(file);
|
||||
return (GCUBEResource) service;
|
||||
}
|
||||
else if (type.compareTo("RunningInstance") == 0) {
|
||||
GCUBERunningInstance instance = GHNContext.getImplementation(GCUBERunningInstance.class);
|
||||
instance.load(file);
|
||||
return (GCUBEResource) instance;
|
||||
} else if (type.compareTo("GHN") == 0) {
|
||||
GCUBEHostingNode node = GHNContext.getImplementation(GCUBEHostingNode.class);
|
||||
node.load(file);
|
||||
return (GCUBEResource) node;
|
||||
} else if (type.compareTo("GenericResource") == 0) {
|
||||
GCUBEGenericResource generic = GHNContext.getImplementation(GCUBEGenericResource.class);
|
||||
generic.load(file);
|
||||
return (GCUBEResource) generic;
|
||||
}
|
||||
|
||||
throw new Exception( type + " is an invalid resource type");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints tester usage syntax
|
||||
*/
|
||||
static void printUsage() {
|
||||
System.out.println("RegistryRegistrationTest <resource file> <resource type> <caller scope>");
|
||||
System.out.println("allowed types are: RunningInstance/Service/GHN/GenericResource");
|
||||
|
|
|
@ -42,7 +42,7 @@ public static void main (String[]args ) throws Exception {
|
|||
|
||||
managerSec.useCredentials(cred);
|
||||
|
||||
registryFactoryPortType =GCUBERemotePortTypeContext.getProxy(registryFactoryPortType,GCUBEScope.getScope("/gcube/devsec"),managerSec);
|
||||
registryFactoryPortType =GCUBERemotePortTypeContext.getProxy(registryFactoryPortType,GCUBEScope.getScope(args[3]),managerSec);
|
||||
try {
|
||||
StringWriter writer =new StringWriter();
|
||||
resource.store(writer);
|
||||
|
|
Loading…
Reference in New Issue