This commit is contained in:
Lucio Lelii 2008-11-13 17:56:41 +00:00
parent f197ceeaaf
commit 0826901222
2 changed files with 64 additions and 8 deletions

View File

@ -141,7 +141,7 @@ public class RegistryFactory{
String [] scopes = mess.getScopes();
if (scopes != null) {
for (String scope : scopes) {
logger.debug("Adding Scopes to Profile "+ scope);
logger.debug(resource.getID()+" Adding Scopes to Profile "+ scope);
resource.addScope(GCUBEScope.getScope(scope));
}
@ -167,7 +167,7 @@ public class RegistryFactory{
} else {
//try to create resource
try {
logger.debug("Creating the stateful resource for " + resource.getID());
logger.debug(resource.getID()+" Creating the stateful resource for " + resource.getID());
ProfileResource presource = (ProfileResource) ProfileContext.getContext().getWSHome().create(ProfileContext.getContext().makeKey(resource.getID()),resource);
presource.getPersistenceDelegate().store(presource);
}
@ -177,10 +177,10 @@ public class RegistryFactory{
throw new RemoteException(msg);
}
try {
updateCounterInfo (resource.getID(), ResourceType.valueOf(mess.getType()), OperationType.create, Calendar.getInstance());
GCUBEEvent<ServiceContext.RegistryTopic, GCUBEResource> event = new GCUBEEvent<ServiceContext.RegistryTopic, GCUBEResource>();
event.setPayload(resource);
ServiceContext.getContext().getTopicProducer().notify(ServiceContext.RegistryTopic.CREATE, event);
updateCounterInfo (resource.getID(), ResourceType.valueOf(mess.getType()), OperationType.create, Calendar.getInstance());
} catch (Exception e) {
logger.warn("Error updating Counting info for resource with ID " + resource.getID(), e);
}
@ -403,7 +403,7 @@ public class RegistryFactory{
/**
* return the resource
*
* @return NotifierResource
* @return NotifierResource resource
* @throws RemoteException Exception
*/
private RegistryFactoryResource getResource() throws RemoteException {
@ -418,10 +418,28 @@ public class RegistryFactory{
return factoryResource;
}
/**
*
* @param message UpdateScopeInProfileMessage
* @return String
* @throws GCUBEFault -
*/
public String updateScopeInProfile(UpdateScopeInProfileMessage message)throws GCUBEFault{return null;}
/**
*
* @param message RemoveScopeInProfileMessage
* @return String
* @throws GCUBEFault -
*/
public String removeScopeInProfile(RemoveScopeInProfileMessage message)throws GCUBEFault{return null;}
/**
*
* @param message UpdateStateMessage
* @return
* @throws GCUBEFault -
*/
public String updateState(UpdateStateMessage message)throws GCUBEFault{return null;}
}

View File

@ -7,6 +7,10 @@ import java.util.ArrayList;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.gcube.common.core.informationsystem.notifier.ISNotifier;
import org.gcube.common.core.informationsystem.publisher.ISPublisher;
@ -66,7 +70,7 @@ public class ProfileResource extends GCUBEWSResource {
@Override
public void initialise(Object... params) throws ResourceException {
GCUBEResource resource = (GCUBEResource) params[0];
logger.debug("initializing resource "+resource.getID());
Document dom = null;
StringWriter writer =new StringWriter();
@ -75,6 +79,7 @@ public class ProfileResource extends GCUBEWSResource {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setNamespaceAware(true);
DocumentBuilder builder = factory.newDocumentBuilder();
StringReader reader = new StringReader(writer.toString().substring(writer.toString().indexOf("?>")+2, writer.toString().length()));
@ -82,6 +87,8 @@ public class ProfileResource extends GCUBEWSResource {
InputSource source = new InputSource(reader);
dom =builder.parse(source);
} catch (Exception e1) {
throw new ResourceException(e1);
}
@ -91,6 +98,8 @@ public class ProfileResource extends GCUBEWSResource {
this.setNotificationProfile(dom);
this.setGCubeResource(resource);
if (hasToLive(resource)) this.setTerminationTime(null);
if (hasToLive(resource)) {
@ -115,24 +124,43 @@ public class ProfileResource extends GCUBEWSResource {
}
/**
* set notification Profile
*
* @param profile Document
*/
public void setNotificationProfile(Document profile) {
this.getResourcePropertySet().get(NotificationProfileRP).clear();
this.getResourcePropertySet().get(NotificationProfileRP).add(profile);
//this.getPersistenceDelegate().store(this);
}
/**
* get notification Profile
*
* @return Document profile
*/
public Document getNotificationProfile() {
return (Document)this.getResourcePropertySet().get(NotificationProfileRP).get(0);
}
/**
* set Profile
*
* @param profile Document
*/
public void setProfile(Document profile) {
this.getResourcePropertySet().get(ProfileRP).clear();
this.getResourcePropertySet().get(ProfileRP).add(profile);
//this.getPersistenceDelegate().store(this);
}
/**
* get Profile
*
* @return Document profile
*/
public Document getProfile() {
return (Document)this.getResourcePropertySet().get(ProfileRP).get(0);
}
@ -141,7 +169,9 @@ public class ProfileResource extends GCUBEWSResource {
/**
* Checks if the profile has to live or not
* return true/false
*
* @param GCUBEReosurce resource
* @return true/false
*/
private boolean hasToLive(GCUBEResource resource) {
if (resource.getType().compareTo(GCUBERunningInstance.TYPE)==0 ||
@ -158,11 +188,19 @@ public class ProfileResource extends GCUBEWSResource {
return new QName(ProfileContext.getContext().getNamespace(), NotificationProfileRP+this.getID().getValue());
}
/**
* returns the Resource
*
* @return resource GCUBEReosurce
*/
public GCUBEResource getGCubeResource() {
return this.gCubeResource;
}
/**
* sets the resource
* @param resource GCUBEReosurce
*/
public void setGCubeResource(GCUBEResource resource) {
this.gCubeResource = resource;
}