2008-03-20 19:19:36 +01:00
|
|
|
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;
|
2008-03-27 10:43:51 +01:00
|
|
|
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
|
2008-03-20 19:19:36 +01:00
|
|
|
import org.gcube.common.core.contexts.GHNContext;
|
|
|
|
import org.gcube.common.core.resources.GCUBEService;
|
2008-03-27 10:43:51 +01:00
|
|
|
import org.gcube.common.core.scope.GCUBEScope;
|
2008-03-20 19:19:36 +01:00
|
|
|
import org.gcube.common.core.security.GCUBESecurityManager;
|
|
|
|
import org.gcube.common.core.security.GCUBESecurityManagerImpl;
|
2008-04-10 02:42:28 +02:00
|
|
|
import org.gcube.informationsystem.registry.stubs.registryfactory.CreateResourceMessage;
|
|
|
|
import org.gcube.informationsystem.registry.stubs.registryfactory.RegistryFactoryPortType;
|
|
|
|
import org.gcube.informationsystem.registry.stubs.registryfactory.service.RegistryFactoryServiceAddressingLocator;
|
2008-03-20 19:19:36 +01:00
|
|
|
import org.gridforum.jgss.ExtendedGSSCredential;
|
|
|
|
|
|
|
|
public class RegistryTest {
|
|
|
|
|
|
|
|
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]);
|
|
|
|
|
|
|
|
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);
|
|
|
|
RegistryFactoryPortType registryFactoryPortType= null;
|
|
|
|
try {
|
|
|
|
factoryEPR.setAddress(new Address(args[0]));
|
|
|
|
registryFactoryPortType = registryLocator.getRegistryFactoryPortTypePort(factoryEPR);
|
|
|
|
}catch(Exception e){
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
CreateResourceMessage message = new CreateResourceMessage();
|
|
|
|
String profile ="";
|
|
|
|
managerSec.useCredentials(cred);
|
2008-03-27 10:43:51 +01:00
|
|
|
registryFactoryPortType =GCUBERemotePortTypeContext.getProxy(registryFactoryPortType,GCUBEScope.getScope("/gcube/devsec"),managerSec);
|
2008-03-20 19:19:36 +01:00
|
|
|
try {
|
|
|
|
StringWriter writer =new StringWriter();
|
|
|
|
resource.store(writer);
|
|
|
|
message.setProfile(writer.toString());
|
|
|
|
message.setType(resource.getType());
|
|
|
|
profile =registryFactoryPortType.createResource(message);
|
|
|
|
|
|
|
|
} catch(Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
System.out.println(profile);
|
|
|
|
}
|
|
|
|
}
|