Compare commits
12 Commits
task_23225
...
master
Author | SHA1 | Date |
---|---|---|
Francesco Mangiacrapa | 97e58fcf91 | |
Francesco Mangiacrapa | 640a2bd097 | |
Francesco Mangiacrapa | bb7f18e8af | |
Francesco Mangiacrapa | 11a5fed7d1 | |
Francesco Mangiacrapa | c6b867198d | |
Francesco Mangiacrapa | 9439ffa8c8 | |
Francesco Mangiacrapa | 4a3f31a0d7 | |
Francesco Mangiacrapa | 106dfc3a2b | |
Francesco Mangiacrapa | 284f2e5dca | |
Francesco Mangiacrapa | 19ae7f2f66 | |
Francesco Mangiacrapa | 0c903981d5 | |
Francesco Mangiacrapa | 5c183c48ce |
|
@ -3,11 +3,16 @@
|
||||||
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.0-SNAPSHOT] - 2022-05-03
|
## [v2.1.1] - 2024-07-29
|
||||||
|
|
||||||
|
- [#27898] Updated `uploadFile` and `uploadArchive` methods. They include the `fileSize` parameter
|
||||||
|
- [#27934] Updated the data structure to handle asynchronous uploading of multiple files
|
||||||
|
|
||||||
|
## [v2.1.0] - 2022-05-03
|
||||||
|
|
||||||
#### Enhancements
|
#### Enhancements
|
||||||
|
|
||||||
- [#23225] pdated the method to read the members of (VRE or Simple) shared folders
|
- [#23225] Updated the method to read the members of (VRE or Simple) shared folders
|
||||||
|
|
||||||
|
|
||||||
## [v2.0.6] - 2020-07-15
|
## [v2.0.6] - 2020-07-15
|
||||||
|
|
64
pom.xml
64
pom.xml
|
@ -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-SNAPSHOT</version>
|
<version>2.1.1</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>4.0.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>4.0.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>4.0.0-SNAPSHOT</maven-portal-bom>
|
||||||
|
</properties>
|
||||||
</profile>
|
</profile>
|
||||||
</profiles>
|
</profiles>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<!-- Google Web Toolkit (GWT) -->
|
<!-- Google Web Toolkit (GWT) -->
|
||||||
|
@ -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>
|
||||||
|
@ -154,13 +175,24 @@
|
||||||
<artifactId>slf4j-api</artifactId>
|
<artifactId>slf4j-api</artifactId>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.portal</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>social-networking-library</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.18.4</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.social-networking</groupId>
|
||||||
|
<artifactId>social-service-client</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- <dependency> -->
|
||||||
|
<!-- <groupId>org.gcube.portal</groupId> -->
|
||||||
|
<!-- <artifactId>social-networking-library</artifactId> -->
|
||||||
|
<!-- <scope>provided</scope> -->
|
||||||
|
<!-- </dependency> -->
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
<groupId>org.gcube.applicationsupportlayer</groupId>
|
||||||
<artifactId>aslsocial</artifactId>
|
<artifactId>aslsocial</artifactId>
|
||||||
|
|
|
@ -32,6 +32,8 @@ public class ConstantsWorkspaceUploader {
|
||||||
public static final String UPLOAD_FORM_ELEMENT = "uploadFormElement";
|
public static final String UPLOAD_FORM_ELEMENT = "uploadFormElement";
|
||||||
|
|
||||||
public static final String CLIENT_UPLOAD_KEYS = "client_upload_keys";
|
public static final String CLIENT_UPLOAD_KEYS = "client_upload_keys";
|
||||||
|
public static final String CLIENT_UPLOAD_FILEOBJ_FILENAME = "filename";
|
||||||
|
public static final String CLIENT_UPLOAD_FILEOBJ_FILESIZE= "filesize";
|
||||||
public static final String CANCEL_UPLOAD = "cancel_upload";
|
public static final String CANCEL_UPLOAD = "cancel_upload";
|
||||||
public static final String JSON_CLIENT_KEYS = "ClientKeys";
|
public static final String JSON_CLIENT_KEYS = "ClientKeys";
|
||||||
|
|
||||||
|
|
|
@ -15,11 +15,15 @@ import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem.UPLOAD_STATUS;
|
import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem.UPLOAD_STATUS;
|
||||||
|
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
|
import com.google.gwt.core.client.JavaScriptObject;
|
||||||
import com.google.gwt.event.dom.client.ChangeEvent;
|
import com.google.gwt.event.dom.client.ChangeEvent;
|
||||||
import com.google.gwt.event.dom.client.ChangeHandler;
|
import com.google.gwt.event.dom.client.ChangeHandler;
|
||||||
import com.google.gwt.json.client.JSONArray;
|
import com.google.gwt.json.client.JSONArray;
|
||||||
|
import com.google.gwt.json.client.JSONNumber;
|
||||||
import com.google.gwt.json.client.JSONObject;
|
import com.google.gwt.json.client.JSONObject;
|
||||||
|
import com.google.gwt.json.client.JSONParser;
|
||||||
import com.google.gwt.json.client.JSONString;
|
import com.google.gwt.json.client.JSONString;
|
||||||
|
import com.google.gwt.json.client.JSONValue;
|
||||||
import com.google.gwt.user.client.Window;
|
import com.google.gwt.user.client.Window;
|
||||||
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent;
|
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent;
|
||||||
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteHandler;
|
import com.google.gwt.user.client.ui.FormPanel.SubmitCompleteHandler;
|
||||||
|
@ -43,21 +47,17 @@ public class MultipleDilaogUpload extends DialogUpload {
|
||||||
private String idFolder;
|
private String idFolder;
|
||||||
private UPLOAD_TYPE type;
|
private UPLOAD_TYPE type;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new multiple dilaog upload stream.
|
* Instantiates a new multiple dilaog upload stream.
|
||||||
*
|
*
|
||||||
* @param headerTitle
|
* @param headerTitle the header title
|
||||||
* the header title
|
* @param parentId the parent id
|
||||||
* @param parentId
|
* @param uploadType the upload type
|
||||||
* the parent id
|
|
||||||
* @param uploadType
|
|
||||||
* the upload type
|
|
||||||
*/
|
*/
|
||||||
public MultipleDilaogUpload(String headerTitle, String parentId, UPLOAD_TYPE uploadType) {
|
public MultipleDilaogUpload(String headerTitle, String parentId, UPLOAD_TYPE uploadType) {
|
||||||
super(headerTitle, parentId, uploadType);
|
super(headerTitle, parentId, uploadType);
|
||||||
|
|
||||||
this.type =uploadType;
|
this.type = uploadType;
|
||||||
this.idFolder = parentId;
|
this.idFolder = parentId;
|
||||||
|
|
||||||
fileUploadID = GenerateUUID.get(10, 16); // is tagID
|
fileUploadID = GenerateUUID.get(10, 16); // is tagID
|
||||||
|
@ -65,7 +65,9 @@ public class MultipleDilaogUpload extends DialogUpload {
|
||||||
this.addHandlers();
|
this.addHandlers();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see com.google.gwt.user.client.ui.DialogBox#show()
|
* @see com.google.gwt.user.client.ui.DialogBox#show()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -73,7 +75,9 @@ public class MultipleDilaogUpload extends DialogUpload {
|
||||||
super.show();
|
super.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see com.google.gwt.user.client.ui.PopupPanel#center()
|
* @see com.google.gwt.user.client.ui.PopupPanel#center()
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
|
@ -88,36 +92,45 @@ public class MultipleDilaogUpload extends DialogUpload {
|
||||||
* @param parentId the parent id
|
* @param parentId the parent id
|
||||||
* @return the list
|
* @return the list
|
||||||
*/
|
*/
|
||||||
public void generateFakeUploaders(String filesSelected, String parentId) {
|
public void generateFakeUploaders(JSONArray filesSelected, String parentId) {
|
||||||
|
|
||||||
if(filesSelected==null || filesSelected.isEmpty())
|
if (filesSelected == null || filesSelected.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String[] files = filesSelected.split(FILE_DELEMITER);
|
// String[] files = filesSelected.split(FILE_DELEMITER);
|
||||||
|
|
||||||
// NORMALIZE FILE NAMES
|
// NORMALIZE FILE NAMES
|
||||||
for (int i = 0; i < files.length; i++) {
|
for (int i = 0; i < filesSelected.size(); i++) {
|
||||||
String normalizedFileName = files[i];
|
JSONObject fileObject = (JSONObject) filesSelected.get(i);
|
||||||
|
GWT.log("checking filename for: " + fileObject.getJavaScriptObject().toString());
|
||||||
|
String normalizedFileName = fileObject.get("filename").isString().stringValue();
|
||||||
if (normalizedFileName.contains("\\")) {
|
if (normalizedFileName.contains("\\")) {
|
||||||
files[i] = normalizedFileName.substring(normalizedFileName.lastIndexOf("\\") + 1); // remove C:\fakepath if exists
|
String sanitizedValue = normalizedFileName.substring(normalizedFileName.lastIndexOf("\\") + 1); // remove
|
||||||
|
// C:\fakepath
|
||||||
|
// if exists
|
||||||
|
JSONValue jsonValue = JSONParser.parseStrict(sanitizedValue);
|
||||||
|
fileObject.put("filename", jsonValue);
|
||||||
|
filesSelected.set(i, fileObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GWT.log("generating fake uploaders on: "+Arrays.asList(files.toString()));
|
fakeUploaders = new ArrayList<WorkspaceUploaderItem>(filesSelected.size());
|
||||||
fakeUploaders = new ArrayList<WorkspaceUploaderItem>(files.length);
|
for (int i = 0; i < filesSelected.size(); i++) {
|
||||||
for (int i = 0; i < files.length; i++) {
|
JSONObject fileObject = (JSONObject) filesSelected.get(i);
|
||||||
WorkspaceUploaderItem fakeItem = new WorkspaceUploaderItem();
|
WorkspaceUploaderItem fakeItem = new WorkspaceUploaderItem();
|
||||||
fakeItem.setClientUploadKey(GenerateUUID.get());
|
fakeItem.setClientUploadKey(GenerateUUID.get());
|
||||||
fakeItem.setUploadStatus(UPLOAD_STATUS.WAIT);
|
fakeItem.setUploadStatus(UPLOAD_STATUS.WAIT);
|
||||||
WorkspaceUploadFile fakeFile = new WorkspaceUploadFile();
|
WorkspaceUploadFile fakeFile = new WorkspaceUploadFile();
|
||||||
fakeFile.setFileName(files[i]);
|
String fileName = fileObject.get("filename").isString().stringValue();
|
||||||
|
Long fileSize = (long) fileObject.get("size").isNumber().doubleValue();
|
||||||
|
fakeFile.setFileName(fileName);
|
||||||
|
fakeFile.setFileSize(fileSize);
|
||||||
fakeFile.setParentId(parentId);
|
fakeFile.setParentId(parentId);
|
||||||
fakeItem.setFile(fakeFile);
|
fakeItem.setFile(fakeFile);
|
||||||
fakeUploaders.add(fakeItem);
|
fakeUploaders.add(fakeItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
GWT.log("fakeUploaders generated: "+fakeUploaders.toString());
|
GWT.log("fakeUploaders generated: " + fakeUploaders.toString());
|
||||||
// return fakeUploaders;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -141,13 +154,11 @@ public class MultipleDilaogUpload extends DialogUpload {
|
||||||
|
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
removeLoading();
|
removeLoading();
|
||||||
new DialogResult(null, "Error during upload",
|
new DialogResult(null, "Error during upload", "An error occurred during file upload.").center();
|
||||||
"An error occurred during file upload.").center();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String strippedResult = new HTML(result).getText();
|
String strippedResult = new HTML(result).getText();
|
||||||
final HandlerResultMessage resultMessage = HandlerResultMessage
|
final HandlerResultMessage resultMessage = HandlerResultMessage.parseResult(strippedResult);
|
||||||
.parseResult(strippedResult);
|
|
||||||
|
|
||||||
switch (resultMessage.getStatus()) {
|
switch (resultMessage.getStatus()) {
|
||||||
case ERROR:
|
case ERROR:
|
||||||
|
@ -159,12 +170,12 @@ public class MultipleDilaogUpload extends DialogUpload {
|
||||||
GWT.log("Error during upload " + resultMessage.getMessage());
|
GWT.log("Error during upload " + resultMessage.getMessage());
|
||||||
break;
|
break;
|
||||||
case WARN: {
|
case WARN: {
|
||||||
GWT.log("Upload completed with warnings "+ resultMessage.getMessage());
|
GWT.log("Upload completed with warnings " + resultMessage.getMessage());
|
||||||
removeLoading();
|
removeLoading();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SESSION_EXPIRED:{
|
case SESSION_EXPIRED: {
|
||||||
GWT.log("Upload aborted due to session expired: "+ resultMessage.getMessage());
|
GWT.log("Upload aborted due to session expired: " + resultMessage.getMessage());
|
||||||
Window.alert("Session expired, please reload the page");
|
Window.alert("Session expired, please reload the page");
|
||||||
removeLoading();
|
removeLoading();
|
||||||
break;
|
break;
|
||||||
|
@ -193,24 +204,26 @@ public class MultipleDilaogUpload extends DialogUpload {
|
||||||
@Override
|
@Override
|
||||||
public void onChange(ChangeEvent event) {
|
public void onChange(ChangeEvent event) {
|
||||||
GWT.log("browse return...");
|
GWT.log("browse return...");
|
||||||
if (fileUpload.getFilename() == null
|
if (fileUpload.getFilename() == null || fileUpload.getFilename().isEmpty()) {
|
||||||
|| fileUpload.getFilename().isEmpty()) {
|
|
||||||
GWT.log("No file specified ");
|
GWT.log("No file specified ");
|
||||||
MultipleDilaogUpload.this.hide();
|
MultipleDilaogUpload.this.hide();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] files = null;
|
GWT.log("Current Uploader has id: " + fileUploadID);
|
||||||
GWT.log("Current Uploader has id: "+fileUploadID);
|
JavaScriptObject filesSelected = getFilesSelected(fileUploadID);
|
||||||
String filesSelected = getFilesSelected(fileUploadID, FILE_DELEMITER);
|
|
||||||
GWT.log("getFilesSelected: " + filesSelected);
|
|
||||||
files = filesSelected.split(FILE_DELEMITER);
|
|
||||||
|
|
||||||
if(isLimitExceeded(files.length))
|
JSONArray jsonArray = new JSONArray(filesSelected);
|
||||||
|
if(jsonArray!=null)
|
||||||
|
GWT.log("sono array");
|
||||||
|
|
||||||
|
GWT.log("getFilesSelected: " + jsonArray);
|
||||||
|
|
||||||
|
if (isLimitExceeded(jsonArray.size()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// GENERATE NEW UPLOADERS
|
// GENERATE NEW UPLOADERS
|
||||||
generateFakeUploaders(filesSelected, parentIdentifier);
|
generateFakeUploaders(jsonArray, parentIdentifier);
|
||||||
GWT.log(fakeUploaders.toString());
|
GWT.log(fakeUploaders.toString());
|
||||||
createJsonKeyForFiles();
|
createJsonKeyForFiles();
|
||||||
GWT.log(jsonKeys);
|
GWT.log(jsonKeys);
|
||||||
|
@ -223,67 +236,23 @@ public class MultipleDilaogUpload extends DialogUpload {
|
||||||
// ADD TO FORM PANEL
|
// ADD TO FORM PANEL
|
||||||
// initJsonClientKeys();
|
// initJsonClientKeys();
|
||||||
jsonClientKeys.setValue(jsonKeys);
|
jsonClientKeys.setValue(jsonKeys);
|
||||||
|
|
||||||
// // CASE 1 FILE
|
|
||||||
// if (files.length == 1) {
|
|
||||||
//
|
|
||||||
// // recall: Some browser would write in
|
|
||||||
// // fileUploadField.getValue() C:\fakepath\$fileName
|
|
||||||
// final String label = files[0];
|
|
||||||
// WorkspaceUploaderServiceAsync.Util.getInstance()
|
|
||||||
// .itemExistsInWorkpaceFolder(parentIdentifier,
|
|
||||||
// label, new AsyncCallback<String>() {
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onSuccess(
|
|
||||||
// final String itemId) {
|
|
||||||
// GWT.log("itemExistsInWorkpaceFolder: "
|
|
||||||
// + itemId);
|
|
||||||
// if (itemId != null) {
|
|
||||||
// removeItemAndSubmitForm(itemId);
|
|
||||||
// updateItemSubmitForm(itemId);
|
|
||||||
//// if (Window.confirm(label+ " exists in folder. If you continue, a new version will be created")) {
|
|
||||||
//// removeItemAndSubmitForm(itemId);
|
|
||||||
//// updateItemSubmitForm(itemId);
|
|
||||||
//// }
|
|
||||||
// } else
|
|
||||||
// submitForm(); // ITEM does NOT
|
|
||||||
// // EXIST SO
|
|
||||||
// // SUBMIT FORM;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onFailure(Throwable caught) {
|
|
||||||
// GWT.log("Sorry an error occurred on the server "
|
|
||||||
// + caught.getLocalizedMessage()
|
|
||||||
// + ". Please try again later");
|
|
||||||
// Window.alert(caught.getMessage());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// });
|
|
||||||
// } else
|
|
||||||
submitForm();
|
submitForm();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if is limit exceeded.
|
* Checks if is limit exceeded.
|
||||||
*
|
*
|
||||||
* @param numbOfFiles the numb of files
|
* @param numbOfFiles the numb of files
|
||||||
* @return true, if is limit exceeded
|
* @return true, if is limit exceeded
|
||||||
*/
|
*/
|
||||||
public boolean isLimitExceeded(int numbOfFiles){
|
public boolean isLimitExceeded(int numbOfFiles) {
|
||||||
|
|
||||||
if (numbOfFiles > ConstantsWorkspaceUploader.LIMIT_UPLOADS) {
|
if (numbOfFiles > ConstantsWorkspaceUploader.LIMIT_UPLOADS) {
|
||||||
Window.alert("Multiple upload limit is "
|
Window.alert("Multiple upload limit is " + ConstantsWorkspaceUploader.LIMIT_UPLOADS + " files");
|
||||||
+ ConstantsWorkspaceUploader.LIMIT_UPLOADS
|
|
||||||
+ " files");
|
|
||||||
MultipleDilaogUpload.this.hide();
|
MultipleDilaogUpload.this.hide();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -294,11 +263,12 @@ public class MultipleDilaogUpload extends DialogUpload {
|
||||||
/**
|
/**
|
||||||
* Adds the new submit to monitor.
|
* Adds the new submit to monitor.
|
||||||
*/
|
*/
|
||||||
public void addNewSubmitToMonitor(){
|
public void addNewSubmitToMonitor() {
|
||||||
GWT.log("addNewSubmitToMonitor...");
|
GWT.log("addNewSubmitToMonitor...");
|
||||||
int queueIndex = UploaderMonitor.getInstance().newQueue();
|
int queueIndex = UploaderMonitor.getInstance().newQueue();
|
||||||
for (final WorkspaceUploaderItem workspaceUploaderItem : fakeUploaders) {
|
for (final WorkspaceUploaderItem workspaceUploaderItem : fakeUploaders) {
|
||||||
UploaderMonitor.getInstance().addNewUploaderToMonitorPanel(workspaceUploaderItem, workspaceUploaderItem.getFile().getFileName());
|
UploaderMonitor.getInstance().addNewUploaderToMonitorPanel(workspaceUploaderItem,
|
||||||
|
workspaceUploaderItem.getFile().getFileName());
|
||||||
setVisible(false);
|
setVisible(false);
|
||||||
removeLoading();
|
removeLoading();
|
||||||
UploaderMonitor.getInstance().addNewUploaderToQueue(queueIndex, workspaceUploaderItem);
|
UploaderMonitor.getInstance().addNewUploaderToQueue(queueIndex, workspaceUploaderItem);
|
||||||
|
@ -308,7 +278,6 @@ public class MultipleDilaogUpload extends DialogUpload {
|
||||||
UploaderMonitor.getInstance().doStartPollingQueue(queueIndex);
|
UploaderMonitor.getInstance().doStartPollingQueue(queueIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the json key for files.
|
* Creates the json key for files.
|
||||||
*
|
*
|
||||||
|
@ -325,12 +294,16 @@ public class MultipleDilaogUpload extends DialogUpload {
|
||||||
for (int i = 0; i < fakeUploaders.size(); i++) {
|
for (int i = 0; i < fakeUploaders.size(); i++) {
|
||||||
WorkspaceUploaderItem file = fakeUploaders.get(i);
|
WorkspaceUploaderItem file = fakeUploaders.get(i);
|
||||||
JSONObject obj = new JSONObject();
|
JSONObject obj = new JSONObject();
|
||||||
obj.put(file.getClientUploadKey(), new JSONString(file.getFile().getFileName()));
|
JSONObject fileObject = new JSONObject();
|
||||||
|
//Feature #27934
|
||||||
|
fileObject.put(ConstantsWorkspaceUploader.CLIENT_UPLOAD_FILEOBJ_FILENAME, new JSONString(file.getFile().getFileName()));
|
||||||
|
fileObject.put(ConstantsWorkspaceUploader.CLIENT_UPLOAD_FILEOBJ_FILESIZE, new JSONNumber(file.getFile().getFileSize()));
|
||||||
|
obj.put(file.getClientUploadKey(), fileObject);
|
||||||
jsonArray.set(i, obj);
|
jsonArray.set(i, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonKeys = productObj.toString();
|
jsonKeys = productObj.toString();
|
||||||
GWT.log("updated jsonKeys: "+jsonKeys);
|
GWT.log("updated jsonKeys: " + jsonKeys);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
GWT.log("error " + e.getMessage());
|
GWT.log("error " + e.getMessage());
|
||||||
jsonKeys = null;
|
jsonKeys = null;
|
||||||
|
@ -394,22 +367,24 @@ public class MultipleDilaogUpload extends DialogUpload {
|
||||||
/**
|
/**
|
||||||
* Gets the files selected.
|
* Gets the files selected.
|
||||||
*
|
*
|
||||||
* @param tagId
|
* @param tagId the tag id
|
||||||
* the tag id
|
* @param fileDelimiter the file delimiter
|
||||||
* @param fileDelimiter
|
|
||||||
* the file delimiter
|
|
||||||
* @return the files selected
|
* @return the files selected
|
||||||
*/
|
*/
|
||||||
public static native String getFilesSelected(final String tagId, final String fileDelimiter) /*-{
|
public static native JavaScriptObject getFilesSelected(final String tagId) /*-{
|
||||||
var count = $wnd.$("#" + tagId)[0].files.length;
|
var count = $wnd.$("#" + tagId)[0].files.length;
|
||||||
console.log(count);
|
console.log("number of files: "+count);
|
||||||
var out = "";
|
var outputs = [];
|
||||||
|
|
||||||
for (i = 0; i < count; i++) {
|
for (i = 0; i < count; i++) {
|
||||||
var file = $wnd.$("#" + tagId)[0].files[i];
|
var file = $wnd.$("#" + tagId)[0].files[i];
|
||||||
// out += file.name + fileDelimiter + file.size + fileDelimiter;
|
//out += file.name + fileDelimiter + file.size + fileDelimiter;
|
||||||
out += file.name + fileDelimiter;
|
var the_file = { "filename": file.name, "size": file.size };
|
||||||
|
//var jsonString = JSON.stringify(the_file);
|
||||||
|
//console.log("the file is: "+jsonString);
|
||||||
|
outputs.push(the_file);
|
||||||
}
|
}
|
||||||
return out;
|
console.log("returning outputs: "+outputs);
|
||||||
|
return outputs;
|
||||||
}-*/;
|
}-*/;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,24 +14,25 @@ import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem
|
||||||
|
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
import com.google.gwt.json.client.JSONArray;
|
import com.google.gwt.json.client.JSONArray;
|
||||||
|
import com.google.gwt.json.client.JSONNumber;
|
||||||
import com.google.gwt.json.client.JSONObject;
|
import com.google.gwt.json.client.JSONObject;
|
||||||
|
import com.google.gwt.json.client.JSONParser;
|
||||||
import com.google.gwt.json.client.JSONString;
|
import com.google.gwt.json.client.JSONString;
|
||||||
|
import com.google.gwt.json.client.JSONValue;
|
||||||
import com.google.gwt.user.client.Window;
|
import com.google.gwt.user.client.Window;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class WorkspaceFieldsUpload.
|
* The Class WorkspaceFieldsUpload.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Oct 20, 2015
|
||||||
* Oct 20, 2015
|
|
||||||
*/
|
*/
|
||||||
public class WorkspaceFieldsUploadManager {
|
public class WorkspaceFieldsUploadManager {
|
||||||
|
|
||||||
//FORM FIELD TO UPLOAD INTO WORKSPACE
|
// FORM FIELD TO UPLOAD INTO WORKSPACE
|
||||||
private String jsonKeys;
|
private String jsonKeys;
|
||||||
public static final String FILE_DELEMITER = ";";
|
public static final String FILE_DELEMITER = ";";
|
||||||
private List<WorkspaceUploaderItem> fakeUploaders = new ArrayList<WorkspaceUploaderItem>();
|
private List<WorkspaceUploaderItem> fakeUploaders = new ArrayList<WorkspaceUploaderItem>();
|
||||||
|
|
||||||
|
|
||||||
public WorkspaceFieldsUploadManager() {
|
public WorkspaceFieldsUploadManager() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,12 +42,10 @@ public class WorkspaceFieldsUploadManager {
|
||||||
* @param numbOfFiles the numb of files
|
* @param numbOfFiles the numb of files
|
||||||
* @return true, if is limit exceeded
|
* @return true, if is limit exceeded
|
||||||
*/
|
*/
|
||||||
public boolean isLimitExceeded(int numbOfFiles){
|
public boolean isLimitExceeded(int numbOfFiles) {
|
||||||
|
|
||||||
if (numbOfFiles > ConstantsWorkspaceUploader.LIMIT_UPLOADS) {
|
if (numbOfFiles > ConstantsWorkspaceUploader.LIMIT_UPLOADS) {
|
||||||
Window.alert("Multiple upload limit is "
|
Window.alert("Multiple upload limit is " + ConstantsWorkspaceUploader.LIMIT_UPLOADS + " files");
|
||||||
+ ConstantsWorkspaceUploader.LIMIT_UPLOADS
|
|
||||||
+ " files");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,18 +55,18 @@ public class WorkspaceFieldsUploadManager {
|
||||||
/**
|
/**
|
||||||
* Adds the new submit to monitor.
|
* Adds the new submit to monitor.
|
||||||
*/
|
*/
|
||||||
public void addNewSubmitToMonitor(){
|
public void addNewSubmitToMonitor() {
|
||||||
GWT.log("addNewSubmitToMonitor...");
|
GWT.log("addNewSubmitToMonitor...");
|
||||||
int queueIndex = UploaderMonitor.getInstance().newQueue();
|
int queueIndex = UploaderMonitor.getInstance().newQueue();
|
||||||
for (final WorkspaceUploaderItem workspaceUploaderItem : fakeUploaders) {
|
for (final WorkspaceUploaderItem workspaceUploaderItem : fakeUploaders) {
|
||||||
UploaderMonitor.getInstance().addNewUploaderToMonitorPanel(workspaceUploaderItem, workspaceUploaderItem.getFile().getFileName());
|
UploaderMonitor.getInstance().addNewUploaderToMonitorPanel(workspaceUploaderItem,
|
||||||
|
workspaceUploaderItem.getFile().getFileName());
|
||||||
UploaderMonitor.getInstance().addNewUploaderToQueue(queueIndex, workspaceUploaderItem);
|
UploaderMonitor.getInstance().addNewUploaderToQueue(queueIndex, workspaceUploaderItem);
|
||||||
// UploaderMonitor.getInstance().pollWorkspaceUploader(workspaceUploaderItem);
|
// UploaderMonitor.getInstance().pollWorkspaceUploader(workspaceUploaderItem);
|
||||||
}
|
}
|
||||||
UploaderMonitor.getInstance().doStartPollingQueue(queueIndex);
|
UploaderMonitor.getInstance().doStartPollingQueue(queueIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the json key for files.
|
* Creates the json key for files.
|
||||||
*
|
*
|
||||||
|
@ -84,12 +83,20 @@ public class WorkspaceFieldsUploadManager {
|
||||||
for (int i = 0; i < fakeUploaders.size(); i++) {
|
for (int i = 0; i < fakeUploaders.size(); i++) {
|
||||||
WorkspaceUploaderItem file = fakeUploaders.get(i);
|
WorkspaceUploaderItem file = fakeUploaders.get(i);
|
||||||
JSONObject obj = new JSONObject();
|
JSONObject obj = new JSONObject();
|
||||||
obj.put(file.getClientUploadKey(), new JSONString(file.getFile().getFileName()));
|
JSONObject fileObject = new JSONObject();
|
||||||
|
// Feature #27934
|
||||||
|
fileObject.put(ConstantsWorkspaceUploader.CLIENT_UPLOAD_FILEOBJ_FILENAME,
|
||||||
|
new JSONString(file.getFile().getFileName()));
|
||||||
|
fileObject.put(ConstantsWorkspaceUploader.CLIENT_UPLOAD_FILEOBJ_FILESIZE,
|
||||||
|
new JSONNumber(file.getFile().getFileSize()));
|
||||||
|
obj.put(file.getClientUploadKey(), fileObject);
|
||||||
|
// obj.put(file.getClientUploadKey(), new
|
||||||
|
// JSONString(file.getFile().getFileName()));
|
||||||
jsonArray.set(i, obj);
|
jsonArray.set(i, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonKeys = productObj.toString();
|
jsonKeys = productObj.toString();
|
||||||
GWT.log("updated jsonKeys: "+jsonKeys);
|
GWT.log("updated jsonKeys: " + jsonKeys);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
GWT.log("error " + e.getMessage());
|
GWT.log("error " + e.getMessage());
|
||||||
jsonKeys = null;
|
jsonKeys = null;
|
||||||
|
@ -103,41 +110,45 @@ public class WorkspaceFieldsUploadManager {
|
||||||
* @param parentId the parent id
|
* @param parentId the parent id
|
||||||
* @return the list
|
* @return the list
|
||||||
*/
|
*/
|
||||||
public void generateFakeUploaders(String filesSelected, String parentId) {
|
public void generateFakeUploaders(JSONArray filesSelected, String parentId) {
|
||||||
|
|
||||||
if(filesSelected==null || filesSelected.isEmpty())
|
if (filesSelected == null || filesSelected.size() == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String[] files = filesSelected.split(FILE_DELEMITER);
|
|
||||||
|
|
||||||
// NORMALIZE FILE NAMES
|
// NORMALIZE FILE NAMES
|
||||||
for (int i = 0; i < files.length; i++) {
|
for (int i = 0; i < filesSelected.size(); i++) {
|
||||||
String normalizedFileName = files[i];
|
JSONObject fileObject = (JSONObject) filesSelected.get(i);
|
||||||
|
GWT.log("checking filename for: " + fileObject.getJavaScriptObject().toString());
|
||||||
|
String normalizedFileName = fileObject.get("filename").isString().stringValue();
|
||||||
if (normalizedFileName.contains("\\")) {
|
if (normalizedFileName.contains("\\")) {
|
||||||
files[i] = normalizedFileName.substring(normalizedFileName.lastIndexOf("\\") + 1); // remove
|
String sanitizedValue = normalizedFileName.substring(normalizedFileName.lastIndexOf("\\") + 1); // remove
|
||||||
// C:\fakepath\
|
// C:\fakepath
|
||||||
// if
|
// if exists
|
||||||
// exists
|
JSONValue jsonValue = JSONParser.parseStrict(sanitizedValue);
|
||||||
|
fileObject.put("filename", jsonValue);
|
||||||
|
filesSelected.set(i, fileObject);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
GWT.log("generating fake uploaders on: "+Arrays.asList(files).toString());
|
fakeUploaders = new ArrayList<WorkspaceUploaderItem>(filesSelected.size());
|
||||||
fakeUploaders = new ArrayList<WorkspaceUploaderItem>(files.length);
|
for (int i = 0; i < filesSelected.size(); i++) {
|
||||||
for (int i = 0; i < files.length; i++) {
|
JSONObject fileObject = (JSONObject) filesSelected.get(i);
|
||||||
WorkspaceUploaderItem fakeItem = new WorkspaceUploaderItem();
|
WorkspaceUploaderItem fakeItem = new WorkspaceUploaderItem();
|
||||||
fakeItem.setClientUploadKey(GenerateUUID.get());
|
fakeItem.setClientUploadKey(GenerateUUID.get());
|
||||||
fakeItem.setUploadStatus(UPLOAD_STATUS.WAIT);
|
fakeItem.setUploadStatus(UPLOAD_STATUS.WAIT);
|
||||||
WorkspaceUploadFile fakeFile = new WorkspaceUploadFile();
|
WorkspaceUploadFile fakeFile = new WorkspaceUploadFile();
|
||||||
fakeFile.setFileName(files[i]);
|
String fileName = fileObject.get("filename").isString().stringValue();
|
||||||
|
Long fileSize = (long) fileObject.get("size").isNumber().doubleValue();
|
||||||
|
fakeFile.setFileName(fileName);
|
||||||
|
fakeFile.setFileSize(fileSize);
|
||||||
fakeFile.setParentId(parentId);
|
fakeFile.setParentId(parentId);
|
||||||
fakeItem.setFile(fakeFile);
|
fakeItem.setFile(fakeFile);
|
||||||
fakeUploaders.add(fakeItem);
|
fakeUploaders.add(fakeItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
GWT.log("fakeUploaders generated: "+fakeUploaders.toString());
|
GWT.log("fakeUploaders generated: " + fakeUploaders.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the jsonKeys
|
* @return the jsonKeys
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -14,7 +14,9 @@ import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploaderList
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.client.uploader.DialogUpload.UPLOAD_TYPE;
|
import org.gcube.portlets.widgets.workspaceuploader.client.uploader.DialogUpload.UPLOAD_TYPE;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.client.uploader.WorkspaceFieldsUploadManager;
|
import org.gcube.portlets.widgets.workspaceuploader.client.uploader.WorkspaceFieldsUploadManager;
|
||||||
|
|
||||||
|
import com.google.gwt.core.client.JavaScriptObject;
|
||||||
import com.google.gwt.core.shared.GWT;
|
import com.google.gwt.core.shared.GWT;
|
||||||
|
import com.google.gwt.json.client.JSONArray;
|
||||||
import com.google.gwt.user.client.Random;
|
import com.google.gwt.user.client.Random;
|
||||||
import com.google.gwt.user.client.Window;
|
import com.google.gwt.user.client.Window;
|
||||||
import com.google.gwt.user.client.ui.HTML;
|
import com.google.gwt.user.client.ui.HTML;
|
||||||
|
@ -252,9 +254,10 @@ public class MultipleDNDUpload extends LayoutPanel implements HasWorskpaceUpload
|
||||||
* @param uploadUUID
|
* @param uploadUUID
|
||||||
* the upload uuid
|
* the upload uuid
|
||||||
*/
|
*/
|
||||||
private void generateFakeUploaders(String filesSelected, String parentId, String uploadUUID) {
|
private void generateFakeUploaders(JavaScriptObject filesSelected, String parentId, String uploadUUID) {
|
||||||
WorkspaceFieldsUploadManager field = getFieldsUploadManager(uploadUUID);
|
WorkspaceFieldsUploadManager field = getFieldsUploadManager(uploadUUID);
|
||||||
field.generateFakeUploaders(filesSelected, parentId);
|
JSONArray jsonArray = new JSONArray(filesSelected);
|
||||||
|
field.generateFakeUploaders(jsonArray, parentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -607,14 +610,15 @@ public class MultipleDNDUpload extends LayoutPanel implements HasWorskpaceUpload
|
||||||
|
|
||||||
console.log("# of file/s: " + files.length);
|
console.log("# of file/s: " + files.length);
|
||||||
|
|
||||||
var filesSelected = "";
|
var arrayFileSelected = [];
|
||||||
|
|
||||||
for (i = 0; i < files.length; i++) {
|
for (i = 0; i < files.length; i++) {
|
||||||
filesSelected += files[i].name + fileDelimiter;
|
var file = files[i];
|
||||||
|
var the_file = { "filename": file.name, "size": file.size };
|
||||||
|
arrayFileSelected.push(the_file);
|
||||||
}
|
}
|
||||||
console.log("filesSelected: " + filesSelected);
|
console.log("Object arrayFileSelected: " + arrayFileSelected);
|
||||||
|
|
||||||
instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::generateFakeUploaders(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)(filesSelected,idfolder,uploadUUID);
|
instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::generateFakeUploaders(Lcom/google/gwt/core/client/JavaScriptObject;Ljava/lang/String;Ljava/lang/String;)(arrayFileSelected,idfolder,uploadUUID);
|
||||||
instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::createJsonKeyForFiles(Ljava/lang/String;)(uploadUUID);
|
instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::createJsonKeyForFiles(Ljava/lang/String;)(uploadUUID);
|
||||||
instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::updateJsonKeys(Ljava/lang/String;)(uploadUUID);
|
instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::updateJsonKeys(Ljava/lang/String;)(uploadUUID);
|
||||||
instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::setCurrentJsonKeValue(Ljava/lang/String;)(uploadUUID);
|
instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::setCurrentJsonKeValue(Ljava/lang/String;)(uploadUUID);
|
||||||
|
@ -657,10 +661,9 @@ public class MultipleDNDUpload extends LayoutPanel implements HasWorskpaceUpload
|
||||||
var numFolder = 0;
|
var numFolder = 0;
|
||||||
for (var i = 0; i < files.length; i++) {
|
for (var i = 0; i < files.length; i++) {
|
||||||
var file = files[i];
|
var file = files[i];
|
||||||
var fileSelected = files[i].name + fileDelimiter;
|
|
||||||
if (!isFolder(file)) {
|
if (!isFolder(file)) {
|
||||||
console.log("fileSelected: " + fileSelected);
|
console.log("fileSelected: " + file.name);
|
||||||
console.log("files: " + files);
|
//console.log("files: " + files);
|
||||||
formdata.append("isOverwrite", true);
|
formdata.append("isOverwrite", true);
|
||||||
formdata.append('uploadFormElement', file);
|
formdata.append('uploadFormElement', file);
|
||||||
}else{
|
}else{
|
||||||
|
@ -668,6 +671,7 @@ public class MultipleDNDUpload extends LayoutPanel implements HasWorskpaceUpload
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
xhr.send(formdata);
|
xhr.send(formdata);
|
||||||
instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::addNewSubmitToMonitor(Ljava/lang/String;)(uploadUUID);
|
instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::addNewSubmitToMonitor(Ljava/lang/String;)(uploadUUID);
|
||||||
|
|
||||||
|
@ -686,6 +690,8 @@ public class MultipleDNDUpload extends LayoutPanel implements HasWorskpaceUpload
|
||||||
instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::showAlert(Ljava/lang/String;)(msg);
|
instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::showAlert(Ljava/lang/String;)(msg);
|
||||||
}
|
}
|
||||||
instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::reset()();
|
instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::reset()();
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
// Tells the browser that we *can* drop on this target
|
// Tells the browser that we *can* drop on this target
|
||||||
// addEventHandler(drop, 'dragover', cancel);
|
// addEventHandler(drop, 'dragover', cancel);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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;
|
||||||
|
|
|
@ -0,0 +1,105 @@
|
||||||
|
package org.gcube.portlets.widgets.workspaceuploader.server.upload;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import org.gcube.portlets.widgets.workspaceuploader.client.ConstantsWorkspaceUploader;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Class UploadItemProperties.
|
||||||
|
*
|
||||||
|
* contains properties sent from client for any file uploaded
|
||||||
|
*
|
||||||
|
* @author Francesco Mangiacrapa at ISTI-CNR francesco.mangiacrapa@isti.cnr.it
|
||||||
|
*
|
||||||
|
* Aug 1, 2024
|
||||||
|
*/
|
||||||
|
@JsonIgnoreProperties(ignoreUnknown = true)
|
||||||
|
public class UploadItemProperties implements Serializable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final long serialVersionUID = -7226677146789586756L;
|
||||||
|
|
||||||
|
@JsonProperty(ConstantsWorkspaceUploader.CLIENT_UPLOAD_FILEOBJ_FILENAME)
|
||||||
|
private String filename;
|
||||||
|
@JsonProperty(ConstantsWorkspaceUploader.CLIENT_UPLOAD_FILEOBJ_FILESIZE)
|
||||||
|
private Long filesize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new upload item properties.
|
||||||
|
*/
|
||||||
|
public UploadItemProperties() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instantiates a new upload item properties.
|
||||||
|
*
|
||||||
|
* @param filename the filename
|
||||||
|
* @param filesize the filesize
|
||||||
|
*/
|
||||||
|
public UploadItemProperties(String filename, Long filesize) {
|
||||||
|
super();
|
||||||
|
this.filename = filename;
|
||||||
|
this.filesize = filesize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the filename.
|
||||||
|
*
|
||||||
|
* @return the filename
|
||||||
|
*/
|
||||||
|
@JsonProperty(ConstantsWorkspaceUploader.CLIENT_UPLOAD_FILEOBJ_FILENAME)
|
||||||
|
public String getFilename() {
|
||||||
|
return filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the filesize.
|
||||||
|
*
|
||||||
|
* @return the filesize
|
||||||
|
*/
|
||||||
|
@JsonProperty(ConstantsWorkspaceUploader.CLIENT_UPLOAD_FILEOBJ_FILESIZE)
|
||||||
|
public Long getFilesize() {
|
||||||
|
return filesize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the filename.
|
||||||
|
*
|
||||||
|
* @param filename the new filename
|
||||||
|
*/
|
||||||
|
public void setFilename(String filename) {
|
||||||
|
this.filename = filename;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the filesize.
|
||||||
|
*
|
||||||
|
* @param filesize the new filesize
|
||||||
|
*/
|
||||||
|
public void setFilesize(Long filesize) {
|
||||||
|
this.filesize = filesize;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To string.
|
||||||
|
*
|
||||||
|
* @return the string
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append("UploadItemProperties [filename=");
|
||||||
|
builder.append(filename);
|
||||||
|
builder.append(", filesize=");
|
||||||
|
builder.append(filesize);
|
||||||
|
builder.append("]");
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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());
|
||||||
|
|
|
@ -22,6 +22,7 @@ public class WorkspaceUploadFile implements Serializable{
|
||||||
private String fileName;
|
private String fileName;
|
||||||
private String itemId;
|
private String itemId;
|
||||||
private String versionName;
|
private String versionName;
|
||||||
|
private Long fileSize;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new workspace upload file.
|
* Instantiates a new workspace upload file.
|
||||||
|
@ -129,6 +130,20 @@ public class WorkspaceUploadFile implements Serializable{
|
||||||
this.fileName = fileName;
|
this.fileName = fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public Long getFileSize() {
|
||||||
|
return fileSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void setFileSize(Long fileSize) {
|
||||||
|
this.fileSize = fileSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
@ -145,12 +160,8 @@ public class WorkspaceUploadFile implements Serializable{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
|
||||||
* @see java.lang.Object#toString()
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
builder.append("WorkspaceUploadFile [parentId=");
|
builder.append("WorkspaceUploadFile [parentId=");
|
||||||
builder.append(parentId);
|
builder.append(parentId);
|
||||||
|
@ -160,10 +171,10 @@ public class WorkspaceUploadFile implements Serializable{
|
||||||
builder.append(itemId);
|
builder.append(itemId);
|
||||||
builder.append(", versionName=");
|
builder.append(", versionName=");
|
||||||
builder.append(versionName);
|
builder.append(versionName);
|
||||||
|
builder.append(", fileSize=");
|
||||||
|
builder.append(fileSize);
|
||||||
builder.append("]");
|
builder.append("]");
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue