diff --git a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/events/HideMonitorEvent.java b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/events/HideMonitorEvent.java new file mode 100644 index 0000000..29eaccf --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/events/HideMonitorEvent.java @@ -0,0 +1,40 @@ +package org.gcube.portlets.widgets.workspaceuploader.client.events; + +import com.google.gwt.event.shared.GwtEvent; + +/** + * The Class HideMonitorEvent. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it Oct 14, 2015 + */ +public class HideMonitorEvent extends GwtEvent { + public static Type TYPE = new Type(); + + /** + * Instantiates a new cancel upload event. + */ + public HideMonitorEvent() { + } + + /* + * (non-Javadoc) + * + * @see com.google.gwt.event.shared.GwtEvent#getAssociatedType() + */ + @Override + public Type getAssociatedType() { + return TYPE; + } + + /* + * (non-Javadoc) + * + * @see + * com.google.gwt.event.shared.GwtEvent#dispatch(com.google.gwt.event.shared + * .EventHandler) + */ + @Override + protected void dispatch(HideMonitorEventHandler handler) { + handler.onHideMonitor(this); + } +} diff --git a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/events/HideMonitorEventHandler.java b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/events/HideMonitorEventHandler.java new file mode 100644 index 0000000..328dfa9 --- /dev/null +++ b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/events/HideMonitorEventHandler.java @@ -0,0 +1,21 @@ +package org.gcube.portlets.widgets.workspaceuploader.client.events; + +import com.google.gwt.event.shared.EventHandler; + + + +/** + * The Interface HideMonitorEventHandler. + * + * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it + * Oct 14, 2015 + */ +public interface HideMonitorEventHandler extends EventHandler { + + /** + * On hide monitor. + * + * @param hideMonitorEvent the hide monitor event + */ + void onHideMonitor(HideMonitorEvent hideMonitorEvent); +} \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/resource/FileUpload.css b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/resource/FileUpload.css index 8befaf8..59a2078 100644 --- a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/resource/FileUpload.css +++ b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/resource/FileUpload.css @@ -19,7 +19,7 @@ font: 13px/20px 'Lucida Grande', Tahoma, Verdana, sans-serif; color: #404040; margin: 0px auto; - width: 320px; + width: 330px; } .bar-container > div { diff --git a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/resource/WorkspaceUploaderIcons.java b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/resource/WorkspaceUploaderIcons.java index 2d3d4cb..d1372f9 100644 --- a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/resource/WorkspaceUploaderIcons.java +++ b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/resource/WorkspaceUploaderIcons.java @@ -19,7 +19,7 @@ public interface WorkspaceUploaderIcons extends ClientBundle { * * @return the image resource */ - @Source("loader2.gif") + @Source("spinner.gif") ImageResource loading(); /** @@ -43,7 +43,7 @@ public interface WorkspaceUploaderIcons extends ClientBundle { * * @return the image resource */ - @Source("delete.gif") + @Source("cancel.png") ImageResource cancel(); /** diff --git a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/resource/spinner.gif b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/resource/spinner.gif new file mode 100644 index 0000000..4cf7523 Binary files /dev/null and b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/resource/spinner.gif differ diff --git a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/uploader/DialogUpload.java b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/uploader/DialogUpload.java index 73e7d4a..c1359ac 100644 --- a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/uploader/DialogUpload.java +++ b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/uploader/DialogUpload.java @@ -10,6 +10,7 @@ import org.gcube.portlets.widgets.workspaceuploader.client.DialogResult; import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceExplorerListenerController; import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploadNotification.HasWorskpaceUploadNotificationListener; import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploadNotification.WorskpaceUploadNotificationListener; +import org.gcube.portlets.widgets.workspaceuploader.client.events.HideMonitorEvent; import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploaderServiceAsync; import org.gcube.portlets.widgets.workspaceuploader.shared.HandlerResultMessage; import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem; @@ -29,6 +30,7 @@ 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.SubmitEvent; import com.google.gwt.user.client.ui.FormPanel.SubmitHandler; +import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HasHorizontalAlignment; import com.google.gwt.user.client.ui.HasVerticalAlignment; @@ -77,7 +79,7 @@ public class DialogUpload extends ClosableDialog implements HasWorskpaceUploadNo */ public DialogUpload(String headerTitle, final String parentId, UPLOAD_TYPE uploadType){ super(false, true, headerTitle); - + setWidth("400px"); fileUpload = new FileUpload(); //ONLY IN CASE OF FILE MULTIPLE UPLOAD IS AVAILABLE @@ -105,24 +107,14 @@ public class DialogUpload extends ClosableDialog implements HasWorskpaceUploadNo initJsonClientKeys(); panel.add(jsonClientKeys); - panel.add(fileUpload); - hpBottom = new HorizontalPanel(); - hpBottom.getElement().getStyle().setMarginTop(10, Unit.PX); - - if(uploadType.equals(UPLOAD_TYPE.File)){ - HTML msg = new HTML("

