git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@1974 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
20fd26f374
commit
ffd9cda8f9
|
@ -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 <resource file> <resource type> <caller scope>");
|
||||
System.out.println("allowed types are: RunningInstance/Service/GHN/GenericResource");
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue