Updated message displaying also version of file after upload completed

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-uploader@146739 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Francesco Mangiacrapa 2017-04-11 09:45:19 +00:00
parent dbf5163ca1
commit 9fe9fa86db
8 changed files with 99 additions and 70 deletions

View File

@ -4,6 +4,7 @@
<Change>[Task #7820] DaD and Browse: create new version of existing
items added</Change>
<Change>Removed currUserId parameter from client-side</Change>
<Change>Updated message displaying also version of file after upload completed</Change>
</Changeset>
<Changeset component="org.gcube.portlets-widgets.workspace-uploader.1-7-0"
date="2017-02-23">

View File

@ -289,11 +289,8 @@ public class DialogUpload extends ClosableDialog implements HasWorskpaceUploadNo
public void onSuccess(final String itemId) {
GWT.log("itemExistsInWorkpaceFolder: "+itemId);
if(itemId!=null){
// HANDLE OWERWRITE
if(Window.confirm(label + " exists in folder. If you continue, a new version will be created")){
removeItemAndSubmitForm(itemId);
updateItemSubmitForm(itemId);
}
removeItemAndSubmitForm(itemId);
updateItemSubmitForm(itemId);
}else
submitForm(); //ITEM does NOT EXIST SO SUBMIT FORM;
}

View File

@ -242,13 +242,12 @@ public class MultipleDilaogUpload extends DialogUpload {
GWT.log("itemExistsInWorkpaceFolder: "
+ itemId);
if (itemId != null) {
// HANDLE OWERWRITE
if (Window
.confirm(label
+ " exists in folder. If you continue, a new version will be created")) {
removeItemAndSubmitForm(itemId);
updateItemSubmitForm(itemId);
}
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

View File

@ -97,7 +97,14 @@ public class UploaderProgressView {
case COMPLETED:
setVisibleBar(true);
text = "<div><img src='"+WorkspaceUploaderResources.getImageCompleted().getUrl()+"'>";
text+="<span style='margin-left:5px; vertical-align: top;'>"+StringUtil.ellipsize(uploader.getFile().getFileName()+" uploaded successfully!", MAX_CHARS, 0)+"</span></div>";
String msgClt = null;
if(uploader.getFile().getVersionName()!=null)
//msgClt = "v. "+ uploader.getFile().getVersionName() +" of "+StringUtil.ellipsize(uploader.getFile().getFileName()+" uploaded successfully!", MAX_CHARS-10, 0);
msgClt = StringUtil.ellipsize(uploader.getFile().getFileName(), MAX_CHARS-23, 0) +" v."+ uploader.getFile().getVersionName() +" uploaded successfully!";
else
msgClt = StringUtil.ellipsize(uploader.getFile().getFileName()+" uploaded successfully!", MAX_CHARS, 0);
text+="<span style='margin-left:5px; vertical-align: top;'>"+msgClt+"</span></div>";
// GWT.log(text);
html.setHTML(text);
html.setTitle(uploader.getStatusDescription());

View File

@ -619,8 +619,6 @@ public class MultipleDNDUpload extends LayoutPanel implements HasWorskpaceUpload
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);
var jsonKeys = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::currentJsonKey;
// var jsonKeys = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::getJsonKeyForFiles(Ljava/lang/String;)
// var jsonKeysMap = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::jsonKeys;
// console.log("jsonKeys: " + jsonKeys);
var xhr = new XMLHttpRequest();
@ -663,46 +661,8 @@ public class MultipleDNDUpload extends LayoutPanel implements HasWorskpaceUpload
if (!isFolder(file)) {
console.log("fileSelected: " + fileSelected);
console.log("files: " + files);
// var jsonKeysMap = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::jsonKeys;
// console.log("jsonKeysMap: " + jsonKeysMap);
// instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::setCurrentJsonKeValue(Ljava/lang/String;)(uploadUUID);
// var keyVal = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::currentJsonKey;
// console.log("keyVal: " + keyVal);
if(files.length == 1){
console.log("one drag, overwrite?");
var wsUtil = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::workspaceUtil;
var folder_parent_id = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::folder_parent_id;
var item_name = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::item_name;
//var scopegroupid = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::scopeGroupId;
console.log("item_name: " + item_name);
var params = folder_parent_id+"="+idfolder+"&"+item_name+"="+files[i].name+"&currGroupId="+scopeGroupId;
//var params = folder_parent_id+"="+idfolder+"&"+item_name+"="+files[i].name+"&currGroupId="+scopeGroupId+"&currUserId="+currUserId;
console.log("params: " + params);
var response = isFileOverwrite(wsUtil, params, "");
console.log("response overwrite: " + response);
if(response!=null && response!=undefined){
console.log("overwrite confirm?");
if($wnd.confirm(files[i].name+" exists in folder. If you continue, a new version will be created")){
overwrite = true;
console.log("overwrite confirmed!");
}else{
overwrite = false;
instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::reset()();
return;
}
}
}
// var xhr = new XMLHttpRequest();
// xhr.open(opts.type, opts.url, true);
formdata.append("isOverwrite", overwrite);
// formdata.append("isOverwrite", overwrite);
//*********uploadFormElement MUST BE THE LAST!!!
formdata.append("isOverwrite", true);
formdata.append('uploadFormElement', file);
// xhr.send(formdata);
// reader.readAsText(file);
}else{
numFolder++;
}

View File

@ -553,6 +553,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
}
}
//saveWorkspaceUploaderInSession(workspaceUploader, request.getSession());
// file.delete();
} catch (InsufficientPrivilegesException e) {
logger.error("Error creating elements", e);
@ -622,7 +623,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
WorkspaceUploaderItem workspaceUploader = new WorkspaceUploaderItem(clientUploadKey);
workspaceUploader.setClientUploadKey(clientUploadKey);
//Create File
WorkspaceUploadFile wsUploadFile = new WorkspaceUploadFile(folderParentId, null, fileName);
WorkspaceUploadFile wsUploadFile = new WorkspaceUploadFile(folderParentId, null, fileName, null);
workspaceUploader.setFile(wsUploadFile);
workspaceUploader.setIsOverwrite(isOverwrite);
return workspaceUploader;

View File

@ -9,6 +9,7 @@ import java.io.InputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import org.gcube.common.homelibary.model.versioning.WorkspaceVersion;
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
import org.gcube.common.homelibrary.home.workspace.Workspace;
import org.gcube.common.homelibrary.home.workspace.WorkspaceFolder;
@ -19,6 +20,7 @@ import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNot
import org.gcube.common.homelibrary.home.workspace.exceptions.WrongDestinationException;
import org.gcube.common.homelibrary.home.workspace.exceptions.WrongItemTypeException;
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile;
import org.gcube.common.homelibrary.util.WorkspaceUtil;
import org.gcube.common.homelibrary.util.zip.UnzipUtil;
import org.gcube.portlets.widgets.workspaceuploader.server.WorkspaceUploadServletStream;
@ -89,6 +91,16 @@ public class WorkspaceUploaderMng {
logger.debug("HL file: "+createdItem.getName() + " with id: "+createdItem.getId() + " uploaded correctly in "+destinationFolder.getPath());
workspaceUploader.getFile().setItemId(createdItem.getId()); //SET HL ID
workspaceUploader.getFile().setParentId(createdItem.getParent().getId());//SET PARENT ID
//ADDING VERSION NAME
if(createdItem instanceof ExternalFile){
ExternalFile file = (ExternalFile) createdItem;
WorkspaceVersion currVersion = file.getCurrentVersion();
workspaceUploader.getFile().setVersionName(currVersion.getName());
logger.debug("HL file: "+createdItem.getName() + " has version: "+currVersion.getName());
}else
logger.debug("HL file: "+createdItem.getName() + " has not version");
workspaceUploader.setStatusDescription("File \""+createdItem.getName()+"\" uploaded correctly in "+destinationFolder.getPath());
workspaceUploader.setUploadStatus(UPLOAD_STATUS.COMPLETED);
WorkspaceUploadServletStream.notifyUploadInSharedFolder(currUser, scopeGroupId, request, httpSession, wa, createdItem.getId(), createdItem.getParent().getId(), isOvewrite);

View File

@ -1,46 +1,80 @@
/**
*
*
*/
package org.gcube.portlets.widgets.workspaceuploader.shared;
import java.io.Serializable;
/**
*
* The Class WorkspaceUploadFile.
*
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
* Aug 3, 2015
*/
public class WorkspaceUploadFile implements Serializable{
/**
*
*
*/
private static final long serialVersionUID = 1513046515926364747L;
private String parentId;
private String fileName;
private String itemId;
private String versionName;
/**
*
* Instantiates a new workspace upload file.
*/
public WorkspaceUploadFile() {
}
/**
* @param parentId
* @param fileName
* Instantiates a new workspace upload file.
*
* @param parentId the parent id
* @param itemId the item id
* @param fileName the file name
* @param versionName the version
*/
public WorkspaceUploadFile(String parentId, String itemId, String fileName) {
public WorkspaceUploadFile(String parentId, String itemId, String fileName, String versionName) {
super();
this.parentId = parentId;
this.itemId = itemId;
this.fileName = fileName;
this.versionName = versionName;
}
/**
* Gets the version name.
*
* @return the version name
*/
public String getVersionName() {
return versionName;
}
/**
* Sets the version name.
*
* @param versionName the new version name
*/
public void setVersionName(String versionName) {
this.versionName = versionName;
}
/**
* Sets the item id.
*
* @param itemId the itemId to set
*/
public void setItemId(String itemId) {
@ -49,6 +83,8 @@ public class WorkspaceUploadFile implements Serializable{
/**
* Gets the parent id.
*
* @return the parentId
*/
public String getParentId() {
@ -56,6 +92,8 @@ public class WorkspaceUploadFile implements Serializable{
}
/**
* Gets the file name.
*
* @return the fileName
*/
public String getFileName() {
@ -63,15 +101,19 @@ public class WorkspaceUploadFile implements Serializable{
}
/**
* Sets the parent id.
*
* @param parentId the parentId to set
*/
public void setParentId(String parentId) {
this.parentId = parentId;
}
/**
* Gets the item id.
*
* @return the itemId
*/
public String getItemId() {
@ -79,6 +121,8 @@ public class WorkspaceUploadFile implements Serializable{
}
/**
* Sets the file name.
*
* @param fileName the fileName to set
*/
public void setFileName(String fileName) {
@ -87,7 +131,7 @@ public class WorkspaceUploadFile implements Serializable{
/*
* (non-Javadoc)
*
*
* @see java.lang.Object#hashCode()
*/
@Override
@ -99,11 +143,14 @@ public class WorkspaceUploadFile implements Serializable{
return hash;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("WorkspaceUploadFile [parentId=");
builder.append(parentId);
@ -111,7 +158,12 @@ public class WorkspaceUploadFile implements Serializable{
builder.append(fileName);
builder.append(", itemId=");
builder.append(itemId);
builder.append(", versionName=");
builder.append(versionName);
builder.append("]");
return builder.toString();
}
}