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:
Francesco Mangiacrapa 2016-08-30 15:11:06 +00:00
parent d6ca12a221
commit e6929fbba2
9 changed files with 228 additions and 121 deletions

14
pom.xml
View File

@ -12,7 +12,7 @@
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>workspace-uploader</artifactId>
<packaging>jar</packaging>
<version>1.4.0-SNAPSHOT</version>
<version>1.5.0-SNAPSHOT</version>
<name>Workspace Uploader Widget</name>
<description>Workspace Uploader Widget allows your application to upload file/s in the gCube Workspace</description>
<scm>
@ -80,7 +80,7 @@
<artifactId>gcube-widgets</artifactId>
<scope>provided</scope>
</dependency>
<!-- FWS -->
<dependency>
<groupId>org.gcube.resources.discovery</groupId>
@ -100,7 +100,7 @@
<artifactId>usermanagement-core</artifactId>
<scope>provided</scope>
</dependency>
<!-- TO USE LIFERAY 6.2 -->
<dependency>
<groupId>com.liferay.portal</groupId>
@ -126,6 +126,12 @@
<scope>provided</scope>
</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 -->
<dependency>
<groupId>org.gcube.common</groupId>
@ -183,7 +189,7 @@
<artifactId>social-networking-library</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>aslsocial</artifactId>

View File

@ -4,12 +4,13 @@
<inherits name='com.google.gwt.user.User' />
<inherits name="com.google.gwt.resources.Resources" />
<inherits name="com.google.gwt.json.JSON" />
<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 -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard' /> -->
<!-- <inherits name='com.google.gwt.user.theme.standard.Standard' /> -->
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->

View File

@ -1,112 +1,112 @@
//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.MultipleDilaogUpload;
//import org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload;
//
//import com.google.gwt.core.client.EntryPoint;
//import com.google.gwt.core.client.ScriptInjector;
//import com.google.gwt.core.shared.GWT;
//import com.google.gwt.event.dom.client.ClickEvent;
//import com.google.gwt.event.dom.client.ClickHandler;
//import com.google.gwt.user.client.Window;
//import com.google.gwt.user.client.rpc.AsyncCallback;
//import com.google.gwt.user.client.ui.Button;
//import com.google.gwt.user.client.ui.RootPanel;
//
///**
// * Entry point classes define <code>onModuleLoad()</code>.
// */
//public class WorkspaceUploader implements EntryPoint {
//
// String headerTitle = "Upload in your Workspace";
// String parentId;
// private Button buttonUploader;
// private Button buttonDirect;
//
// public void onModuleLoad() {
//
// boolean jQueryLoaded = isjQueryLoaded();
// GWT.log("jQueryLoaded: "+jQueryLoaded);
//
// GWT.log("Injected : http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js");
//
// if (!jQueryLoaded) {
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.MultipleDilaogUpload;
import org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.ScriptInjector;
import com.google.gwt.core.shared.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.RootPanel;
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class WorkspaceUploader implements EntryPoint {
String headerTitle = "Upload in your Workspace";
String parentId;
private Button buttonUploader;
private Button buttonDirect;
public void onModuleLoad() {
boolean jQueryLoaded = isjQueryLoaded();
GWT.log("jQueryLoaded: "+jQueryLoaded);
GWT.log("Injected : http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js");
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")
// .setWindow(ScriptInjector.TOP_WINDOW)
// .inject();
// }
//
//// ScriptInjector.fromUrl("http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js")
//// .setWindow(ScriptInjector.TOP_WINDOW)
//// .inject();
//
// buttonUploader = new Button("Upload in your Workspace");
// buttonDirect = new Button("Upload (Stream) in your Workspace");
// enableUpload(false);
//
// WorkspaceUploaderServiceAsync.Util.getInstance().getWorkspaceId(
// new AsyncCallback<String>() {
//
// @Override
// public void onSuccess(String result) {
//
// if (result != null) {
// parentId = result;
// enableUpload(true);
// } else {
// 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");
// enableUpload(true);
// }
// });
//
// buttonDirect.addClickHandler(new ClickHandler() {
//
// @Override
// public void onClick(ClickEvent event) {
buttonUploader = new Button("Upload in your Workspace");
buttonDirect = new Button("Upload (Stream) in your Workspace");
enableUpload(false);
WorkspaceUploaderServiceAsync.Util.getInstance().getWorkspaceId(
new AsyncCallback<String>() {
@Override
public void onSuccess(String result) {
if (result != null) {
parentId = result;
enableUpload(true);
} else {
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");
enableUpload(true);
}
});
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);
// uploadStream.initFileReader();
uploadStream.center();
}
});
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);
// uploadStream.initFileReader();
// uploadStream.center();
//
// }
// });
//
// 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);
//// uploadStream.initFileReader();
//// uploadStream.center();
// dnd.setParameters(parentId, UPLOAD_TYPE.File);
//
// }
// });
//
// RootPanel.get("workspace-uploader").add(dnd);
// RootPanel.get("workspace-uploader").add(buttonDirect);
// }
//
// 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');
// }-*/;
//}
dnd.setParameters(parentId, UPLOAD_TYPE.File);
}
});
RootPanel.get("workspace-uploader").add(dnd);
RootPanel.get("workspace-uploader").add(buttonDirect);
}
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');
}-*/;
}

