2008-05-06 00:44:24 +02:00
|
|
|
package org.gcube.informationsystem.registry.impl;
|
2008-04-15 19:28:28 +02:00
|
|
|
|
2008-10-10 00:02:20 +02:00
|
|
|
import java.io.BufferedReader;
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
|
import java.io.InputStreamReader;
|
2008-04-15 19:28:28 +02:00
|
|
|
import java.io.StringReader;
|
|
|
|
import java.io.StringWriter;
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
import java.rmi.RemoteException;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.Calendar;
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.List;
|
|
|
|
import org.apache.axis.components.uuid.UUIDGen;
|
|
|
|
import org.apache.axis.components.uuid.UUIDGenFactory;
|
2008-09-26 18:10:12 +02:00
|
|
|
import org.gcube.common.core.contexts.GHNContext;
|
2008-04-15 19:28:28 +02:00
|
|
|
import org.gcube.common.core.faults.GCUBEFault;
|
2008-10-10 00:13:33 +02:00
|
|
|
import org.gcube.common.core.resources.GCUBEGenericResource;
|
2008-04-15 19:28:28 +02:00
|
|
|
import org.gcube.common.core.resources.GCUBEHostingNode;
|
|
|
|
import org.gcube.common.core.resources.GCUBEResource;
|
2008-09-26 18:10:12 +02:00
|
|
|
import org.gcube.common.core.resources.impl.kxml.GCUBEResourceImpl;
|
2008-04-15 19:28:28 +02:00
|
|
|
import org.gcube.common.core.scope.GCUBEScope;
|
|
|
|
import org.gcube.common.core.state.GCUBEWSResourceKey;
|
2008-09-26 18:10:12 +02:00
|
|
|
import org.gcube.common.core.utils.events.GCUBEEvent;
|
2008-04-15 19:28:28 +02:00
|
|
|
import org.gcube.common.core.utils.logging.GCUBELog;
|
2008-05-06 18:25:31 +02:00
|
|
|
import org.gcube.informationsystem.registry.impl.contexts.FactoryContext;
|
2008-05-06 00:44:24 +02:00
|
|
|
import org.gcube.informationsystem.registry.impl.contexts.ProfileContext;
|
|
|
|
import org.gcube.informationsystem.registry.impl.contexts.ServiceContext;
|
|
|
|
import org.gcube.informationsystem.registry.impl.state.ProfileResource;
|
|
|
|
import org.gcube.informationsystem.registry.impl.state.RegistryFactoryResource;
|
2008-04-15 19:28:28 +02:00
|
|
|
import org.gcube.informationsystem.registry.impl.util.ProfileManager;
|
|
|
|
import org.gcube.informationsystem.registry.impl.util.RegistryUtil;
|
|
|
|
import org.gcube.informationsystem.registry.stubs.CreateResourceMessage;
|
|
|
|
import org.gcube.informationsystem.registry.stubs.ProfileAlreadyRegisteredFault;
|
|
|
|
import org.gcube.informationsystem.registry.stubs.RegistryProperty;
|
|
|
|
import org.gcube.informationsystem.registry.stubs.RemoveResourceMessage;
|
|
|
|
import org.gcube.informationsystem.registry.stubs.RemoveResourceResponse;
|
|
|
|
import org.gcube.informationsystem.registry.stubs.RemoveScopeInProfileMessage;
|
|
|
|
import org.gcube.informationsystem.registry.stubs.SchemaValidationFault;
|
|
|
|
import org.gcube.informationsystem.registry.stubs.StartRegistration;
|
|
|
|
import org.gcube.informationsystem.registry.stubs.StartRegistrationResponse;
|
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.UpdateResourceResponse;
|
|
|
|
import org.gcube.informationsystem.registry.stubs.UpdateScopeInProfileMessage;
|
|
|
|
import org.gcube.informationsystem.registry.stubs.UpdateStateMessage;
|
|
|
|
import org.globus.wsrf.security.SecurityManager;
|
2008-05-06 18:25:31 +02:00
|
|
|
import static org.gcube.informationsystem.registry.impl.core.RegistryConfiguration.ResourceType;
|
|
|
|
|
2008-04-15 19:28:28 +02:00
|
|
|
|
|
|
|
/**
|
2008-05-06 00:44:24 +02:00
|
|
|
* Implementation of the <em>Registry Factory</em> portType
|
2008-04-24 02:12:47 +02:00
|
|
|
*
|
2008-05-06 00:44:24 +02:00
|
|
|
* @author Andrea Manzi, Manuele Simi (ISTI-CNR)
|
2008-04-15 19:28:28 +02:00
|
|
|
*
|
|
|
|
*/
|
2008-09-15 16:51:26 +02:00
|
|
|
public class RegistryFactory{
|
2008-04-15 19:28:28 +02:00
|
|
|
|
2008-05-06 18:25:31 +02:00
|
|
|
|
2008-04-17 15:50:17 +02:00
|
|
|
|
2008-04-15 19:28:28 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The UUIDGen
|
|
|
|
*/
|
|
|
|
private static final UUIDGen uuidgen = UUIDGenFactory.getUUIDGen();
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Object logger.
|
|
|
|
* */
|
|
|
|
protected final GCUBELog logger = new GCUBELog(RegistryFactory.class);
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
2008-05-06 00:44:24 +02:00
|
|
|
enum OperationType {create,update,destroy};
|
2008-04-15 19:28:28 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Map of registration to Notification
|
|
|
|
*/
|
|
|
|
public static List<GCUBEWSResourceKey> notificationMap = Collections.synchronizedList(new ArrayList<GCUBEWSResourceKey>());
|
|
|
|
|
|
|
|
/** the key used to label the Factory Resource */
|
2008-05-06 00:44:24 +02:00
|
|
|
public static final String NOTIFICATOR_RESOURCE_KEY = "RegistryResource";
|
2008-04-15 19:28:28 +02:00
|
|
|
|
|
|
|
|
2008-09-15 16:51:26 +02:00
|
|
|
/**
|
2008-04-15 19:28:28 +02:00
|
|
|
* Use to Load from Disk persistence profiles and registers it into the IS-IC ( in case the IS-IC is empty)
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param start same as void
|
|
|
|
* @return void
|
|
|
|
* @throws RemoteException Exception
|
|
|
|
*/
|
|
|
|
public StartRegistrationResponse startRegistration(StartRegistration start ) throws GCUBEFault{
|
|
|
|
//start registration to broker and new profiles registration
|
|
|
|
logger.debug("Starting profile registration from disk");
|
|
|
|
try {
|
|
|
|
//loadProfiles();
|
|
|
|
} catch (Exception e) {
|
|
|
|
logger.error("Error Loading profiles");
|
|
|
|
throw new GCUBEFault(e.getMessage());
|
|
|
|
}
|
|
|
|
return new StartRegistrationResponse();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
2008-05-06 00:44:24 +02:00
|
|
|
* Creates a new GCUBEResource's profile manager
|
2008-04-15 19:28:28 +02:00
|
|
|
*
|
|
|
|
* @param inputMessage
|
2008-05-06 00:44:24 +02:00
|
|
|
* @return the profile as string
|
2008-04-15 19:28:28 +02:00
|
|
|
* @throws SchemaValidationFault
|
|
|
|
* @throws RemoteException
|
|
|
|
* @throws ProfileAlreadyRegisteredFault
|
|
|
|
*/
|
2008-05-06 18:25:31 +02:00
|
|
|
public String createResource(CreateResourceMessage mess) throws SchemaValidationFault,RemoteException,ProfileAlreadyRegisteredFault {
|
2008-04-15 19:28:28 +02:00
|
|
|
|
2008-04-17 10:11:22 +02:00
|
|
|
GCUBEResource resource = null;
|
2008-04-15 19:28:28 +02:00
|
|
|
logger.info("CreateResource operation invoked");
|
2008-04-17 10:11:22 +02:00
|
|
|
logSecurityInfo("createResource");
|
2008-04-15 19:28:28 +02:00
|
|
|
|
2008-09-04 20:29:19 +02:00
|
|
|
|
|
|
|
|
2008-05-06 18:25:31 +02:00
|
|
|
String profile = mess.getProfile();
|
2008-04-15 19:28:28 +02:00
|
|
|
if (profile == null || profile.compareTo("") == 0) {
|
|
|
|
String msg = "Profile file empty";
|
|
|
|
logger.debug(msg);
|
|
|
|
throw new RemoteException(msg);
|
|
|
|
}
|
2008-10-10 00:02:20 +02:00
|
|
|
|
|
|
|
System.out.println("profile:" +profile);
|
2008-04-15 19:28:28 +02:00
|
|
|
try {
|
2008-10-10 00:34:39 +02:00
|
|
|
ResourceType.valueOf(mess.getType()).getResourceClass().getClass().cast(resource);
|
|
|
|
|
2008-10-10 00:02:20 +02:00
|
|
|
resource.load(new BufferedReader(new InputStreamReader(new ByteArrayInputStream(profile.getBytes("UTF-8")), "UTF-8")));
|
2008-10-10 00:13:33 +02:00
|
|
|
|
2008-10-10 00:26:23 +02:00
|
|
|
if (mess.getType().compareTo(GCUBEGenericResource.TYPE)==0){
|
2008-10-10 00:13:33 +02:00
|
|
|
System.out.println(((GCUBEGenericResource) resource).getBody());
|
|
|
|
}
|
2008-04-15 19:28:28 +02:00
|
|
|
//the parse Profile class allows to extract from profiles information about type/SCOPE/UniqueID
|
2008-04-17 10:11:22 +02:00
|
|
|
//in order to distinguish among different Resource Type
|
2008-04-15 19:28:28 +02:00
|
|
|
//Adding scopes to Profile
|
2008-05-06 18:25:31 +02:00
|
|
|
String [] scopes = mess.getScopes();
|
2008-04-15 19:28:28 +02:00
|
|
|
if (scopes != null) {
|
|
|
|
for (String scope : scopes) {
|
|
|
|
logger.debug("Adding Scopes to Profile "+ scope);
|
|
|
|
resource.addScope(GCUBEScope.getScope(scope));
|
|
|
|
}
|
2008-09-04 20:29:19 +02:00
|
|
|
|
2008-04-15 19:28:28 +02:00
|
|
|
}
|
|
|
|
//check ID
|
|
|
|
if (resource.getID()== null || resource.getID().compareTo("")==0) {resource.setID(uuidgen.nextUUID()); }
|
2008-10-10 00:13:33 +02:00
|
|
|
|
2008-04-15 19:28:28 +02:00
|
|
|
}
|
2008-04-22 22:18:06 +02:00
|
|
|
catch (Exception ex) {
|
2008-04-15 19:28:28 +02:00
|
|
|
logger.error("Error trying to load profile", ex);
|
|
|
|
throw new SchemaValidationFault();
|
|
|
|
}
|
|
|
|
//check if the Resource already exists
|
2008-04-17 15:50:17 +02:00
|
|
|
if (isResourceCreated(resource.getID())) {
|
|
|
|
// update the existing resource
|
|
|
|
logger.warn("A Resource with ID "+ resource.getID()+" is already registered");
|
2008-05-06 18:25:31 +02:00
|
|
|
UpdateResourceMessage upmess = new UpdateResourceMessage();
|
|
|
|
upmess.setUniqueID(resource.getID());
|
|
|
|
upmess.setXmlProfile(mess.getProfile());
|
|
|
|
upmess.setType(mess.getType());
|
|
|
|
this.updateResource(upmess);
|
2008-04-17 15:50:17 +02:00
|
|
|
//throw new ProfileAlreadyRegisteredFault();
|
|
|
|
} else {
|
|
|
|
//try to create resource
|
|
|
|
try {
|
|
|
|
logger.debug("Creating the stateful resource for " + resource.getID());
|
2008-04-23 17:25:01 +02:00
|
|
|
ProfileResource presource = (ProfileResource) ProfileContext.getContext().getWSHome().create(ProfileContext.getContext().makeKey(resource.getID()),resource);
|
|
|
|
presource.getPersistenceDelegate().store(presource);
|
2008-04-17 15:50:17 +02:00
|
|
|
}
|
|
|
|
catch (Exception ex) {
|
|
|
|
String msg = "Error creating Resource";
|
|
|
|
logger.error(msg,ex);
|
|
|
|
throw new RemoteException(msg);
|
|
|
|
}
|
|
|
|
try {
|
2008-09-26 18:10:12 +02:00
|
|
|
GCUBEEvent<ServiceContext.RegistryTopic, GCUBEResource> event = new GCUBEEvent<ServiceContext.RegistryTopic, GCUBEResource>();
|
|
|
|
event.setPayload(resource);
|
|
|
|
ServiceContext.getContext().getTopicProducer().notify(ServiceContext.RegistryTopic.CREATE, event);
|
2008-05-06 18:25:31 +02:00
|
|
|
updateCounterInfo (resource.getID(), ResourceType.valueOf(mess.getType()), OperationType.create, Calendar.getInstance());
|
2008-04-17 15:50:17 +02:00
|
|
|
} catch (Exception e) {
|
2008-05-06 18:25:31 +02:00
|
|
|
logger.warn("Error updating Counting info for resource with ID " + resource.getID(), e);
|
2008-04-17 15:50:17 +02:00
|
|
|
}
|
2008-04-15 19:28:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
StringWriter writer = new StringWriter();
|
|
|
|
try {
|
|
|
|
logger.debug("Persisting the stateful resource for " + resource.getID());
|
|
|
|
resource.store(writer);
|
|
|
|
} catch (Exception e) {
|
|
|
|
logger.error("Persistence failed for " + resource.getID(), e);
|
|
|
|
}
|
2008-04-23 17:25:01 +02:00
|
|
|
logger.info("Profile " + resource.getID() + " created ");
|
2008-04-15 19:28:28 +02:00
|
|
|
return writer.toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2008-04-23 17:25:01 +02:00
|
|
|
* Updates Resource Profiles (in case of an update of an ID not present it invokes calls the Create resource operation)
|
2008-04-15 19:28:28 +02:00
|
|
|
*
|
2008-04-23 17:25:01 +02:00
|
|
|
* @param mess Complex Object that contains a String representing the XML profile to update and the diligentID
|
2008-04-15 19:28:28 +02:00
|
|
|
* @return UpdateResourceResponse
|
|
|
|
* @throws RemoteException Exception
|
|
|
|
* @throws SchemaValidationException Exception
|
|
|
|
*/
|
2008-09-26 18:10:12 +02:00
|
|
|
@SuppressWarnings("unchecked")
|
2008-04-17 15:50:17 +02:00
|
|
|
public UpdateResourceResponse updateResource(UpdateResourceMessage mess) throws RemoteException,SchemaValidationFault,GCUBEFault {
|
2008-04-15 19:28:28 +02:00
|
|
|
|
|
|
|
logSecurityInfo("updateResource");
|
|
|
|
logger.info("UpdateResource operation invoked");
|
|
|
|
String ID = mess.getUniqueID();
|
|
|
|
String xmlProfile = mess.getXmlProfile();
|
|
|
|
GCUBEResource resource = null;
|
|
|
|
CreateResourceMessage input =null;
|
|
|
|
//validating input parameters
|
|
|
|
if (ID == null || ID.compareTo("") ==0) {
|
|
|
|
logger.debug(" ID missing ");
|
|
|
|
throw new RemoteException("Error, ID missing");
|
|
|
|
}
|
|
|
|
if (xmlProfile == null || xmlProfile.compareTo("") ==0) {
|
|
|
|
logger.debug("Profile missing" );
|
|
|
|
throw new RemoteException("Error, profile missing");
|
|
|
|
}
|
|
|
|
//check if the profile exist
|
|
|
|
if (!isResourceCreated(ID)) {
|
|
|
|
input = new CreateResourceMessage();
|
|
|
|
input.setProfile(xmlProfile);
|
|
|
|
input.setType(mess.getType());
|
|
|
|
this.createResource(input);
|
|
|
|
return new UpdateResourceResponse();
|
|
|
|
}
|
|
|
|
try {
|
2008-05-06 18:25:31 +02:00
|
|
|
resource = ResourceType.valueOf(mess.getType()).getResourceClass();
|
2008-04-15 19:28:28 +02:00
|
|
|
resource.load(new StringReader(xmlProfile));
|
|
|
|
getProfileResource(ID).updateResource(resource);
|
|
|
|
}
|
|
|
|
catch (Exception e) {
|
|
|
|
logger.error("Error updating profile for ID "+ e);
|
|
|
|
throw new RemoteException(e.toString());
|
|
|
|
}
|
|
|
|
|
|
|
|
try {
|
2008-05-06 18:25:31 +02:00
|
|
|
updateCounterInfo (ID,ResourceType.valueOf(mess.getType()),OperationType.update, Calendar.getInstance());
|
2008-09-26 18:10:12 +02:00
|
|
|
GCUBEEvent<ServiceContext.RegistryTopic, GCUBEResource> event = new GCUBEEvent<ServiceContext.RegistryTopic, GCUBEResource>();
|
|
|
|
event.setPayload(resource);
|
|
|
|
ServiceContext.getContext().getTopicProducer().notify(ServiceContext.RegistryTopic.UPDATE, event);
|
2008-04-15 19:28:28 +02:00
|
|
|
} catch (Exception e) {
|
2008-05-06 18:25:31 +02:00
|
|
|
logger.warn("Error updating counting info for resource with ID " + resource.getID(), e);
|
2008-04-15 19:28:28 +02:00
|
|
|
}
|
2008-04-23 17:25:01 +02:00
|
|
|
logger.info("Profile " + mess.getUniqueID() + " updated");
|
2008-04-15 19:28:28 +02:00
|
|
|
return new UpdateResourceResponse();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-04-23 17:25:01 +02:00
|
|
|
* Removes a Resource profile identified by the given the resource ID
|
2008-04-15 19:28:28 +02:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param inputMessage Defined into WSDL file
|
|
|
|
* @return RemoveResourceResponse
|
|
|
|
* @throws RemoteException Exceptions
|
|
|
|
*/
|
|
|
|
public RemoveResourceResponse removeResource (RemoveResourceMessage inputMessage) throws RemoteException,GCUBEFault{
|
|
|
|
logSecurityInfo("removeResource");
|
|
|
|
logger.info("RemoveResource operation invoked");
|
|
|
|
String ID = inputMessage.getUniqueID();
|
|
|
|
String type = inputMessage.getType();
|
|
|
|
if (ID == null || ID.compareTo("") ==0) {
|
2008-05-03 01:53:30 +02:00
|
|
|
logger.warn("Resource ID is missing");
|
|
|
|
throw new RemoteException("Resource ID is missing");
|
2008-04-15 19:28:28 +02:00
|
|
|
}
|
|
|
|
//check if the UniqueID exist
|
2008-05-03 01:53:30 +02:00
|
|
|
|
|
|
|
/*GCUBEResource resource = null;
|
2008-04-15 19:28:28 +02:00
|
|
|
try {
|
|
|
|
resource = RegistryUtil.getProfileFromIS(ID,this.getResourceClass(type).getClass());
|
|
|
|
} catch (Exception e1) {
|
|
|
|
logger.error("Error gettign profile from IS ");
|
|
|
|
return new RemoveResourceResponse();
|
2008-05-03 01:53:30 +02:00
|
|
|
}*/
|
|
|
|
//if( resource == null) return new RemoveResourceResponse();
|
|
|
|
//else {
|
|
|
|
logger.debug("trying to remove the resource from the IS-IC");
|
2008-04-15 19:28:28 +02:00
|
|
|
try {
|
2008-05-03 01:53:30 +02:00
|
|
|
new ProfileManager().removeFromISIC(ID, type, ServiceContext.getContext().getCredentials());
|
|
|
|
logger.debug("resource removed");
|
2008-04-15 19:28:28 +02:00
|
|
|
} catch (Exception e) {
|
|
|
|
logger.error("Unable to remove the resource", e);
|
|
|
|
throw ServiceContext.getContext().getDefaultException("", e).toFault("Unable to remove the resource: the remote IS-IC returns an error");
|
|
|
|
}
|
2008-05-03 01:53:30 +02:00
|
|
|
//}
|
|
|
|
|
|
|
|
try {
|
|
|
|
if (type.compareTo(GCUBEHostingNode.TYPE) == 0)
|
|
|
|
RegistryUtil.unregisterRIRelatedToGHN(ID,this);
|
|
|
|
} catch (Exception e) {
|
|
|
|
logger.error("Error removing profile related to this GHNID for ID ", e);
|
2008-04-15 19:28:28 +02:00
|
|
|
}
|
|
|
|
|
2008-05-03 01:53:30 +02:00
|
|
|
if (this.isResourceCreated(ID)){
|
|
|
|
//destroy the resource
|
|
|
|
try{
|
2008-09-04 20:29:19 +02:00
|
|
|
|
|
|
|
ProfileContext.getContext().getWSHome().remove(ProfileContext.getContext().makeKey(ID));
|
|
|
|
logger.info(" Resource Destroyed");
|
2008-05-03 01:53:30 +02:00
|
|
|
}
|
|
|
|
catch (Exception e) {
|
|
|
|
logger.error("Error removing resource for ID ", e);
|
|
|
|
throw new RemoteException();
|
|
|
|
}
|
|
|
|
try {
|
2008-09-26 18:10:12 +02:00
|
|
|
|
|
|
|
GCUBEEvent<ServiceContext.RegistryTopic, GCUBEResource> event = new GCUBEEvent<ServiceContext.RegistryTopic, GCUBEResource>();
|
|
|
|
GCUBEResource resource =GHNContext.getImplementation(GCUBEResource.class);
|
|
|
|
resource.setID(ID);
|
|
|
|
event.setPayload(resource);
|
|
|
|
ServiceContext.getContext().getTopicProducer().notify(ServiceContext.RegistryTopic.REMOVE, event);
|
|
|
|
|
2008-05-06 18:25:31 +02:00
|
|
|
updateCounterInfo(ID, ResourceType.valueOf(type), OperationType.destroy, Calendar.getInstance());
|
2008-05-03 01:53:30 +02:00
|
|
|
}
|
|
|
|
catch (Exception e) {
|
2008-05-06 18:25:31 +02:00
|
|
|
logger.warn("Error updating counting info for resource with ID " + ID ,e);
|
2008-04-15 19:28:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return new RemoveResourceResponse();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Log Security info
|
|
|
|
*
|
|
|
|
* @param methodName The Method Name
|
|
|
|
*/
|
|
|
|
private void logSecurityInfo(String methodName) {
|
|
|
|
logger.info("Security info for method "+ methodName );
|
|
|
|
String identity = SecurityManager.getManager().getCaller();
|
|
|
|
logger.info("The caller is: " + identity);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2008-04-23 17:25:01 +02:00
|
|
|
* Checks if the Resource has been created
|
2008-04-15 19:28:28 +02:00
|
|
|
*
|
|
|
|
* @param id the Resource ID
|
|
|
|
* @return the resource ( null if the resource has not been created yet
|
|
|
|
*/
|
2008-04-23 17:25:01 +02:00
|
|
|
protected synchronized ProfileResource getProfileResource(String id ){
|
2008-04-15 19:28:28 +02:00
|
|
|
try {
|
2008-04-23 17:25:01 +02:00
|
|
|
return (ProfileResource) ProfileContext.getContext().getWSHome().find(ProfileContext.getContext().makeKey(id));
|
2008-04-15 19:28:28 +02:00
|
|
|
}
|
|
|
|
catch (Exception e ){
|
2008-08-22 21:21:47 +02:00
|
|
|
logger.debug("A profile with the given id "+ id+" has not been created yet");
|
2008-04-15 19:28:28 +02:00
|
|
|
}
|
2008-04-23 17:25:01 +02:00
|
|
|
return null;
|
2008-04-15 19:28:28 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param id
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
protected synchronized boolean isResourceCreated(String id) {
|
|
|
|
if (getProfileResource(id) != null) return true; else return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2008-05-06 18:25:31 +02:00
|
|
|
* Updates the RegistryFactoryResource RPs for notification
|
2008-04-15 19:28:28 +02:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param ID resource ID
|
|
|
|
* @param type the resource type
|
|
|
|
* @param operationType the type of Operation performed on the Profile
|
|
|
|
* @param updateTime The last operation Time
|
|
|
|
* @throws Exception Exception
|
|
|
|
*/
|
|
|
|
|
2008-04-17 15:50:17 +02:00
|
|
|
@SuppressWarnings("unchecked")
|
2008-05-06 18:25:31 +02:00
|
|
|
private synchronized void updateCounterInfo(String ID, ResourceType resType, OperationType opType, Calendar updateTime) throws Exception{
|
2008-04-15 19:28:28 +02:00
|
|
|
|
|
|
|
RegistryProperty property = new RegistryProperty();
|
|
|
|
property.setUniqueID(ID);
|
2008-05-06 18:25:31 +02:00
|
|
|
property.setOperationType(opType.name());
|
2008-04-15 19:28:28 +02:00
|
|
|
property.setChangeTime(updateTime);
|
|
|
|
//select the type of the resource to update
|
|
|
|
for (Method method :this.getResource().getClass().getDeclaredMethods()) {
|
2008-05-06 18:25:31 +02:00
|
|
|
if (method.getName().contains(resType.name()) && method.getName().contains("set")) {
|
2008-04-15 19:28:28 +02:00
|
|
|
method.invoke(this.getResource(),property);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
this.getResource().getPersistenceDelegate().store(this.getResource());
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* return the resource
|
|
|
|
*
|
|
|
|
* @return NotifierResource
|
|
|
|
* @throws RemoteException Exception
|
|
|
|
*/
|
|
|
|
private RegistryFactoryResource getResource() throws RemoteException {
|
|
|
|
Object resource = null;
|
|
|
|
try {
|
2008-05-06 18:25:31 +02:00
|
|
|
resource = FactoryContext.getContext().getWSHome().find(FactoryContext.getContext().makeKey(NOTIFICATOR_RESOURCE_KEY));
|
2008-04-15 19:28:28 +02:00
|
|
|
} catch (Exception e) {
|
|
|
|
logger.error(" Unable to access resource", e);
|
|
|
|
}
|
|
|
|
|
|
|
|
RegistryFactoryResource factoryResource = (RegistryFactoryResource) resource;
|
|
|
|
return factoryResource;
|
2008-05-06 18:25:31 +02:00
|
|
|
}
|
2008-04-15 19:28:28 +02:00
|
|
|
|
|
|
|
public String updateScopeInProfile(UpdateScopeInProfileMessage message)throws GCUBEFault{return null;}
|
|
|
|
|
|
|
|
public String removeScopeInProfile(RemoveScopeInProfileMessage message)throws GCUBEFault{return null;}
|
|
|
|
|
|
|
|
public String updateState(UpdateStateMessage message)throws GCUBEFault{return null;}
|
|
|
|
|
|
|
|
}
|