From 3214fd599f75c51ea0760bbf788e9c0e2729e643 Mon Sep 17 00:00:00 2001 From: Manuele Simi Date: Wed, 23 Apr 2008 15:25:01 +0000 Subject: [PATCH] git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Registry@482 82a268e6-3cf1-43bd-a215-b396298e98cf --- etc/deploy-jndi-config.xml | 4 +-- .../registry/impl/core/ProfileResource.java | 23 +++++++--------- .../registry/impl/core/RegistryFactory.java | 27 +++++++++---------- 3 files changed, 24 insertions(+), 30 deletions(-) diff --git a/etc/deploy-jndi-config.xml b/etc/deploy-jndi-config.xml index 74ef480..5b5d585 100644 --- a/etc/deploy-jndi-config.xml +++ b/etc/deploy-jndi-config.xml @@ -32,11 +32,11 @@ type="java.lang.String" override="false"/> - + override="false" /> --> diff --git a/src/org/gcube/informationsystem/registry/impl/core/ProfileResource.java b/src/org/gcube/informationsystem/registry/impl/core/ProfileResource.java index d2b9a2f..36286b8 100644 --- a/src/org/gcube/informationsystem/registry/impl/core/ProfileResource.java +++ b/src/org/gcube/informationsystem/registry/impl/core/ProfileResource.java @@ -64,11 +64,9 @@ public class ProfileResource extends GCUBEWSResource { StringWriter writer =new StringWriter(); try { - resource.store(writer); - + resource.store(writer); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder builder = factory.newDocumentBuilder(); - + 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); @@ -106,7 +104,7 @@ public class ProfileResource extends GCUBEWSResource { public void setNotificationProfile(Document profile) { this.getResourcePropertySet().get(NotificationProfileRP).clear(); this.getResourcePropertySet().get(NotificationProfileRP).add(profile); - this.getPersistenceDelegate().store(this); + //this.getPersistenceDelegate().store(this); } public Document getNotificationProfile() { @@ -118,7 +116,7 @@ public class ProfileResource extends GCUBEWSResource { public void setProfile(Document profile) { this.getResourcePropertySet().get(ProfileRP).clear(); this.getResourcePropertySet().get(ProfileRP).add(profile); - this.getPersistenceDelegate().store(this); + //this.getPersistenceDelegate().store(this); } public Document getProfile() { @@ -128,7 +126,7 @@ public class ProfileResource extends GCUBEWSResource { /** - * Check if the profile has to live or not + * Checks if the profile has to live or not * return true/false */ private boolean hasToLive(GCUBEResource resource) { @@ -139,8 +137,8 @@ public class ProfileResource extends GCUBEWSResource { } /** - * Get the Resource Qname - * @return the Resource Qname + * Gets the Resource QName + * @return the Resource QName */ private QName generateQName() { return QName.valueOf(NotificationProfileRP.toString()+"_"+this.getID()); @@ -205,14 +203,13 @@ public class ProfileResource extends GCUBEWSResource { StringReader reader = new StringReader(writer.toString()); InputSource source = new InputSource(reader); Document dom = builder.parse(source); - - this.setProfile(dom); this.setGCubeResource(resource); - + // updates the notification profile too if (this.hasToLive(resource)) this.setNotificationProfile(dom); - + + this.getPersistenceDelegate().store(this); } diff --git a/src/org/gcube/informationsystem/registry/impl/core/RegistryFactory.java b/src/org/gcube/informationsystem/registry/impl/core/RegistryFactory.java index 7fe2a3a..0b0c03a 100644 --- a/src/org/gcube/informationsystem/registry/impl/core/RegistryFactory.java +++ b/src/org/gcube/informationsystem/registry/impl/core/RegistryFactory.java @@ -47,7 +47,6 @@ import org.gcube.informationsystem.registry.stubs.UpdateResourceResponse; import org.gcube.informationsystem.registry.stubs.UpdateScopeInProfileMessage; import org.gcube.informationsystem.registry.stubs.UpdateStateMessage; import org.gcube.informationsystem.registry.stubs.service.RegistryServiceAddressingLocator; -import org.globus.wsrf.ResourceKey; import org.globus.wsrf.security.SecurityManager; import org.oasis.wsrf.lifetime.Destroy; @@ -187,7 +186,8 @@ public class RegistryFactory extends GCUBEStartupPortType{ //try to create resource try { logger.debug("Creating the stateful resource for " + resource.getID()); - ProfileContext.getContext().getWSHome().create(ProfileContext.getContext().makeKey(resource.getID()),resource); + ProfileResource presource = (ProfileResource) ProfileContext.getContext().getWSHome().create(ProfileContext.getContext().makeKey(resource.getID()),resource); + presource.getPersistenceDelegate().store(presource); } catch (Exception ex) { String msg = "Error creating Resource"; @@ -208,16 +208,15 @@ public class RegistryFactory extends GCUBEStartupPortType{ } catch (Exception e) { logger.error("Persistence failed for " + resource.getID(), e); } - logger.info("Profile created: " + writer.toString()); + logger.info("Profile " + resource.getID() + " created "); return writer.toString(); } /** - * Updates Resource Profiles ( in case of an update of an ID not present it simply calls the Create resource method) + * Updates Resource Profiles (in case of an update of an ID not present it invokes calls the Create resource operation) * - * - * @param mess Complex Object that contains a String representing the xml profile to update and the diligentID + * @param mess Complex Object that contains a String representing the XML profile to update and the diligentID * @return UpdateResourceResponse * @throws RemoteException Exception * @throws SchemaValidationException Exception @@ -263,12 +262,12 @@ public class RegistryFactory extends GCUBEStartupPortType{ logger.error("Error updating Counting info for resource with ID " + resource.getID()); e.printStackTrace(); } - logger.info("Profile updated: " + mess.getXmlProfile()); + logger.info("Profile " + mess.getUniqueID() + " updated"); return new UpdateResourceResponse(); } /** - * Remove a Resource profile given the ID + * Removes a Resource profile identified by the given the resource ID * * * @param inputMessage Defined into WSDL file @@ -357,21 +356,19 @@ public class RegistryFactory extends GCUBEStartupPortType{ } /** - * Check if the Resource has been created + * Checks if the Resource has been created * * @param id the Resource ID * @return the resource ( null if the resource has not been created yet */ - protected synchronized ProfileResource getProfileResource(String id ){ - ProfileResource resource = null; + protected synchronized ProfileResource getProfileResource(String id ){ try { - resource = (ProfileResource) ProfileContext.getContext().getWSHome().find(ProfileContext.getContext().makeKey(id)); + return (ProfileResource) ProfileContext.getContext().getWSHome().find(ProfileContext.getContext().makeKey(id)); } catch (Exception e ){ - logger.debug("A profile with the given id has not been created yet"); - return null; + logger.debug("A profile with the given id has not been created yet"); } - return resource; + return null; }