This commit is contained in:
Manuele Simi 2008-04-23 15:25:01 +00:00
parent 988510b4c3
commit 3214fd599f
3 changed files with 24 additions and 30 deletions

View File

@ -32,11 +32,11 @@
type="java.lang.String"
override="false"/>
<environment
<!--<environment
name="lifeTime"
value="120"
type="java.lang.Integer"
override="false" />
override="false" /> -->
<resource name="publicationProfile" type="org.gcube.common.core.state.GCUBEPublicationProfile">
<resourceParams>

View File

@ -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);
}

View File

@ -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;
}