diff --git a/pom.xml b/pom.xml
index 1e4e13a..288fa07 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,7 +12,7 @@
4.0.0
org.gcube.data.access
storagehub
- 1.0.9
+ 1.1.0
storagehub
diff --git a/src/main/java/org/gcube/data/access/storagehub/services/ItemsManager.java b/src/main/java/org/gcube/data/access/storagehub/services/ItemsManager.java
index 2122c80..d5e9e5e 100644
--- a/src/main/java/org/gcube/data/access/storagehub/services/ItemsManager.java
+++ b/src/main/java/org/gcube/data/access/storagehub/services/ItemsManager.java
@@ -148,7 +148,65 @@ public class ItemsManager {
return new ItemWrapper- (toReturn);
}
+
+ @GET
+ @Path("{id}/path")
+ @Produces(MediaType.APPLICATION_JSON)
+ public ItemWrapper
- getByRelativePath(@QueryParam("path") String path, @QueryParam("exclude") List excludes){
+ InnerMethodName.instance.set("getByPath");
+ Session ses = null;
+ Item toReturn = null;
+ try{
+ ses = repository.getRepository().login(CredentialHandler.getAdminCredentials(context));
+ authChecker.checkReadAuthorizationControl(ses, id);
+
+ String relativePath = path.startsWith("/")? path.substring(1) : path;
+ if (path.endsWith("/"))
+ relativePath.substring(0,relativePath.lastIndexOf("/"));
+
+ if (relativePath.isEmpty()) throw new InvalidCallParameters("empty path");
+
+ Item item =null;
+ String nextId = id;
+ String[] paths = relativePath.split("/");
+ for (String actualPath: paths) {
+ item = getChildrenMatchingName(ses, nextId, actualPath, excludes);
+ if (item ==null) throw new InvalidCallParameters("relative path "+actualPath+" not found under item with id "+nextId);
+ authChecker.checkReadAuthorizationControl(ses, item.getId());
+ nextId = item.getId();
+ }
+
+ return new ItemWrapper
- (item);
+ }catch(RepositoryException re){
+ log.error("jcr error getting item", re);
+ GXOutboundErrorResponse.throwException(new BackendGenericError("jcr error searching item", re));
+ }catch(StorageHubException she ){
+ log.error(she.getErrorMessage(), she);
+ GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus()));
+ }finally{
+ if (ses!=null)
+ ses.logout();
+ }
+ return new ItemWrapper
- (toReturn);
+ }
+
+ private Item getChildrenMatchingName(Session ses, String id, String name, List excludes) throws ItemNotFoundException , RepositoryException, StorageHubException {
+
+ NodeIterator it = ses.getNodeByIdentifier(id).getNodes();
+ while (it.hasNext()) {
+ Node child= it.nextNode();
+ String nodeName = child.getName();
+ if (!child.hasProperty(NodeProperty.TITLE.toString())) continue;
+ String title = child.getProperty(NodeProperty.TITLE.toString()).getString();
+
+ if (nodeName.equals(name) || title.equals(name)){
+ return node2Item.getItem(child, excludes);
+ }
+ }
+ return null;
+ }
+
@GET
@Path("{id}/items/{name}")
@Produces(MediaType.APPLICATION_JSON)
diff --git a/src/main/webapp/WEB-INF/README b/src/main/webapp/WEB-INF/README
index 8b47ba8..4651c9b 100644
--- a/src/main/webapp/WEB-INF/README
+++ b/src/main/webapp/WEB-INF/README
@@ -25,7 +25,7 @@ The projects leading to this software have received funding from a series of
Version
--------------------------------------------------
-1.0.9 (2020-01-24)
+1.1.0 (2020-03-03)
Please see the file named "changelog.xml" in this directory for the release notes.
diff --git a/src/main/webapp/WEB-INF/gcube-app.xml b/src/main/webapp/WEB-INF/gcube-app.xml
index 19885b9..57df01d 100644
--- a/src/main/webapp/WEB-INF/gcube-app.xml
+++ b/src/main/webapp/WEB-INF/gcube-app.xml
@@ -1,7 +1,7 @@
StorageHub
DataAccess
- 1.0.9
+ 1.1.0
Storage Hub webapp
\ No newline at end of file