Francesco Mangiacrapa 2016-03-14 14:28:56 +00:00
parent 8c08f92afd
commit 89d265969e
6 changed files with 77 additions and 65 deletions

View File

View File

@ -1,4 +0,0 @@
Mantainers
-------
* Francesco Mangiacrapa (francesco.mangiacrapa@isti.cnr.it), CNR Pisa, Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo"

View File

@ -1,44 +1,60 @@
The gCube System - Workspace Uploader
------------------------------------------------------------
This work has been partially supported by the following European projects: DILIGENT (FP6-2003-IST-2),
D4Science (FP7-INFRA-2007-1.2.2), D4Science-II (FP7-INFRA-2008-1.2.2), iMarine (FP7-INFRASTRUCTURES-2011-2),
and EUBrazilOpenBio (FP7-ICT-2011-EU-Brazil), Parthenos (H2020-INFRADEV-1-2014-1), BlueBridge (H2020-EINFRA-2015-1)
Authors
-------
* Francesco Mangiacrapa (francesco.mangiacrapa@isti.cnr.it), CNR Pisa,
Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo".
Version and Release Date
------------------------
v. 1.1.0 January 2016
The gCube System - ${name}
--------------------------------------------------
Description
${description}
${gcube.description}
${gcube.funding}
Version
--------------------------------------------------
${version} (${buildDate})
Please see the file named "changelog.xml" in this directory for the release notes.
Authors
--------------------------------------------------
* Francesco Mangiacrapa (francesco.mangiacrapa-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy).
Maintainers
-----------
The Workspace Uploader
* Francesco Mangiacrapa (francesco.mangiacrapa-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy).
Download information
--------------------
Source code is available from SVN:
Binaries can be downloaded from:
n/a
--------------------------------------------------
Source code is available from SVN:
${scm.url}
Binaries can be downloaded from the gCube website:
${gcube.website}
Installation
--------------------------------------------------
Documentation
-------------
Documentation is available on-line from the Projects Documentation Wiki:
--------------------------------------------------
Documentation is available on-line in the gCube Wiki:
${gcube.wikiRoot}/gcube/GCube_Widgets_Store#Workspace_Uploader
Support
--------------------------------------------------
Bugs and support requests can be reported in the gCube issue tracking tool:
${gcube.issueTracking}
Licensing
---------
--------------------------------------------------
This software is licensed under the terms you may find in the file named "LICENSE" in this directory.

View File

@ -1 +0,0 @@
${scm.url}

View File

@ -14,6 +14,7 @@
<packaging>jar</packaging>
<version>1.1.1-SNAPSHOT</version>
<name>Workspace Uploader Widget</name>
<description>Workspace Uploader Widget allows your application to upload file/s in the gCube Workspace</description>
<scm>
<connection>scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/${project.artifactId}</connection>
<developerConnection>scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/${project.artifactId}</developerConnection>

View File

