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:
parent
aca4200071
commit
56f79282b6
|
@ -127,7 +127,7 @@ public class AggregatorPersistentResource extends PersistentResource {
|
||||||
}
|
}
|
||||||
} else { //it's a RP doc
|
} else { //it's a RP doc
|
||||||
//we need to replace the schema and colons in order to make it an ID accepted by eXist
|
//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
|
* @return the ID
|
||||||
*/
|
*/
|
||||||
public String getID() {
|
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();
|
|
||||||
return this.resourceID;
|
return this.resourceID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -445,7 +445,7 @@ public class XMLStorageManager {
|
||||||
logger.warn("Invalid resource ID");
|
logger.warn("Invalid resource ID");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.lock();
|
||||||
Collection propCollection = this.loadPropertiesCollection();
|
Collection propCollection = this.loadPropertiesCollection();
|
||||||
|
|
||||||
if (propCollection == null) {
|
if (propCollection == null) {
|
||||||
|
@ -454,13 +454,14 @@ public class XMLStorageManager {
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
logger.info("Trying to remove resource " + resourceID + " from collection " + propCollection.getName());
|
logger.info("Trying to remove resource " + resourceID + " from collection " + propCollection.getName());
|
||||||
deleteResource(resourceID, propCollection);
|
deleteResource(resourceID, propCollection, false);
|
||||||
} catch (XMLDBException edb) {
|
} catch (XMLDBException edb) {
|
||||||
logger.error("Failed to remove the resource from the storage! ");
|
logger.error("Failed to remove the resource from the storage! ");
|
||||||
logger.error("", edb);
|
logger.error("", edb);
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
} finally {
|
} finally {
|
||||||
this.resetCollection(propCollection);
|
this.resetCollection(propCollection);
|
||||||
|
this.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -474,21 +475,22 @@ public class XMLStorageManager {
|
||||||
logger.warn("Invalid profile ID");
|
logger.warn("Invalid profile ID");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.lock();
|
||||||
Collection profileCollection = this.loadProfileCollection(profileType);
|
Collection profileCollection = this.loadProfileCollection(profileType);
|
||||||
|
|
||||||
if (profileCollection == null) {
|
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");
|
throw new Exception("unable to load collection Profile");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
logger.info("Trying to remove profile '" + profileID + "' from collection " + profileCollection.getName());
|
logger.info("Trying to remove profile '" + profileID + "' from collection " + profileCollection.getName());
|
||||||
deleteResource(profileID, profileCollection);
|
deleteResource(profileID, profileCollection, false);
|
||||||
} catch (XMLDBException edb) {
|
} catch (Exception edb) {
|
||||||
logger.error("Failed to remove the profile from the storage! ");
|
logger.error("Failed to remove the profile from the storage! ");
|
||||||
logger.error("", edb);
|
throw new Exception(edb);
|
||||||
throw new Exception();
|
} finally {
|
||||||
} finally {
|
|
||||||
this.resetCollection(profileCollection);
|
this.resetCollection(profileCollection);
|
||||||
|
this.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -502,11 +504,12 @@ public class XMLStorageManager {
|
||||||
* - the collection from which the resource has to be removed
|
* - the collection from which the resource has to be removed
|
||||||
* @throws Exception
|
* @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;
|
XMLResource res = null;
|
||||||
// lock the instance
|
// lock the instance
|
||||||
this.lock();
|
if (lock != null && lock.length > 0 && lock[0])
|
||||||
|
this.lock();
|
||||||
try {
|
try {
|
||||||
res = (XMLResource) col.getResource(resourceID);
|
res = (XMLResource) col.getResource(resourceID);
|
||||||
if (res == null)
|
if (res == null)
|
||||||
|
@ -517,11 +520,11 @@ public class XMLStorageManager {
|
||||||
}
|
}
|
||||||
} catch (XMLDBException edb) {
|
} catch (XMLDBException edb) {
|
||||||
logger.error("Failed to retrieve resource " + resourceID);
|
logger.error("Failed to retrieve resource " + resourceID);
|
||||||
logger.error("", edb);
|
throw new Exception(edb);
|
||||||
throw new Exception();
|
|
||||||
} finally {
|
} finally {
|
||||||
this.resetCollection(col);
|
this.resetCollection(col);
|
||||||
this.unlock();
|
if (lock != null && lock.length > 0 && lock[0])
|
||||||
|
this.unlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue