summaryrefslogtreecommitdiffstats
path: root/idrop-web/grails-app/services
diff options
context:
space:
mode:
authormconway <michael.c.conway@gmail.com>2013-01-30 23:33:51 (GMT)
committer mconway <michael.c.conway@gmail.com>2013-01-30 23:33:51 (GMT)
commit95bcee38a3b4e0e2683e708d344d1cf7317c0e98 (patch)
treec43778939f72cc8388553601709a2f6e0bd95fef /idrop-web/grails-app/services
parent75760d046520dc34698d354c238aca52edecc88a (diff)
downloadQCG-Data-95bcee38a3b4e0e2683e708d344d1cf7317c0e98.zip
QCG-Data-95bcee38a3b4e0e2683e708d344d1cf7317c0e98.tar.gz
QCG-Data-95bcee38a3b4e0e2683e708d344d1cf7317c0e98.tar.bz2
[#511] add share
Diffstat (limited to 'idrop-web/grails-app/services')
-rw-r--r--idrop-web/grails-app/services/org/irods/mydrop/service/SharingService.groovy77
1 files changed, 76 insertions, 1 deletions
diff --git a/idrop-web/grails-app/services/org/irods/mydrop/service/SharingService.groovy b/idrop-web/grails-app/services/org/irods/mydrop/service/SharingService.groovy
index 17e7177..b59ebb4 100644
--- a/idrop-web/grails-app/services/org/irods/mydrop/service/SharingService.groovy
+++ b/idrop-web/grails-app/services/org/irods/mydrop/service/SharingService.groovy
@@ -1,5 +1,6 @@
package org.irods.mydrop.service
+import org.codehaus.groovy.grails.commons.ApplicationHolder
import org.irods.jargon.core.connection.IRODSAccount
import org.irods.jargon.core.exception.JargonException
import org.irods.jargon.core.pub.IRODSAccessObjectFactory
@@ -14,11 +15,38 @@ import org.irods.jargon.usertagging.sharing.IRODSSharingServiceImpl
* @author Mike Conway - DICE (www.irods.org).
*
*/
+@SuppressWarnings("deprecation")
class SharingService {
static transactional = false
IRODSAccessObjectFactory irodsAccessObjectFactory
-
+
+ /**
+ * Check to see if sharing is enabled, either by the idrop config setting (idrop.config.use.sharing), or because
+ * a previous request indicated that sharing was not supported for this grid
+ *
+ * @param irodsAccount
+ * @return <code>boolean</code> that will be <code>false</code> if I should not bother with the sharing feature
+ * @throws JargonException
+ */
+ boolean isSharingSupported(IRODSAccount irodsAccount) throws JargonException {
+
+ boolean sharing = ApplicationHolder.application.config.idrop.config.use.sharing
+ log.info("sharing supported in config:${sharing}")
+
+ if (sharing) {
+ log.info("supported in config, see if specific query is set up for sharing...")
+ def prop = irodsAccessObjectFactory.discoveredServerPropertiesCache.retrieveValue(irodsAccount.getHost(), irodsAccount.getZone(), IRODSSharingService.SHARING_DISABLED_PROPERTY)
+ if (prop) {
+ log.info("sharing is disabled, no specific query support is enabled")
+ sharing = false;
+ }
+ }
+
+ return sharing
+
+ }
+
/**
* List all shares owned by the given user (Shared by me with others)
* @param irodsAccount
@@ -48,6 +76,53 @@ class SharingService {
IRODSSharingService irodsSharingService = new IRODSSharingServiceImpl(irodsAccessObjectFactory, irodsAccount)
return irodsSharingService.listSharedCollectionsSharedWithUser(irodsAccount.getUserName(), irodsAccount.getZone())
}
+
+ /**
+ * Find a share if it exists, otherwise null will be returned
+ * @param irodsAbsolutePath
+ * @return
+ * @throws JargonException
+ */
+ IRODSSharedFileOrCollection findShareForPath(String irodsAbsolutePath, IRODSAccount irodsAccount) throws JargonException {
+
+ if (irodsAbsolutePath == null || irodsAbsolutePath.isEmpty()) {
+ throw new IllegalArgumentException("null or empty irodsAbsolutePath")
+ }
+
+ if (irodsAccount == null) {
+ throw new IllegalArgumentException("null irodsAccount");
+ }
+
+ IRODSSharingService irodsSharingService = new IRODSSharingServiceImpl(irodsAccessObjectFactory, irodsAccount)
+ return irodsSharingService.findShareByAbsolutePath(irodsAbsolutePath)
+
+ }
+
+ /**
+ * Create a share with a short-hand method that does not list users, these can be set by setting ACLs as normal
+ * @param irodsAbsolutePath
+ * @param shareName
+ * @param irodsAccount
+ * @throws JargonException
+ */
+ IRODSSharedFileOrCollection createShare(String irodsAbsolutePath, String shareName, IRODSAccount irodsAccount) throws JargonException {
+
+ if (irodsAbsolutePath == null || irodsAbsolutePath.isEmpty()) {
+ throw new IllegalArgumentException("null or empty irodsAbsolutePath")
+ }
+
+ if (shareName == null || shareName.isEmpty()) {
+ throw new IllegalArgumentException("null or empty shareName")
+ }
+
+ if (irodsAccount == null) {
+ throw new IllegalArgumentException("null irodsAccount");
+ }
+
+ IRODSSharingService irodsSharingService = new IRODSSharingServiceImpl(irodsAccessObjectFactory, irodsAccount)
+ irodsSharingService.createShare(irodsAbsolutePath, shareName);
+ return irodsSharingService.findShareByAbsolutePath(irodsAbsolutePath)
+ }