summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormconway <michael.c.conway@gmail.com>2013-02-04 20:08:50 (GMT)
committer mconway <michael.c.conway@gmail.com>2013-02-04 20:08:50 (GMT)
commit03185adbd834e572ac631f761980b89dfa4bf1fe (patch)
treefbf352f3901c5668712fde46c80bec65477a16cc
parent598f05b8c42301a40beea7d9def478c691698ceb (diff)
downloadQCG-Data-03185adbd834e572ac631f761980b89dfa4bf1fe.zip
QCG-Data-03185adbd834e572ac631f761980b89dfa4bf1fe.tar.gz
QCG-Data-03185adbd834e572ac631f761980b89dfa4bf1fe.tar.bz2
[#511] share crud done
-rwxr-xr-xidrop-web/grails-app/controllers/org/irods/mydrop/controller/SharingController.groovy51
-rwxr-xr-xidrop-web/grails-app/i18n/messages.properties3
-rw-r--r--idrop-web/grails-app/services/org/irods/mydrop/service/SharingService.groovy27
-rwxr-xr-xidrop-web/grails-app/views/sharing/addShareDialog.gsp2
-rwxr-xr-xidrop-web/web-app/js/bundles/messages.properties1
-rwxr-xr-xidrop-web/web-app/js/mydrop/home.js52
6 files changed, 119 insertions, 17 deletions
diff --git a/idrop-web/grails-app/controllers/org/irods/mydrop/controller/SharingController.groovy b/idrop-web/grails-app/controllers/org/irods/mydrop/controller/SharingController.groovy
index b8773ed..f03e988 100755
--- a/idrop-web/grails-app/controllers/org/irods/mydrop/controller/SharingController.groovy
+++ b/idrop-web/grails-app/controllers/org/irods/mydrop/controller/SharingController.groovy
@@ -4,6 +4,7 @@ package org.irods.mydrop.controller
import grails.converters.JSON
import org.irods.jargon.core.connection.IRODSAccount
+import org.irods.jargon.core.exception.DataNotFoundException
import org.irods.jargon.core.exception.JargonException
import org.irods.jargon.core.protovalues.FilePermissionEnum
import org.irods.jargon.core.pub.CollectionAO
@@ -189,7 +190,7 @@ class SharingController {
log.info("prepareAddShareDialog")
log.info(params)
def absPath = params['absPath']
- def action = "add"
+ def formAction = "add"
if (!absPath) {
log.error "no absPath in request for prepareAclDialog()"
@@ -201,7 +202,7 @@ class SharingController {
log.info("absPath:${absPath}")
def shareName = ""
- render(view:"addShareDialog", model:[absPath:absPath, shareName:shareName, action:action])
+ render(view:"addShareDialog", model:[absPath:absPath, shareName:shareName, formAction:formAction])
}
@@ -212,7 +213,7 @@ class SharingController {
log.info("prepareExistingShareDialog")
log.info(params)
def absPath = params['absPath']
- def action = "update"
+ def formAction = "update"
if (!absPath) {
log.error "no absPath in request for prepareExistingShareDialog()"
@@ -235,7 +236,7 @@ class SharingController {
}
}
- render(view:"addShareDialog", model:[absPath:absPath, shareName:irodsSharedFileOrCollection.shareName, action:action])
+ render(view:"addShareDialog", model:[absPath:absPath, shareName:irodsSharedFileOrCollection.shareName, formAction:formAction])
}
def processUpdateShareDialog = {
@@ -244,7 +245,7 @@ class SharingController {
log.info(params)
def absPath = params['absPath']
def shareName = params['shareName']
- def action = params['action']
+ String formAction = params['formAction']
if (!absPath) {
log.error "no absPath in request for prepareAclDialog()"
@@ -253,7 +254,7 @@ class SharingController {
return
}
- if (!action) {
+ if (!formAction) {
log.error "no action in request for prepareAclDialog()"
def message = message(code:"error.no.action")
response.sendError(500,message)
@@ -262,15 +263,22 @@ class SharingController {
if (!shareName) {
flash.message = message(code:"error.no.share.name")
- render(view:"addShareDialog", model:[absPath:absPath, action:action, shareName:shareName])
+ render(view:"addShareDialog", model:[absPath:absPath, formAction:formAction, shareName:shareName])
return
}
+ log.info("checking action to see if add or update, current action is ${formAction}")
IRODSSharedFileOrCollection irodsSharedFileOrCollection
- if (action == "add") {
+ if (formAction == "add") {
log.info("adding share:${shareName}")
- irodsSharedFileOrCollection = sharingService.createShare(absPath, shareName, irodsAccount)
- log.info("rendering new share:${irodsSharedFileOrCollection}")
+ try {
+ irodsSharedFileOrCollection = sharingService.createShare(absPath, shareName, irodsAccount)
+ log.info("rendering new share:${irodsSharedFileOrCollection}")
+ } catch(DataNotFoundException e) {
+ def message = message(code:"error.duplicate.share")
+ response.sendError(500,message)
+ return
+ }
} else {
irodsSharedFileOrCollection = sharingService.updateShare(absPath, shareName, irodsAccount)
@@ -278,10 +286,31 @@ class SharingController {
}
flash.message = message(code:"message.share.update.successful")
- render(view:"sharingPanelWrapper", model:[absPath:absPath, irodsSharedFileOrCollection:irodsSharedFileOrCollection, action:action])
+ render(view:"sharingPanelWrapper", model:[absPath:absPath, irodsSharedFileOrCollection:irodsSharedFileOrCollection, formAction:formAction])
}
+ /**
+ * Remove a share at a given absolute path
+ */
+ def removeShare = {
+
+ log.info("removeShare")
+ log.info(params)
+ def absPath = params['absPath']
+
+ if (!absPath) {
+ log.error "no absPath in request for removeShare()"
+ def message = message(code:"error.no.path.provided")
+ response.sendError(500,message)
+ return
+ }
+
+ flash.message = message(code:"message.share.delete.successful")
+ sharingService.deleteShare(absPath, irodsAccount)
+ redirect(action: "getSharingDialogInfo", params: [absPath: absPath])
+ }
+
def processAddAclDialog = {
log.info("processAddAclDialog")
diff --git a/idrop-web/grails-app/i18n/messages.properties b/idrop-web/grails-app/i18n/messages.properties
index 5a62f81..c3ccc1e 100755
--- a/idrop-web/grails-app/i18n/messages.properties
+++ b/idrop-web/grails-app/i18n/messages.properties
@@ -195,6 +195,7 @@ error.no.uri.provided=No iRODS URI provided in request
error.duplicate.acl=User already has an ACL
error.duplicate.file=File already exists
error.duplicate.metadata=Metadata entry already exists
+error.dupicate.share=Duplicate share data, reload and try again
error.file.not.found=The file was not found, please reload
error.no.resource=No resource name provided
error.passwords.dont.match=Confirm password not equal to password
@@ -219,6 +220,8 @@ message.update.successful=Update successful
message.no.starred=No starred files or folders to display
message.cannot.create.profile=A profile cannot be created for this user, this may be a mis-configuration
message.no.files.to.display=No files to display
+message.share.delete.successful=Delete of share successful, note that permissions still remain as defined before
+message.update.share.successful=Update of share successful
# validation errors
org.irods.mydrop.controller.AddMetadataCommand.attribute.blank.error.attribute=Attribute must be entered
org.irods.mydrop.controller.AddMetadataCommand.value.blank.error.value=Value must be entered
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 b964ab3..ab13cd6 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
@@ -149,5 +149,32 @@ class SharingService {
irodsSharingService.updateShareName(irodsAbsolutePath, newShareName)
return irodsSharingService.findShareByAbsolutePath(irodsAbsolutePath)
}
+
+ /**
+ * Delete the share at the given path
+ * @param irodsAbsolutePath
+ * @param irodsAccount
+ * @return
+ * @throws JargonException
+ */
+ void deleteShare(String irodsAbsolutePath, IRODSAccount irodsAccount) throws JargonException {
+
+ log.info("deleteShare()")
+ if (irodsAbsolutePath == null || irodsAbsolutePath.isEmpty()) {
+ throw new IllegalArgumentException("null or empty irodsAbsolutePath")
+ }
+
+
+ if (irodsAccount == null) {
+ throw new IllegalArgumentException("null irodsAccount");
+ }
+
+
+ log.info("share to delete:${irodsAbsolutePath}")
+ IRODSSharingService irodsSharingService = new IRODSSharingServiceImpl(irodsAccessObjectFactory, irodsAccount)
+ irodsSharingService.removeShare(irodsAbsolutePath)
+ log.info("share removed")
+ }
+
}
diff --git a/idrop-web/grails-app/views/sharing/addShareDialog.gsp b/idrop-web/grails-app/views/sharing/addShareDialog.gsp
index 5527afc..91f5396 100755
--- a/idrop-web/grails-app/views/sharing/addShareDialog.gsp
+++ b/idrop-web/grails-app/views/sharing/addShareDialog.gsp
@@ -5,7 +5,7 @@
<form class="form-horizontal" id="addShareForm" name="addShareForm"
action="">
- <g:hiddenField name="action" id="action" value="${action }"/>
+ <g:hiddenField name="formAction" id="formAction" value="${formAction}"/>
<g:if test="${flash.error}">
<script type="text/javascript">
$(function() { setErrorMessage("${flash.error}"); });
diff --git a/idrop-web/web-app/js/bundles/messages.properties b/idrop-web/web-app/js/bundles/messages.properties
index 0dec68b..b47b976 100755
--- a/idrop-web/web-app/js/bundles/messages.properties
+++ b/idrop-web/web-app/js/bundles/messages.properties
@@ -3,6 +3,7 @@ msg_hello = Hello
msg_world = World
msg_complex = Good morning {0}!
msg_delete_selected_file=Delete selected file?
+msg_delete_share=Delete the share? Note that permissions will remain, but the share will not appear in the user's home page
msg_file_deleted=File deleted
msg_file_starred=File starred
msg_file_unstarred=File unstarred
diff --git a/idrop-web/web-app/js/mydrop/home.js b/idrop-web/web-app/js/mydrop/home.js
index 00e222c..7999f71 100755
--- a/idrop-web/web-app/js/mydrop/home.js
+++ b/idrop-web/web-app/js/mydrop/home.js
@@ -2631,6 +2631,48 @@ function editShareAtPath() {
});
}
+/**
+ * remove a named share
+ */
+function removeShareAtPath() {
+ var path = $("#aclDetailsAbsPath").val();
+
+ if (path == null) {
+ setMessage(jQuery.i18n.prop('msg_path_missing'));
+ unblockPanel();
+ return false;
+ }
+
+ var params = {
+ absPath : path
+ }
+
+ var answer = confirm(jQuery.i18n.prop('msg_delete_share'));
+
+ if (!answer) {
+ return false;
+ }
+
+ showBlockingPanel();
+
+ var jqxhr = $.post(context + "/sharing/removeShare", params,
+ function(data, status, xhr) {
+
+ var continueReq = checkForSessionTimeout(data, xhr);
+ if (!continueReq) {
+ return false;
+ }
+
+ $("#sharingPanelContainingDiv").empty().append( data );
+ unblockPanel();
+
+ }).fail(function(xhr, status, error) {
+ setErrorMessage(xhr.responseText);
+ unblockPanel();
+ });
+
+}
+
/*
* put content into the share dialog
*/
@@ -2646,17 +2688,17 @@ function fillInShareDialog(data) {
function updateNamedShare() {
var path = $("#aclDetailsAbsPath").val();
var shareName = $("#shareName").val();
- var action = $("#action").val();
+ var formAction = $("#formAction").val();
showBlockingPanel();
if (path == null) {
- setMessage(jQuery.i18n.prop('msg.path.missing'));
+ setMessage(jQuery.i18n.prop('msg_path_missing'));
unblockPanel();
return false;
}
- if (action == null) {
- setErrorMessage(jQuery.i18n.prop('msg.action.missing'));
+ if (formAction == null) {
+ setErrorMessage(jQuery.i18n.prop('msg_action_missing'));
unblockPanel();
return false;
}
@@ -2665,7 +2707,7 @@ function updateNamedShare() {
var params = {
absPath : path,
shareName: shareName,
- action : action
+ formAction : formAction
}
var jqxhr = $.post(context + "/sharing/processUpdateShareDialog", params,