To select multiple files, press and hold down the Ctrl key, and then click each item

that you want to select

"); - msg.getElement().getStyle().setFontSize(10, Unit.PX); - hpBottom.add(msg); - } - - panel.add(hpBottom); - + HorizontalPanel hp = new HorizontalPanel(); - hp.getElement().setId("hpID"); +// hp.getElement().setId("hpID"); hp.getElement().getStyle().setWidth(100, Unit.PCT); + hp.getElement().getStyle().setMarginTop(5, Unit.PX); hp.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); - hp.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); + hp.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT); anchorMyUploads = new Anchor(ConstantsWorkspaceUploader.MY_UPLOADS); anchorMyUploads.addClickHandler(new ClickHandler() { @@ -134,6 +126,39 @@ public class DialogUpload extends ClosableDialog implements HasWorskpaceUploadNo }); hp.add(anchorMyUploads); panel.add(hp); + + hpBottom = new HorizontalPanel(); + hpBottom.setWidth("100%"); +// hpBottom.getElement().getStyle().setMarginTop(5, Unit.PX); + hpBottom.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); + + if(uploadType.equals(UPLOAD_TYPE.File)){ + HTML msg = new HTML("

To select multiple files, press and hold down the Ctrl key, and then

click each item that you want to select

"); + msg.getElement().getStyle().setFontSize(10, Unit.PX); + hpBottom.add(msg); + } + + + + HorizontalPanel hp2 = new HorizontalPanel(); + hp2.getElement().getStyle().setMarginTop(5, Unit.PX); +// hp2.getElement().getStyle().setWidth(100, Unit.PCT); + hp2.addStyleName("align-right-close"); + + Button bClose = new Button("Close"); + bClose.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + DialogUpload.this.hide(); + } + }); + + + hp2.add(bClose); + hpBottom.add(hp2); + panel.add(hpBottom); + add(formPanel); } diff --git a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/uploader/MonitorPanel.java b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/uploader/MonitorPanel.java index 1113d7b..3dc8cd2 100644 --- a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/uploader/MonitorPanel.java +++ b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/uploader/MonitorPanel.java @@ -6,18 +6,24 @@ package org.gcube.portlets.widgets.workspaceuploader.client.uploader; import java.util.HashMap; import java.util.Map; +import org.gcube.portlets.widgets.workspaceuploader.client.events.HideMonitorEvent; import org.gcube.portlets.widgets.workspaceuploader.client.resource.ProgressBarCssAndImages; import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem; import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem.UPLOAD_STATUS; import com.google.gwt.core.shared.GWT; import com.google.gwt.dom.client.Style.Unit; +import com.google.gwt.event.dom.client.ClickEvent; +import com.google.gwt.event.dom.client.ClickHandler; import com.google.gwt.event.logical.shared.CloseEvent; import com.google.gwt.event.logical.shared.CloseHandler; import com.google.gwt.event.shared.HandlerManager; import com.google.gwt.user.client.Window; import com.google.gwt.user.client.Window.ClosingEvent; +import com.google.gwt.user.client.ui.Button; import com.google.gwt.user.client.ui.HTML; +import com.google.gwt.user.client.ui.HasHorizontalAlignment; +import com.google.gwt.user.client.ui.HasVerticalAlignment; import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.ScrollPanel; import com.google.gwt.user.client.ui.VerticalPanel; @@ -31,34 +37,90 @@ import com.google.gwt.user.client.ui.VerticalPanel; */ public class MonitorPanel extends ScrollPanel{ - private static final int MAX_CHARS = 50; - private VerticalPanel verticalPanel = new VerticalPanel(); + private VerticalPanel vpListUpload = new VerticalPanel(); + private VerticalPanel mainPanel = new VerticalPanel(); private Map mapUploading = new HashMap(); -// private Map mapTimer = new HashMap(); -// private Map mapDialog= new HashMap(); private Map mapPanels = new HashMap(); private HandlerManager eventBus; private HorizontalPanel hpNoUploads = new HorizontalPanel(); + private HTML labelNumbUpload = new HTML("Uploaded 0 of 0"); + private HorizontalPanel hpBottomPanel = new HorizontalPanel(); + + private HorizontalPanel hpCloseMonitor = new HorizontalPanel(); + static { ProgressBarCssAndImages.INSTANCE.css().ensureInjected(); } /** * Instantiates a new monitor panel. * - * @param eventBus the event bus + * @param bus the event bus */ - public MonitorPanel(HandlerManager eventBus) { - this.eventBus = eventBus; + public MonitorPanel(HandlerManager bus) { + this.eventBus = bus; initPanelNoUploads(); addCloseHandler(); - verticalPanel.getElement().getStyle().setMargin(5, Unit.PX); - add(verticalPanel); + + //NUMBER OF UPLOADS + hpBottomPanel.getElement().setId("hpBottomPanel"); +// hpNumbUpload.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); + hpBottomPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE); + hpBottomPanel.setWidth("100%"); + hpBottomPanel.add(labelNumbUpload); - verticalPanel.add(hpNoUploads); +// mainPanel.add(hpNumbUpload); +// mainPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER); + + //LIST OF UPLOADS + vpListUpload.getElement().getStyle().setMargin(5, Unit.PX); +// setHeight("500px"); + vpListUpload.add(hpNoUploads); + ScrollPanel scroll = new ScrollPanel(); + scroll.add(vpListUpload); + scroll.setHeight("200px"); +// scroll.getElement().getStyle().setBorderStyle(BorderStyle.SOLID); +// scroll.getElement().getStyle().setBorderWidth(1.0, Unit.PX); + + mainPanel.add(scroll); + + //CLOSE MONITOR +// hpCloseMonitor.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT); +// hpCloseMonitor.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM); + Button bClose = new Button("Close"); + bClose.addClickHandler(new ClickHandler() { + + @Override + public void onClick(ClickEvent event) { + eventBus.fireEvent(new HideMonitorEvent()); + } + }); + +// hpNumbUpload.add(bClose); + + hpCloseMonitor.add(bClose); + hpCloseMonitor.addStyleName("align-right-close"); + hpBottomPanel.add(hpCloseMonitor); + hpBottomPanel.getElement().getStyle().setMarginTop(5.0, Unit.PX); + mainPanel.setWidth("100%"); + mainPanel.add(hpBottomPanel); + + add(mainPanel); // RootPanel.get("workspace-uploader").add(verticalPanel); } + + private void updateNumberUpload(){ + int numCompleted = 0; + for (String uploadKey : mapUploading.keySet()) { + WorkspaceUploaderItem uploader = mapUploading.get(uploadKey); + if(uploader.getUploadStatus().equals(UPLOAD_STATUS.COMPLETED) || uploader.getUploadStatus().equals(UPLOAD_STATUS.FAILED)) + numCompleted++; + } + + labelNumbUpload.setHTML("Uploaded "+numCompleted +" of "+mapUploading.size()); + } + private void initPanelNoUploads(){ hpNoUploads = new HorizontalPanel(); hpNoUploads.addStyleName("noUploads"); @@ -68,7 +130,7 @@ public class MonitorPanel extends ScrollPanel{ private void removeNoUploads(){ try{ - verticalPanel.remove(hpNoUploads); + vpListUpload.remove(hpNoUploads); }catch(Exception e){ } @@ -89,6 +151,8 @@ public class MonitorPanel extends ScrollPanel{ }else{ GWT.log("Skip update, uploader: "+uploader.getClientUploadKey() +" "+uploader.getFile().toString()+", not found!"); } + + updateNumberUpload(); } /** @@ -104,98 +168,11 @@ public class MonitorPanel extends ScrollPanel{ mapPanels.put(uploader.getClientUploadKey(), upv); VerticalPanel upvPanel = upv.getPanel(); upvPanel.addStyleName("upladerMargin"); - verticalPanel.add(upvPanel); + vpListUpload.add(upvPanel); + + updateNumberUpload(); } - - /** - * Handle cancel upload. - * - * @param uploader the uploader - * @param vp the hp - * @return the image - */ - /*private Image handleCancelUpload(final WorkspaceUploaderItem uploader, final VerticalPanel vp){ - - Image cancel = WorkspaceUploaderResources.getImageCancel(); - cancel.setTitle("Cancel upload"); - cancel.addStyleName("cancel-upload"); - cancel.addClickHandler(new ClickHandler() { - - @Override - public void onClick(ClickEvent event) { - GWT.log("Click cancel"); - String fileName = uploader.getFile()!=null? uploader.getFile().getFileName(): ""; - if(Window.confirm("Confirm cancel uploading "+fileName+"?")){ - vp.clear(); - HTML html = new HTML(); - vp.add(html); - String text = "
"; - String msg = StringUtil.ellipsize("Aborting upload: "+fileName, MAX_CHARS, 0); - text+=""+msg+"
"; - html.setHTML(text); - eventBus.fireEvent(new CancelUploadEvent(uploader, vp, fileName)); - } - } - }); - return cancel; - }*/ - -// /** -// * Update info. -// * -// * @param vp the hp -// * @param uploader the uploader -// */ -// private void updateInfo(VerticalPanel vp, WorkspaceUploaderItem uploader){ -// vp.clear(); -// HTML html = new HTML(); -// vp.add(html); -// String text; -// switch(uploader.getUploadStatus()){ -// case COMPLETED: -// text = "
"; -// text+=""+StringUtil.ellipsize(uploader.getFile().getFileName()+" uploaded successfully!", MAX_CHARS, 0)+"
"; -//// GWT.log(text); -// html.setHTML(text); -// html.setTitle(uploader.getStatusDescription()); -// break; -// case FAILED: -// text = "
"; -// text+=""+StringUtil.ellipsize(uploader.getStatusDescription(), MAX_CHARS, 0)+"
"; -//// GWT.log(text); -// html.setHTML(text); -// html.setTitle(uploader.getStatusDescription()); -// break; -// case IN_PROGRESS: -// text = "
"; -// String msg = StringUtil.ellipsize(uploader.getUploadProgress().getLastEvent().getReadPercentage()+"% "+uploader.getFile().getFileName(), MAX_CHARS, 0); -// text+=""+msg+""; -// text+="
"; -//// GWT.log(text); -// html.setHTML(text); -// html.setTitle(uploader.getStatusDescription()); -// if(uploader.getUploadProgress().getLastEvent().getReadPercentage()!=100) -// vp.add(handleCancelUpload(uploader, vp)); -// break; -// case WAIT: -// text = "
"; -// -// String descr = ""; -// if(uploader.getFile()!=null && uploader.getFile().getFileName()!=null) -// descr = uploader.getFile().getFileName(); -// else -// descr = uploader.getStatusDescription(); -// -// text+=""+descr+""; -// text+="
"; -//// GWT.log(text); -// html.setHTML(text); -//// hp.add(handleCancelUplad(uploader, hp)); -// break; -// } -// } - /** * Adds the close handler. */ @@ -225,8 +202,6 @@ public class MonitorPanel extends ScrollPanel{ // Window.alert("bye bye Closed"); } }); - - } } diff --git a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/uploader/UploaderMonitor.java b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/uploader/UploaderMonitor.java index 850097b..d7c6621 100644 --- a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/uploader/UploaderMonitor.java +++ b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/uploader/UploaderMonitor.java @@ -12,6 +12,8 @@ import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceExplorerList import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploaderServiceAsync; import org.gcube.portlets.widgets.workspaceuploader.client.events.CancelUploadEvent; import org.gcube.portlets.widgets.workspaceuploader.client.events.CancelUploadEventHandler; +import org.gcube.portlets.widgets.workspaceuploader.client.events.HideMonitorEvent; +import org.gcube.portlets.widgets.workspaceuploader.client.events.HideMonitorEventHandler; import org.gcube.portlets.widgets.workspaceuploader.client.events.NotifyUploadEvent; import org.gcube.portlets.widgets.workspaceuploader.client.events.NotifyUploadEvent.UPLOAD_EVENT_TYPE; import org.gcube.portlets.widgets.workspaceuploader.client.resource.WorkspaceUploaderResources; @@ -59,6 +61,7 @@ public class UploaderMonitor { } private UploaderMonitor(){ + dialogUploadMonitor.setWidth("400px"); bindEvents(); } @@ -129,6 +132,15 @@ public class UploaderMonitor { } } }); + + + monitorEventBus.addHandler(HideMonitorEvent.TYPE, new HideMonitorEventHandler() { + + @Override + public void onHideMonitor(HideMonitorEvent hideMonitorEvent) { + dialogUploadMonitor.hide(); + } + }); } /** diff --git a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/uploader/UploaderProgressView.java b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/uploader/UploaderProgressView.java index 384ab49..9c7f33d 100644 --- a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/uploader/UploaderProgressView.java +++ b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/client/uploader/UploaderProgressView.java @@ -101,11 +101,7 @@ public class UploaderProgressView { html.setHTML(text); html.setTitle(uploader.getStatusDescription()); bar.update(uploader.getUploadProgress().getLastEvent().getReadPercentage()); - try{ -// hpBar.remove(cancelImg); - }catch (Exception e) {} try{ -// hpBar.remove(bar); hpBar.clear(); }catch (Exception e) {} break; @@ -116,7 +112,10 @@ public class UploaderProgressView { // GWT.log(text); html.setHTML(text); html.setTitle(uploader.getStatusDescription()); - bar.update(uploader.getUploadProgress().getLastEvent().getReadPercentage()); +// bar.update(uploader.getUploadProgress().getLastEvent().getReadPercentage()); + try{ + hpBar.clear(); + }catch (Exception e) {} break; case IN_PROGRESS: setVisibleBar(true); diff --git a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/public/workspaceuploader.css b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/public/workspaceuploader.css index fd9041c..be3e55c 100644 --- a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/public/workspaceuploader.css +++ b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/public/workspaceuploader.css @@ -97,17 +97,23 @@ h1 { min-width: 350px; } -.noUploads{ +.noUploads { min-width: 350px; font-size: 15px; font-family: "Lucida Grande", Verdana, "Bitstream Vera Sans", Arial, sans-serif; } -.upladerMargin{ +.upladerMargin { margin-bottom: 3px; } +.align-right-close { + width: auto; + margin-right: 0px; + margin-left: auto; +} + /* .baloonGoTop :HOVER { */ /* cursor: pointer; */ /* color: #FFF; */ diff --git a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/WorkspaceUploadServlet.java b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/WorkspaceUploadServlet.java index 5d86de7..6cfc387 100644 --- a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/WorkspaceUploadServlet.java +++ b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/WorkspaceUploadServlet.java @@ -331,10 +331,10 @@ public class WorkspaceUploadServlet extends HttpServlet { return workspaceUploader; } catch (Exception e) { logger.error("Error during WorkspaceUploaderItem save in session workspace uploader: "+workspaceUploader,e); - throw new Exception("An error occurred during uploading. Try again"); + throw new Exception("An error occurred in the upload. Try again"); } } - throw new Exception("An error occurred during uploading. Workspace Uploader not found. Abort and try again"); + throw new Exception("An error occurredin the upload. Workspace Uploader not found. Abort and try again"); } /** diff --git a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/WorkspaceUploadServletStream.java b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/WorkspaceUploadServletStream.java index 8a9fcea..a92899e 100644 --- a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/WorkspaceUploadServletStream.java +++ b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/WorkspaceUploadServletStream.java @@ -345,13 +345,13 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet workspaceUploader = WsUtil.getWorkspaceUploaderInSession(request.getSession(), clientUploadKey); } catch (Exception e) { logger.error("Error during workspace uploader retrieving", e); - saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "An error occurred when uploading "+fileName+". Error processing request in upload servlet", request.getSession()); + saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "An error occurred during upload: "+fileName+". Error processing request in upload servlet", request.getSession()); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Error processing request in upload servlet"); return; } //TODO DEBUG REMOVE THIS -// saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "An error occurred when uploading "+fileName+". Error processing request in upload servlet", request.getSession()); +// saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "An error occurred during upload: "+fileName+". Error processing request in upload servlet", request.getSession()); // response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Error processing request in upload servlet"); // return; @@ -361,14 +361,14 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet wa = WsUtil.getWorkspace(request.getSession()); } catch (Exception e) { logger.error("Error during workspace retrieving", e); - saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "An error occurred when uploading "+fileName+". Error processing request in upload servlet", request.getSession()); + saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "An error occurred during upload: "+fileName+". Error processing request in upload servlet", request.getSession()); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Error processing request in upload servlet"); return; } if (wa == null) { logger.error("Now workspace found in session"); - saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "An error occurred when uploading "+fileName+". No workspace in session", request.getSession()); + saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "An error occurred during upload: "+fileName+". No workspace in session", request.getSession()); sendError(response, "Internal error: No workspace in session"); return; } @@ -379,14 +379,14 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet item = wa.getItem(destinationId); } catch (ItemNotFoundException e) { logger.error("Error, no destination folder found", e); - saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "An error occurred when uploading "+fileName+". No destination folder found", request.getSession()); + saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "An error occurred during upload: "+fileName+". No destination folder found", request.getSession()); sendError(response, "Internal error: No destination folder found"); return; } if (item.getType() != WorkspaceItemType.FOLDER && item.getType() != WorkspaceItemType.SHARED_FOLDER) { logger.error("Error processing request in upload servlet: Wrong destination item"); - saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "An error occurred when uploading "+fileName+". Wrong destination item", request.getSession()); + saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "An error occurred during upload: "+fileName+". Wrong destination item", request.getSession()); sendError(response, "Internal error: Wrong destination item"); return; } @@ -486,22 +486,22 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet // file.delete(); } catch (InsufficientPrivilegesException e) { logger.error("Error creating elements", e); - saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "An error occurred when uploading. Insufficient privileges", request.getSession()); + saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "An error occurred in the upload. Insufficient privileges", request.getSession()); sendError(response, "Internal error: Insufficient privileges"); return; } catch (InternalErrorException e) { logger.error("Error creating elements", e); - saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "An error occurred when uploading:"+e.getMessage(), request.getSession()); + saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "An error occurred in the upload:"+e.getMessage(), request.getSession()); sendError(response, "Internal error: "+e.getMessage()); return; } catch (ItemAlreadyExistException e) { logger.error("Error creating elements", e); - saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "An error occurred when uploading. An item with that name already exists", request.getSession()); + saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "An error occurred in the upload. An item with that name already exists", request.getSession()); sendError(response, "Internal error: An item with that name already exists"); return; }catch (Exception e) { logger.error("Error creating elements", e); - saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "An error occurred when uploading. "+e.getMessage(), request.getSession()); + saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "An error occurred in the upload. "+e.getMessage(), request.getSession()); // sendError(response, "Internal error: An error occurred on uploading the file, try again later"); return; }finally{ @@ -574,10 +574,10 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet WsUtil.putWorkspaceUploaderInSession(httpSession, workspaceUploader); } catch (Exception e) { logger.error("Error during WorkspaceUploaderItem save in session workspace uploader: "+workspaceUploader,e); - throw new Exception("An error occurred during uploading. Try again"); + throw new Exception("An error occurred in the upload. Try again"); } }else - throw new Exception("An error occurred during uploading. Workspace Uploader not found. Abort and try again"); + throw new Exception("An error occurred in the upload. Workspace Uploader not found. Abort and try again"); } //TEST TIME @@ -714,12 +714,12 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet } catch (WrongDestinationException e) { logger.error("Error creating elements", e); workspaceUploader.setUploadStatus(UPLOAD_STATUS.FAILED); - workspaceUploader.setStatusDescription("An error occurred when uploading. Wrong Destination"); + workspaceUploader.setStatusDescription("An error occurred in the upload. Wrong Destination"); sendError(response, "Internal error: Wrong Destination"); } catch (WorkspaceFolderNotFoundException e) { logger.error("Error creating elements", e); workspaceUploader.setUploadStatus(UPLOAD_STATUS.FAILED); - workspaceUploader.setStatusDescription("An error occurred when uploading. Workspace Folder Not Found"); + workspaceUploader.setStatusDescription("An error occurred in the upload. Workspace Folder Not Found"); sendError(response, "Internal error: Workspace Folder Not Found"); }finally{ try { @@ -776,12 +776,12 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet } catch (WrongDestinationException e) { logger.error("Error creating elements", e); workspaceUploader.setUploadStatus(UPLOAD_STATUS.FAILED); - workspaceUploader.setStatusDescription("An error occurred when uploading. Wrong Destination"); + workspaceUploader.setStatusDescription("An error occurred in the upload. Wrong Destination"); sendError(response, "Internal error: Wrong Destination"); } catch (WorkspaceFolderNotFoundException e) { logger.error("Error creating elements", e); workspaceUploader.setUploadStatus(UPLOAD_STATUS.FAILED); - workspaceUploader.setStatusDescription("An error occurred when uploading. Workspace Folder Not Found"); + workspaceUploader.setStatusDescription("An error occurred in the upload. Workspace Folder Not Found"); sendError(response, "Internal error: Workspace Folder Not Found"); }finally{ try { diff --git a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/upload/WorkspaceUploaderManager.java b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/upload/WorkspaceUploaderManager.java index a4278c3..ae83d6f 100644 --- a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/upload/WorkspaceUploaderManager.java +++ b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/upload/WorkspaceUploaderManager.java @@ -222,7 +222,7 @@ public class WorkspaceUploaderManager { return createWorkspaceUploaderFile(request, workspaceUploader, request.getSession(), isOverwrite, wa, file, itemName, destinationFolder, contentType, totolaBytes); } catch (Exception e) { logger.error("Error when uploading file to HL : ",e); - throw new Exception("An error occurred when uploading "+itemName+". Try again"); + throw new Exception("An error occurred during upload: "+itemName+". Try again"); } } @@ -246,7 +246,7 @@ public class WorkspaceUploaderManager { } catch (Exception e) { logger.error("Error when uploading Archive to HL creation: ",e); - throw new Exception("An error occurred when uploading "+itemName+". Try again"); + throw new Exception("An error occurred during upload: "+itemName+". Try again"); } } diff --git a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/upload/WorkspaceUploaderMng.java b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/upload/WorkspaceUploaderMng.java index 487822a..24fbce9 100644 --- a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/upload/WorkspaceUploaderMng.java +++ b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/upload/WorkspaceUploaderMng.java @@ -89,7 +89,7 @@ public class WorkspaceUploaderMng { WorkspaceUploadServletStream.notifyUploadInSharedFolder(httpSession, wa, createdItem.getId(), createdItem.getParent().getId(), isOvewrite); }else{ workspaceUploader.setUploadStatus(UPLOAD_STATUS.FAILED); - workspaceUploader.setStatusDescription("An error occurred when uploading \""+itemName + "\". Try again"); + workspaceUploader.setStatusDescription("An error occurred during upload: \""+itemName + "\". Try again"); } try { WsUtil.putWorkspaceUploaderInSession(httpSession, workspaceUploader); @@ -101,7 +101,7 @@ public class WorkspaceUploaderMng { | IOException e) { logger.error("Error during upload: ",e); workspaceUploader.setUploadStatus(UPLOAD_STATUS.FAILED); - workspaceUploader.setStatusDescription("An error occurred when uploading "+itemName+": "+e.getMessage()); + workspaceUploader.setStatusDescription("An error occurred during upload: "+itemName+": "+e.getMessage()); try { WsUtil.putWorkspaceUploaderInSession(httpSession, workspaceUploader); } catch (Exception e1) { @@ -110,7 +110,7 @@ public class WorkspaceUploaderMng { } catch (ItemNotFoundException | WrongItemTypeException | WorkspaceFolderNotFoundException | WrongDestinationException e) { logger.error("Error during overwrite: ",e); workspaceUploader.setUploadStatus(UPLOAD_STATUS.FAILED); - workspaceUploader.setStatusDescription("An error occurred when uploading "+itemName+": "+e.getMessage()); + workspaceUploader.setStatusDescription("An error occurred during upload: "+itemName+": "+e.getMessage()); try { WsUtil.putWorkspaceUploaderInSession(httpSession, workspaceUploader); } catch (Exception e1) { @@ -160,7 +160,7 @@ public class WorkspaceUploaderMng { } catch (InternalErrorException e) { logger.error("Error during uploading: ",e); workspaceUploader.setUploadStatus(UPLOAD_STATUS.FAILED); - workspaceUploader.setStatusDescription("An error occurred when uploading "+itemName+": "+e.getMessage()); + workspaceUploader.setStatusDescription("An error occurred during upload: "+itemName+": "+e.getMessage()); try { WsUtil.putWorkspaceUploaderInSession(httpSession, workspaceUploader); } catch (Exception e1) { @@ -200,7 +200,7 @@ public class WorkspaceUploaderMng { return createWorkspaceUploaderFile(workspaceUploader, httpSession, isOverwrite, wa, file, itemName, destinationFolder, contentType, totolaBytes); } catch (Exception e) { logger.error("Error when uploading file to HL : ",e); - throw new Exception("An error occurred when uploading "+itemName+". Try again"); + throw new Exception("An error occurred during upload: "+itemName+". Try again"); } } @@ -224,7 +224,7 @@ public class WorkspaceUploaderMng { } catch (Exception e) { logger.error("Error when uploading Archive to HL creation: ",e); - throw new Exception("An error occurred when uploading "+itemName+". Try again"); + throw new Exception("An error occurred during upload:: "+itemName+". Try again"); } }