summaryrefslogtreecommitdiffstats
path: root/idrop-web
diff options
context:
space:
mode:
authorMike Conway <mikeconway@dhcp152-54-6-70.wireless.europa.renci.org>2011-04-04 12:26:19 (GMT)
committer Mike Conway <mikeconway@dhcp152-54-6-70.wireless.europa.renci.org>2011-04-04 12:26:19 (GMT)
commitce9c6b0440659ed35d3e95a0409a8978d2615586 (patch)
tree7d11d9bb54939289ac95bbeac2d1a50083efe8ca /idrop-web
parenta5f9a49bb67d83c604138e9c17f1205e93f97965 (diff)
downloadQCG-Data-ce9c6b0440659ed35d3e95a0409a8978d2615586.zip
QCG-Data-ce9c6b0440659ed35d3e95a0409a8978d2615586.tar.gz
QCG-Data-ce9c6b0440659ed35d3e95a0409a8978d2615586.tar.bz2
adding upload/download to web
Diffstat (limited to 'idrop-web')
-rw-r--r--idrop-web/grails-app/conf/Config.groovy8
-rw-r--r--idrop-web/grails-app/conf/UrlMappings.groovy6
-rw-r--r--idrop-web/grails-app/controllers/org/irods/mydrop/controller/FileController.groovy70
-rw-r--r--idrop-web/grails-app/views/browse/browseDetails.gsp6
-rw-r--r--idrop-web/grails-app/views/home/index.gsp48
-rw-r--r--idrop-web/grails-app/views/search/searchResult.gsp31
-rw-r--r--idrop-web/test/unit/org/irods/mydrop/controller/FileControllerTests.groovy41
-rw-r--r--idrop-web/web-app/js/mydrop/home.js34
8 files changed, 215 insertions, 29 deletions
diff --git a/idrop-web/grails-app/conf/Config.groovy b/idrop-web/grails-app/conf/Config.groovy
index 159f673..a6dd830 100644
--- a/idrop-web/grails-app/conf/Config.groovy
+++ b/idrop-web/grails-app/conf/Config.groovy
@@ -91,8 +91,8 @@ log4j = {
'net.sf.ehcache.hibernate'
warn 'org.mortbay.log'
-
- debug 'org.irods'
- debug 'grails.app.controller'
- debug 'org.springframework.security'
+ debug 'org.irods.idrop'
+ info 'org.irods.jargon'
+ info 'grails.app.controller'
+ warn 'org.springframework.security'
}
diff --git a/idrop-web/grails-app/conf/UrlMappings.groovy b/idrop-web/grails-app/conf/UrlMappings.groovy
index dc2aeef..20520eb 100644
--- a/idrop-web/grails-app/conf/UrlMappings.groovy
+++ b/idrop-web/grails-app/conf/UrlMappings.groovy
@@ -5,6 +5,12 @@ class UrlMappings {
constraints {
// apply constraints here
}
+
+ }
+
+ //"/file/**" (controller:"file", action:"index")
+ "/file/**" (controller:"file", action:"index"){
+ name = {request.requestURI}
}
"/"(controller:"home", action:"index")
diff --git a/idrop-web/grails-app/controllers/org/irods/mydrop/controller/FileController.groovy b/idrop-web/grails-app/controllers/org/irods/mydrop/controller/FileController.groovy
new file mode 100644
index 0000000..48747c5
--- /dev/null
+++ b/idrop-web/grails-app/controllers/org/irods/mydrop/controller/FileController.groovy
@@ -0,0 +1,70 @@
+package org.irods.mydrop.controller
+
+
+import org.irods.jargon.core.connection.IRODSAccount
+import org.irods.jargon.core.exception.JargonException
+import org.irods.jargon.core.exception.JargonRuntimeException
+import org.irods.jargon.core.pub.IRODSAccessObjectFactory
+import org.irods.jargon.core.pub.io.IRODSFileFactory
+import org.irods.jargon.core.pub.io.IRODSFileInputStream
+import org.springframework.security.core.context.SecurityContextHolder
+
+class FileController {
+
+ IRODSAccessObjectFactory irodsAccessObjectFactory
+ IRODSAccount irodsAccount
+
+ /**
+ * Interceptor grabs IRODSAccount from the SecurityContextHolder
+ */
+ def beforeInterceptor = {
+ def irodsAuthentication = SecurityContextHolder.getContext().authentication
+
+ if (irodsAuthentication == null) {
+ throw new JargonRuntimeException("no irodsAuthentication in security context!")
+ }
+
+ irodsAccount = irodsAuthentication.irodsAccount
+ log.debug("retrieved account for request: ${irodsAccount}")
+ }
+
+ def afterInterceptor = {
+ log.debug("closing the session")
+ irodsAccessObjectFactory.closeSession()
+ }
+
+
+ def index = {
+
+ // TODO: file not found?
+
+ String parseString = "/file/download"
+ def parseStringLength = parseString.length()
+ String fullPath = params.name
+ if (fullPath == null || fullPath.isEmpty()) {
+ log.error("null or missing path info")
+ throw new JargonException("null or missing path info")
+ }
+
+ log.info("add path info is ${params.name}")
+ def idx = fullPath.indexOf(parseString)
+ log.debug("parsing out additional path info")
+ if (idx == -1) {
+ log.error("unable to parse addl path info for irods absolute path, path info was ${fullPath}")
+ throw new JargonException("unable to parse addl path info for irods absolute path")
+ }
+
+ fullPath = fullPath.substring(idx + parseStringLength)
+ log.info("iRODS path for file is: ${fullPath}")
+
+ IRODSFileFactory irodsFileFactory = irodsAccessObjectFactory.getIRODSFileFactory(irodsAccount)
+ IRODSFileInputStream irodsFileInputStream = irodsFileFactory.instanceIRODSFileInputStream(fullPath)
+ log.info("opened input stream")
+
+ response.setContentType("application/octet-stream")
+ response.setHeader("Content-disposition", "attachment;filename=${fullPath}")
+
+ response.outputStream << irodsFileInputStream // Performing a binary stream copy
+
+ }
+}
diff --git a/idrop-web/grails-app/views/browse/browseDetails.gsp b/idrop-web/grails-app/views/browse/browseDetails.gsp
index 4959eeb..7cbabc4 100644
--- a/idrop-web/grails-app/views/browse/browseDetails.gsp
+++ b/idrop-web/grails-app/views/browse/browseDetails.gsp
@@ -16,7 +16,13 @@
<tr id="${entry.formattedAbsolutePath}">
<td><span class="ui-icon-circle-plus browse_detail_icon ui-icon"></span></td>
<td>
+ <g:if test="${entry.objectType.toString() == 'COLLECTION'}">
${entry.nodeLabelDisplayValue}
+ </g:if>
+ <g:else>
+
+ <g:link url="${'file/download' + entry.formattedAbsolutePath}">${entry.nodeLabelDisplayValue}</g:link>
+ </g:else>
</td>
<td>
diff --git a/idrop-web/grails-app/views/home/index.gsp b/idrop-web/grails-app/views/home/index.gsp
index 4c321f1..7cdf013 100644
--- a/idrop-web/grails-app/views/home/index.gsp
+++ b/idrop-web/grails-app/views/home/index.gsp
@@ -7,16 +7,13 @@
<div id="tabs">
<ul>
- <li><a href="#quickView">Quick View</a>
- </li>
- <li><a href="#search">Search</a>
- </li>
- <li><a href="#browse">Browse</a>
- </li>
+ <li><a href="#quickView">Quick View</a></li>
+ <li><a href="#search">Search</a></li>
+ <li><a href="#browse">Browse</a></li>
</ul>
<div id="quickView">
<div class="objectContainer">
-
+
<div class="objectContainerDetails">
<span class="objectHeader">A data object</span>
<div class="objectDescription">This is a really nice data
@@ -30,16 +27,15 @@
<span class="objectContainerActions"><a href="edit"
class="objectAction">EDIT</a> - <a href="viewInTree"
class="objectAction">VIEW</a> - <a href="share"
- class="objectAction">SHARE</a>
- </span> <span class="objectContainerTags">tag1 tag2:detail tag3
- hello</span>
+ class="objectAction">SHARE</a> </span> <span class="objectContainerTags">tag1
+ tag2:detail tag3 hello</span>
</div>
</div>
<div class="objectContainer">
-
+
<div class="objectContainerDetails">
<span class="objectHeader">A data object</span>
<div class="objectDescription">This is a really nice data
@@ -53,9 +49,8 @@
<span class="objectContainerActions"><a href="edit"
class="objectAction">EDIT</a> - <a href="viewInTree"
class="objectAction">VIEW</a> - <a href="share"
- class="objectAction">SHARE</a>
- </span> <span class="objectContainerTags">tag1 tag2:detail tag3
- hello</span>
+ class="objectAction">SHARE</a> </span> <span class="objectContainerTags">tag1
+ tag2:detail tag3 hello</span>
</div>
</div>
@@ -82,10 +77,29 @@
<!-- no empty divs -->
</div>
<div id="browseToolbar" class="ui-layout-north">
- Display Option:<g:select name="browseDisplayOption" id="browseDisplayOption" from="${['info', 'details', 'sharing', 'metadata']}" onChange="setBrowseMode()" /></div>
-
+ <div id="headerSearchBox" class="ui-widget-header fg-toolbar">
+
+ <div id="browseMenu" class="fg-buttonset fg-buttonset-multi"
+ style="float: left">
+
+ Display Option:
+ <g:select name="browseDisplayOption" id="browseDisplayOption"
+ from="${['info', 'sharing', 'metadata']}"
+ noSelection="${['details':'details']}"
+ onChange="setBrowseMode()" />
+ </div>
+
+ <button type="button" id="upload"
+ class="ui-state-default ui-corner-all" value="upload"
+ onclick="showUploadDialog()")>Upload</button>
+ </div>
+
+
+ </div>
+
<div id="infoDiv" class="ui-layout-center">
- <h2>Select a directory or file to see info and tags based on the view option</h2>
+ <h2>Select a directory or file to see info and tags based on
+ the view option</h2>
</div>
</div>
diff --git a/idrop-web/grails-app/views/search/searchResult.gsp b/idrop-web/grails-app/views/search/searchResult.gsp
index 20e9cf2..fa4a2c8 100644
--- a/idrop-web/grails-app/views/search/searchResult.gsp
+++ b/idrop-web/grails-app/views/search/searchResult.gsp
@@ -11,14 +11,31 @@
</tr>
</thead>
<tbody>
- <g:each in="${results}" var="entry">
+ <g:each in="${results}" var="entry">
<tr id="${entry.formattedAbsolutePath}">
- <td><div class="ui-icon-circle-plus user_detail_icon ui-icon "/></td>
- <td>${entry.nodeLabelDisplayValue}</td>
- <td>${entry.formattedAbsolutePath}</td>
- <td>${entry.objectType}</td>
- <td>${entry.modifiedAt}</td>
- <td>${entry.dataSize}</td>
+ <td><div class="ui-icon-circle-plus user_detail_icon ui-icon " />
+ </td>
+ <td><g:if test="${entry.objectType.toString() == 'COLLECTION'}">
+ ${entry.nodeLabelDisplayValue}
+ </g:if> <g:else>
+
+ <g:link url="${'file/download' + entry.formattedAbsolutePath}">
+ ${entry.nodeLabelDisplayValue}
+ </g:link>
+ </g:else></td>
+
+ <td>
+ ${entry.formattedAbsolutePath}
+ </td>
+ <td>
+ ${entry.objectType}
+ </td>
+ <td>
+ ${entry.modifiedAt}
+ </td>
+ <td>
+ ${entry.dataSize}
+ </td>
</tr>
</g:each>
diff --git a/idrop-web/test/unit/org/irods/mydrop/controller/FileControllerTests.groovy b/idrop-web/test/unit/org/irods/mydrop/controller/FileControllerTests.groovy
new file mode 100644
index 0000000..ba2d135
--- /dev/null
+++ b/idrop-web/test/unit/org/irods/mydrop/controller/FileControllerTests.groovy
@@ -0,0 +1,41 @@
+package org.irods.mydrop.controller
+
+import grails.test.ControllerUnitTestCase
+
+import java.util.Properties
+
+import org.irods.jargon.core.connection.IRODSAccount
+import org.irods.jargon.core.pub.IRODSAccessObjectFactory
+import org.irods.jargon.core.pub.IRODSFileSystem
+import org.irods.jargon.spring.security.IRODSAuthenticationToken
+import org.irods.jargon.testutils.TestingPropertiesHelper
+import org.springframework.security.core.context.SecurityContextHolder
+
+class FileControllerTests extends ControllerUnitTestCase {
+
+ IRODSAccessObjectFactory irodsAccessObjectFactory
+ IRODSAccount irodsAccount
+ Properties testingProperties
+ TestingPropertiesHelper testingPropertiesHelper
+ IRODSFileSystem irodsFileSystem
+
+
+ protected void setUp() {
+ super.setUp()
+ testingPropertiesHelper = new TestingPropertiesHelper()
+ testingProperties = testingPropertiesHelper.getTestProperties()
+ irodsAccount = testingPropertiesHelper.buildIRODSAccountFromTestProperties(testingProperties)
+ irodsFileSystem = IRODSFileSystem.instance()
+ irodsAccessObjectFactory = irodsFileSystem.getIRODSAccessObjectFactory()
+ def irodsAuthentication = new IRODSAuthenticationToken(irodsAccount)
+ SecurityContextHolder.getContext().authentication = irodsAuthentication
+ }
+
+ protected void tearDown() {
+ super.tearDown()
+ }
+
+ void testSomething() {
+
+ }
+}
diff --git a/idrop-web/web-app/js/mydrop/home.js b/idrop-web/web-app/js/mydrop/home.js
index fa6a706..33a8ce1 100644
--- a/idrop-web/web-app/js/mydrop/home.js
+++ b/idrop-web/web-app/js/mydrop/home.js
@@ -8,7 +8,7 @@
* Global var holds jquery ref to the dataTree
*/
var dataTree;
-var browseOptionVal = "info";
+var browseOptionVal = "details";
var selectedPath = null;
/**
@@ -156,4 +156,36 @@ function updateBrowseDetailsForPathBasedOnCurrentModel(absPath) {
}
}
+/**
+ * Show the dialog to allow upload of data
+ */
+function showUploadDialog() {
+
+ if (selectedPath == null) {
+ return;
+ }
+
+ var $dialog = $('<div id="uploadDialog"></div>')
+ .html('Upload to iRODS')
+ .dialog({
+ autoOpen: true,
+ modal: true,
+ title: 'Upload to iRODS'
+ });
+
+ fillInUploadDialog(selectedPath);
+
+
+}
+
+
+function fillInUploadDialog(absolutePath) {
+
+ if (absolutePath == null) {
+ return;
+ }
+
+
+}
+