Updated pom version at 1.5.0
Completed task: https://support.d4science.org/issues/4893 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-uploader@131048 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
d6ca12a221
commit
e6929fbba2
8
pom.xml
8
pom.xml
|
@ -12,7 +12,7 @@
|
||||||
<groupId>org.gcube.portlets.widgets</groupId>
|
<groupId>org.gcube.portlets.widgets</groupId>
|
||||||
<artifactId>workspace-uploader</artifactId>
|
<artifactId>workspace-uploader</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<version>1.4.0-SNAPSHOT</version>
|
<version>1.5.0-SNAPSHOT</version>
|
||||||
<name>Workspace Uploader Widget</name>
|
<name>Workspace Uploader Widget</name>
|
||||||
<description>Workspace Uploader Widget allows your application to upload file/s in the gCube Workspace</description>
|
<description>Workspace Uploader Widget allows your application to upload file/s in the gCube Workspace</description>
|
||||||
<scm>
|
<scm>
|
||||||
|
@ -126,6 +126,12 @@
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.gcube.portlets.widgets</groupId>
|
||||||
|
<artifactId>session-checker</artifactId>
|
||||||
|
<version>[0.0.1-SNAPSHOT, 1.0.0-SNAPSHOT)</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- HOME LIBRARY -->
|
<!-- HOME LIBRARY -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.common</groupId>
|
<groupId>org.gcube.common</groupId>
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
<inherits name="com.google.gwt.json.JSON" />
|
<inherits name="com.google.gwt.json.JSON" />
|
||||||
|
|
||||||
<inherits name='org.gcube.portlets.user.gcubewidgets.WidgetFactory' />
|
<inherits name='org.gcube.portlets.user.gcubewidgets.WidgetFactory' />
|
||||||
|
<inherits name='org.gcube.portlets.widgets.sessionchecker.SessionChecker' />
|
||||||
<!-- Inherit the default GWT style sheet. You can change -->
|
<!-- Inherit the default GWT style sheet. You can change -->
|
||||||
<!-- the theme of your GWT application by uncommenting -->
|
<!-- the theme of your GWT application by uncommenting -->
|
||||||
<!-- any one of the following lines. -->
|
<!-- any one of the following lines. -->
|
||||||
|
|
|
@ -1,112 +1,112 @@
|
||||||
//package org.gcube.portlets.widgets.workspaceuploader.client;
|
package org.gcube.portlets.widgets.workspaceuploader.client;
|
||||||
//
|
|
||||||
//import org.gcube.portlets.widgets.workspaceuploader.client.uploader.DialogUpload.UPLOAD_TYPE;
|
import org.gcube.portlets.widgets.workspaceuploader.client.uploader.DialogUpload.UPLOAD_TYPE;
|
||||||
//import org.gcube.portlets.widgets.workspaceuploader.client.uploader.MultipleDilaogUpload;
|
import org.gcube.portlets.widgets.workspaceuploader.client.uploader.MultipleDilaogUpload;
|
||||||
//import org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload;
|
import org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload;
|
||||||
//
|
|
||||||
//import com.google.gwt.core.client.EntryPoint;
|
import com.google.gwt.core.client.EntryPoint;
|
||||||
//import com.google.gwt.core.client.ScriptInjector;
|
import com.google.gwt.core.client.ScriptInjector;
|
||||||
//import com.google.gwt.core.shared.GWT;
|
import com.google.gwt.core.shared.GWT;
|
||||||
//import com.google.gwt.event.dom.client.ClickEvent;
|
import com.google.gwt.event.dom.client.ClickEvent;
|
||||||
//import com.google.gwt.event.dom.client.ClickHandler;
|
import com.google.gwt.event.dom.client.ClickHandler;
|
||||||
//import com.google.gwt.user.client.Window;
|
import com.google.gwt.user.client.Window;
|
||||||
//import com.google.gwt.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
//import com.google.gwt.user.client.ui.Button;
|
import com.google.gwt.user.client.ui.Button;
|
||||||
//import com.google.gwt.user.client.ui.RootPanel;
|
import com.google.gwt.user.client.ui.RootPanel;
|
||||||
//
|
|
||||||
///**
|
/**
|
||||||
// * Entry point classes define <code>onModuleLoad()</code>.
|
* Entry point classes define <code>onModuleLoad()</code>.
|
||||||
// */
|
*/
|
||||||
//public class WorkspaceUploader implements EntryPoint {
|
public class WorkspaceUploader implements EntryPoint {
|
||||||
//
|
|
||||||
// String headerTitle = "Upload in your Workspace";
|
String headerTitle = "Upload in your Workspace";
|
||||||
// String parentId;
|
String parentId;
|
||||||
// private Button buttonUploader;
|
private Button buttonUploader;
|
||||||
// private Button buttonDirect;
|
private Button buttonDirect;
|
||||||
//
|
|
||||||
// public void onModuleLoad() {
|
public void onModuleLoad() {
|
||||||
//
|
|
||||||
// boolean jQueryLoaded = isjQueryLoaded();
|
boolean jQueryLoaded = isjQueryLoaded();
|
||||||
// GWT.log("jQueryLoaded: "+jQueryLoaded);
|
GWT.log("jQueryLoaded: "+jQueryLoaded);
|
||||||
//
|
|
||||||
// GWT.log("Injected : http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js");
|
GWT.log("Injected : http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js");
|
||||||
//
|
|
||||||
// if (!jQueryLoaded) {
|
if (!jQueryLoaded) {
|
||||||
|
ScriptInjector.fromUrl("http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js")
|
||||||
|
.setWindow(ScriptInjector.TOP_WINDOW)
|
||||||
|
.inject();
|
||||||
|
}
|
||||||
|
|
||||||
// ScriptInjector.fromUrl("http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js")
|
// ScriptInjector.fromUrl("http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js")
|
||||||
// .setWindow(ScriptInjector.TOP_WINDOW)
|
// .setWindow(ScriptInjector.TOP_WINDOW)
|
||||||
// .inject();
|
// .inject();
|
||||||
// }
|
|
||||||
//
|
buttonUploader = new Button("Upload in your Workspace");
|
||||||
//// ScriptInjector.fromUrl("http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js")
|
buttonDirect = new Button("Upload (Stream) in your Workspace");
|
||||||
//// .setWindow(ScriptInjector.TOP_WINDOW)
|
enableUpload(false);
|
||||||
//// .inject();
|
|
||||||
//
|
WorkspaceUploaderServiceAsync.Util.getInstance().getWorkspaceId(
|
||||||
// buttonUploader = new Button("Upload in your Workspace");
|
new AsyncCallback<String>() {
|
||||||
// buttonDirect = new Button("Upload (Stream) in your Workspace");
|
|
||||||
// enableUpload(false);
|
@Override
|
||||||
//
|
public void onSuccess(String result) {
|
||||||
// WorkspaceUploaderServiceAsync.Util.getInstance().getWorkspaceId(
|
|
||||||
// new AsyncCallback<String>() {
|
if (result != null) {
|
||||||
//
|
parentId = result;
|
||||||
// @Override
|
enableUpload(true);
|
||||||
// public void onSuccess(String result) {
|
} else {
|
||||||
//
|
Window.alert("An error occurred on recovering workspace, try again later");
|
||||||
// if (result != null) {
|
enableUpload(true);
|
||||||
// parentId = result;
|
}
|
||||||
// enableUpload(true);
|
}
|
||||||
// } else {
|
|
||||||
// Window.alert("An error occurred on recovering workspace, try again later");
|
@Override
|
||||||
// enableUpload(true);
|
public void onFailure(Throwable caught) {
|
||||||
// }
|
Window.alert("An error occurred on recovering workspace, try again later");
|
||||||
// }
|
enableUpload(true);
|
||||||
//
|
}
|
||||||
// @Override
|
});
|
||||||
// public void onFailure(Throwable caught) {
|
|
||||||
// Window.alert("An error occurred on recovering workspace, try again later");
|
buttonDirect.addClickHandler(new ClickHandler() {
|
||||||
// enableUpload(true);
|
|
||||||
// }
|
@Override
|
||||||
// });
|
public void onClick(ClickEvent event) {
|
||||||
//
|
MultipleDilaogUpload uploadStream = new MultipleDilaogUpload(headerTitle, parentId, org.gcube.portlets.widgets.workspaceuploader.client.uploader.DialogUpload.UPLOAD_TYPE.File);
|
||||||
// buttonDirect.addClickHandler(new ClickHandler() {
|
// uploadStream.initFileReader();
|
||||||
//
|
uploadStream.center();
|
||||||
// @Override
|
|
||||||
// public void onClick(ClickEvent event) {
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
final MultipleDNDUpload dnd = new MultipleDNDUpload();
|
||||||
|
|
||||||
|
buttonDirect.addClickHandler(new ClickHandler() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(ClickEvent event) {
|
||||||
// MultipleDilaogUpload uploadStream = new MultipleDilaogUpload(headerTitle, parentId, org.gcube.portlets.widgets.workspaceuploader.client.uploader.DialogUpload.UPLOAD_TYPE.File);
|
// MultipleDilaogUpload uploadStream = new MultipleDilaogUpload(headerTitle, parentId, org.gcube.portlets.widgets.workspaceuploader.client.uploader.DialogUpload.UPLOAD_TYPE.File);
|
||||||
// uploadStream.initFileReader();
|
// uploadStream.initFileReader();
|
||||||
// uploadStream.center();
|
// uploadStream.center();
|
||||||
//
|
dnd.setParameters(parentId, UPLOAD_TYPE.File);
|
||||||
// }
|
|
||||||
// });
|
}
|
||||||
//
|
});
|
||||||
// final MultipleDNDUpload dnd = new MultipleDNDUpload();
|
|
||||||
//
|
RootPanel.get("workspace-uploader").add(dnd);
|
||||||
// buttonDirect.addClickHandler(new ClickHandler() {
|
RootPanel.get("workspace-uploader").add(buttonDirect);
|
||||||
//
|
}
|
||||||
// @Override
|
|
||||||
// public void onClick(ClickEvent event) {
|
private void enableUpload(boolean bool){
|
||||||
//// MultipleDilaogUpload uploadStream = new MultipleDilaogUpload(headerTitle, parentId, org.gcube.portlets.widgets.workspaceuploader.client.uploader.DialogUpload.UPLOAD_TYPE.File);
|
buttonUploader.setEnabled(bool);
|
||||||
//// uploadStream.initFileReader();
|
buttonDirect.setEnabled(bool);
|
||||||
//// uploadStream.center();
|
}
|
||||||
// dnd.setParameters(parentId, UPLOAD_TYPE.File);
|
|
||||||
//
|
/**
|
||||||
// }
|
* Checks if is j query loaded.
|
||||||
// });
|
*
|
||||||
//
|
* @return true, if is j query loaded
|
||||||
// RootPanel.get("workspace-uploader").add(dnd);
|
*/
|
||||||
// RootPanel.get("workspace-uploader").add(buttonDirect);
|
private native boolean isjQueryLoaded() /*-{
|
||||||
// }
|
return (typeof $wnd['jQuery'] !== 'undefined');
|
||||||
//
|
}-*/;
|
||||||
// private void enableUpload(boolean bool){
|
}
|
||||||
// buttonUploader.setEnabled(bool);
|
|
||||||
// buttonDirect.setEnabled(bool);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * Checks if is j query loaded.
|
|
||||||
// *
|
|
||||||
// * @return true, if is j query loaded
|
|
||||||
// */
|
|
||||||
// private native boolean isjQueryLoaded() /*-{
|
|
||||||
// return (typeof $wnd['jQuery'] !== 'undefined');
|
|
||||||
// }-*/;
|
|
||||||
//}
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ package org.gcube.portlets.widgets.workspaceuploader.client.uploader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.portlets.widgets.sessionchecker.client.CheckSession;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.client.ClosableDialog;
|
import org.gcube.portlets.widgets.workspaceuploader.client.ClosableDialog;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.client.ConstantsWorkspaceUploader;
|
import org.gcube.portlets.widgets.workspaceuploader.client.ConstantsWorkspaceUploader;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.client.DialogResult;
|
import org.gcube.portlets.widgets.workspaceuploader.client.DialogResult;
|
||||||
|
@ -216,6 +217,12 @@ public class DialogUpload extends ClosableDialog implements HasWorskpaceUploadNo
|
||||||
removeLoading();
|
removeLoading();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case SESSION_EXPIRED:{
|
||||||
|
GWT.log("Upload aborted due to session expired: "+ resultMessage.getMessage());
|
||||||
|
CheckSession.showLogoutDialog();
|
||||||
|
removeLoading();
|
||||||
|
break;
|
||||||
|
}
|
||||||
case OK: {
|
case OK: {
|
||||||
// removeLoading();
|
// removeLoading();
|
||||||
// UploaderMonitor.getInstance().pollWorkspaceUploaderId(resultMessage.getMessage());
|
// UploaderMonitor.getInstance().pollWorkspaceUploaderId(resultMessage.getMessage());
|
||||||
|
|
|
@ -6,6 +6,7 @@ package org.gcube.portlets.widgets.workspaceuploader.client.uploader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import org.gcube.portlets.widgets.sessionchecker.client.CheckSession;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.client.ConstantsWorkspaceUploader;
|
import org.gcube.portlets.widgets.workspaceuploader.client.ConstantsWorkspaceUploader;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.client.DialogResult;
|
import org.gcube.portlets.widgets.workspaceuploader.client.DialogResult;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploaderServiceAsync;
|
import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploaderServiceAsync;
|
||||||
|
@ -161,13 +162,19 @@ public class MultipleDilaogUpload extends DialogUpload {
|
||||||
GWT.log("Error during upload " + resultMessage.getMessage());
|
GWT.log("Error during upload " + resultMessage.getMessage());
|
||||||
break;
|
break;
|
||||||
case WARN: {
|
case WARN: {
|
||||||
GWT.log("Upload completed with warnings "
|
GWT.log("Upload completed with warnings "+ resultMessage.getMessage());
|
||||||
+ resultMessage.getMessage());
|
removeLoading();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SESSION_EXPIRED:{
|
||||||
|
GWT.log("Upload aborted due to session expired: "+ resultMessage.getMessage());
|
||||||
|
CheckSession.showLogoutDialog();
|
||||||
removeLoading();
|
removeLoading();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case OK: {
|
case OK: {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ package org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.gcube.portlets.widgets.sessionchecker.client.CheckSession;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.client.ConstantsWorkspaceUploader;
|
import org.gcube.portlets.widgets.workspaceuploader.client.ConstantsWorkspaceUploader;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploadNotification.HasWorskpaceUploadNotificationListener;
|
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.WorkspaceUploadNotification.WorskpaceUploadNotificationListener;
|
||||||
|
@ -543,7 +544,7 @@ public class MultipleDNDUpload extends LayoutPanel implements HasWorskpaceUpload
|
||||||
} // stops the browser from redirecting off to the image.
|
} // stops the browser from redirecting off to the image.
|
||||||
|
|
||||||
var uploadUUID = generateUUID();
|
var uploadUUID = generateUUID();
|
||||||
console.log("uploadKey: " + uploadUUID);
|
// console.log("uploadKey: " + uploadUUID);
|
||||||
//NEW WORKSPACE FIELDS
|
//NEW WORKSPACE FIELDS
|
||||||
instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::newWorkspaceFieldsManagerForUUID(Ljava/lang/String;)(uploadUUID);
|
instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::newWorkspaceFieldsManagerForUUID(Ljava/lang/String;)(uploadUUID);
|
||||||
|
|
||||||
|
@ -607,9 +608,29 @@ public class MultipleDNDUpload extends LayoutPanel implements HasWorskpaceUpload
|
||||||
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::currentJsonKey;
|
||||||
// var jsonKeys = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::getJsonKeyForFiles(Ljava/lang/String;)
|
// 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;
|
// var jsonKeysMap = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::jsonKeys;
|
||||||
console.log("jsonKeys: " + jsonKeys);
|
// console.log("jsonKeys: " + jsonKeys);
|
||||||
|
|
||||||
var xhr = new XMLHttpRequest();
|
var xhr = new XMLHttpRequest();
|
||||||
|
|
||||||
|
xhr.onreadystatechange=function() {
|
||||||
|
if (xhr.readyState === 4){ //if complete
|
||||||
|
if(xhr.status === 200){ //check if "OK" (200)
|
||||||
|
// console.log("status is OK");
|
||||||
|
//success
|
||||||
|
} else {
|
||||||
|
//otherwise, some other code was returned
|
||||||
|
|
||||||
|
if(xhr.status === 401){ //ASL session is expired
|
||||||
|
// console.log("status is 401");
|
||||||
|
instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::showLogoutDialog()();
|
||||||
|
}else{
|
||||||
|
console.log(xhr.status);
|
||||||
|
instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::showAlert(Ljava/lang/String;)("Sorry, an error occurred during file/s upload. Try again");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
xhr.open(opts.type, opts.url, true);
|
xhr.open(opts.type, opts.url, true);
|
||||||
|
|
||||||
var formdata = new FormData();
|
var formdata = new FormData();
|
||||||
|
@ -738,6 +759,14 @@ public class MultipleDNDUpload extends LayoutPanel implements HasWorskpaceUpload
|
||||||
controller.addWorkspaceUploadListener(handler);
|
controller.addWorkspaceUploadListener(handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show logout dialog.
|
||||||
|
*/
|
||||||
|
private void showLogoutDialog(){
|
||||||
|
CheckSession.showLogoutDialog();
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
|
|
@ -169,6 +169,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
if (!ServletFileUpload.isMultipartContent(request)) {
|
if (!ServletFileUpload.isMultipartContent(request)) {
|
||||||
logger.error("ERROR: multipart request not found");
|
logger.error("ERROR: multipart request not found");
|
||||||
sendError(response, "ERROR: multipart request not found");
|
sendError(response, "ERROR: multipart request not found");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -177,6 +178,14 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
HttpSession session = request.getSession();
|
HttpSession session = request.getSession();
|
||||||
logger.info("UPLOAD-SERVLET session: "+session);
|
logger.info("UPLOAD-SERVLET session: "+session);
|
||||||
logger.debug("UPLOAD-SERVLET (" + session.getId() + ") new upload request received.");
|
logger.debug("UPLOAD-SERVLET (" + session.getId() + ") new upload request received.");
|
||||||
|
|
||||||
|
if(WsUtil.isSessionExpired(session)){
|
||||||
|
logger.error("SESSION_EXPIRED: session is expired");
|
||||||
|
sendSessionExpired(response, "SESSION_EXPIRED: session is expired");
|
||||||
|
return;
|
||||||
|
// sendError(response, "SESSION_EXPIRED: session is expired");
|
||||||
|
}
|
||||||
|
|
||||||
String destinationId = null;
|
String destinationId = null;
|
||||||
String uploadType = null;
|
String uploadType = null;
|
||||||
boolean isOverwrite = false;
|
boolean isOverwrite = false;
|
||||||
|
@ -767,6 +776,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
/**
|
/**
|
||||||
* Creates the template.
|
* Creates the template.
|
||||||
*
|
*
|
||||||
|
* @param request the request
|
||||||
* @param workspaceUploader the workspace uploader
|
* @param workspaceUploader the workspace uploader
|
||||||
* @param httpSession the http session
|
* @param httpSession the http session
|
||||||
* @param wa the wa
|
* @param wa the wa
|
||||||
|
@ -851,6 +861,32 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Send session expired.
|
||||||
|
*
|
||||||
|
* @param response the response
|
||||||
|
* @param message the message
|
||||||
|
* @throws IOException Signals that an I/O exception has occurred.
|
||||||
|
*/
|
||||||
|
protected void sendSessionExpired(HttpServletResponse response, String message) throws IOException{
|
||||||
|
try {
|
||||||
|
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||||
|
HandlerResultMessage resultMessage = HandlerResultMessage.sessionExpiredResult(message);
|
||||||
|
response.getWriter().write(resultMessage.toString());
|
||||||
|
//5.6 Closure of Response Object:
|
||||||
|
//When a response is closed, the container must immediately flush all remaining content in the response buffer to the client
|
||||||
|
// response.flushBuffer();
|
||||||
|
} catch (IOException e){
|
||||||
|
logger.warn("IOException class name: "+e.getClass().getSimpleName());
|
||||||
|
if (e.getClass().getSimpleName().equals("ClientAbortException"))
|
||||||
|
logger.warn("Skipping ClientAbortException: "+e.getMessage());
|
||||||
|
else
|
||||||
|
throw e; //Sending Exceptions
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send message.
|
* Send message.
|
||||||
*
|
*
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class WsUtil {
|
||||||
public static final String NOTIFICATION_PORTLET_CLASS_ID = "org.gcube.portlets.user.workspace.server.GWTWorkspaceServiceImpl";
|
public static final String NOTIFICATION_PORTLET_CLASS_ID = "org.gcube.portlets.user.workspace.server.GWTWorkspaceServiceImpl";
|
||||||
//IN DEV
|
//IN DEV
|
||||||
public static final String TEST_SCOPE = "/gcube/devsec";
|
public static final String TEST_SCOPE = "/gcube/devsec";
|
||||||
public static String TEST_USER = "francesco.mangiacrapa";
|
public static String TEST_USER = "test.user";
|
||||||
public static String TEST_USER_FULL_NAME = "Test User";
|
public static String TEST_USER_FULL_NAME = "Test User";
|
||||||
|
|
||||||
|
|
||||||
|
@ -78,7 +78,8 @@ public class WsUtil {
|
||||||
user=TEST_USER;
|
user=TEST_USER;
|
||||||
|
|
||||||
if (!isWithinPortal()) { //DEV MODE
|
if (!isWithinPortal()) { //DEV MODE
|
||||||
user = "francesco.mangiacrapa";
|
// user = "francesco.mangiacrapa";
|
||||||
|
user=TEST_USER;
|
||||||
TEST_USER_FULL_NAME = "Francesco Mangiacrapa";
|
TEST_USER_FULL_NAME = "Francesco Mangiacrapa";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,6 +15,10 @@ import java.io.Serializable;
|
||||||
public class HandlerResultMessage implements Serializable{
|
public class HandlerResultMessage implements Serializable{
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
private static final String SEPARATOR = ":";
|
||||||
protected Status status;
|
protected Status status;
|
||||||
protected String message;
|
protected String message;
|
||||||
|
|
||||||
|
@ -46,12 +50,17 @@ public class HandlerResultMessage implements Serializable{
|
||||||
/**
|
/**
|
||||||
* If the result is unknown.
|
* If the result is unknown.
|
||||||
*/
|
*/
|
||||||
UNKNOWN;
|
UNKNOWN,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the session is expired.
|
||||||
|
*/
|
||||||
|
SESSION_EXPIRED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TO SERIALIZATION
|
* TO SERIALIZATION.
|
||||||
*/
|
*/
|
||||||
public HandlerResultMessage() {
|
public HandlerResultMessage() {
|
||||||
}
|
}
|
||||||
|
@ -96,6 +105,17 @@ public class HandlerResultMessage implements Serializable{
|
||||||
return new HandlerResultMessage(Status.WARN, message);
|
return new HandlerResultMessage(Status.WARN, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Session expired result.
|
||||||
|
*
|
||||||
|
* @param message the message
|
||||||
|
* @return the handler result message
|
||||||
|
*/
|
||||||
|
public static HandlerResultMessage sessionExpiredResult(String message){
|
||||||
|
return new HandlerResultMessage(Status.SESSION_EXPIRED, message);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses the result.
|
* Parses the result.
|
||||||
* expected status:message (e.g. OK:Upload aborted)
|
* expected status:message (e.g. OK:Upload aborted)
|
||||||
|
@ -158,7 +178,7 @@ public class HandlerResultMessage implements Serializable{
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
builder.append(status);
|
builder.append(status);
|
||||||
builder.append(":");
|
builder.append(SEPARATOR);
|
||||||
builder.append(message);
|
builder.append(message);
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue