fixing issue regarding filename https://support.d4science.org/issues/12470#change-74271
added a shuffle message on 100% git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-uploader@171523 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
943d34fde6
commit
e47d5b4165
|
@ -3,7 +3,10 @@
|
|||
date="2018-09-19">
|
||||
<Change>[Feature #11722] Workspace Uploader - Update to StorageHUB
|
||||
</Change>
|
||||
<Change>In case of 100% added the message "Finalising the upload of [filename]"
|
||||
<Change>In case of 100% added the message "Finalising the upload of
|
||||
[filename]"
|
||||
</Change>
|
||||
<Change>[Task #12470] Check uploading of files in the Workpace by the drag and drop facility on Windows Operating System
|
||||
</Change>
|
||||
</Changeset>
|
||||
<Changeset component="org.gcube.portlets-widgets.workspace-uploader.1-8-0"
|
||||
|
|
|
@ -146,7 +146,8 @@ public class UploaderProgressView {
|
|||
if(uploader.getUploadProgress().getLastEvent().getReadPercentage()<100){
|
||||
msg = StringUtil.ellipsize(uploader.getFile().getFileName(), MAX_CHARS, 0);
|
||||
}else{ //is 100%
|
||||
msg = StringUtil.ellipsize("Finalising the upload of "+uploader.getFile().getFileName(), MAX_CHARS, 0);
|
||||
String message = UploadingMessageBeforeCompleted.getMessage(uploader.getClientUploadKey(), uploader.getFile().getFileName());
|
||||
msg = StringUtil.ellipsize(message, MAX_CHARS, 0);
|
||||
}
|
||||
|
||||
text+="<span style='margin-left:5px; vertical-align: top;'>"+msg+"</span>";
|
||||
|
|
|
@ -0,0 +1,73 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.widgets.workspaceuploader.client.uploader;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* The Class UploadingMessageBeforeCompleted.
|
||||
*
|
||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||
* Sep 19, 2018
|
||||
*/
|
||||
public class UploadingMessageBeforeCompleted {
|
||||
|
||||
public static String[] MESSAGES = new String[]{
|
||||
"Finalising the upload of $",
|
||||
"Setting the privacy policy for $",
|
||||
"Identifying devices where to persist $",
|
||||
"Replicating $ on multiple servers",
|
||||
"Setting the active replica of $",
|
||||
"Setting the access policy for $",
|
||||
"Checking the consistency of $",
|
||||
"Setting the business metadata for $",
|
||||
"Accounting the operation for $"
|
||||
};
|
||||
|
||||
public static int OFFSET = 15;
|
||||
|
||||
public static Map<String,Long> mapStartTime = new HashMap<String, Long>();
|
||||
|
||||
|
||||
/**
|
||||
* Gets the message.
|
||||
*
|
||||
* @param fileUploadKey the file upload key
|
||||
* @param fileName the file name
|
||||
* @return the message
|
||||
*/
|
||||
public static String getMessage(String fileUploadKey, String fileName) {
|
||||
|
||||
if(fileUploadKey==null)
|
||||
return MESSAGES[0].replace("$", fileName);
|
||||
|
||||
Long uploadingStartTime = mapStartTime.get(fileUploadKey);
|
||||
|
||||
if(uploadingStartTime==null){
|
||||
uploadingStartTime = System.currentTimeMillis();
|
||||
mapStartTime.put(fileUploadKey, uploadingStartTime);
|
||||
}
|
||||
|
||||
long diff = System.currentTimeMillis() - uploadingStartTime;
|
||||
int index = 0;
|
||||
try{
|
||||
//TO SEC
|
||||
diff = diff/1000;
|
||||
//System.out.println("DIFF TO SEC: "+diff);
|
||||
int divResult = (int) (diff/OFFSET);
|
||||
index = divResult>=MESSAGES.length?MESSAGES.length-1:divResult;
|
||||
//MESSAGES.length
|
||||
}catch(Exception e){
|
||||
//silent
|
||||
index = 0;
|
||||
}
|
||||
|
||||
return MESSAGES[index].replace("$", fileName);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -486,6 +486,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
|||
try {
|
||||
//we calculate an unique name for the current destination
|
||||
String itemName = fileName;
|
||||
itemName = FilenameUtils.getBaseName(itemName); //Using base name in order to avoid Task #12470
|
||||
|
||||
logger.debug("getItemName from HL");
|
||||
/*if(!isOverwrite){
|
||||
|
@ -552,7 +553,9 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
|||
String contentType = uploadItem.getContentType();
|
||||
logger.debug("Stream content type: "+contentType);
|
||||
|
||||
if(uploadType.compareTo(ARCHIVE)==0){ //UPLOAD ARCHIVE
|
||||
|
||||
if(uploadType.compareTo(ARCHIVE)==0){
|
||||
//UPLOAD ARCHIVE
|
||||
|
||||
logger.debug("Uploding archive....");
|
||||
boolean isSupportedArchive = false;
|
||||
|
@ -585,10 +588,10 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
|||
return;
|
||||
}
|
||||
|
||||
}else{ //UPLOAD FILE. IT IS DEFAULT CASE
|
||||
//I don't need to check this if(uploadType.compareTo(FILE)==0) {//IS FILE UPLOAD
|
||||
logger.debug("Uploding file....");
|
||||
}else{
|
||||
//UPLOAD FILE. IT IS DEFAULT CASE
|
||||
|
||||
logger.debug("Uploding file....");
|
||||
workspaceUploader = WorkspaceUploaderMng.uploadFile(storageHubWrapper, user, scopeGroupId, request, workspaceUploader, request.getSession(), itemName, inputStream, destinationFolder, contentType, isOverwrite, size);
|
||||
|
||||
if(workspaceUploader==null)
|
||||
|
|
Loading…
Reference in New Issue