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 The gCube System - ${name}
------------------------------------------------------------ --------------------------------------------------
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
${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 Download information
-------------------- --------------------------------------------------
Source code is available from SVN: Source code is available from SVN:
${scm.url}
Binaries can be downloaded from:
n/a Binaries can be downloaded from the gCube website:
${gcube.website}
Installation
--------------------------------------------------
Documentation 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 Licensing
--------- --------------------------------------------------
This software is licensed under the terms you may find in the file named "LICENSE" in this directory. 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> <packaging>jar</packaging>
<version>1.1.1-SNAPSHOT</version> <version>1.1.1-SNAPSHOT</version>
<name>Workspace Uploader Widget</name> <name>Workspace Uploader Widget</name>
<description>Workspace Uploader Widget allows your application to upload file/s in the gCube Workspace</description>
<scm> <scm>
<connection>scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/${project.artifactId}</connection> <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> <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; package org.gcube.portlets.widgets.workspaceuploader.server.upload;
@ -35,17 +35,17 @@ import org.slf4j.LoggerFactory;
* Sep 2, 2015 * Sep 2, 2015
*/ */
public class WorkspaceUploaderMng { public class WorkspaceUploaderMng {
public static Logger logger = LoggerFactory.getLogger(WorkspaceUploaderMng.class); public static Logger logger = LoggerFactory.getLogger(WorkspaceUploaderMng.class);
/** /**
* Instantiates a new workspace uploader manager. * Instantiates a new workspace uploader manager.
*/ */
public WorkspaceUploaderMng() { public WorkspaceUploaderMng() {
} }
/** /**
* Creates the workspace uploader file. * 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{ 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..."); logger.debug("Creating WorkspaceUploaderFile...");
workspaceUploader.setUploadStatus(UPLOAD_STATUS.IN_PROGRESS); workspaceUploader.setUploadStatus(UPLOAD_STATUS.IN_PROGRESS);
workspaceUploader.setStatusDescription("Uploading "+itemName); workspaceUploader.setStatusDescription("Uploading "+itemName);
FolderItem createdItem = null; FolderItem createdItem = null;
try{ try{
Long startTime = WorkspaceUploadServletStream.printStartTime(); Long startTime = WorkspaceUploadServletStream.printStartTime();
if(!isOvewrite){ if(!isOvewrite){
@ -78,7 +78,7 @@ public class WorkspaceUploaderMng {
else{ else{
createdItem = overwriteItem(wa, itemName, uploadFile, destinationFolder); //CASE OVERWRITE createdItem = overwriteItem(wa, itemName, uploadFile, destinationFolder); //CASE OVERWRITE
} }
if(createdItem!=null){ if(createdItem!=null){
WorkspaceUploadServletStream.printElapsedTime(startTime); WorkspaceUploadServletStream.printElapsedTime(startTime);
logger.debug("HL file: "+createdItem.getName() + " with id: "+createdItem.getId() + " uploaded correctly in "+destinationFolder.getPath()); logger.debug("HL file: "+createdItem.getName() + " with id: "+createdItem.getId() + " uploaded correctly in "+destinationFolder.getPath());
@ -126,7 +126,7 @@ public class WorkspaceUploaderMng {
return workspaceUploader; return workspaceUploader;
} }
/** /**
* Creates the workspace uploader archive. * Creates the workspace uploader archive.
@ -142,16 +142,16 @@ public class WorkspaceUploaderMng {
* @throws IOException Signals that an I/O exception has occurred. * @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{ 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+"]"); logger.info("calling upload archive - [itemName: "+itemName+"]");
try { try {
workspaceUploader.setUploadStatus(UPLOAD_STATUS.IN_PROGRESS); workspaceUploader.setUploadStatus(UPLOAD_STATUS.IN_PROGRESS);
UnzipUtil.unzip(destinationFolder, uploadFile, itemName); UnzipUtil.unzip(destinationFolder, uploadFile, itemName);
logger.info("Archive "+itemName+ " imported correctly in "+destinationFolder.getPath()); logger.info("Archive "+itemName+ " imported correctly in "+destinationFolder.getPath());
workspaceUploader.setStatusDescription("Archive "+itemName+ " imported correctly in "+destinationFolder.getPath()); workspaceUploader.setStatusDescription("Archive "+itemName+ " imported correctly in "+destinationFolder.getPath());
workspaceUploader.setUploadStatus(UPLOAD_STATUS.COMPLETED); workspaceUploader.setUploadStatus(UPLOAD_STATUS.COMPLETED);
try { try {
WsUtil.putWorkspaceUploaderInSession(httpSession, workspaceUploader); WsUtil.putWorkspaceUploaderInSession(httpSession, workspaceUploader);
} catch (Exception e1) { } catch (Exception e1) {
@ -176,7 +176,7 @@ public class WorkspaceUploaderMng {
} }
return workspaceUploader; return workspaceUploader;
} }
/** /**
@ -195,7 +195,7 @@ public class WorkspaceUploaderMng {
* @throws Exception the exception * @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 { 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 { try {
return createWorkspaceUploaderFile(workspaceUploader, httpSession, isOverwrite, wa, file, itemName, destinationFolder, contentType, totolaBytes); return createWorkspaceUploaderFile(workspaceUploader, httpSession, isOverwrite, wa, file, itemName, destinationFolder, contentType, totolaBytes);
} catch (Exception e) { } catch (Exception e) {
@ -203,8 +203,8 @@ public class WorkspaceUploaderMng {
throw new Exception("An error occurred during upload: "+itemName+". Try again"); throw new Exception("An error occurred during upload: "+itemName+". Try again");
} }
} }
/** /**
* Upload archive. * Upload archive.
* *
@ -218,16 +218,16 @@ public class WorkspaceUploaderMng {
* @throws Exception the exception * @throws Exception the exception
*/ */
public static WorkspaceUploaderItem uploadArchive(WorkspaceUploaderItem workspaceUploader, HttpSession httpSession, String itemName, InputStream file, WorkspaceFolder destinationFolder, long totalBytes) throws Exception { public static WorkspaceUploaderItem uploadArchive(WorkspaceUploaderItem workspaceUploader, HttpSession httpSession, String itemName, InputStream file, WorkspaceFolder destinationFolder, long totalBytes) throws Exception {
try { try {
return createWorkspaceUploaderArchive(workspaceUploader, httpSession, file, itemName, destinationFolder, totalBytes); return createWorkspaceUploaderArchive(workspaceUploader, httpSession, file, itemName, destinationFolder, totalBytes);
} catch (Exception e) { } catch (Exception e) {
logger.error("Error when uploading Archive to HL creation: ",e); logger.error("Error when uploading Archive to HL creation: ",e);
throw new Exception("An error occurred during upload:: "+itemName+". Try again"); throw new Exception("An error occurred during upload:: "+itemName+". Try again");
} }
} }
/** /**
* Upload file status. * Upload file status.
* *
@ -239,7 +239,7 @@ public class WorkspaceUploaderMng {
public static WorkspaceUploaderItem uploadFileStatus(HttpSession httpSession, WorkspaceUploaderItem workspaceUploader) throws Exception { public static WorkspaceUploaderItem uploadFileStatus(HttpSession httpSession, WorkspaceUploaderItem workspaceUploader) throws Exception {
return WsUtil.getWorkspaceUploaderInSession(httpSession, workspaceUploader.getIdentifier()); return WsUtil.getWorkspaceUploaderInSession(httpSession, workspaceUploader.getIdentifier());
} }
/** /**
* Overwrite item. * Overwrite item.
* *
@ -257,7 +257,7 @@ public class WorkspaceUploaderMng {
* @throws WrongDestinationException the wrong destination exception * @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{ private static FolderItem overwriteItem(Workspace wa, String itemName, InputStream fileData, WorkspaceFolder destinationFolder) throws ItemNotFoundException, WrongItemTypeException, InternalErrorException, InsufficientPrivilegesException, WorkspaceFolderNotFoundException, ItemAlreadyExistException, WrongDestinationException{
FolderItem overwriteItem = null; FolderItem overwriteItem = null;
logger.debug("case overwriting item.. "+itemName); logger.debug("case overwriting item.. "+itemName);
overwriteItem = (FolderItem) wa.find(itemName, destinationFolder.getId()); overwriteItem = (FolderItem) wa.find(itemName, destinationFolder.getId());
@ -265,6 +265,6 @@ public class WorkspaceUploaderMng {
wa.updateItem(overwriteItem.getId(), fileData); wa.updateItem(overwriteItem.getId(), fileData);
logger.debug("updateItem with id: "+overwriteItem.getId()+ ", is completed"); logger.debug("updateItem with id: "+overwriteItem.getId()+ ", is completed");
return overwriteItem; return overwriteItem;
} }
} }