feature_27934 #2
|
@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
|
||||||
## [v2.1.1-SNAPSHOT] - 2024-07-29
|
## [v2.1.1-SNAPSHOT] - 2024-07-29
|
||||||
|
|
||||||
- [#27898] Updated `uploadFile` and `uploadArchive` methods. They include the `fileSize` parameter
|
- [#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
|
## [v2.1.0] - 2022-05-03
|
||||||
|
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -88,37 +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
|
String sanitizedValue = normalizedFileName.substring(normalizedFileName.lastIndexOf("\\") + 1); // remove
|
||||||
// if exists
|
// 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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -198,17 +210,20 @@ public class MultipleDilaogUpload extends DialogUpload {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] files = null;
|
|
||||||
GWT.log("Current Uploader has id: " + fileUploadID);
|
GWT.log("Current Uploader has id: " + fileUploadID);
|
||||||
String filesSelected = getFilesSelected(fileUploadID, FILE_DELEMITER);
|
JavaScriptObject filesSelected = getFilesSelected(fileUploadID);
|
||||||
GWT.log("getFilesSelected: " + filesSelected);
|
|
||||||
files = filesSelected.split(FILE_DELEMITER);
|
JSONArray jsonArray = new JSONArray(filesSelected);
|
||||||
|
if(jsonArray!=null)
|
||||||
|
GWT.log("sono array");
|
||||||
|
|
||||||
|
GWT.log("getFilesSelected: " + jsonArray);
|
||||||
|
|
||||||
if (isLimitExceeded(files.length))
|
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);
|
||||||
|
@ -279,7 +294,11 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -352,16 +371,20 @@ public class MultipleDilaogUpload extends DialogUpload {
|
||||||
* @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;
|
||||||
|
@ -100,44 +107,48 @@ public class WorkspaceFieldsUploadManager {
|
||||||
* Generate new upload client keys.
|
* Generate new upload client keys.
|
||||||
*
|
*
|
||||||
* @param filesSelected the files selected
|
* @param filesSelected the files selected
|
||||||
* @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);
|
||||||
|
|
|
@ -9,7 +9,6 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
@ -25,7 +24,6 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
import javax.servlet.http.HttpSession;
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import org.apache.commons.fileupload.FileItemFactory;
|
import org.apache.commons.fileupload.FileItemFactory;
|
||||||
import org.apache.commons.fileupload.FileItemHeaders;
|
|
||||||
import org.apache.commons.fileupload.FileItemIterator;
|
import org.apache.commons.fileupload.FileItemIterator;
|
||||||
import org.apache.commons.fileupload.FileItemStream;
|
import org.apache.commons.fileupload.FileItemStream;
|
||||||
import org.apache.commons.fileupload.FileUploadBase;
|
import org.apache.commons.fileupload.FileUploadBase;
|
||||||
|
@ -36,6 +34,7 @@ import org.apache.commons.fileupload.util.Streams;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
|
import org.gcube.com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.gcube.common.portal.PortalContext;
|
import org.gcube.common.portal.PortalContext;
|
||||||
import org.gcube.common.storagehub.model.items.FolderItem;
|
import org.gcube.common.storagehub.model.items.FolderItem;
|
||||||
import org.gcube.common.storagehub.model.items.Item;
|
import org.gcube.common.storagehub.model.items.Item;
|
||||||
|
@ -51,6 +50,7 @@ import org.gcube.portlets.widgets.workspaceuploader.client.ConstantsWorkspaceUpl
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.server.notification.NotificationsWorkspaceUploader;
|
import org.gcube.portlets.widgets.workspaceuploader.server.notification.NotificationsWorkspaceUploader;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.server.notification.NotificationsWorkspaceUploaderProducer;
|
import org.gcube.portlets.widgets.workspaceuploader.server.notification.NotificationsWorkspaceUploaderProducer;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.server.upload.AbstractUploadProgressListener;
|
import org.gcube.portlets.widgets.workspaceuploader.server.upload.AbstractUploadProgressListener;
|
||||||
|
import org.gcube.portlets.widgets.workspaceuploader.server.upload.UploadItemProperties;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.server.upload.MemoryUploadListener;
|
import org.gcube.portlets.widgets.workspaceuploader.server.upload.MemoryUploadListener;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.server.upload.UploadCanceledException;
|
import org.gcube.portlets.widgets.workspaceuploader.server.upload.UploadCanceledException;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.server.upload.UploadProgressInputStream;
|
import org.gcube.portlets.widgets.workspaceuploader.server.upload.UploadProgressInputStream;
|
||||||
|
@ -122,6 +122,11 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
|
|
||||||
private static boolean appEngine = false;
|
private static boolean appEngine = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Inits the.
|
||||||
|
*
|
||||||
|
* @throws ServletException the servlet exception
|
||||||
|
*/
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
@ -246,16 +251,20 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
if (item.isFormField() && CLIENT_UPLOAD_KEYS.equals(item.getFieldName())) {
|
if (item.isFormField() && CLIENT_UPLOAD_KEYS.equals(item.getFieldName())) {
|
||||||
String jsonClientUploadKey = Streams.asString(item.openStream());
|
String jsonClientUploadKey = Streams.asString(item.openStream());
|
||||||
logger.debug("CLIENT_UPLOAD_KEY OK " + jsonClientUploadKey);
|
logger.debug("CLIENT_UPLOAD_KEY OK " + jsonClientUploadKey);
|
||||||
LinkedHashMap<String, String> mapKeys = parseJSONClientUploadKeys(jsonClientUploadKey);
|
|
||||||
listClientUploadKeys = new ArrayList<String>(mapKeys.keySet());
|
LinkedHashMap<String, UploadItemProperties> theMapOfUploadingFiles = parseJSONClientMapUploadPropertyFiles(
|
||||||
|
jsonClientUploadKey);
|
||||||
|
listClientUploadKeys = new ArrayList<String>(theMapOfUploadingFiles.keySet());
|
||||||
removeListenersIfDone(session, listClientUploadKeys);
|
removeListenersIfDone(session, listClientUploadKeys);
|
||||||
for (String clientUploadKey : listClientUploadKeys) {
|
for (String clientUploadKey : listClientUploadKeys) {
|
||||||
String fileName = mapKeys.get(clientUploadKey);
|
UploadItemProperties uip = theMapOfUploadingFiles.get(clientUploadKey);
|
||||||
|
String filename = uip.getFilename();
|
||||||
|
Long filesize = uip.getFilesize();
|
||||||
WorkspaceUploaderItem workspaceUploader = createNewWorkspaceUploader(clientUploadKey,
|
WorkspaceUploaderItem workspaceUploader = createNewWorkspaceUploader(clientUploadKey,
|
||||||
destinationId, mapKeys.get(clientUploadKey), isOverwrite);
|
destinationId, filename, filesize, isOverwrite);
|
||||||
logger.debug("created " + workspaceUploader);
|
logger.debug("created " + workspaceUploader);
|
||||||
saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.WAIT,
|
saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.WAIT,
|
||||||
"Uploading " + fileName + " at 0%", request.getSession());
|
"Uploading " + filename + " at 0%", request.getSession());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,6 +303,14 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Coy stream to file.
|
||||||
|
*
|
||||||
|
* @param in the in
|
||||||
|
* @param fileExtension the file extension
|
||||||
|
* @return the file
|
||||||
|
* @throws IOException Signals that an I/O exception has occurred.
|
||||||
|
*/
|
||||||
public File coyStreamToFile(InputStream in, String fileExtension) throws IOException {
|
public File coyStreamToFile(InputStream in, String fileExtension) throws IOException {
|
||||||
File tempFile = File.createTempFile(UUID.randomUUID().toString(), fileExtension);
|
File tempFile = File.createTempFile(UUID.randomUUID().toString(), fileExtension);
|
||||||
tempFile.deleteOnExit();
|
tempFile.deleteOnExit();
|
||||||
|
@ -302,25 +319,6 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
return tempFile;
|
return tempFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
// public static InputStream clone(final InputStream inputStream) {
|
|
||||||
// try {
|
|
||||||
// inputStream.mark(0);
|
|
||||||
// ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
||||||
// byte[] buffer = new byte[1024];
|
|
||||||
// int readLength = 0;
|
|
||||||
// while ((readLength = inputStream.read(buffer)) != -1) {
|
|
||||||
// outputStream.write(buffer, 0, readLength);
|
|
||||||
// }
|
|
||||||
// inputStream.reset();
|
|
||||||
// outputStream.flush();
|
|
||||||
// return new ByteArrayInputStream(outputStream.toByteArray());
|
|
||||||
// }
|
|
||||||
// catch (Exception ex) {
|
|
||||||
// ex.printStackTrace();
|
|
||||||
// }
|
|
||||||
// return null;
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the listener if done.
|
* Removes the listener if done.
|
||||||
*
|
*
|
||||||
|
@ -381,6 +379,53 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
return keyFiles;
|
return keyFiles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses the JSON client map upload property files.
|
||||||
|
*
|
||||||
|
* @param jsonClientUploadKeys the json client upload keys
|
||||||
|
* @return the linked hash map
|
||||||
|
* @throws FileUploadException the file upload exception
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("rawtypes")
|
||||||
|
private static LinkedHashMap<String, UploadItemProperties> parseJSONClientMapUploadPropertyFiles(
|
||||||
|
final String jsonClientUploadKeys) throws FileUploadException {
|
||||||
|
JSONTokener tokener = new JSONTokener(jsonClientUploadKeys);
|
||||||
|
JSONObject root;
|
||||||
|
LinkedHashMap<String, UploadItemProperties> keyFiles = null;
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
try {
|
||||||
|
|
||||||
|
root = new JSONObject(tokener);
|
||||||
|
JSONArray jsonArray = root.getJSONArray(JSON_CLIENT_KEYS);
|
||||||
|
keyFiles = new LinkedHashMap<String, UploadItemProperties>(jsonArray.length());
|
||||||
|
logger.debug("jsonArray :" + jsonArray.toString());
|
||||||
|
for (int i = 0; i < jsonArray.length(); i++) {
|
||||||
|
JSONObject object = jsonArray.getJSONObject(i);
|
||||||
|
logger.debug("object :" + object);
|
||||||
|
String key = (String) object.keys().next();
|
||||||
|
String value = object.getString(key);
|
||||||
|
UploadItemProperties uploadRequest;
|
||||||
|
try {
|
||||||
|
uploadRequest = objectMapper.readValue(value, UploadItemProperties.class);
|
||||||
|
logger.debug("key :" + key + ", value: " + uploadRequest);
|
||||||
|
keyFiles.put(key, uploadRequest);
|
||||||
|
} catch (IOException e) {
|
||||||
|
String theError = "Serialization issue on: " + key;
|
||||||
|
logger.error(theError, e);
|
||||||
|
throw new JSONException(theError);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (JSONException e) {
|
||||||
|
logger.error("An error occurred during parsing file names: " + keyFiles, e);
|
||||||
|
throw new FileUploadException("An error occurred during parsing file names");
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.debug("keyFiles: " + keyFiles);
|
||||||
|
return keyFiles;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Upload data.
|
* Upload data.
|
||||||
*
|
*
|
||||||
|
@ -536,31 +581,24 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
logger.debug("purged item name is: " + itemName);
|
logger.debug("purged item name is: " + itemName);
|
||||||
// HttpServletRequest size
|
// HttpServletRequest size
|
||||||
long requestContentLenght = getContentLength(request);
|
long requestContentLenght = getContentLength(request);
|
||||||
logger.info(
|
logger.info("HttpServletRequest " + FileUploadBase.CONTENT_LENGTH + "/size is: " + requestContentLenght);
|
||||||
"HttpServletRequest " + FileUploadBase.CONTENT_LENGTH + "/size is: " + requestContentLenght);
|
|
||||||
|
|
||||||
Long fileSize = null;
|
Long fileSize = workspaceUploader.getFile().getFileSize();
|
||||||
FileItemHeaders itemHeaders = uploadItem.getHeaders();
|
/*
|
||||||
if (itemHeaders != null) {
|
* FileItemHeaders itemHeaders = uploadItem.getHeaders(); if (itemHeaders !=
|
||||||
Iterator<String> headerNames = uploadItem.getHeaders().getHeaderNames();
|
* null) { Iterator<String> headerNames =
|
||||||
while(headerNames.hasNext()) {
|
* uploadItem.getHeaders().getHeaderNames(); while(headerNames.hasNext()) {
|
||||||
String headerName = headerNames.next();
|
* String headerName = headerNames.next(); logger.info("headerName: "+headerName
|
||||||
logger.info("headerName: "+headerName +" value: "+itemHeaders.getHeader(headerName));
|
* +" value: "+itemHeaders.getHeader(headerName)); }
|
||||||
}
|
*
|
||||||
|
* String contentLength = itemHeaders.getHeader(FileUploadBase.CONTENT_LENGTH);
|
||||||
String contentLength = itemHeaders.getHeader(FileUploadBase.CONTENT_LENGTH);
|
* if (contentLength != null) { try { fileSize = Long.parseLong(contentLength);
|
||||||
if (contentLength != null) {
|
* } catch (Exception e) { logger.warn("Error on getting fileSize", e); } } }
|
||||||
try {
|
*/
|
||||||
fileSize = Long.parseLong(contentLength);
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.warn("Error on getting fileSize", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.info("File " + FileUploadBase.CONTENT_LENGTH + "/size is: " + fileSize);
|
logger.info("File size is: " + fileSize);
|
||||||
|
|
||||||
if(fileSize==null)
|
if (fileSize == null)
|
||||||
fileSize = requestContentLenght;
|
fileSize = requestContentLenght;
|
||||||
|
|
||||||
// CONFIRM DESTINATION FOLDER
|
// CONFIRM DESTINATION FOLDER
|
||||||
|
@ -714,16 +752,19 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
* @param clientUploadKey the client upload key
|
* @param clientUploadKey the client upload key
|
||||||
* @param folderParentId the folder parent id
|
* @param folderParentId the folder parent id
|
||||||
* @param fileName the file name
|
* @param fileName the file name
|
||||||
|
* @param filesize
|
||||||
* @param isOverwrite the is overwrite
|
* @param isOverwrite the is overwrite
|
||||||
* @return the workspace uploader item
|
* @return the workspace uploader item
|
||||||
*/
|
*/
|
||||||
private WorkspaceUploaderItem createNewWorkspaceUploader(String clientUploadKey, String folderParentId,
|
private WorkspaceUploaderItem createNewWorkspaceUploader(String clientUploadKey, String folderParentId,
|
||||||
String fileName, boolean isOverwrite) {
|
String fileName, Long filesize, boolean isOverwrite) {
|
||||||
// CLIENT UPLOAD IS THE KEY
|
// CLIENT UPLOAD IS THE KEY
|
||||||
WorkspaceUploaderItem workspaceUploader = new WorkspaceUploaderItem(clientUploadKey);
|
WorkspaceUploaderItem workspaceUploader = new WorkspaceUploaderItem(clientUploadKey);
|
||||||
workspaceUploader.setClientUploadKey(clientUploadKey);
|
workspaceUploader.setClientUploadKey(clientUploadKey);
|
||||||
// Create File
|
// Create File
|
||||||
WorkspaceUploadFile wsUploadFile = new WorkspaceUploadFile(folderParentId, null, fileName, null);
|
WorkspaceUploadFile wsUploadFile = new WorkspaceUploadFile(folderParentId, null, fileName, null);
|
||||||
|
wsUploadFile.setFileSize(filesize);
|
||||||
|
|
||||||
workspaceUploader.setFile(wsUploadFile);
|
workspaceUploader.setFile(wsUploadFile);
|
||||||
workspaceUploader.setIsOverwrite(isOverwrite);
|
workspaceUploader.setIsOverwrite(isOverwrite);
|
||||||
return workspaceUploader;
|
return workspaceUploader;
|
||||||
|
@ -795,7 +836,6 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
* @param scopeGroupId the scope group id
|
* @param scopeGroupId the scope group id
|
||||||
* @param request the request
|
* @param request the request
|
||||||
* @param httpSession the http session
|
* @param httpSession the http session
|
||||||
* @param workspace the workspace
|
|
||||||
* @param itemId the item id
|
* @param itemId the item id
|
||||||
* @param destinationFolderId the destination folder id
|
* @param destinationFolderId the destination folder id
|
||||||
* @param isOverwrite the is overwrite
|
* @param isOverwrite the is overwrite
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -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.
|
||||||
|
@ -128,6 +129,20 @@ public class WorkspaceUploadFile implements Serializable{
|
||||||
public void setFileName(String fileName) {
|
public void setFileName(String fileName) {
|
||||||
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