fixing RPs deletion

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Collector@15599 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Manuele Simi 2009-09-28 22:29:06 +00:00
parent aca4200071
commit 56f79282b6
2 changed files with 19 additions and 19 deletions

View File

@ -127,7 +127,7 @@ public class AggregatorPersistentResource extends PersistentResource {
}
} else { //it's a RP doc
//we need to replace the schema and colons in order to make it an ID accepted by eXist
this.resourceID = this.source.replace("http://", "").replace(":", "") + "-" + this.sourceKey;//this.getGroupKey() + this.getEntryKey();
this.resourceID = this.source.replace("http://", "").replace(":", "").replace("/", "-") + "-" + this.sourceKey.replace("http://", "").replace(":", "").replace("/", "-");
}
}
/**
@ -180,10 +180,7 @@ public class AggregatorPersistentResource extends PersistentResource {
*
* @return the ID
*/
public String getID() {
// create a unique ID unless the resource contains a profile
//if (this.resourceID == null)
// this.resourceID = this.source + this.sourceKey;//this.getGroupKey() + this.getEntryKey();
public String getID() {
return this.resourceID;
}

View File

@ -445,7 +445,7 @@ public class XMLStorageManager {
logger.warn("Invalid resource ID");
return;
}
this.lock();
Collection propCollection = this.loadPropertiesCollection();
if (propCollection == null) {
@ -454,13 +454,14 @@ public class XMLStorageManager {
}
try {
logger.info("Trying to remove resource " + resourceID + " from collection " + propCollection.getName());
deleteResource(resourceID, propCollection);
deleteResource(resourceID, propCollection, false);
} catch (XMLDBException edb) {
logger.error("Failed to remove the resource from the storage! ");
logger.error("", edb);
throw new Exception();
} finally {
this.resetCollection(propCollection);
this.unlock();
}
}
@ -474,21 +475,22 @@ public class XMLStorageManager {
logger.warn("Invalid profile ID");
return;
}
this.lock();
Collection profileCollection = this.loadProfileCollection(profileType);
if (profileCollection == null) {
logger.error("Uunable to load collection Profile!");
logger.error("Unable to load collection Profile!");
this.unlock();
throw new Exception("unable to load collection Profile");
}
try {
logger.info("Trying to remove profile '" + profileID + "' from collection " + profileCollection.getName());
deleteResource(profileID, profileCollection);
} catch (XMLDBException edb) {
deleteResource(profileID, profileCollection, false);
} catch (Exception edb) {
logger.error("Failed to remove the profile from the storage! ");
logger.error("", edb);
throw new Exception();
} finally {
throw new Exception(edb);
} finally {
this.resetCollection(profileCollection);
this.unlock();
}
}
@ -502,11 +504,12 @@ public class XMLStorageManager {
* - the collection from which the resource has to be removed
* @throws Exception
*/
private void deleteResource(String resourceID, Collection col) throws Exception {
private void deleteResource(String resourceID, Collection col, boolean ... lock) throws Exception {
XMLResource res = null;
// lock the instance
this.lock();
if (lock != null && lock.length > 0 && lock[0])
this.lock();
try {
res = (XMLResource) col.getResource(resourceID);
if (res == null)
@ -517,11 +520,11 @@ public class XMLStorageManager {
}
} catch (XMLDBException edb) {
logger.error("Failed to retrieve resource " + resourceID);
logger.error("", edb);
throw new Exception();
throw new Exception(edb);
} finally {
this.resetCollection(col);
this.unlock();
if (lock != null && lock.length > 0 && lock[0])
this.unlock();
}
}