is-collector/src/org/gcube/informationsystem/collector/impl/state/ICAggregatorRemoveCallback....

63 lines
2.1 KiB
Java
Executable File

package org.gcube.informationsystem.collector.impl.state;
import org.gcube.common.core.utils.logging.GCUBELog;
import org.gcube.informationsystem.collector.impl.persistence.AggregatorPersistentResource;
import org.gcube.informationsystem.collector.impl.utils.EntryEPRParser;
import org.gcube.informationsystem.collector.impl.xmlstorage.exist.State;
import org.globus.mds.aggregator.impl.AggregatorServiceGroupEntryRemovedCallback;
import org.globus.mds.aggregator.impl.AggregatorServiceGroupEntryResource;
/**
* Whenever a AggregatorServiceGroupEntryResource is removed from an
* AggregatorServiceGroupEntryHome, the corresponding remove method of this class will be invoked
* passing as a parameter the instance of the resource that is about to be removed.
*
*
* @author Manuele Simi (ISTI-CNR)
*
*/
public class ICAggregatorRemoveCallback implements AggregatorServiceGroupEntryRemovedCallback {
private static GCUBELog logger = new GCUBELog(ICAggregatorRemoveCallback.class);
/**
* Creates a new Callback object
*
*/
public ICAggregatorRemoveCallback() {
super();
}
/**
* Removes from the storage the supplied resource
*
* @param entry the AggregatorServiceGroupEntryResource that is about to be removed
* @throws Exception
* if the delete operation fails
*/
public void remove(AggregatorServiceGroupEntryResource entry) throws Exception {
logger.debug("ICAggregatorRemoveCallback invoked " + entry.getEntryEPR().toString());
EntryEPRParser parser = new EntryEPRParser(entry.getEntryEPR());
AggregatorPersistentResource res = new AggregatorPersistentResource();
res.setEntryKey(parser.getEntryKey());
res.setGroupKey(parser.getGroupKey());
// mark the resource as no longer available
synchronized (State.deletedResources) {
State.deletedResources.add(res);
}
// delete the resource from the database
try {
State.storage_manager.retrieveAndDeleteResourceFromID(res.getID());
} catch (Exception e) {
logger.error(State.logPrefix + "unable to remove resource: " + res.getID(), e);
}
}
}