completed upload archive integration
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-uploader@171516 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
471cb428a9
commit
168cc2dc2d
|
@ -75,4 +75,10 @@ public interface WorkspaceUploaderIcons extends ClientBundle {
|
||||||
*/
|
*/
|
||||||
@Source("upload.gif")
|
@Source("upload.gif")
|
||||||
ImageResource uploadIcon();
|
ImageResource uploadIcon();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Source("abort.png")
|
||||||
|
ImageResource abort();
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,15 @@ public class WorkspaceUploaderResources {
|
||||||
return new Image(ICONS.cancel());
|
return new Image(ICONS.cancel());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the image cancel.
|
||||||
|
*
|
||||||
|
* @return the image cancel
|
||||||
|
*/
|
||||||
|
public static Image getImageAbort() {
|
||||||
|
return new Image(ICONS.abort());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the image cancel red.
|
* Gets the image cancel red.
|
||||||
*
|
*
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 319 B |
|
@ -80,7 +80,8 @@ public class TimerUpload extends Timer{
|
||||||
cancel();
|
cancel();
|
||||||
monitor.goNextUploaderAfterKey(workspaceUploader.getClientUploadKey());
|
monitor.goNextUploaderAfterKey(workspaceUploader.getClientUploadKey());
|
||||||
}else if(result.getUploadStatus().equals(UPLOAD_STATUS.FAILED)){
|
}else if(result.getUploadStatus().equals(UPLOAD_STATUS.FAILED)){
|
||||||
GWT.log("Upload Failed "+result.getFile().getItemId() +" name: "+result.getFile().getFileName());
|
//GWT.log("Upload Failed "+result.getFile().getItemId() +" name: "+result.getFile().getFileName());
|
||||||
|
GWT.log("Upload Failed Upload Key: "+result.getClientUploadKey() +" status description: "+result.getStatusDescription());
|
||||||
// monitor.deleteUploaderByClientKey(workspaceUploader.getClientUploadKey());
|
// monitor.deleteUploaderByClientKey(workspaceUploader.getClientUploadKey());
|
||||||
// queue.remove(workspaceUploader.getClientUploadKey());
|
// queue.remove(workspaceUploader.getClientUploadKey());
|
||||||
monitor.notifyUploadError(result.getFile().getParentId(), null, result.getStatusDescription(), null);
|
monitor.notifyUploadError(result.getFile().getParentId(), null, result.getStatusDescription(), null);
|
||||||
|
@ -90,7 +91,7 @@ public class TimerUpload extends Timer{
|
||||||
monitor.goNextUploaderAfterKey(workspaceUploader.getClientUploadKey());
|
monitor.goNextUploaderAfterKey(workspaceUploader.getClientUploadKey());
|
||||||
}else if(result.getUploadStatus().equals(UPLOAD_STATUS.ABORTED)){
|
}else if(result.getUploadStatus().equals(UPLOAD_STATUS.ABORTED)){
|
||||||
// monitor.deleteUploaderByClientKey(workspaceUploader.getClientUploadKey());
|
// monitor.deleteUploaderByClientKey(workspaceUploader.getClientUploadKey());
|
||||||
GWT.log("Upload Aborted "+result.getFile().getItemId() +" name: "+result.getFile().getFileName());
|
GWT.log("Upload Aborted Upload Key: "+result.getClientUploadKey() +" status description: "+result.getStatusDescription());
|
||||||
cancel();
|
cancel();
|
||||||
monitor.notifyUploadAborted(result.getFile().getParentId(), null);
|
monitor.notifyUploadAborted(result.getFile().getParentId(), null);
|
||||||
monitor.goNextUploaderAfterKey(workspaceUploader.getClientUploadKey());
|
monitor.goNextUploaderAfterKey(workspaceUploader.getClientUploadKey());
|
||||||
|
|
|
@ -120,6 +120,18 @@ public class UploaderProgressView {
|
||||||
// GWT.log(text);
|
// GWT.log(text);
|
||||||
html.setHTML(text);
|
html.setHTML(text);
|
||||||
html.setTitle(uploader.getStatusDescription());
|
html.setTitle(uploader.getStatusDescription());
|
||||||
|
// bar.update(uploader.getUploadProgress().getLastEvent().getReadPercentage());
|
||||||
|
try{
|
||||||
|
hpBar.clear();
|
||||||
|
}catch (Exception e) {}
|
||||||
|
break;
|
||||||
|
case ABORTED:
|
||||||
|
setVisibleBar(true);
|
||||||
|
text = "<div><img src='"+WorkspaceUploaderResources.getImageAbort().getUrl()+"'>";
|
||||||
|
text+="<span style='margin-left:5px; vertical-align: top;'>"+StringUtil.ellipsize(uploader.getStatusDescription(), MAX_CHARS, 0)+"</span></div>";
|
||||||
|
// GWT.log(text);
|
||||||
|
html.setHTML(text);
|
||||||
|
html.setTitle(uploader.getStatusDescription());
|
||||||
// bar.update(uploader.getUploadProgress().getLastEvent().getReadPercentage());
|
// bar.update(uploader.getUploadProgress().getLastEvent().getReadPercentage());
|
||||||
try{
|
try{
|
||||||
hpBar.clear();
|
hpBar.clear();
|
||||||
|
|
|
@ -8,8 +8,10 @@ import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
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.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
@ -104,6 +106,15 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
|
|
||||||
public static final String ARCHIVE = "Archive";
|
public static final String ARCHIVE = "Archive";
|
||||||
|
|
||||||
|
public static final Map<String, String> SUPPORTED_UNPACKING_ARCHIVE = new HashMap<String, String>() {{
|
||||||
|
put("zip","application/zip"); //.zip
|
||||||
|
put("7z","application/x-7z-compressed"); //.7z
|
||||||
|
put("tar","application/x-tar"); //tar
|
||||||
|
put("java archive","application/java-archive");//.jar
|
||||||
|
put("jar","application/x-java-archive");
|
||||||
|
put("gtar","application/x-gtar");
|
||||||
|
}};
|
||||||
|
|
||||||
// public static final String D4ST = Extensions.REPORT_TEMPLATE.getName(); //extension of Report Template type
|
// public static final String D4ST = Extensions.REPORT_TEMPLATE.getName(); //extension of Report Template type
|
||||||
// public static final String D4SR = Extensions.REPORT.getName(); //extension of Report type
|
// public static final String D4SR = Extensions.REPORT.getName(); //extension of Report type
|
||||||
|
|
||||||
|
@ -538,13 +549,25 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
|
|
||||||
saveWorkspaceUploaderInSession(workspaceUploader, request.getSession());
|
saveWorkspaceUploaderInSession(workspaceUploader, request.getSession());
|
||||||
|
|
||||||
String contentType = null; //It's set into HL
|
String contentType = uploadItem.getContentType();
|
||||||
|
logger.debug("Stream content type: "+contentType);
|
||||||
|
|
||||||
if(uploadType.compareTo(ARCHIVE)==0){ //UPLOAD ARCHIVE
|
if(uploadType.compareTo(ARCHIVE)==0){ //UPLOAD ARCHIVE
|
||||||
|
|
||||||
//TODO UPLOAD ARCHIVE
|
logger.debug("Uploding archive....");
|
||||||
logger.debug("Archive content type: "+uploadItem.getContentType());
|
boolean isSupportedArchive = false;
|
||||||
|
for (String archive_extension : SUPPORTED_UNPACKING_ARCHIVE.keySet()) {
|
||||||
|
|
||||||
|
//is content-type supported?
|
||||||
|
if(SUPPORTED_UNPACKING_ARCHIVE.get(archive_extension).compareTo(uploadItem.getContentType())==0){
|
||||||
|
isSupportedArchive = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isSupportedArchive){ //Uploading Archive OK
|
||||||
|
|
||||||
|
logger.debug("Supported archive " +uploadItem.getContentType() +" for unpacking");
|
||||||
workspaceUploader = WorkspaceUploaderMng.uploadArchive(storageHubWrapper, user, scopeGroupId, workspaceUploader, request, itemName, inputStream, destinationFolder, size);
|
workspaceUploader = WorkspaceUploaderMng.uploadArchive(storageHubWrapper, user, scopeGroupId, workspaceUploader, request, itemName, inputStream, destinationFolder, size);
|
||||||
// if (MimeTypeUtil.isZipContentType(uploadItem.getContentType())){ //UNZIP??
|
// if (MimeTypeUtil.isZipContentType(uploadItem.getContentType())){ //UNZIP??
|
||||||
// logger.debug("Unziping content");
|
// logger.debug("Unziping content");
|
||||||
|
@ -555,8 +578,16 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
|
|
||||||
sendMessage(response, workspaceUploader.getIdentifier());
|
sendMessage(response, workspaceUploader.getIdentifier());
|
||||||
|
|
||||||
|
}else{
|
||||||
|
logger.warn("Unsuppoterd archive for unpacking: " +uploadItem.getContentType());
|
||||||
|
saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.ABORTED, "Unpacking not supported for: "+uploadItem.getContentType()+" Supported archive are: "+SUPPORTED_UNPACKING_ARCHIVE.keySet().toString(), request.getSession());
|
||||||
|
sendError(response, "Internal error: Unpacking not supported for "+uploadItem.getContentType());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
}else{ //UPLOAD FILE. IT IS DEFAULT CASE
|
}else{ //UPLOAD FILE. IT IS DEFAULT CASE
|
||||||
//I don't need to check this if(uploadType.compareTo(FILE)==0) {//IS FILE UPLOAD
|
//I don't need to check this if(uploadType.compareTo(FILE)==0) {//IS FILE UPLOAD
|
||||||
|
logger.debug("Uploding file....");
|
||||||
|
|
||||||
workspaceUploader = WorkspaceUploaderMng.uploadFile(storageHubWrapper, user, scopeGroupId, request, workspaceUploader, request.getSession(), itemName, inputStream, destinationFolder, contentType, isOverwrite, size);
|
workspaceUploader = WorkspaceUploaderMng.uploadFile(storageHubWrapper, user, scopeGroupId, request, workspaceUploader, request.getSession(), itemName, inputStream, destinationFolder, contentType, isOverwrite, size);
|
||||||
|
|
||||||
|
@ -569,29 +600,29 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
|
|
||||||
} catch (InsufficientPrivilegesException e) {
|
} catch (InsufficientPrivilegesException e) {
|
||||||
logger.error("Error creating elements", e);
|
logger.error("Error creating elements", e);
|
||||||
saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "An error occurred in the upload. Insufficient privileges", request.getSession());
|
saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "Uploading error. Insufficient privileges", request.getSession());
|
||||||
sendError(response, "Internal error: Insufficient privileges");
|
sendError(response, "Internal error: Insufficient privileges");
|
||||||
return;
|
return;
|
||||||
} catch (InternalErrorException e) {
|
} catch (InternalErrorException e) {
|
||||||
logger.error("Error creating elements", e);
|
logger.error("Error creating elements", e);
|
||||||
saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "An error occurred in the upload:"+e.getMessage(), request.getSession());
|
saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "Uploading error:"+e.getMessage(), request.getSession());
|
||||||
sendError(response, "Internal error: "+e.getMessage());
|
sendError(response, "Internal error: "+e.getMessage());
|
||||||
return;
|
return;
|
||||||
} catch (ItemAlreadyExistException e) {
|
} catch (ItemAlreadyExistException e) {
|
||||||
logger.error("Error creating elements", e);
|
logger.error("Error creating elements", e);
|
||||||
saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "An error occurred in the upload. An item with that name already exists", request.getSession());
|
saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "Uploading error. An item with that name already exists", request.getSession());
|
||||||
sendError(response, "Internal error: An item with that name already exists");
|
sendError(response, "Internal error: An item with that name already exists");
|
||||||
return;
|
return;
|
||||||
} catch (IOException e){
|
} catch (IOException e){
|
||||||
logger.error("Error creating elements, is it cancel?", e);
|
logger.error("Error creating elements, is it cancel?", e);
|
||||||
saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "An error occurred in the upload", request.getSession());
|
saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "Uploading error", request.getSession());
|
||||||
sendError(response, "Internal error: An item with that name already exists");
|
sendError(response, "Internal error: An item with that name already exists");
|
||||||
return;
|
return;
|
||||||
// sendError(response, "Internal error: An item with that name already exists");
|
// sendError(response, "Internal error: An item with that name already exists");
|
||||||
// return;
|
// return;
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
logger.error("Error creating elements", e);
|
logger.error("Error creating elements", e);
|
||||||
saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "An error occurred in the upload. "+e.getMessage(), request.getSession());
|
saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "Uploading error. "+e.getMessage(), request.getSession());
|
||||||
// sendError(response, "Internal error: An error occurred on uploading the file, try again later");
|
// sendError(response, "Internal error: An error occurred on uploading the file, try again later");
|
||||||
// return;
|
// return;
|
||||||
}finally{
|
}finally{
|
||||||
|
|
|
@ -111,7 +111,7 @@ public class WorkspaceUploaderMng {
|
||||||
workspaceUploader.setUploadStatus(UPLOAD_STATUS.COMPLETED);
|
workspaceUploader.setUploadStatus(UPLOAD_STATUS.COMPLETED);
|
||||||
WorkspaceUploadServletStream.notifyUploadInSharedFolder(storageWrapper, currUser, scopeGroupId, request, httpSession, createdItem.getId(), createdItem.getParentId(), isOvewrite);
|
WorkspaceUploadServletStream.notifyUploadInSharedFolder(storageWrapper, currUser, scopeGroupId, request, httpSession, createdItem.getId(), createdItem.getParentId(), isOvewrite);
|
||||||
}else{
|
}else{
|
||||||
workspaceUploader.setStatusDescription("An error occurred during upload: \""+itemName + "\". Try again");
|
workspaceUploader.setStatusDescription("Error on uploading: \""+itemName + "\". Try again");
|
||||||
workspaceUploader.setUploadStatus(UPLOAD_STATUS.FAILED);
|
workspaceUploader.setUploadStatus(UPLOAD_STATUS.FAILED);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -121,7 +121,7 @@ public class WorkspaceUploaderMng {
|
||||||
}
|
}
|
||||||
} catch (InternalErrorException e) {
|
} catch (InternalErrorException e) {
|
||||||
logger.error("Error during upload: ",e);
|
logger.error("Error during upload: ",e);
|
||||||
workspaceUploader.setStatusDescription("An error occurred server-side during upload: "+itemName+". "+e.getMessage() +". Try again");
|
workspaceUploader.setStatusDescription("Error on uploading: "+itemName+". "+e.getMessage());
|
||||||
workspaceUploader.setUploadStatus(UPLOAD_STATUS.FAILED);
|
workspaceUploader.setUploadStatus(UPLOAD_STATUS.FAILED);
|
||||||
try {
|
try {
|
||||||
WsUtil.putWorkspaceUploaderInSession(httpSession, workspaceUploader);
|
WsUtil.putWorkspaceUploaderInSession(httpSession, workspaceUploader);
|
||||||
|
@ -222,7 +222,7 @@ public class WorkspaceUploaderMng {
|
||||||
final boolean isOvewrite = false;
|
final boolean isOvewrite = false;
|
||||||
WorkspaceUploadServletStream.notifyUploadInSharedFolder(storageWrapper, currUser, scopeGroupId, request, httpSession, createdItem.getId(), createdItem.getParentId(), isOvewrite);
|
WorkspaceUploadServletStream.notifyUploadInSharedFolder(storageWrapper, currUser, scopeGroupId, request, httpSession, createdItem.getId(), createdItem.getParentId(), isOvewrite);
|
||||||
}else{
|
}else{
|
||||||
workspaceUploader.setStatusDescription("An error occurred during upload: \""+itemName + "\". Try again");
|
workspaceUploader.setStatusDescription("Error on uploading: \""+itemName + "\". Try again");
|
||||||
workspaceUploader.setUploadStatus(UPLOAD_STATUS.FAILED);
|
workspaceUploader.setUploadStatus(UPLOAD_STATUS.FAILED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ public class WorkspaceUploaderMng {
|
||||||
}
|
}
|
||||||
} catch (InternalErrorException e) {
|
} catch (InternalErrorException e) {
|
||||||
logger.error("Error during upload: ",e);
|
logger.error("Error during upload: ",e);
|
||||||
workspaceUploader.setStatusDescription("An error occurred server-side during upload: "+itemName+". "+e.getMessage() +". Try again");
|
workspaceUploader.setStatusDescription("Error on uploading: "+itemName+". "+e.getMessage());
|
||||||
workspaceUploader.setUploadStatus(UPLOAD_STATUS.FAILED);
|
workspaceUploader.setUploadStatus(UPLOAD_STATUS.FAILED);
|
||||||
try {
|
try {
|
||||||
WsUtil.putWorkspaceUploaderInSession(httpSession, workspaceUploader);
|
WsUtil.putWorkspaceUploaderInSession(httpSession, workspaceUploader);
|
||||||
|
@ -331,7 +331,7 @@ public class WorkspaceUploaderMng {
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error when uploading Archive to HL creation: ",e);
|
logger.error("Error when uploading Archive to HL creation: ",e);
|
||||||
throw new Exception("An error occurred during upload:: "+itemName+". Try again");
|
throw new Exception("An error occurred during upload: "+itemName+". Try again");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue