diff --git a/src/main/java/org/gcube/data/access/storagehub/services/ACLManager.java b/src/main/java/org/gcube/data/access/storagehub/services/ACLManager.java index c3001d7..edff108 100644 --- a/src/main/java/org/gcube/data/access/storagehub/services/ACLManager.java +++ b/src/main/java/org/gcube/data/access/storagehub/services/ACLManager.java @@ -34,6 +34,7 @@ import org.gcube.common.storagehub.model.exceptions.BackendGenericError; import org.gcube.common.storagehub.model.exceptions.InvalidCallParameters; import org.gcube.common.storagehub.model.exceptions.InvalidItemException; import org.gcube.common.storagehub.model.exceptions.StorageHubException; +import org.gcube.common.storagehub.model.exceptions.UserNotAuthorizedException; import org.gcube.common.storagehub.model.items.Item; import org.gcube.common.storagehub.model.items.SharedFolder; import org.gcube.common.storagehub.model.types.ACLList; @@ -112,7 +113,8 @@ public class ACLManager { return new ACLList(acls); } - + + /** * Set a new AccessType for a user in a shared folder * @@ -192,5 +194,33 @@ public class ACLManager { } } + + + @GET + @Path("{id}/acls/user/{user}/canwrite") + public Boolean checkAccess(@PathParam("user") String user) { + InnerMethodName.instance.set("checkAccess"); + Session ses = null; + Boolean canWrite = false; + try{ + try { + authChecker.checkWriteAuthorizationControl(ses, id, true); + }catch (UserNotAuthorizedException e) { + return false; + } + return true; + }catch(RepositoryException re){ + log.error("jcr error getting acl", re); + GXOutboundErrorResponse.throwException(new BackendGenericError("jcr error getting acl", re)); + }catch(StorageHubException she ){ + log.error(she.getErrorMessage(), she); + GXOutboundErrorResponse.throwException(she, Response.Status.fromStatusCode(she.getStatus())); + }finally{ + if (ses!=null) + ses.logout(); + } + return canWrite; + + } } diff --git a/src/main/webapp/WEB-INF/README b/src/main/webapp/WEB-INF/README index e6765f0..ff52ab2 100644 --- a/src/main/webapp/WEB-INF/README +++ b/src/main/webapp/WEB-INF/README @@ -25,7 +25,7 @@ no. 654119), SoBigData (grant no. 654024), AGINFRA PLUS (grant no. 731001). Version -------------------------------------------------- -1.0.5-SNAPSHOT (2019-05-06) +1.0.5-SNAPSHOT (2019-05-29) Please see the file named "changelog.xml" in this directory for the release notes. diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index 30e611b..4dbf04d 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -10,7 +10,7 @@ resolver-basepath - https://data1-d.d4science.org/shub + https://data-pre.d4science.org/shub org.gcube.data.access.storagehub.StorageHub