- [#27898] Updated `uploadFile` and `uploadArchive` methods. They

include the `fileSize` parameter
This commit is contained in:
Francesco Mangiacrapa 2024-07-29 16:02:57 +02:00
parent 0c903981d5
commit 19ae7f2f66
4 changed files with 46 additions and 21 deletions

View File

@ -3,6 +3,10 @@
All notable changes to this project will be documented in this file. All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [v2.1.1-SNAPSHOT] - 2024-07-29
- [#27898] Updated `uploadFile` and `uploadArchive` methods. They include the `fileSize` parameter
## [v2.1.0] - 2022-05-03 ## [v2.1.0] - 2022-05-03
#### Enhancements #### Enhancements

55
pom.xml
View File

@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent> <parent>
<artifactId>maven-parent</artifactId> <artifactId>maven-parent</artifactId>
<groupId>org.gcube.tools</groupId> <groupId>org.gcube.tools</groupId>
<version>1.1.0</version> <version>1.2.0</version>
<relativePath /> <relativePath />
</parent> </parent>
@ -12,7 +13,7 @@
<groupId>org.gcube.portlets.widgets</groupId> <groupId>org.gcube.portlets.widgets</groupId>
<artifactId>workspace-uploader</artifactId> <artifactId>workspace-uploader</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>2.1.0</version> <version>2.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> <description>Workspace Uploader Widget allows your application to upload file/s in the gCube Workspace</description>
<scm> <scm>
@ -30,6 +31,7 @@
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory> <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven-portal-bom>3.7.0</maven-portal-bom>
</properties> </properties>
<dependencyManagement> <dependencyManagement>
@ -37,26 +39,40 @@
<dependency> <dependency>
<groupId>org.gcube.distribution</groupId> <groupId>org.gcube.distribution</groupId>
<artifactId>maven-portal-bom</artifactId> <artifactId>maven-portal-bom</artifactId>
<version>3.6.3</version> <version>${maven-portal-bom}</version>
<type>pom</type> <type>pom</type>
<scope>import</scope> <scope>import</scope>
</dependency> </dependency>
</dependencies> </dependencies>
</dependencyManagement> </dependencyManagement>
<!-- Profiles required for managing SHUB vesion via maven-portal-bom -->
<profiles> <profiles>
<!-- PROD profile -->
<profile> <profile>
<id>localRun</id> <id>workspace-release-profile</id>
<dependencies> <activation>
<dependency> <property>
<groupId>xerces</groupId> <name>Release</name>
<artifactId>xerces</artifactId> </property>
<version>2.4.0</version> </activation>
</dependency> <properties>
</dependencies> <maven-portal-bom>3.7.0</maven-portal-bom>
</properties>
</profile>
<!-- DEV profile -->
<profile>
<id>workspace-snapshot-profile</id>
<activation>
<property>
<name>!Release</name>
</property>
</activation>
<properties>
<maven-portal-bom>3.8.0-SNAPSHOT</maven-portal-bom>
</properties>
</profile> </profile>
</profiles> </profiles>
<dependencies> <dependencies>
<!-- Google Web Toolkit (GWT) --> <!-- Google Web Toolkit (GWT) -->
@ -117,7 +133,7 @@
<artifactId>storagehub-client-library</artifactId> <artifactId>storagehub-client-library</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.common</groupId> <groupId>org.gcube.common</groupId>
<artifactId>storagehub-client-wrapper</artifactId> <artifactId>storagehub-client-wrapper</artifactId>
@ -131,7 +147,7 @@
<artifactId>json</artifactId> <artifactId>json</artifactId>
<version>20090211</version> <version>20090211</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-httpclient</groupId> <groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId> <artifactId>commons-httpclient</artifactId>
@ -143,6 +159,11 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
<!-- Logger --> <!-- Logger -->
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
@ -262,8 +283,8 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<!-- GWT Maven Plugin - not needed --> <!-- GWT Maven Plugin - not needed -->
<!-- GWT Maven Plugin --> <!-- GWT Maven Plugin -->
<plugin> <plugin>

View File

@ -3,7 +3,6 @@
*/ */
package org.gcube.portlets.widgets.workspaceuploader.server.notification; package org.gcube.portlets.widgets.workspaceuploader.server.notification;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;

View File

@ -77,7 +77,8 @@ public class WorkspaceUploaderMng {
Long startTime = WorkspaceUploadServletStream.printStartTime(); Long startTime = WorkspaceUploadServletStream.printStartTime();
//UPLOAD //UPLOAD
createdItem = storageWrapper.getWorkspace().uploadFile(destinationFolder.getId(), uploadFile, itemName, ""); logger.info("calling upload file - [itemName: "+itemName+", totalBytes: "+totalBytes+"]");
createdItem = storageWrapper.getWorkspace().uploadFile(destinationFolder.getId(), uploadFile, itemName, "", totalBytes);
if(createdItem!=null){ if(createdItem!=null){
WorkspaceUploadServletStream.printElapsedTime(startTime); WorkspaceUploadServletStream.printElapsedTime(startTime);
@ -199,13 +200,13 @@ public class WorkspaceUploaderMng {
*/ */
private static WorkspaceUploaderItem createWorkspaceUploaderArchive(StorageHubWrapper storageWrapper, final GCubeUser currUser, final String scopeGroupId, final WorkspaceUploaderItem workspaceUploader, final HttpServletRequest request, final InputStream uploadArchive, final String itemName, final WorkspaceFolder destinationFolder, final long totalBytes) throws InternalErrorException, IOException{ private static WorkspaceUploaderItem createWorkspaceUploaderArchive(StorageHubWrapper storageWrapper, final GCubeUser currUser, final String scopeGroupId, final WorkspaceUploaderItem workspaceUploader, final HttpServletRequest request, final InputStream uploadArchive, final String itemName, final WorkspaceFolder destinationFolder, final long totalBytes) throws InternalErrorException, IOException{
HttpSession httpSession = request.getSession(); HttpSession httpSession = request.getSession();
logger.info("calling upload archive - [itemName: "+itemName+"]"); logger.info("calling upload archive - [itemName: "+itemName+", totalBytes: "+totalBytes+"]");
WorkspaceItem createdItem = null; WorkspaceItem createdItem = null;
try { try {
workspaceUploader.setUploadStatus(UPLOAD_STATUS.IN_PROGRESS); workspaceUploader.setUploadStatus(UPLOAD_STATUS.IN_PROGRESS);
workspaceUploader.setStatusDescription("Uploading "+itemName); workspaceUploader.setStatusDescription("Uploading "+itemName);
createdItem = storageWrapper.getWorkspace().uploadArchive(destinationFolder.getId(), uploadArchive, itemName); createdItem = storageWrapper.getWorkspace().uploadArchive(destinationFolder.getId(), uploadArchive, itemName, totalBytes);
if(createdItem!=null){ if(createdItem!=null){
logger.debug("StorageHub"+createdItem.getName() + " with id: "+createdItem.getId() + " uploaded correctly in "+destinationFolder.getPath()); logger.debug("StorageHub"+createdItem.getName() + " with id: "+createdItem.getId() + " uploaded correctly in "+destinationFolder.getPath());