View File

@ -4,6 +4,7 @@ package org.gcube.portlets.widgets.workspaceuploader.client.uploader;
import java.util.ArrayList;
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.ConstantsWorkspaceUploader;
import org.gcube.portlets.widgets.workspaceuploader.client.DialogResult;
@ -216,6 +217,12 @@ public class DialogUpload extends ClosableDialog implements HasWorskpaceUploadNo
removeLoading();
break;
}
case SESSION_EXPIRED:{
GWT.log("Upload aborted due to session expired: "+ resultMessage.getMessage());
CheckSession.showLogoutDialog();
removeLoading();
break;
}
case OK: {
// removeLoading();
// UploaderMonitor.getInstance().pollWorkspaceUploaderId(resultMessage.getMessage());

View File

@ -6,6 +6,7 @@ package org.gcube.portlets.widgets.workspaceuploader.client.uploader;
import java.util.ArrayList;
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.DialogResult;
import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploaderServiceAsync;
@ -161,13 +162,19 @@ public class MultipleDilaogUpload extends DialogUpload {
GWT.log("Error during upload " + resultMessage.getMessage());
break;
case WARN: {
GWT.log("Upload completed with warnings "
+ resultMessage.getMessage());
GWT.log("Upload completed with warnings "+ resultMessage.getMessage());
removeLoading();
break;
}
case SESSION_EXPIRED:{
GWT.log("Upload aborted due to session expired: "+ resultMessage.getMessage());
CheckSession.showLogoutDialog();
removeLoading();
break;
}
case OK: {
}
}
}

View File

@ -6,6 +6,7 @@ package org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop;
import java.util.HashMap;
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.WorkspaceUploadNotification.HasWorskpaceUploadNotificationListener;
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.
var uploadUUID = generateUUID();
console.log("uploadKey: " + uploadUUID);
// console.log("uploadKey: " + uploadUUID);
//NEW WORKSPACE FIELDS
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::getJsonKeyForFiles(Ljava/lang/String;)
// 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();
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);
var formdata = new FormData();
@ -738,6 +759,14 @@ public class MultipleDNDUpload extends LayoutPanel implements HasWorskpaceUpload
controller.addWorkspaceUploadListener(handler);
}
/**
* Show logout dialog.
*/
private void showLogoutDialog(){
CheckSession.showLogoutDialog();
}
/*
* (non-Javadoc)
*

View File

@ -169,6 +169,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
if (!ServletFileUpload.isMultipartContent(request)) {
logger.error("ERROR: multipart request not found");
sendError(response, "ERROR: multipart request not found");
return;
}
try {
@ -177,6 +178,14 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
HttpSession session = request.getSession();
logger.info("UPLOAD-SERVLET session: "+session);
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 uploadType = null;
boolean isOverwrite = false;
@ -767,6 +776,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
/**
* Creates the template.
*
* @param request the request
* @param workspaceUploader the workspace uploader
* @param httpSession the http session
* @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.
*

View File

@ -35,7 +35,7 @@ public class WsUtil {
public static final String NOTIFICATION_PORTLET_CLASS_ID = "org.gcube.portlets.user.workspace.server.GWTWorkspaceServiceImpl";
//IN DEV
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";
@ -78,7 +78,8 @@ public class WsUtil {
user=TEST_USER;
if (!isWithinPortal()) { //DEV MODE
user = "francesco.mangiacrapa";
// user = "francesco.mangiacrapa";
user=TEST_USER;
TEST_USER_FULL_NAME = "Francesco Mangiacrapa";
}

View File

@ -15,6 +15,10 @@ import java.io.Serializable;
public class HandlerResultMessage implements Serializable{
/**
*
*/
private static final String SEPARATOR = ":";
protected Status status;
protected String message;
@ -46,12 +50,17 @@ public class HandlerResultMessage implements Serializable{
/**
* If the result is unknown.
*/
UNKNOWN;
UNKNOWN,
/**
* If the session is expired.
*/
SESSION_EXPIRED;
}
/**
* TO SERIALIZATION
* TO SERIALIZATION.
*/
public HandlerResultMessage() {
}
@ -96,6 +105,17 @@ public class HandlerResultMessage implements Serializable{
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.
* expected status:message (e.g. OK:Upload aborted)
@ -158,7 +178,7 @@ public class HandlerResultMessage implements Serializable{
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append(status);
builder.append(":");
builder.append(SEPARATOR);
builder.append(message);
return builder.toString();
}