removing query for retreiving VRE root Folder

This commit is contained in:
Lucio Lelii 2021-10-04 17:11:43 +02:00
parent 24576cd30f
commit 68eb65e168
2 changed files with 18 additions and 7 deletions

View File

@ -12,7 +12,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.gcube.data.access</groupId>
<artifactId>storagehub</artifactId>
<version>1.3.1</version>
<version>1.3.2-SNAPSHOT</version>
<name>storagehub</name>
<scm>

View File

@ -8,6 +8,7 @@ import java.util.concurrent.Executors;
import javax.inject.Inject;
import javax.inject.Singleton;
import javax.jcr.ItemNotFoundException;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.RepositoryException;
@ -101,14 +102,24 @@ public class VREManager {
VRE vre = this.getVRE(groupName);
if (vre!=null) return vre;
else {
String query = String.format("SELECT * FROM [nthl:workspaceItem] As node WHERE node.[jcr:title] like '%s' AND ISDESCENDANTNODE('%s')",groupName, vrePath.toPath());
Query jcrQuery = ses.getWorkspace().getQueryManager().createQuery(query, Constants.QUERY_LANGUAGE);
NodeIterator it = jcrQuery.execute().getNodes();
if (!it.hasNext()) throw new BackendGenericError("vre folder not found for context "+groupName);
Node shareNode = ses.getNode(Constants.SHARED_FOLDER_PATH);
Node folder = it.nextNode();
Item vreFolder = node2Item.getItem(folder, excludes);
NodeIterator it = shareNode.getNodes();
Node vreFolderNode = null;
while (it.hasNext()) {
Node nextNode = it.nextNode();
if (nextNode.hasProperty("jcr:title") && nextNode.getProperty("jcr:title").getString().equals(groupName)) {
vreFolderNode = nextNode;
break;
}
}
if (vreFolderNode==null) throw new ItemNotFoundException("vre folder not found for context "+groupName);
Item vreFolder = node2Item.getItem(vreFolderNode, excludes);
return this.putVRE(vreFolder);
}
}