summaryrefslogtreecommitdiffstats
path: root/idrop-web/grails-app/controllers/org/irods/mydrop/controller/FileController.groovy
diff options
context:
space:
mode:
Diffstat (limited to 'idrop-web/grails-app/controllers/org/irods/mydrop/controller/FileController.groovy')
-rwxr-xr-xidrop-web/grails-app/controllers/org/irods/mydrop/controller/FileController.groovy76
1 files changed, 16 insertions, 60 deletions
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
index 971b89e..137b225 100755
--- a/idrop-web/grails-app/controllers/org/irods/mydrop/controller/FileController.groovy
+++ b/idrop-web/grails-app/controllers/org/irods/mydrop/controller/FileController.groovy
@@ -71,6 +71,7 @@ class FileController {
fullPath = fullPath.substring(idx + parseStringLength)
log.info("iRODS path for file is: ${fullPath}")
+
try {
IRODSFileFactory irodsFileFactory = irodsAccessObjectFactory.getIRODSFileFactory(irodsAccount)
IRODSFileInputStream irodsFileInputStream = irodsFileFactory.instanceIRODSFileInputStream(fullPath)
@@ -78,18 +79,12 @@ class FileController {
def length = irodsFile.length()
log.info("file length = ${length}")
log.info("opened input stream")
-
+
response.setContentType("application/octet-stream")
response.setContentLength((int) length)
response.setHeader("Content-disposition", "attachment;filename=\"${irodsFile.name}\"")
-
- //response.outputStream << irodsFileInputStream // Performing a binary stream copy
-
- Stream2StreamAO stream2Stream = irodsAccessObjectFactory.getStream2StreamAO(irodsAccount)
- def stats = stream2Stream
- .streamToStreamCopyUsingStandardIO(irodsFileInputStream, response.outputStream)
- log.info("transferStats:${stats}")
-
+
+ response.outputStream << irodsFileInputStream // Performing a binary stream copy
} catch (CatNoAccessException e) {
log.error("no access error", e)
response.sendError(500, message(code:"message.no.access"))
@@ -132,14 +127,14 @@ class FileController {
render(view:"uploadDialog", model:[irodsTargetCollection:irodsTargetCollection])
}
-
+
/**
* Prepare a quick upload dialog to upload a file to the default location using the quick upload service
*
*/
def prepareQuickUploadDialog = {
log.info("prepareQuickUploadDialog")
-
+
log.info("checking if uploads default directory needs to be created")
/* here we could do any processing on irods, such as provisioning of metadata fields based on target
@@ -199,8 +194,7 @@ class FileController {
IRODSFile targetFile = irodsFileFactory.instanceIRODSFile(irodsCollectionPath, name)
targetFile.setResource(irodsAccount.defaultStorageResource)
Stream2StreamAO stream2Stream = irodsAccessObjectFactory.getStream2StreamAO(irodsAccount)
- def transferStats = stream2Stream.transferStreamToFileUsingIOStreams(fis, targetFile, f.size, 0)
- log.info("transferStats:${transferStats}")
+ stream2Stream.transferStreamToFileUsingIOStreams(fis, targetFile, f.size, 0)
} catch (NoResourceDefinedException nrd) {
log.error("no resource defined exception", nrd)
response.sendError(500, message(code:"message.no.resource"))
@@ -319,20 +313,20 @@ class FileController {
log.info("name for create folder:${newFolderName}")
IRODSFileFactory irodsFileFactory = irodsAccessObjectFactory.getIRODSFileFactory(irodsAccount)
IRODSFile targetFile = irodsFileFactory.instanceIRODSFile(parent + "/" + newFolderName)
-
+
if (targetFile.exists()) {
log.error "no name in request"
def message = message(code:"error.duplicate.file")
response.sendError(500,message)
}
-
+
targetFile.mkdirs()
log.info("file created:${targetFile.absolutePath}")
render targetFile.getAbsolutePath()
} catch (CatNoAccessException e) {
- log.error("no access error", e)
- response.sendError(500, message(code:"message.no.access"))
- }
+ log.error("no access error", e)
+ response.sendError(500, message(code:"message.no.access"))
+ }
}
@@ -374,12 +368,12 @@ class FileController {
}
try {
prevFile.renameTo(newFile)
-
+
// return the parent, which will be reloaded
render newFile.parent
} catch (CatNoAccessException e) {
- log.error("no access error", e)
- response.sendError(500, message(code:"message.no.access"))
+ log.error("no access error", e)
+ response.sendError(500, message(code:"message.no.access"))
}
}
@@ -420,44 +414,6 @@ class FileController {
render targetAbsPath
}
- /**
- * Do a check for access rights to a file at a given path, if it exists, is a data object, and the user has read access, return "OK", otherwise
- * throw an appropriate exception
- */
- def screenForDownloadRights = {
- log.info("screenForDownloadRights")
-
- String sourceAbsPath = params['absPath']
- if (!sourceAbsPath) {
- log.error "no source path in request"
- def message = message(code:"error.no.path.provided")
- response.sendError(500,message)
- }
-
- log.info("getting file for path:${sourceAbsPath}")
- IRODSFile irodsFile = irodsAccessObjectFactory.getIRODSFileFactory(irodsAccount).instanceIRODSFile(sourceAbsPath)
- if (!irodsFile.exists()) {
- log.error "file does not exist"
- def message = message(code:"error.file.not.found")
- response.sendError(500,message)
- }
-
- if (!irodsFile.isFile()) {
- log.error "not a file"
- def message = message(code:"error.file.not.found")
- response.sendError(500,message)
- }
-
- if (!irodsFile.canRead()) {
- log.error "no access to file"
- def message = message(code:"error.no.access.permission")
- response.sendError(500,message)
- }
-
- render "OK"
-
- }
-
/**
* Copy a file in iRODS
*/
@@ -477,7 +433,7 @@ class FileController {
def message = message(code:"error.no.path.provided")
response.sendError(500,message)
}
-
+
String defaultResource = irodsAccount.defaultStorageResource
log.info("defaultResource:${defaultResource}")