Propagated error case to improve error messages client-side
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-uploader@142309 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
938d9ace9c
commit
d23603d024
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.widgets.workspaceuploader.client;
|
||||
|
||||
|
@ -23,9 +23,9 @@ import com.google.gwt.event.shared.HandlerManager;
|
|||
public class WorkspaceUploaderListenerController {
|
||||
|
||||
private static HandlerManager controllerEventBus = null;
|
||||
|
||||
|
||||
private List<WorskpaceUploadNotificationListener> listenersUpload = new ArrayList<WorskpaceUploadNotificationListener>();
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new workspace explorer listener controller.
|
||||
*/
|
||||
|
@ -34,21 +34,21 @@ public class WorkspaceUploaderListenerController {
|
|||
bindEvents();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Bind events.
|
||||
*/
|
||||
private void bindEvents() {
|
||||
controllerEventBus.addHandler(NotifyUploadEvent.TYPE, new NotifyUploadEventHandler() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onNotifyUpload(NotifyUploadEvent notifyUploadEvent) {
|
||||
|
||||
|
||||
if(notifyUploadEvent.getEvent()==null)
|
||||
return;
|
||||
|
||||
|
||||
switch(notifyUploadEvent.getEvent()){
|
||||
|
||||
|
||||
case UPLOAD_COMPLETED:
|
||||
GWT.log("NotifyUploadEvent Completed");
|
||||
notifyUploadCompleted(notifyUploadEvent.getParentId(), notifyUploadEvent.getItemId());
|
||||
|
@ -59,7 +59,7 @@ public class WorkspaceUploaderListenerController {
|
|||
break;
|
||||
case FAILED:
|
||||
GWT.log("NotifyUploadEvent FAILED");
|
||||
notifyUploadError(notifyUploadEvent.getParentId(), notifyUploadEvent.getItemId(), notifyUploadEvent.getException());
|
||||
notifyUploadError(notifyUploadEvent.getParentId(), notifyUploadEvent.getItemId(), new Exception(notifyUploadEvent.getUploadResultMsg()));
|
||||
break;
|
||||
case OVERWRITE_COMPLETED:
|
||||
GWT.log("NotifyUploadEvent OVERWRITE_COMPLETED");
|
||||
|
@ -67,7 +67,7 @@ public class WorkspaceUploaderListenerController {
|
|||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -103,14 +103,14 @@ public class WorkspaceUploaderListenerController {
|
|||
// SILENT
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reset listeners.
|
||||
*/
|
||||
public void resetListeners(){
|
||||
this.listenersUpload.clear();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notify upload completed.
|
||||
*
|
||||
|
@ -123,7 +123,7 @@ public class WorkspaceUploaderListenerController {
|
|||
listener.onUploadCompleted(parentId, itemId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notify overwrite completed.
|
||||
*
|
||||
|
@ -136,7 +136,7 @@ public class WorkspaceUploaderListenerController {
|
|||
listener.onOverwriteCompleted(parentId, itemId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notify upload aborted.
|
||||
*
|
||||
|
@ -148,7 +148,7 @@ public class WorkspaceUploaderListenerController {
|
|||
listener.onUploadAborted(parentId, itemId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Notify upload error.
|
||||
*
|
||||
|
@ -161,7 +161,7 @@ public class WorkspaceUploaderListenerController {
|
|||
listener.onError(parentId, itemId, t);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Listeners size.
|
||||
*
|
||||
|
|
|
@ -25,10 +25,13 @@ public class NotifyUploadEvent extends GwtEvent<NotifyUploadEventHandler> {
|
|||
private UPLOAD_EVENT_TYPE event;
|
||||
private String parentId;
|
||||
private String itemId;
|
||||
private String uploadResultMsg;
|
||||
private Throwable exception;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gets the exception.
|
||||
*
|
||||
* @return the exception
|
||||
*/
|
||||
public Throwable getException() {
|
||||
|
@ -36,6 +39,8 @@ public class NotifyUploadEvent extends GwtEvent<NotifyUploadEventHandler> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets the exception.
|
||||
*
|
||||
* @param exception the exception to set
|
||||
*/
|
||||
public void setException(Throwable exception) {
|
||||
|
@ -43,6 +48,8 @@ public class NotifyUploadEvent extends GwtEvent<NotifyUploadEventHandler> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the event.
|
||||
*
|
||||
* @return the event
|
||||
*/
|
||||
public UPLOAD_EVENT_TYPE getEvent() {
|
||||
|
@ -50,6 +57,8 @@ public class NotifyUploadEvent extends GwtEvent<NotifyUploadEventHandler> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets the event.
|
||||
*
|
||||
* @param event the event to set
|
||||
*/
|
||||
public void setEvent(UPLOAD_EVENT_TYPE event) {
|
||||
|
@ -58,15 +67,24 @@ public class NotifyUploadEvent extends GwtEvent<NotifyUploadEventHandler> {
|
|||
|
||||
/**
|
||||
* Instantiates a new notify upload event.
|
||||
*
|
||||
* @param event the event
|
||||
* @param parentId the parent id
|
||||
* @param itemId the item id
|
||||
*/
|
||||
public NotifyUploadEvent(UPLOAD_EVENT_TYPE event, String parentId, String itemId) {
|
||||
this.parentId = parentId;
|
||||
this.itemId = itemId;
|
||||
this.event = event;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new notify upload event.
|
||||
*
|
||||
* @param event the event
|
||||
* @param parentId the parent id
|
||||
* @param itemId the item id
|
||||
* @param e the e
|
||||
*/
|
||||
public NotifyUploadEvent(UPLOAD_EVENT_TYPE event, String parentId, String itemId, Throwable e) {
|
||||
this.parentId = parentId;
|
||||
|
@ -75,7 +93,27 @@ public class NotifyUploadEvent extends GwtEvent<NotifyUploadEventHandler> {
|
|||
this.exception = e;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new notify upload event.
|
||||
*
|
||||
* @param event the event
|
||||
* @param parentId the parent id
|
||||
* @param itemId the item id
|
||||
* @param uploadResultMsg the upload result msg
|
||||
* @param e the e
|
||||
*/
|
||||
public NotifyUploadEvent(UPLOAD_EVENT_TYPE event, String parentId, String itemId, String uploadResultMsg, Throwable e) {
|
||||
this.parentId = parentId;
|
||||
this.itemId = itemId;
|
||||
this.event = event;
|
||||
this.uploadResultMsg = uploadResultMsg;
|
||||
this.exception = e;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the parent id.
|
||||
*
|
||||
* @return the parentId
|
||||
*/
|
||||
public String getParentId() {
|
||||
|
@ -83,6 +121,8 @@ public class NotifyUploadEvent extends GwtEvent<NotifyUploadEventHandler> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Gets the item id.
|
||||
*
|
||||
* @return the itemId
|
||||
*/
|
||||
public String getItemId() {
|
||||
|
@ -90,6 +130,8 @@ public class NotifyUploadEvent extends GwtEvent<NotifyUploadEventHandler> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets the parent id.
|
||||
*
|
||||
* @param parentId the parentId to set
|
||||
*/
|
||||
public void setParentId(String parentId) {
|
||||
|
@ -97,15 +139,27 @@ public class NotifyUploadEvent extends GwtEvent<NotifyUploadEventHandler> {
|
|||
}
|
||||
|
||||
/**
|
||||
* Sets the item id.
|
||||
*
|
||||
* @param itemId the itemId to set
|
||||
*/
|
||||
public void setItemId(String itemId) {
|
||||
this.itemId = itemId;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return the uploadResultMsg
|
||||
*/
|
||||
public String getUploadResultMsg() {
|
||||
|
||||
return uploadResultMsg;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see com.google.gwt.event.shared.GwtEvent#getAssociatedType()
|
||||
*/
|
||||
@Override
|
||||
|
@ -115,7 +169,7 @@ public class NotifyUploadEvent extends GwtEvent<NotifyUploadEventHandler> {
|
|||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
*
|
||||
* @see
|
||||
* com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared
|
||||
* .EventHandler)
|
||||
|
|
|
@ -71,7 +71,7 @@ public class TimerUpload extends Timer{
|
|||
GWT.log("Upload Failed "+result.getFile().getItemId() +" name: "+result.getFile().getFileName());
|
||||
// monitor.deleteUploaderByClientKey(workspaceUploader.getClientUploadKey());
|
||||
// queue.remove(workspaceUploader.getClientUploadKey());
|
||||
monitor.notifyUploadError(result.getFile().getParentId(), null, null);
|
||||
monitor.notifyUploadError(result.getFile().getParentId(), null, result.getStatusDescription(), null);
|
||||
// new DialogResult(null, "Upload Failed!!", result.getStatusDescription()).center();
|
||||
|
||||
cancel();
|
||||
|
@ -80,6 +80,7 @@ public class TimerUpload extends Timer{
|
|||
// monitor.deleteUploaderByClientKey(workspaceUploader.getClientUploadKey());
|
||||
GWT.log("Upload Aborted "+result.getFile().getItemId() +" name: "+result.getFile().getFileName());
|
||||
cancel();
|
||||
monitor.notifyUploadAborted(result.getFile().getParentId(), null);
|
||||
monitor.goNextUploaderAfterKey(workspaceUploader.getClientUploadKey());
|
||||
}
|
||||
|
||||
|
@ -103,7 +104,7 @@ public class TimerUpload extends Timer{
|
|||
cancel();
|
||||
// monitor.deleteUploaderByClientKey(workspaceUploader.getClientUploadKey());
|
||||
monitor.goNextUploaderAfterKey(workspaceUploader.getClientUploadKey());
|
||||
monitor.notifyUploadError(workspaceUploader.getFile().getParentId(), null, caught);
|
||||
monitor.notifyUploadError(workspaceUploader.getFile().getParentId(), null, null, caught);
|
||||
// removeTimer(workspaceUploader.getClientUploadKey());
|
||||
}
|
||||
});
|
||||
|
|
|
@ -299,8 +299,8 @@ public class UploaderMonitor {
|
|||
* @param itemId the item id
|
||||
* @param t the t
|
||||
*/
|
||||
protected void notifyUploadError(String parentId, String itemId, Throwable t){
|
||||
WorkspaceUploaderListenerController.getEventBus().fireEvent(new NotifyUploadEvent(UPLOAD_EVENT_TYPE.FAILED, parentId, itemId, t));
|
||||
protected void notifyUploadError(String parentId, String itemId, String error, Throwable t){
|
||||
WorkspaceUploaderListenerController.getEventBus().fireEvent(new NotifyUploadEvent(UPLOAD_EVENT_TYPE.FAILED, parentId, itemId, error, t));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -101,11 +101,10 @@ public class WorkspaceUploaderMng {
|
|||
} catch (Exception e1) {
|
||||
logger.error("Error during WorkspaceUploaderItem session update: ",e1);
|
||||
}
|
||||
} catch (InsufficientPrivilegesException
|
||||
| ItemAlreadyExistException | InternalErrorException
|
||||
} catch (InternalErrorException
|
||||
| IOException e) {
|
||||
logger.error("Error during upload: ",e);
|
||||
workspaceUploader.setStatusDescription("An error occurred during upload: "+itemName+". "+e.getMessage());
|
||||
workspaceUploader.setStatusDescription("An error occurred server-side during upload: "+itemName+". "+e.getMessage() +". Try again");
|
||||
workspaceUploader.setUploadStatus(UPLOAD_STATUS.FAILED);
|
||||
try {
|
||||
WsUtil.putWorkspaceUploaderInSession(httpSession, workspaceUploader);
|
||||
|
@ -113,7 +112,7 @@ public class WorkspaceUploaderMng {
|
|||
logger.error("Error during WorkspaceUploaderItem session update: ",e1);
|
||||
}
|
||||
|
||||
} catch (ItemNotFoundException | WrongItemTypeException | WorkspaceFolderNotFoundException | WrongDestinationException e) {
|
||||
} catch (InsufficientPrivilegesException| ItemAlreadyExistException | ItemNotFoundException | WrongItemTypeException | WorkspaceFolderNotFoundException | WrongDestinationException e) {
|
||||
logger.error("Error during overwrite: ",e);
|
||||
workspaceUploader.setStatusDescription("An error occurred during upload: "+itemName+". "+e.getMessage());
|
||||
workspaceUploader.setUploadStatus(UPLOAD_STATUS.FAILED);
|
||||
|
|
Loading…
Reference in New Issue