2008-04-15 19:28:28 +02: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;
|
|
|
|
import org.gcube.common.core.contexts.GCUBERemotePortTypeContext;
|
|
|
|
import org.gcube.common.core.contexts.GHNContext;
|
|
|
|
import org.gcube.common.core.resources.GCUBEService;
|
|
|
|
import org.gcube.common.core.scope.GCUBEScope;
|
|
|
|
import org.gcube.common.core.security.GCUBESecurityManagerImpl;
|
|
|
|
import org.gcube.informationsystem.registry.stubs.RegistryFactoryPortType;
|
2008-04-17 15:50:17 +02:00
|
|
|
import org.gcube.informationsystem.registry.stubs.UpdateResourceMessage;
|
2008-04-15 19:28:28 +02:00
|
|
|
import org.gcube.informationsystem.registry.stubs.service.RegistryFactoryServiceAddressingLocator;
|
|
|
|
import org.gridforum.jgss.ExtendedGSSCredential;
|
|
|
|
|
|
|
|
public class RegistryUpdateTest {
|
|
|
|
|
|
|
|
public static void main (String[]args ) throws Exception {
|
|
|
|
|
|
|
|
RegistryFactoryServiceAddressingLocator registryLocator = new RegistryFactoryServiceAddressingLocator();
|
|
|
|
|
|
|
|
GCUBESecurityManagerImpl managerSec = new GCUBESecurityManagerImpl() { public boolean isSecurityEnabled() {return true;}};
|
|
|
|
|
2008-09-18 20:11:28 +02:00
|
|
|
|
2008-04-15 19:28:28 +02:00
|
|
|
|
|
|
|
FileReader fis = new FileReader (args[1]);
|
|
|
|
GCUBEService resource =GHNContext.getImplementation(GCUBEService.class);
|
|
|
|
EndpointReferenceType factoryEPR = new EndpointReferenceType();
|
|
|
|
resource.load(fis);
|
|
|
|
|
|
|
|
|
|
|
|
RegistryFactoryPortType registryFactoryPortType= null;
|
|
|
|
try {
|
|
|
|
factoryEPR.setAddress(new Address(args[0]));
|
|
|
|
registryFactoryPortType = registryLocator.getRegistryFactoryPortTypePort(factoryEPR);
|
|
|
|
}catch(Exception e){
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
2008-04-17 15:50:17 +02:00
|
|
|
UpdateResourceMessage message = new UpdateResourceMessage();
|
2008-04-15 19:28:28 +02:00
|
|
|
|
2008-09-18 20:11:28 +02:00
|
|
|
|
2008-04-15 19:28:28 +02:00
|
|
|
|
2008-07-01 00:55:31 +02:00
|
|
|
registryFactoryPortType =GCUBERemotePortTypeContext.getProxy(registryFactoryPortType,GCUBEScope.getScope(args[3]),managerSec);
|
2008-04-15 19:28:28 +02:00
|
|
|
try {
|
|
|
|
StringWriter writer =new StringWriter();
|
|
|
|
resource.store(writer);
|
|
|
|
message.setXmlProfile(writer.toString());
|
|
|
|
message.setUniqueID(resource.getID());
|
|
|
|
message.setType(GCUBEService.TYPE);
|
|
|
|
|
|
|
|
registryFactoryPortType.updateResource(message);
|
|
|
|
|
|
|
|
} catch(Exception e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
System.out.println("Profile has been updated");
|
|
|
|
}
|
|
|
|
}
|