@ -1,5 +1,5 @@
/**
*
*
*/
package org.gcube.portlets.widgets.workspaceuploader.server.upload;
@ -35,17 +35,17 @@ import org.slf4j.LoggerFactory;
* Sep 2, 2015
*/
public class WorkspaceUploaderMng {
public static Logger logger = LoggerFactory.getLogger(WorkspaceUploaderMng.class);
/**
* Instantiates a new workspace uploader manager.
*/
public WorkspaceUploaderMng() {
}
/**
* Creates the workspace uploader file.
*
@ -64,11 +64,11 @@ public class WorkspaceUploaderMng {
*/
private static WorkspaceUploaderItem createWorkspaceUploaderFile(final WorkspaceUploaderItem workspaceUploader, final HttpSession httpSession, final boolean isOvewrite, final Workspace wa, final InputStream uploadFile, final String itemName, final WorkspaceFolder destinationFolder, final String contentType, final long totalBytes) throws InternalErrorException, IOException{
logger.debug("Creating WorkspaceUploaderFile...");
workspaceUploader.setUploadStatus(UPLOAD_STATUS.IN_PROGRESS);
workspaceUploader.setStatusDescription("Uploading "+itemName);
FolderItem createdItem = null;
try{
Long startTime = WorkspaceUploadServletStream.printStartTime();
if(!isOvewrite){
@ -78,7 +78,7 @@ public class WorkspaceUploaderMng {
else{
createdItem = overwriteItem(wa, itemName, uploadFile, destinationFolder); //CASE OVERWRITE
}
if(createdItem!=null){
WorkspaceUploadServletStream.printElapsedTime(startTime);
logger.debug("HL file: "+createdItem.getName() + " with id: "+createdItem.getId() + " uploaded correctly in "+destinationFolder.getPath());
@ -126,7 +126,7 @@ public class WorkspaceUploaderMng {
return workspaceUploader;
}
/**
* Creates the workspace uploader archive.
@ -142,16 +142,16 @@ public class WorkspaceUploaderMng {
* @throws IOException Signals that an I/O exception has occurred.
*/
private static WorkspaceUploaderItem createWorkspaceUploaderArchive(final WorkspaceUploaderItem workspaceUploader, final HttpSession httpSession, final InputStream uploadFile, final String itemName, final WorkspaceFolder destinationFolder, final long totalBytes) throws InternalErrorException, IOException{
logger.info("calling upload archive - [itemName: "+itemName+"]");
try {
workspaceUploader.setUploadStatus(UPLOAD_STATUS.IN_PROGRESS);
UnzipUtil.unzip(destinationFolder, uploadFile, itemName);
logger.info("Archive "+itemName+ " imported correctly in "+destinationFolder.getPath());
workspaceUploader.setStatusDescription("Archive "+itemName+ " imported correctly in "+destinationFolder.getPath());
workspaceUploader.setUploadStatus(UPLOAD_STATUS.COMPLETED);
try {
WsUtil.putWorkspaceUploaderInSession(httpSession, workspaceUploader);
} catch (Exception e1) {
@ -176,7 +176,7 @@ public class WorkspaceUploaderMng {
}
return workspaceUploader;
}
/**
@ -195,7 +195,7 @@ public class WorkspaceUploaderMng {
* @throws Exception the exception
*/
public static WorkspaceUploaderItem uploadFile(WorkspaceUploaderItem workspaceUploader, HttpSession httpSession, Workspace wa, String itemName, InputStream file, WorkspaceFolder destinationFolder, String contentType, boolean isOverwrite, long totolaBytes) throws Exception {
try {
return createWorkspaceUploaderFile(workspaceUploader, httpSession, isOverwrite, wa, file, itemName, destinationFolder, contentType, totolaBytes);
} catch (Exception e) {
@ -203,8 +203,8 @@ public class WorkspaceUploaderMng {
throw new Exception("An error occurred during upload: "+itemName+". Try again");
}
}
/**
* Upload archive.
*
@ -218,16 +218,16 @@ public class WorkspaceUploaderMng {
* @throws Exception the exception
*/
public static WorkspaceUploaderItem uploadArchive(WorkspaceUploaderItem workspaceUploader, HttpSession httpSession, String itemName, InputStream file, WorkspaceFolder destinationFolder, long totalBytes) throws Exception {
try {
return createWorkspaceUploaderArchive(workspaceUploader, httpSession, file, itemName, destinationFolder, totalBytes);
} catch (Exception e) {
logger.error("Error when uploading Archive to HL creation: ",e);
throw new Exception("An error occurred during upload:: "+itemName+". Try again");
}
}
/**
* Upload file status.
*
@ -239,7 +239,7 @@ public class WorkspaceUploaderMng {
public static WorkspaceUploaderItem uploadFileStatus(HttpSession httpSession, WorkspaceUploaderItem workspaceUploader) throws Exception {
return WsUtil.getWorkspaceUploaderInSession(httpSession, workspaceUploader.getIdentifier());
}
/**
* Overwrite item.
*
@ -257,7 +257,7 @@ public class WorkspaceUploaderMng {
* @throws WrongDestinationException the wrong destination exception
*/
private static FolderItem overwriteItem(Workspace wa, String itemName, InputStream fileData, WorkspaceFolder destinationFolder) throws ItemNotFoundException, WrongItemTypeException, InternalErrorException, InsufficientPrivilegesException, WorkspaceFolderNotFoundException, ItemAlreadyExistException, WrongDestinationException{
FolderItem overwriteItem = null;
logger.debug("case overwriting item.. "+itemName);
overwriteItem = (FolderItem) wa.find(itemName, destinationFolder.getId());
@ -265,6 +265,6 @@ public class WorkspaceUploaderMng {
wa.updateItem(overwriteItem.getId(), fileData);
logger.debug("updateItem with id: "+overwriteItem.getId()+ ", is completed");
return overwriteItem;
}
}