diff --git a/.classpath b/.classpath index b621e08..69162da 100644 --- a/.classpath +++ b/.classpath @@ -5,5 +5,8 @@ + + + diff --git a/build.xml b/build.xml index 300bd13..1f7fa73 100755 --- a/build.xml +++ b/build.xml @@ -15,23 +15,19 @@ flag, or placing them in a separate "build.properties" file). Note that some of properties make sense _relative_ to other properties for which this buildfile provides sensible default values (see below) - -name: Unique name of the service. -wsdl.: Filename of the -th wsdl file associated with the service. The script assumes up to 3 wsdls (wsdl.1, wsdl.2, wsdl.3). +wsdl.: Filename of the -th wsdl file associated with the service. The script assumes up to 6 wsdls (wsdl.1, wsdl.2, wsdl.3,...). Further wsdls require a simple script extension (see guidelines at end of script). package: Root package of the service implementation: includes code and configuration. -package.dir: Directory corresponding to $package, relative to $base.dir (same as $package - but with directory separators instead of dots). It must contain WSDD and JNDI files. -lib.dir: Root directory where auxiliary jar files are located. Ideally outside $base.dir as not needed for remote build and dynamic deployment. +package.dir: Directory corresponding to $package, relative to ${base.dir} (same as ${package} but with directory separators instead of dots). +lib.dir: Root directory where auxiliary jar files are located. Ideally outside ${base.dir} as not needed for remote build and dynamic deployment. OPTIONAL INPUT PROPERTIES (DEFAULT AVAILABLE) base.dir: Root directory of the service. Defaults to "."). -schema.dir.name: Name of the $base.dir subdirectory which contains the wsdl/s. Defaults to "schema". - Defaults to $name. -etc.dir.name: Name of the $package.dir subdirectory which contains the configuration (other than WSSD and JNDI). Defaults to "etc". -stubs.dir.name: Name of the $package.dir subdirectory which contains auxiliary files and resources for stubs. Defaults to "stubs". -garname: Unique name of the GAR file to be generated. Defaults to $name. +schema.dir.name: Name of the ${base.dir }subdirectory which contains the wsdl(s). Defaults to "schema". +etc.dir.name: Name of the directory which contains the configuration (other than WSSD and JNDI). Defaults to "etc". +stubs.dir.name: Name of the ${package.dir} subdirectory which contains auxiliary files and resources for stubs. Defaults to "stubs". +garname: Unique name of the GAR file to be generated. Defaults to ${package}. --> @@ -77,7 +73,6 @@ garname: Unique name of the GAR file to be generated. Defaults to $name. - @@ -87,8 +82,8 @@ garname: Unique name of the GAR file to be generated. Defaults to $name. - - + + @@ -104,9 +99,9 @@ garname: Unique name of the GAR file to be generated. Defaults to $name. - + - + @@ -128,7 +123,7 @@ garname: Unique name of the GAR file to be generated. Defaults to $name. - + @@ -419,7 +414,10 @@ garname: Unique name of the GAR file to be generated. Defaults to $name. - + + + + diff --git a/etc/deploy-jndi-config.xml b/etc/deploy-jndi-config.xml index 1df4a87..62bd4c9 100644 --- a/etc/deploy-jndi-config.xml +++ b/etc/deploy-jndi-config.xml @@ -3,9 +3,9 @@ - diff --git a/etc/deploy-server.wsdd b/etc/deploy-server.wsdd index 53b3dbb..99501e9 100644 --- a/etc/deploy-server.wsdd +++ b/etc/deploy-server.wsdd @@ -6,27 +6,27 @@ - share/schema/Registry/Registry_service.wsdl + share/schema/org.gcube.informationsystem.registry/Registry_service.wsdl - + - share/schema/Registry/RegistryFactory_service.wsdl + share/schema/org.gcube.informationsystem.registry/RegistryFactory_service.wsdl - + diff --git a/etc/deploy-server.wsdd_NOSEC b/etc/deploy-server.wsdd_NOSEC index 2ddca5c..339655d 100644 --- a/etc/deploy-server.wsdd_NOSEC +++ b/etc/deploy-server.wsdd_NOSEC @@ -6,7 +6,7 @@ - share/schema/Registry/Registry_service.wsdl + share/schema/org.gcube.informationsystem.registry/Registry_service.wsdl @@ -19,7 +19,7 @@ - share/schema/Registry/RegistryFactory_service.wsdl + share/schema/org.gcube.informationsystem.registry/RegistryFactory_service.wsdl diff --git a/etc/pushFactory.xml b/etc/pushFactory.xml index 009a8af..e5753dc 100644 --- a/etc/pushFactory.xml +++ b/etc/pushFactory.xml @@ -14,7 +14,7 @@ - wssgtopic:ExternalRunningInstanceCounter + wssgtopic:ExternalRunningInstance diff --git a/org/gcube/informationsystem/registry/impl/core/ProfileResource.java b/org/gcube/informationsystem/registry/impl/core/ProfileResource.java index 08e2752..918dfa6 100644 --- a/org/gcube/informationsystem/registry/impl/core/ProfileResource.java +++ b/org/gcube/informationsystem/registry/impl/core/ProfileResource.java @@ -1,9 +1,12 @@ package org.gcube.informationsystem.registry.impl.core; +import java.io.StringReader; import java.io.StringWriter; import java.util.ArrayList; import javax.xml.namespace.QName; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; import org.gcube.common.core.is.publisher.ISPublisher; @@ -16,6 +19,8 @@ import org.gcube.common.core.resources.GCUBEService; import org.gcube.common.core.state.GCUBEWSResource; import org.gcube.common.core.utils.logging.GCUBELog; import org.globus.wsrf.ResourceException; +import org.w3c.dom.Document; +import org.xml.sax.InputSource; /** @@ -55,15 +60,24 @@ public class ProfileResource extends GCUBEWSResource { @Override public void initialise(Object... params) throws ResourceException { GCUBEResource resource = (GCUBEResource) params[0]; - + Document dom = null; StringWriter writer =new StringWriter(); + try { resource.store(writer); + + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + + StringReader reader = new StringReader(writer.toString().substring(writer.toString().indexOf("?>")+2, writer.toString().length())); + InputSource source = new InputSource(reader); + dom =builder.parse(source); } catch (Exception e1) { - throw new ResourceException(); + throw new ResourceException(e1); } - this.setProfile(writer.toString()); - this.setNotificationProfile(writer.toString()); + + this.setProfile(dom); + this.setNotificationProfile(dom); this.setGCubeResource(resource); if (hasToLive(resource)) this.setTerminationTime(null); @@ -89,26 +103,26 @@ public class ProfileResource extends GCUBEWSResource { } - public void setNotificationProfile(String profile) { + public void setNotificationProfile(Document profile) { this.getResourcePropertySet().get(NotificationProfileRP).clear(); this.getResourcePropertySet().get(NotificationProfileRP).add(profile); this.getPersistenceDelegate().store(this); } - public String getNotificationProfile() { - return (String)this.getResourcePropertySet().get(NotificationProfileRP).get(0); + public Document getNotificationProfile() { + return (Document)this.getResourcePropertySet().get(NotificationProfileRP).get(0); } - public void setProfile(String profile) { + public void setProfile(Document profile) { this.getResourcePropertySet().get(ProfileRP).clear(); this.getResourcePropertySet().get(ProfileRP).add(profile); this.getPersistenceDelegate().store(this); } - public String getProfile() { - return (String)this.getResourcePropertySet().get(ProfileRP).get(0); + public Document getProfile() { + return (Document)this.getResourcePropertySet().get(ProfileRP).get(0); } @@ -183,13 +197,21 @@ public class ProfileResource extends GCUBEWSResource { public void updateResource(GCUBEResource resource) throws Exception{ + + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); StringWriter writer = new StringWriter(); resource.store(writer); - this.setProfile(writer.toString()); + StringReader reader = new StringReader(writer.toString()); + InputSource source = new InputSource(reader); + Document dom = builder.parse(source); + + + this.setProfile(dom); this.setGCubeResource(resource); if (this.hasToLive(resource)) - this.setNotificationProfile(writer.toString()); + this.setNotificationProfile(dom); } diff --git a/org/gcube/informationsystem/registry/impl/core/Registry.java b/org/gcube/informationsystem/registry/impl/core/Registry.java index fdd3c35..372aac8 100644 --- a/org/gcube/informationsystem/registry/impl/core/Registry.java +++ b/org/gcube/informationsystem/registry/impl/core/Registry.java @@ -1,5 +1,6 @@ package org.gcube.informationsystem.registry.impl.core; +import org.apache.axis.utils.XMLUtils; import org.gcube.common.core.faults.GCUBEFault; import org.gcube.informationsystem.registry.stubs.GetProfileString; import org.gcube.informationsystem.registry.impl.core.ProfileResource; @@ -9,8 +10,9 @@ import org.globus.wsrf.ResourceException; public class Registry { public String getProfileString(GetProfileString voidType) throws GCUBEFault{ + try { - return ((ProfileResource)ProfileContext.getContext().getWSHome().find()).getProfile(); + return XMLUtils.DocumentToString(((ProfileResource)ProfileContext.getContext().getWSHome().find()).getProfile()); } catch (ResourceException e) { e.printStackTrace(); throw new GCUBEFault(); diff --git a/org/gcube/informationsystem/registry/impl/core/RegistryFactory.java b/org/gcube/informationsystem/registry/impl/core/RegistryFactory.java index 390c231..910bac4 100644 --- a/org/gcube/informationsystem/registry/impl/core/RegistryFactory.java +++ b/org/gcube/informationsystem/registry/impl/core/RegistryFactory.java @@ -7,6 +7,7 @@ import java.rmi.RemoteException; import java.util.ArrayList; import java.util.Calendar; +import org.apache.axis.utils.XMLUtils; import org.gcube.common.core.contexts.GCUBEServiceContext; import org.gcube.common.core.contexts.GHNContext; import org.gcube.common.core.faults.GCUBEFault; @@ -311,7 +312,7 @@ public class RegistryFactory extends GCUBEStartupPortType{ try{ ProfileResource resource = getProfileResource(ID ); - profile.load(new StringReader(resource.getProfile())); + profile.load(new StringReader( XMLUtils.DocumentToString(resource.getProfile()))); //remove profile resource.removeProfile(); RegistryServiceAddressingLocator locator = new RegistryServiceAddressingLocator(); diff --git a/org/gcube/informationsystem/registry/impl/core/RegistryPersistenceDelegate.java b/org/gcube/informationsystem/registry/impl/core/RegistryPersistenceDelegate.java index 93273bf..2724809 100644 --- a/org/gcube/informationsystem/registry/impl/core/RegistryPersistenceDelegate.java +++ b/org/gcube/informationsystem/registry/impl/core/RegistryPersistenceDelegate.java @@ -3,6 +3,7 @@ package org.gcube.informationsystem.registry.impl.core; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import org.gcube.common.core.persistence.GCUBEWSFilePersistenceDelegate; +import org.w3c.dom.Document; public class RegistryPersistenceDelegate extends GCUBEWSFilePersistenceDelegate { @@ -10,14 +11,14 @@ public class RegistryPersistenceDelegate extends GCUBEWSFilePersistenceDelegate< protected void onLoad(ProfileResource resource, ObjectInputStream ois) throws Exception { super.onLoad(resource, ois); - resource.setProfile((String)ois.readUTF()); + resource.setProfile((Document)ois.readObject()); resource.setNotificationProfile(resource.getProfile()); } protected void onStore(ProfileResource resource,ObjectOutputStream oos) throws Exception { super.onStore(resource, oos); - oos.writeUTF(resource.getProfile()); + oos.writeObject((Document)resource.getProfile()); } } diff --git a/org/gcube/informationsystem/registry/impl/util/RegistrationThread.java b/org/gcube/informationsystem/registry/impl/util/RegistrationThread.java index bae8f84..7c8475b 100644 --- a/org/gcube/informationsystem/registry/impl/util/RegistrationThread.java +++ b/org/gcube/informationsystem/registry/impl/util/RegistrationThread.java @@ -20,7 +20,7 @@ public class RegistrationThread implements Runnable{ /** * */ - private static GCUBELog logger = new GCUBELog(RegistrationThread.class.getName()); + private static GCUBELog logger = new GCUBELog(RegistrationThread.class); /** * @@ -55,6 +55,7 @@ public class RegistrationThread implements Runnable{ } try { ISPublisher publisher = GHNContext.getImplementation(ISPublisher.class); + logger.debug("DefaultScope: "+GHNContext.getContext().getDefaultScope() ); publisher.registerToISNotification(FactoryContext.getContext().getEPR(),topics, GHNContext.getContext().getDefaultScope(), ServiceContext.getContext() ); return; diff --git a/org/gcube/informationsystem/registry/test/RegistryRemoveTest.java b/org/gcube/informationsystem/registry/test/RegistryRemoveTest.java new file mode 100644 index 0000000..850dc48 --- /dev/null +++ b/org/gcube/informationsystem/registry/test/RegistryRemoveTest.java @@ -0,0 +1,51 @@ +package org.gcube.informationsystem.registry.test; + +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.resources.GCUBEService; +import org.gcube.common.core.scope.GCUBEScope; +import org.gcube.common.core.security.GCUBESecurityManagerImpl; +import org.gcube.informationsystem.registry.stubs.RegistryFactoryPortType; +import org.gcube.informationsystem.registry.stubs.RemoveResourceMessage; +import org.gcube.informationsystem.registry.stubs.service.RegistryFactoryServiceAddressingLocator; +import org.gridforum.jgss.ExtendedGSSCredential; + +public class RegistryRemoveTest { + + 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]); + + EndpointReferenceType factoryEPR = new EndpointReferenceType(); + + RegistryFactoryPortType registryFactoryPortType= null; + try { + factoryEPR.setAddress(new Address(args[0])); + registryFactoryPortType = registryLocator.getRegistryFactoryPortTypePort(factoryEPR); + }catch(Exception e){ + e.printStackTrace(); + } + RemoveResourceMessage message = new RemoveResourceMessage(); + + managerSec.useCredentials(cred); + registryFactoryPortType =GCUBERemotePortTypeContext.getProxy(registryFactoryPortType,GCUBEScope.getScope("/gcube/devsec"),managerSec); + try { + StringWriter writer =new StringWriter(); + message.setType(GCUBEService.TYPE); + message.setUniqueID(args[1]); + registryFactoryPortType.removeResource(message); + + } catch(Exception e) { + e.printStackTrace(); + } + System.out.println("Profile with ID "+ args[1]+ "has been succesfully removed"); + } + +} diff --git a/org/gcube/informationsystem/registry/test/RegistryTest.java b/org/gcube/informationsystem/registry/test/RegistryTest.java index 79a02eb..22add4b 100644 --- a/org/gcube/informationsystem/registry/test/RegistryTest.java +++ b/org/gcube/informationsystem/registry/test/RegistryTest.java @@ -5,8 +5,10 @@ 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.GCUBESecurityManager; import org.gcube.common.core.security.GCUBESecurityManagerImpl; import org.gcube.informationsystem.registry.stubs.CreateResourceMessage; @@ -43,7 +45,7 @@ public class RegistryTest { CreateResourceMessage message = new CreateResourceMessage(); String profile =""; managerSec.useCredentials(cred); - managerSec.setSecurity(registryFactoryPortType, GCUBESecurityManager.AuthMode.INTEGRITY, GCUBESecurityManager.DelegationMode.NONE); + registryFactoryPortType =GCUBERemotePortTypeContext.getProxy(registryFactoryPortType,GCUBEScope.getScope("/gcube/devsec"),managerSec); try { StringWriter writer =new StringWriter(); resource.store(writer); diff --git a/org/gcube/informationsystem/registry/test/RegistryUpdateTest.java b/org/gcube/informationsystem/registry/test/RegistryUpdateTest.java new file mode 100644 index 0000000..4d3e9b3 --- /dev/null +++ b/org/gcube/informationsystem/registry/test/RegistryUpdateTest.java @@ -0,0 +1,60 @@ +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; +import org.gcube.informationsystem.registry.stubs.UpdateProfileMessage; +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;}}; + + ExtendedGSSCredential cred =org.diligentproject.dvos.authentication.util.ProxyUtil.loadProxyCredentials(args[2]); + + 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(); + } + UpdateProfileMessage message = new UpdateProfileMessage(); + + managerSec.useCredentials(cred); + + registryFactoryPortType =GCUBERemotePortTypeContext.getProxy(registryFactoryPortType,GCUBEScope.getScope("/gcube/devsec"),managerSec); + 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"); + } +} diff --git a/schema/Registry.wsdl b/schema/Registry.wsdl index 5b44e4a..dce1d7d 100644 --- a/schema/Registry.wsdl +++ b/schema/Registry.wsdl @@ -44,7 +44,7 @@ - +