XQuery locking issue fixed

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/information-system/gCubeIS/Collector@15579 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Manuele Simi 2009-09-27 20:08:18 +00:00
parent 2f81819f91
commit aca4200071
3 changed files with 50 additions and 41 deletions

View File

@ -93,7 +93,7 @@
<Shareable level="VO"/>
<Type>application</Type>
<Files>
<File>org.gcube.informationsystem.collector.testsuite.jar</File>
<File>lib/org.gcube.informationsystem.collector.testsuite.jar</File>
</Files>
</Software>
</Packages>

View File

@ -35,8 +35,10 @@ public class QueryManager extends XMLStorageManager {
int attempts = 0;
ResourceSet result = null;
Collection currentCollection = null;
State.getDataManager().lock();
try {
currentCollection = this.loadAllCollections();
this.lock();
while ((retry) && (attempts < MAXQUERYATTEMPTS)) {
try {
// execute query and get results in ResourceSet
@ -70,9 +72,11 @@ public class QueryManager extends XMLStorageManager {
}
}
//operationsCounter++;
this.resetCollection(currentCollection);
this.unlock();
} catch (Exception e) {
logger.error("Failed to execute the XQuery", e);
} finally {State.getDataManager().unlock(); }
//operationsCounter++;
//this.checkConnection();
return result;
}

View File

@ -314,8 +314,12 @@ public class XMLStorageManager {
*/
public void storeResource(PersistentResource resource) throws XMLStorageNotAvailableException, MalformedResourceException {
if (status != STATUS.INITIALISED)
this.lock();
if (status != STATUS.INITIALISED) {
this.unlock();
throw new XMLStorageNotAvailableException("XMLStorage not initialized");
}
Collection currentCollection = null;
if (resource.getType() == RESOURCETYPE.Profile) {
// the entry contains a gCube resource profile
@ -327,9 +331,10 @@ public class XMLStorageManager {
if (currentCollection == null) {
logger.error("Unable to open the Collection");
this.unlock();
throw new XMLStorageNotAvailableException("Unable to open the Collection");
}
this.lock();
try {
XMLResource document = (XMLResource) currentCollection.createResource(resource.getID(), "XMLResource");
document.setContent(resource.toString());