Removed ASL Session Dependency
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-uploader@134673 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
02ad0cc313
commit
a6ba885760
32
pom.xml
32
pom.xml
|
@ -12,7 +12,7 @@
|
|||
<groupId>org.gcube.portlets.widgets</groupId>
|
||||
<artifactId>workspace-uploader</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>1.5.0-SNAPSHOT</version>
|
||||
<version>2.0.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,12 @@
|
|||
<artifactId>gcube-widgets</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>client-context-library</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT,)</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!-- FWS -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.resources.discovery</groupId>
|
||||
|
@ -109,29 +114,11 @@
|
|||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>custom-portal-handler</artifactId>
|
||||
<groupId>org.gcube.common.portal</groupId>
|
||||
<artifactId>portal-manager</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
||||
<artifactId>aslcore</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
||||
<artifactId>accesslogger</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.widgets</groupId>
|
||||
<artifactId>session-checker</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT,2.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
|
||||
<!-- HOME LIBRARY -->
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
|
@ -158,7 +145,6 @@
|
|||
<dependency>
|
||||
<groupId>commons-httpclient</groupId>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
<version>3.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
|
|
@ -6,19 +6,14 @@
|
|||
<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.chrome.Chrome'/> -->
|
||||
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
|
||||
|
||||
<!--Inherit the GCubeClientContext widget code -->
|
||||
<inherits name='org.gcube.portal.clientcontext.GCubeClientContext' />
|
||||
<!-- Other module inherits -->
|
||||
|
||||
<stylesheet src='workspaceuploader.css' />
|
||||
<!-- Specify the app entry point class. -->
|
||||
<!-- <entry-point class='org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploader' /> -->
|
||||
<!-- <entry-point class='org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploader'
|
||||
/> -->
|
||||
|
||||
<!-- Specify the paths for translatable code -->
|
||||
<source path='client' />
|
||||
|
|
|
@ -11,18 +11,19 @@ import com.google.gwt.core.client.GWT;
|
|||
*/
|
||||
public class ConstantsWorkspaceUploader {
|
||||
|
||||
public static final String WORKSPACE_UPLOADER_SERVLET = GWT.getModuleBaseURL() + "workspaceUploadServlet";
|
||||
public static final String WORKSPACE_UPLOADER_SERVLET_MODIFIED = GWT.getModuleBaseURL() + "workspaceUploadServlet";
|
||||
|
||||
public static final String WORKSPACE_UPLOADER_SERVLET_STREAM = GWT.getModuleBaseURL() + "workspaceUploadServletStream";
|
||||
public static final String WORKSPACE_UPLOADER_SERVLET_STREAM__MODIFIED = GWT.getModuleBaseURL() + "workspaceUploadServletStream";
|
||||
|
||||
public static final String WORKSPACE_UPLOADER_SERVICE = GWT.getModuleBaseURL() + "workspaceUploaderService";
|
||||
public static final String WORKSPACE_UPLOADER_SERVICE_MODIFIED = GWT.getModuleBaseURL() + "workspaceUploaderService";
|
||||
|
||||
public static final String WORKSPACE_UPLOADER_WS_UTIL = GWT.getModuleBaseURL() + "workspaceUploaderWsUtil";
|
||||
public static final String WORKSPACE_UPLOADER_WS_UTIL_MODIFIED = GWT.getModuleBaseURL() + "workspaceUploaderWsUtil";
|
||||
|
||||
public static final String SERVER_ERROR = "Sorry, an error has occurred on the server when";
|
||||
public static final String TRY_AGAIN = "Try again";
|
||||
|
||||
// UPLOAD SERVLET PARAMETERS
|
||||
public static final String CURR_GROUP_ID = "currGroupId";
|
||||
public static final String IS_OVERWRITE = "isOverwrite";
|
||||
public static final String UPLOAD_TYPE = "uploadType";
|
||||
public static final String ID_FOLDER = "idFolder";
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package org.gcube.portlets.widgets.workspaceuploader.client;
|
||||
|
||||
import org.gcube.portlets.widgets.workspaceuploader.client.uploader.DialogUpload.UPLOAD_TYPE;
|
||||
import org.gcube.portal.clientcontext.client.GCubeClientContext;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.client.uploader.MultipleDilaogUpload;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload;
|
||||
|
||||
|
@ -78,7 +79,7 @@ public class WorkspaceUploader implements EntryPoint {
|
|||
}
|
||||
});
|
||||
|
||||
final MultipleDNDUpload dnd = new MultipleDNDUpload();
|
||||
final MultipleDNDUpload dnd = new MultipleDNDUpload(parentId, UPLOAD_TYPE.File);
|
||||
|
||||
buttonDirect.addClickHandler(new ClickHandler() {
|
||||
|
||||
|
@ -87,7 +88,7 @@ public class WorkspaceUploader implements EntryPoint {
|
|||
// 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);
|
||||
dnd.setParameters(parentId, UPLOAD_TYPE.File, GCubeClientContext.getCurrentContextId());
|
||||
|
||||
}
|
||||
});
|
||||
|
|
|
@ -4,7 +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.portal.clientcontext.client.GCubeClientContext;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.client.ClosableDialog;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.client.ConstantsWorkspaceUploader;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.client.DialogResult;
|
||||
|
@ -90,11 +90,12 @@ public class DialogUpload extends ClosableDialog implements HasWorskpaceUploadNo
|
|||
this.parentIdentifier = parentId;
|
||||
this.uploadType = uploadType;
|
||||
this.addStyleName("fileInputUploader");
|
||||
formPanel.setAction(ConstantsWorkspaceUploader.WORKSPACE_UPLOADER_SERVLET_STREAM);
|
||||
formPanel.setAction(ConstantsWorkspaceUploader.WORKSPACE_UPLOADER_SERVLET_STREAM__MODIFIED);
|
||||
formPanel.setEncoding(FormPanel.ENCODING_MULTIPART);
|
||||
formPanel.setMethod(FormPanel.METHOD_POST);
|
||||
formPanel.setWidth("auto");
|
||||
|
||||
|
||||
|
||||
// Create a panel to hold all of the form widgets.
|
||||
panel = new VerticalPanel();
|
||||
formPanel.setWidget(panel);
|
||||
|
@ -103,8 +104,10 @@ public class DialogUpload extends ClosableDialog implements HasWorskpaceUploadNo
|
|||
fileUpload.setName(ConstantsWorkspaceUploader.UPLOAD_FORM_ELEMENT);
|
||||
|
||||
// Add hidden parameters
|
||||
panel.add(new Hidden(ConstantsWorkspaceUploader.CURR_GROUP_ID, GCubeClientContext.getCurrentContextId()));
|
||||
panel.add(new Hidden(ConstantsWorkspaceUploader.ID_FOLDER,parentId));
|
||||
panel.add(new Hidden(ConstantsWorkspaceUploader.UPLOAD_TYPE,uploadType.toString()));
|
||||
|
||||
panel.add(hiddenOverwrite);
|
||||
|
||||
initJsonClientKeys();
|
||||
|
@ -219,7 +222,7 @@ public class DialogUpload extends ClosableDialog implements HasWorskpaceUploadNo
|
|||
}
|
||||
case SESSION_EXPIRED:{
|
||||
GWT.log("Upload aborted due to session expired: "+ resultMessage.getMessage());
|
||||
CheckSession.showLogoutDialog();
|
||||
Window.alert("Session expired, please reload the page");
|
||||
removeLoading();
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -6,7 +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;
|
||||
|
@ -45,7 +45,7 @@ public class MultipleDilaogUpload extends DialogUpload {
|
|||
|
||||
private String idFolder;
|
||||
private UPLOAD_TYPE type;
|
||||
private String servlet = ConstantsWorkspaceUploader.WORKSPACE_UPLOADER_SERVLET_STREAM;
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new multiple dilaog upload stream.
|
||||
|
@ -168,7 +168,7 @@ public class MultipleDilaogUpload extends DialogUpload {
|
|||
}
|
||||
case SESSION_EXPIRED:{
|
||||
GWT.log("Upload aborted due to session expired: "+ resultMessage.getMessage());
|
||||
CheckSession.showLogoutDialog();
|
||||
Window.alert("Session expired, please reload the page");
|
||||
removeLoading();
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import java.util.LinkedHashMap;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.gcube.portal.clientcontext.client.GCubeClientContext;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.client.ClosableDialog;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.client.ConstantsWorkspaceUploader;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploaderListenerController;
|
||||
|
@ -102,7 +103,8 @@ public class UploaderMonitor {
|
|||
|
||||
timer.cancel();
|
||||
|
||||
RequestBuilder request = new RequestBuilder(RequestBuilder.GET, ConstantsWorkspaceUploader.WORKSPACE_UPLOADER_SERVLET_STREAM+"?"+ConstantsWorkspaceUploader.CLIENT_UPLOAD_KEYS+"="+clientKey+"&"+ConstantsWorkspaceUploader.CANCEL_UPLOAD+"=true");
|
||||
RequestBuilder request = new RequestBuilder(RequestBuilder.GET, ConstantsWorkspaceUploader.WORKSPACE_UPLOADER_SERVLET_STREAM__MODIFIED+"?"+ConstantsWorkspaceUploader.CLIENT_UPLOAD_KEYS+"="+clientKey+"&"+ConstantsWorkspaceUploader.CANCEL_UPLOAD+"=true");
|
||||
request = GCubeClientContext.injectContext(request);
|
||||
try {
|
||||
request.sendRequest(null, new RequestCallback() {
|
||||
|
||||
|
|
|
@ -6,7 +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.portal.clientcontext.client.GCubeClientContext;
|
||||
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;
|
||||
|
@ -18,6 +18,7 @@ import com.google.gwt.core.shared.GWT;
|
|||
import com.google.gwt.user.client.Random;
|
||||
import com.google.gwt.user.client.Window;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.gwt.user.client.ui.Hidden;
|
||||
import com.google.gwt.user.client.ui.LayoutPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
|
||||
|
@ -34,12 +35,13 @@ public class MultipleDNDUpload extends LayoutPanel implements HasWorskpaceUpload
|
|||
private UPLOAD_TYPE type;
|
||||
|
||||
// private String jsonKeys;
|
||||
private String servlet = ConstantsWorkspaceUploader.WORKSPACE_UPLOADER_SERVLET_STREAM;
|
||||
private String service = ConstantsWorkspaceUploader.WORKSPACE_UPLOADER_SERVICE;
|
||||
private String workspaceUtil = ConstantsWorkspaceUploader.WORKSPACE_UPLOADER_WS_UTIL;
|
||||
private String servlet = ConstantsWorkspaceUploader.WORKSPACE_UPLOADER_SERVLET_STREAM__MODIFIED;
|
||||
private String service = ConstantsWorkspaceUploader.WORKSPACE_UPLOADER_SERVICE_MODIFIED;
|
||||
private String workspaceUtil = ConstantsWorkspaceUploader.WORKSPACE_UPLOADER_WS_UTIL_MODIFIED;
|
||||
|
||||
private String folder_parent_id = ConstantsWorkspaceUploader.FOLDER_PARENT_ID;
|
||||
private String item_name = ConstantsWorkspaceUploader.ITEM_NAME;
|
||||
private String scopeGroupId = "";
|
||||
|
||||
public static final String FILE_DELEMITER = ";";
|
||||
private Widget onlyChild;
|
||||
|
@ -65,18 +67,6 @@ public class MultipleDNDUpload extends LayoutPanel implements HasWorskpaceUpload
|
|||
private String dropTargetInnerID = DROP_TARGET_INNER_CLASS +"-"+ randomID;
|
||||
private String dropTargetUniqueChildID = DROP_TARGET_UNIQUE_CHILD_ID +"-"+ randomID;
|
||||
|
||||
/**
|
||||
* Instantiates a new DND file reader.
|
||||
*/
|
||||
public MultipleDNDUpload() {
|
||||
this.getElement().setId(dropTargetID);
|
||||
String dnd = "<div id='"+this.dropTargetOuterID+"' class='"+DROP_TARGET_OUTER_CLASS+"'><div id='"+this.dropTargetInnerID+"' class='"+DROP_TARGET_INNER_CLASS+"'></div></div>";
|
||||
GWT.log(dnd);
|
||||
HTML html = new HTML(dnd);
|
||||
this.add(html);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Instantiates a new multiple dnd upload.
|
||||
*
|
||||
|
@ -84,8 +74,13 @@ public class MultipleDNDUpload extends LayoutPanel implements HasWorskpaceUpload
|
|||
* @param uploadType the upload type
|
||||
*/
|
||||
public MultipleDNDUpload(String parentId, UPLOAD_TYPE uploadType) {
|
||||
this();
|
||||
setParameters(parentId, uploadType);
|
||||
this.getElement().setId(dropTargetID);
|
||||
String dnd = "<div id='"+this.dropTargetOuterID+"' class='"+DROP_TARGET_OUTER_CLASS+"'><div id='"+this.dropTargetInnerID+"' class='"+DROP_TARGET_INNER_CLASS+"'></div></div>";
|
||||
GWT.log(dnd);
|
||||
HTML html = new HTML(dnd);
|
||||
this.add(html);
|
||||
scopeGroupId = GCubeClientContext.getCurrentContextId();
|
||||
setParameters(parentId, uploadType, scopeGroupId);
|
||||
}
|
||||
|
||||
|
||||
|
@ -129,9 +124,10 @@ public class MultipleDNDUpload extends LayoutPanel implements HasWorskpaceUpload
|
|||
* @param uploadType
|
||||
* the upload type
|
||||
*/
|
||||
public void setParameters(String parentId, UPLOAD_TYPE uploadType) {
|
||||
public void setParameters(String parentId, UPLOAD_TYPE uploadType, String scopeGroupId) {
|
||||
this.idFolder = parentId;
|
||||
this.type = uploadType;
|
||||
this.scopeGroupId = scopeGroupId;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -561,6 +557,9 @@ public class MultipleDNDUpload extends LayoutPanel implements HasWorskpaceUpload
|
|||
|
||||
var uploadType = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::type;
|
||||
console.log("uploadType: " + uploadType);
|
||||
|
||||
var scopeGroupId = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::scopeGroupId;
|
||||
console.log("scopeGroupId: " + scopeGroupId);
|
||||
|
||||
if (idfolder === null || idfolder === undefined
|
||||
|| uploadType === null
|
||||
|
@ -637,6 +636,7 @@ public class MultipleDNDUpload extends LayoutPanel implements HasWorskpaceUpload
|
|||
formdata.append("client_upload_keys", jsonKeys);
|
||||
formdata.append("uploadType", uploadType);
|
||||
formdata.append("idFolder", idfolder);
|
||||
formdata.append("currGroupId", scopeGroupId);
|
||||
|
||||
var overwrite = false;
|
||||
formdata.append("isOverwrite", overwrite);
|
||||
|
@ -659,6 +659,7 @@ public class MultipleDNDUpload extends LayoutPanel implements HasWorskpaceUpload
|
|||
var wsUtil = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::workspaceUtil;
|
||||
var folder_parent_id = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::folder_parent_id;
|
||||
var item_name = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::item_name;
|
||||
|
||||
console.log("item_name: " + item_name);
|
||||
var params = folder_parent_id+"="+idfolder+"&"+item_name+"="+files[i].name
|
||||
console.log("params: " + params);
|
||||
|
@ -764,7 +765,7 @@ public class MultipleDNDUpload extends LayoutPanel implements HasWorskpaceUpload
|
|||
* Show logout dialog.
|
||||
*/
|
||||
private void showLogoutDialog(){
|
||||
CheckSession.showLogoutDialog();
|
||||
Window.alert("Session expired, please reload the page");
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -8,8 +8,6 @@ import javax.portlet.PortletRequestDispatcher;
|
|||
import javax.portlet.RenderRequest;
|
||||
import javax.portlet.RenderResponse;
|
||||
|
||||
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
||||
|
||||
|
||||
/**
|
||||
* The Class WorkspaceUploaderPortlet.
|
||||
|
@ -40,11 +38,7 @@ public class WorkspaceUploaderPortlet extends GenericPortlet{
|
|||
* @throws IOException .
|
||||
*/
|
||||
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
|
||||
|
||||
System.out.println("LOADING ********* FROM "+VIEW_JSP);
|
||||
|
||||
ScopeHelper.setContext(request, ScopeHelper.USERNAME_ATTRIBUTE);
|
||||
|
||||
|
||||
// request.setAttribute("fromportlet","true");
|
||||
|
||||
// Invoke the JSP to render
|
||||
|
|
|
@ -374,11 +374,11 @@ public class WorkspaceUploadServlet extends HttpServlet {
|
|||
* @param destinationFolderId the destination folder id
|
||||
* @param isOverwrite the is overwrite
|
||||
*/
|
||||
public static void notifyUploadInSharedFolder(final HttpServletRequest request, final HttpSession httpSession, final Workspace workspace, final String itemId, final String destinationFolderId, final boolean isOverwrite){
|
||||
public static void notifyUploadInSharedFolder(final String scopeGroupId, final HttpServletRequest request, final HttpSession httpSession, final Workspace workspace, final String itemId, final String destinationFolderId, final boolean isOverwrite){
|
||||
|
||||
boolean requestIsNull = request==null;
|
||||
logger.trace("[2] HttpServletRequest is: null? "+requestIsNull+", URI: "+request.getRequestURI() +", ServerName: "+request.getServerName());
|
||||
final NotificationsWorkspaceUploaderProducer np = new NotificationsWorkspaceUploaderProducer(httpSession,request);
|
||||
final NotificationsWorkspaceUploaderProducer np = new NotificationsWorkspaceUploaderProducer(scopeGroupId, httpSession,request);
|
||||
new Thread(){
|
||||
public void run() {
|
||||
WorkspaceItem sourceItem;
|
||||
|
@ -387,7 +387,7 @@ public class WorkspaceUploadServlet extends HttpServlet {
|
|||
String sourceSharedId = sourceItem.getIdSharedFolder();
|
||||
WorkspaceItem folderDestinationItem = workspace.getItem(destinationFolderId);
|
||||
logger.trace("[3] HttpServletRequest is: URI: "+request.getRequestURI() +", ServerName: "+request.getServerName());
|
||||
NotificationsWorkspaceUploader.checkSendNotifyChangedItemToShare(np, request, httpSession, sourceItem, sourceSharedId, folderDestinationItem,isOverwrite);
|
||||
NotificationsWorkspaceUploader.checkSendNotifyChangedItemToShare(scopeGroupId, np, request, httpSession, sourceItem, sourceSharedId, folderDestinationItem,isOverwrite);
|
||||
} catch (Exception e) {
|
||||
logger.error("Error in notifyUploadInSharedFolder", e);
|
||||
}
|
||||
|
@ -429,7 +429,7 @@ public class WorkspaceUploadServlet extends HttpServlet {
|
|||
}
|
||||
|
||||
|
||||
private void createReport(final HttpServletRequest request, HttpSession httpSession, Workspace wa, String itemName, File file, WorkspaceFolder destinationFolder, HttpServletResponse response, boolean isOverwrite) throws InsufficientPrivilegesException, ItemAlreadyExistException, InternalErrorException, IOException{
|
||||
private void createReport(String scopeGroupId, final HttpServletRequest request, HttpSession httpSession, Workspace wa, String itemName, File file, WorkspaceFolder destinationFolder, HttpServletResponse response, boolean isOverwrite) throws InsufficientPrivilegesException, ItemAlreadyExistException, InternalErrorException, IOException{
|
||||
|
||||
try {
|
||||
|
||||
|
@ -439,7 +439,7 @@ public class WorkspaceUploadServlet extends HttpServlet {
|
|||
itemName = WorkspaceUtil.getUniqueName(itemName, destinationFolder);
|
||||
report = wa.createReport(itemName, "", Calendar.getInstance(), Calendar.getInstance(), "", "", "", 0, "", StreamUtils.openInputStream(file), destinationFolder.getId());
|
||||
|
||||
notifyUploadInSharedFolder(request, httpSession,wa,report.getId(),destinationFolder.getId(), isOverwrite);
|
||||
notifyUploadInSharedFolder(scopeGroupId, request, httpSession,wa,report.getId(),destinationFolder.getId(), isOverwrite);
|
||||
sendMessage(response, "File "+report.getName()+" imported correctly in "+destinationFolder.getPath());
|
||||
}
|
||||
else{ //CASE OVERWRITE
|
||||
|
@ -447,7 +447,7 @@ public class WorkspaceUploadServlet extends HttpServlet {
|
|||
|
||||
if(rep!=null){
|
||||
|
||||
notifyUploadInSharedFolder(request, httpSession,wa,rep.getId(),destinationFolder.getId(), isOverwrite);
|
||||
notifyUploadInSharedFolder(scopeGroupId, request, httpSession,wa,rep.getId(),destinationFolder.getId(), isOverwrite);
|
||||
sendMessage(response, "File "+rep.getName()+" imported correctly in "+destinationFolder.getPath());
|
||||
}
|
||||
else
|
||||
|
@ -469,7 +469,7 @@ public class WorkspaceUploadServlet extends HttpServlet {
|
|||
|
||||
}
|
||||
|
||||
private void createTemplate(final HttpServletRequest request, HttpSession httpSession, Workspace wa, String itemName, File file, WorkspaceFolder destinationFolder, HttpServletResponse response, boolean isOverwrite) throws InsufficientPrivilegesException, ItemAlreadyExistException, InternalErrorException, IOException{
|
||||
private void createTemplate(String scopeGroupId, final HttpServletRequest request, HttpSession httpSession, Workspace wa, String itemName, File file, WorkspaceFolder destinationFolder, HttpServletResponse response, boolean isOverwrite) throws InsufficientPrivilegesException, ItemAlreadyExistException, InternalErrorException, IOException{
|
||||
|
||||
try {
|
||||
|
||||
|
@ -479,7 +479,7 @@ public class WorkspaceUploadServlet extends HttpServlet {
|
|||
itemName = WorkspaceUtil.getUniqueName(itemName, destinationFolder);
|
||||
template = wa.createReportTemplate(itemName, "", Calendar.getInstance(), Calendar.getInstance(), "", "", 0, "", StreamUtils.openInputStream(file), destinationFolder.getId());
|
||||
|
||||
notifyUploadInSharedFolder(request, httpSession,wa,template.getId(),destinationFolder.getId(), isOverwrite);
|
||||
notifyUploadInSharedFolder(scopeGroupId, request, httpSession,wa,template.getId(),destinationFolder.getId(), isOverwrite);
|
||||
sendMessage(response, "File "+template.getName()+" imported correctly in "+destinationFolder.getPath());
|
||||
|
||||
}else{ //CASE OVERWRITE
|
||||
|
@ -487,7 +487,7 @@ public class WorkspaceUploadServlet extends HttpServlet {
|
|||
|
||||
if(rep!=null){
|
||||
|
||||
notifyUploadInSharedFolder(request, httpSession,wa,rep.getId(),destinationFolder.getId(), isOverwrite);
|
||||
notifyUploadInSharedFolder(scopeGroupId, request, httpSession,wa,rep.getId(),destinationFolder.getId(), isOverwrite);
|
||||
sendMessage(response, "File "+rep.getName()+" imported correctly in "+destinationFolder.getPath());
|
||||
}
|
||||
else
|
||||
|
|
|
@ -18,6 +18,7 @@ import javax.servlet.http.HttpServlet;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.servlet.http.HttpSession;
|
||||
import javax.servlet.http.HttpServletRequestWrapper;
|
||||
|
||||
import org.apache.commons.fileupload.FileItemFactory;
|
||||
import org.apache.commons.fileupload.FileItemIterator;
|
||||
|
@ -45,6 +46,7 @@ import org.gcube.common.homelibrary.home.workspace.folder.items.ReportTemplate;
|
|||
import org.gcube.common.homelibrary.util.Extensions;
|
||||
import org.gcube.common.homelibrary.util.MimeTypeUtil;
|
||||
import org.gcube.common.homelibrary.util.WorkspaceUtil;
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.client.ConstantsWorkspaceUploader;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.server.notification.NotificationsWorkspaceUploader;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.server.notification.NotificationsWorkspaceUploaderProducer;
|
||||
|
@ -81,6 +83,9 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
|||
|
||||
protected static final String UTF_8 = "UTF-8";
|
||||
|
||||
public static final String VRE_ID_ATTR_NAME = "gcube-vreid";
|
||||
public static final String CURR_GROUP_ID = ConstantsWorkspaceUploader.CURR_GROUP_ID;
|
||||
|
||||
public static final String UPLOAD_TYPE = ConstantsWorkspaceUploader.UPLOAD_TYPE;
|
||||
|
||||
public static final String ID_FOLDER = ConstantsWorkspaceUploader.ID_FOLDER;
|
||||
|
@ -179,12 +184,12 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
|||
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");
|
||||
}
|
||||
// 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;
|
||||
|
@ -204,7 +209,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
|||
FileItemIterator fileItemIterator = servletFileUpload.getItemIterator(request);
|
||||
|
||||
int uploadItemsCnt = 0;
|
||||
|
||||
String scopeGroupId = "";
|
||||
//GET FILE STREAM
|
||||
while (fileItemIterator.hasNext()) {
|
||||
FileItemStream item = fileItemIterator.next();
|
||||
|
@ -237,13 +242,18 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
|||
saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.WAIT, "Uploading "+fileName+" at 0%", request.getSession());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (item.isFormField() && CURR_GROUP_ID.equals(item.getFieldName())){
|
||||
scopeGroupId = Streams.asString(item.openStream());
|
||||
logger.debug("currentGroupId OK scope=" + PortalContext.getConfiguration().getCurrentScope(scopeGroupId));
|
||||
}
|
||||
|
||||
//MUST BE THE LAST PARAMETER TRASMITTED
|
||||
if (UPLOAD_FORM_ELEMENT.equals(item.getFieldName())){
|
||||
uploadItem = item;
|
||||
logger.debug("UPLOAD_FORM_ELEMENT OK "+uploadItem.getName());
|
||||
logger.debug("UPLOAD_FORM_ELEMENT OK "+uploadItem.getName() + " scopeGroupId="+scopeGroupId);
|
||||
// break;
|
||||
uploadData(request, response, uploadItem, destinationId, uploadType, listClientUploadKeys.get(uploadItemsCnt), isOverwrite);
|
||||
uploadData(scopeGroupId, request, response, uploadItem, destinationId, uploadType, listClientUploadKeys.get(uploadItemsCnt), isOverwrite);
|
||||
uploadItemsCnt++;
|
||||
}
|
||||
}
|
||||
|
@ -342,8 +352,10 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
|||
* @throws ServletException the servlet exception
|
||||
* @throws IOException Signals that an I/O exception has occurred.
|
||||
*/
|
||||
private void uploadData(HttpServletRequest request, final HttpServletResponse response, final FileItemStream uploadItem, String destinationId,String uploadType,String clientUploadKey, boolean isOverwrite) throws ServletException, IOException{
|
||||
private void uploadData(String scopeGroupId, HttpServletRequest request, final HttpServletResponse response, final FileItemStream uploadItem, String destinationId,String uploadType,String clientUploadKey, boolean isOverwrite) throws ServletException, IOException{
|
||||
|
||||
|
||||
|
||||
String fileName = uploadItem.getName();
|
||||
logger.info("Upload servlet parameters: [fileName: "+fileName+ ", destinationId: "+destinationId +", uploadType: "+uploadType+", isOverwrite: "+isOverwrite+", clientUploadKey: "+clientUploadKey+"]");
|
||||
|
||||
|
@ -368,7 +380,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
|||
|
||||
WorkspaceUploaderItem workspaceUploader = null;
|
||||
try {
|
||||
workspaceUploader = WsUtil.getWorkspaceUploaderInSession(request.getSession(), clientUploadKey);
|
||||
workspaceUploader = WsUtil.getWorkspaceUploaderInSession(request, clientUploadKey);
|
||||
workspaceUploader.setIsOverwrite(isOverwrite); //SET IS OVERWRITE
|
||||
} catch (Exception e) {
|
||||
logger.error("Error during workspace uploader retrieving", e);
|
||||
|
@ -384,8 +396,8 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
|||
|
||||
Workspace wa = null;
|
||||
try {
|
||||
logger.debug("getWorkspace from HL");
|
||||
wa = WsUtil.getWorkspace(request.getSession());
|
||||
logger.debug("getWorkspace from HL scopeGroupId="+scopeGroupId);
|
||||
wa = WsUtil.getWorkspace(request, scopeGroupId);
|
||||
} catch (Exception e) {
|
||||
logger.error("Error during workspace retrieving", e);
|
||||
saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "An error occurred during upload: "+fileName+". Error processing request in upload servlet", request.getSession());
|
||||
|
@ -400,7 +412,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
|||
return;
|
||||
}
|
||||
|
||||
WorkspaceItem item;
|
||||
WorkspaceItem item = null;
|
||||
try {
|
||||
logger.debug("getWorkspaceItem destination id: "+destinationId+" from HL");
|
||||
item = wa.getItem(destinationId);
|
||||
|
@ -409,6 +421,9 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
|||
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;
|
||||
} catch (InsufficientPrivilegesException e) {
|
||||
sendError(response, "Internal error: InsufficientPrivilegesException");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (item.getType() != WorkspaceItemType.FOLDER && item.getType() != WorkspaceItemType.SHARED_FOLDER) {
|
||||
|
@ -471,16 +486,16 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
|||
String newItemName = itemName;
|
||||
logger.debug("createTemplate: "+newItemName);
|
||||
|
||||
createTemplate(request, workspaceUploader, request.getSession(), wa, newItemName, inputStream, destinationFolder, response, isOverwrite);
|
||||
createTemplate(scopeGroupId, request, workspaceUploader, request.getSession(), wa, newItemName, inputStream, destinationFolder, response, isOverwrite);
|
||||
|
||||
}else if(isZipFile && extension.compareToIgnoreCase(D4SR)==0){ //Create REPORT
|
||||
|
||||
String newItemName = itemName;
|
||||
logger.debug("createReport: "+newItemName);
|
||||
createReport(request, workspaceUploader, request.getSession(), wa, newItemName, inputStream, destinationFolder, response, isOverwrite);
|
||||
createReport(scopeGroupId, request, workspaceUploader, request.getSession(), wa, newItemName, inputStream, destinationFolder, response, isOverwrite);
|
||||
}else{ //CREATE AN EXTERNAL FILE
|
||||
|
||||
workspaceUploader = WorkspaceUploaderMng.uploadFile(request, workspaceUploader, request.getSession(), wa, itemName, inputStream, destinationFolder, contentType, isOverwrite, size);
|
||||
workspaceUploader = WorkspaceUploaderMng.uploadFile(scopeGroupId, request, workspaceUploader, request.getSession(), wa, itemName, inputStream, destinationFolder, contentType, isOverwrite, size);
|
||||
|
||||
if(workspaceUploader==null)
|
||||
throw new Exception("Error when creating uploader, it is null!");
|
||||
|
@ -494,14 +509,14 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
|||
|
||||
if (MimeTypeUtil.isZipContentType(uploadItem.getContentType())){ //UNZIP??
|
||||
logger.debug("Unziping content");
|
||||
workspaceUploader = WorkspaceUploaderMng.uploadArchive(workspaceUploader, request.getSession(), itemName, inputStream, destinationFolder, size);
|
||||
workspaceUploader = WorkspaceUploaderMng.uploadArchive(workspaceUploader, request, itemName, inputStream, destinationFolder, size);
|
||||
|
||||
if(workspaceUploader==null)
|
||||
throw new Exception("Error when creating uploader, it is null!");
|
||||
|
||||
sendMessage(response, workspaceUploader.getIdentifier());
|
||||
} else{
|
||||
workspaceUploader = WorkspaceUploaderMng.uploadFile(request, workspaceUploader, request.getSession(), wa, itemName, inputStream, destinationFolder, contentType, isOverwrite, size);
|
||||
workspaceUploader = WorkspaceUploaderMng.uploadFile(scopeGroupId, request, workspaceUploader, request.getSession(), wa, itemName, inputStream, destinationFolder, contentType, isOverwrite, size);
|
||||
|
||||
if(workspaceUploader==null)
|
||||
throw new Exception("Error when creating uploader, it is null!");
|
||||
|
@ -649,10 +664,10 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
|||
* @param destinationFolderId the destination folder id
|
||||
* @param isOverwrite the is overwrite
|
||||
*/
|
||||
public static void notifyUploadInSharedFolder(final HttpServletRequest request, final HttpSession httpSession, final Workspace workspace, final String itemId, final String destinationFolderId, final boolean isOverwrite){
|
||||
public static void notifyUploadInSharedFolder(final String scopeGroupId, final HttpServletRequest request, final HttpSession httpSession, final Workspace workspace, final String itemId, final String destinationFolderId, final boolean isOverwrite){
|
||||
|
||||
logger.trace("[2] HttpServletRequest is: URI: "+request.getRequestURI() +", ServerName: "+request.getServerName());
|
||||
final NotificationsWorkspaceUploaderProducer np = new NotificationsWorkspaceUploaderProducer(httpSession,request);
|
||||
final NotificationsWorkspaceUploaderProducer np = new NotificationsWorkspaceUploaderProducer(scopeGroupId, httpSession,request);
|
||||
new Thread(){
|
||||
public void run() {
|
||||
WorkspaceItem sourceItem;
|
||||
|
@ -661,7 +676,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
|||
String sourceSharedId = sourceItem.getIdSharedFolder();
|
||||
WorkspaceItem folderDestinationItem = workspace.getItem(destinationFolderId);
|
||||
logger.trace("[3] HttpServletRequest is: URI: "+request.getRequestURI() +", ServerName: "+request.getServerName());
|
||||
NotificationsWorkspaceUploader.checkSendNotifyChangedItemToShare(np, request, httpSession, sourceItem, sourceSharedId, folderDestinationItem,isOverwrite);
|
||||
NotificationsWorkspaceUploader.checkSendNotifyChangedItemToShare(scopeGroupId, np, request, httpSession, sourceItem, sourceSharedId, folderDestinationItem,isOverwrite);
|
||||
} catch (Exception e) {
|
||||
logger.error("Error in notifyUploadInSharedFolder", e);
|
||||
}
|
||||
|
@ -728,7 +743,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
|||
* @throws InternalErrorException the internal error exception
|
||||
* @throws IOException Signals that an I/O exception has occurred.
|
||||
*/
|
||||
private void createReport(final HttpServletRequest request, WorkspaceUploaderItem workspaceUploader, HttpSession httpSession, Workspace wa, String itemName, InputStream fileInputStream, WorkspaceFolder destinationFolder, HttpServletResponse response, boolean isOverwrite) throws InsufficientPrivilegesException, ItemAlreadyExistException, InternalErrorException, IOException{
|
||||
private void createReport(String scopeGroupId, final HttpServletRequest request, WorkspaceUploaderItem workspaceUploader, HttpSession httpSession, Workspace wa, String itemName, InputStream fileInputStream, WorkspaceFolder destinationFolder, HttpServletResponse response, boolean isOverwrite) throws InsufficientPrivilegesException, ItemAlreadyExistException, InternalErrorException, IOException{
|
||||
|
||||
try {
|
||||
|
||||
|
@ -738,7 +753,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
|||
itemName = WorkspaceUtil.getUniqueName(itemName, destinationFolder);
|
||||
report = wa.createReport(itemName, "", Calendar.getInstance(), Calendar.getInstance(), "", "", "", 0, "",fileInputStream, destinationFolder.getId());
|
||||
|
||||
notifyUploadInSharedFolder(request, httpSession,wa,report.getId(),destinationFolder.getId(), isOverwrite);
|
||||
notifyUploadInSharedFolder(scopeGroupId, request, httpSession,wa,report.getId(),destinationFolder.getId(), isOverwrite);
|
||||
sendMessage(response, "File "+report.getName()+" imported correctly in "+destinationFolder.getPath());
|
||||
}
|
||||
else{ //CASE OVERWRITE
|
||||
|
@ -746,7 +761,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
|||
|
||||
if(rep!=null){
|
||||
|
||||
notifyUploadInSharedFolder(request, httpSession,wa,rep.getId(),destinationFolder.getId(), isOverwrite);
|
||||
notifyUploadInSharedFolder(scopeGroupId, request, httpSession,wa,rep.getId(),destinationFolder.getId(), isOverwrite);
|
||||
sendMessage(response, "File "+rep.getName()+" imported correctly in "+destinationFolder.getPath());
|
||||
}
|
||||
else
|
||||
|
@ -765,7 +780,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
|||
}finally{
|
||||
try {
|
||||
// StreamUtils.deleteTempFile(file);
|
||||
WsUtil.setErasableWorkspaceUploaderInSession(httpSession, workspaceUploader.getIdentifier());
|
||||
WsUtil.setErasableWorkspaceUploaderInSession(request, workspaceUploader.getIdentifier());
|
||||
} catch (Exception e2) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
|
@ -790,7 +805,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
|||
* @throws InternalErrorException the internal error exception
|
||||
* @throws IOException Signals that an I/O exception has occurred.
|
||||
*/
|
||||
private void createTemplate(final HttpServletRequest request, WorkspaceUploaderItem workspaceUploader, HttpSession httpSession, Workspace wa, String itemName, InputStream fileInputStream, WorkspaceFolder destinationFolder, HttpServletResponse response, boolean isOverwrite) throws InsufficientPrivilegesException, ItemAlreadyExistException, InternalErrorException, IOException{
|
||||
private void createTemplate(String scopeGroupId, final HttpServletRequest request, WorkspaceUploaderItem workspaceUploader, HttpSession httpSession, Workspace wa, String itemName, InputStream fileInputStream, WorkspaceFolder destinationFolder, HttpServletResponse response, boolean isOverwrite) throws InsufficientPrivilegesException, ItemAlreadyExistException, InternalErrorException, IOException{
|
||||
|
||||
try {
|
||||
|
||||
|
@ -800,7 +815,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
|||
itemName = WorkspaceUtil.getUniqueName(itemName, destinationFolder);
|
||||
template = wa.createReportTemplate(itemName, "", Calendar.getInstance(), Calendar.getInstance(), "", "", 0, "", fileInputStream, destinationFolder.getId());
|
||||
|
||||
notifyUploadInSharedFolder(request, httpSession,wa,template.getId(),destinationFolder.getId(), isOverwrite);
|
||||
notifyUploadInSharedFolder(scopeGroupId, request, httpSession,wa,template.getId(),destinationFolder.getId(), isOverwrite);
|
||||
sendMessage(response, "File "+template.getName()+" imported correctly in "+destinationFolder.getPath());
|
||||
|
||||
}else{ //CASE OVERWRITE
|
||||
|
@ -808,7 +823,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
|||
|
||||
if(rep!=null){
|
||||
|
||||
notifyUploadInSharedFolder(request, httpSession,wa,rep.getId(),destinationFolder.getId(), isOverwrite);
|
||||
notifyUploadInSharedFolder(scopeGroupId, request, httpSession,wa,rep.getId(),destinationFolder.getId(), isOverwrite);
|
||||
sendMessage(response, "File "+rep.getName()+" imported correctly in "+destinationFolder.getPath());
|
||||
}
|
||||
else
|
||||
|
@ -828,7 +843,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
|||
}finally{
|
||||
try {
|
||||
// StreamUtils.deleteTempFile(fileInputStream);
|
||||
WsUtil.setErasableWorkspaceUploaderInSession(httpSession, workspaceUploader.getIdentifier());
|
||||
WsUtil.setErasableWorkspaceUploaderInSession(request, workspaceUploader.getIdentifier());
|
||||
} catch (Exception e2) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import javax.servlet.http.HttpSession;
|
|||
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.client.WorkspaceUploaderService;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.server.util.WsUtil;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.shared.UploadProgress;
|
||||
|
@ -38,7 +39,7 @@ public class WorkspaceUploaderServiceImpl extends RemoteServiceServlet implement
|
|||
throw new Exception(exception);
|
||||
}
|
||||
logger.trace("Get UploadStatus for id: "+identifier);
|
||||
WorkspaceUploaderItem uploader = WsUtil.getWorkspaceUploaderInSession(getThreadLocalRequest().getSession(), identifier);
|
||||
WorkspaceUploaderItem uploader = WsUtil.getWorkspaceUploaderInSession(getThreadLocalRequest(), identifier);
|
||||
logger.trace("Uploader status for id: "+identifier +" returns "+uploader);
|
||||
|
||||
if (uploader == null) {
|
||||
|
@ -86,7 +87,7 @@ public class WorkspaceUploaderServiceImpl extends RemoteServiceServlet implement
|
|||
try {
|
||||
|
||||
logger.trace("Uploader: "+uploader.getClientUploadKey() +", is erasable?");
|
||||
WsUtil.eraseWorkspaceUploaderInSession(httpSession, uploader);
|
||||
WsUtil.eraseWorkspaceUploaderInSession(getThreadLocalRequest(), uploader);
|
||||
}
|
||||
catch (Exception e) {
|
||||
logger.warn("Error during checkUploaderErasable: ", e);
|
||||
|
@ -103,7 +104,8 @@ public class WorkspaceUploaderServiceImpl extends RemoteServiceServlet implement
|
|||
logger.trace("getWorkspaceId");
|
||||
Workspace workspace;
|
||||
try {
|
||||
workspace = WsUtil.getWorkspace(getThreadLocalRequest().getSession());
|
||||
String scopeGroupId = ""+PortalContext.getConfiguration().getCurrentGroupId(getThreadLocalRequest());
|
||||
workspace = WsUtil.getWorkspace(getThreadLocalRequest(), scopeGroupId);
|
||||
if(workspace!=null)
|
||||
return workspace.getRoot().getId();
|
||||
} catch (Exception e) {
|
||||
|
@ -123,8 +125,8 @@ public class WorkspaceUploaderServiceImpl extends RemoteServiceServlet implement
|
|||
public String itemExistsInWorkpaceFolder(String parentId, String itemName) throws Exception {
|
||||
logger.trace("get itemExistsInWorkpace by parentId: "+parentId);
|
||||
try {
|
||||
|
||||
Workspace workspace = WsUtil.getWorkspace(getThreadLocalRequest().getSession());
|
||||
String scopeGroupId = ""+PortalContext.getConfiguration().getCurrentGroupId(getThreadLocalRequest());
|
||||
Workspace workspace = WsUtil.getWorkspace(getThreadLocalRequest(), scopeGroupId);
|
||||
WorkspaceItem wsItem = workspace.getItem(parentId); //GET PARENT
|
||||
|
||||
if(wsItem.getType().equals(WorkspaceItemType.FOLDER) || wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
|
||||
|
|
|
@ -11,6 +11,7 @@ import javax.servlet.http.HttpSession;
|
|||
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.client.ConstantsWorkspaceUploader;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.server.util.WsUtil;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -62,8 +63,8 @@ public class WorkspaceUploaderWsUtil extends HttpServlet {
|
|||
public String itemExistsInWorkpaceFolder(HttpServletRequest req, String parentId, String itemName) throws Exception {
|
||||
logger.trace("get itemExistsInWorkpace for name: "+itemName+", by parentId: "+parentId);
|
||||
try {
|
||||
HttpSession session = req.getSession();
|
||||
Workspace workspace = WsUtil.getWorkspace(session);
|
||||
String scopeGroupId = PortalContext.getConfiguration().getCurrentScope(req);
|
||||
Workspace workspace = WsUtil.getWorkspace(req, scopeGroupId);
|
||||
WorkspaceItem wsItem = workspace.getItem(parentId); //GET PARENT
|
||||
|
||||
if(wsItem.getType().equals(WorkspaceItemType.FOLDER) || wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
|
||||
|
|
|
@ -35,7 +35,7 @@ public class NotificationsWorkspaceUploader {
|
|||
* @param sourceSharedId
|
||||
* @param folderDestinationItem
|
||||
*/
|
||||
public static void checkSendNotifyChangedItemToShare(NotificationsWorkspaceUploaderProducer np, HttpServletRequest request, HttpSession httpSession, final WorkspaceItem sourceItem, final String sourceSharedId, final WorkspaceItem folderDestinationItem, boolean isOverwrite) {
|
||||
public static void checkSendNotifyChangedItemToShare(String scopeGroupId, NotificationsWorkspaceUploaderProducer np, HttpServletRequest request, HttpSession httpSession, final WorkspaceItem sourceItem, final String sourceSharedId, final WorkspaceItem folderDestinationItem, boolean isOverwrite) {
|
||||
|
||||
logger.trace("checkSendNotifyAddItemToShare");
|
||||
|
||||
|
@ -56,7 +56,7 @@ public class NotificationsWorkspaceUploader {
|
|||
//if shareChangeCondition is true.. notifies added item to sharing
|
||||
if(shareChangeCondition){
|
||||
|
||||
Workspace workspace = WsUtil.getWorkspace(httpSession);
|
||||
Workspace workspace = WsUtil.getWorkspace(request, scopeGroupId);
|
||||
|
||||
List<ContactModel> listContacts = getListUserSharedByFolderSharedId(workspace, folderDestinationItem.getIdSharedFolder());
|
||||
|
||||
|
@ -144,14 +144,14 @@ public class NotificationsWorkspaceUploader {
|
|||
* @param wsItem
|
||||
* @return
|
||||
*/
|
||||
public static boolean isASharedFolderForId(HttpSession httpSession, String itemId){
|
||||
public static boolean isASharedFolderForId(String scopeGroupId, HttpServletRequest request, String itemId){
|
||||
|
||||
if(itemId==null || itemId.isEmpty())
|
||||
return false;
|
||||
|
||||
try {
|
||||
|
||||
Workspace workspace = WsUtil.getWorkspace(httpSession);
|
||||
Workspace workspace = WsUtil.getWorkspace(request, scopeGroupId);
|
||||
WorkspaceItem wsItem = workspace.getItem(itemId);
|
||||
|
||||
if(wsItem!=null)
|
||||
|
|
|
@ -9,16 +9,17 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager;
|
||||
import org.gcube.applicationsupportlayer.social.NotificationsManager;
|
||||
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingSite;
|
||||
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder;
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.common.scope.impl.ScopeBean;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.server.util.WsUtil;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.shared.ContactModel;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -34,7 +35,7 @@ public class NotificationsWorkspaceUploaderProducer {
|
|||
protected static Logger logger = Logger.getLogger(NotificationsWorkspaceUploaderProducer.class);
|
||||
|
||||
protected NotificationsManager notificationsMng;
|
||||
protected ASLSession aslSession;
|
||||
|
||||
protected String userId;
|
||||
|
||||
/**
|
||||
|
@ -44,10 +45,12 @@ public class NotificationsWorkspaceUploaderProducer {
|
|||
* @param aslSession the asl session
|
||||
* @param request the request
|
||||
*/
|
||||
public NotificationsWorkspaceUploaderProducer(HttpSession httpSession, HttpServletRequest request) {
|
||||
this.aslSession = WsUtil.getAslSession(httpSession);
|
||||
this.notificationsMng = getNotificationManager(httpSession, aslSession, request);
|
||||
this.userId = aslSession.getUsername();
|
||||
public NotificationsWorkspaceUploaderProducer(String scopeGroupId, HttpSession httpSession, HttpServletRequest request) {
|
||||
|
||||
this.notificationsMng = getNotificationManager(scopeGroupId, httpSession, request);
|
||||
PortalContext pContext = PortalContext.getConfiguration();
|
||||
GCubeUser currUser = pContext.getCurrentUser(request);
|
||||
this.userId = currUser.getUsername();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -81,22 +84,26 @@ public class NotificationsWorkspaceUploaderProducer {
|
|||
* @param request the request
|
||||
* @return the notification manager
|
||||
*/
|
||||
public NotificationsManager getNotificationManager(HttpSession httpSession, ASLSession session, HttpServletRequest request)
|
||||
{
|
||||
public NotificationsManager getNotificationManager(String scopeGroupId, HttpSession httpSession, HttpServletRequest request) {
|
||||
|
||||
NotificationsManager notifMng = (NotificationsManager) httpSession.getAttribute(WsUtil.NOTIFICATION_MANAGER_UPLOADER);
|
||||
|
||||
PortalContext pContext = PortalContext.getConfiguration();
|
||||
GCubeUser currUser = pContext.getCurrentUser(request);
|
||||
if (notifMng == null) {
|
||||
try{
|
||||
logger.trace("Create new NotificationsManager for user: "+session.getUsername());
|
||||
|
||||
String scope = pContext.getCurrentScope(scopeGroupId);
|
||||
logger.trace("Create new NotificationsManager for user: "+currUser.getUsername() + " Scope="+scope);
|
||||
logger.trace("New ApplicationNotificationsManager with portlet class name: "+WsUtil.NOTIFICATION_PORTLET_CLASS_ID);
|
||||
logger.info("Request URI: "+request.getRequestURI());
|
||||
SocialNetworkingSite site = new SocialNetworkingSite(request);
|
||||
SocialNetworkingUser curser = new SocialNetworkingUser(session.getUsername(), session.getUserEmailAddress(), session.getUserFullName(), session.getUserAvatarId());
|
||||
notifMng = new ApplicationNotificationsManager(site, session.getScope(), curser, WsUtil.NOTIFICATION_PORTLET_CLASS_ID);
|
||||
SocialNetworkingUser curser = new SocialNetworkingUser(currUser.getUsername(), currUser.getEmail(), currUser.getFullname(), currUser.getUserAvatarURL());
|
||||
|
||||
|
||||
notifMng = new ApplicationNotificationsManager(site, scope, curser, WsUtil.NOTIFICATION_PORTLET_CLASS_ID);
|
||||
httpSession.setAttribute(WsUtil.NOTIFICATION_MANAGER_UPLOADER, notifMng);
|
||||
}catch (Exception e) {
|
||||
logger.error("An error occurred instancing ApplicationNotificationsManager for user: "+session.getUsername(),e);
|
||||
logger.error("An error occurred instancing ApplicationNotificationsManager for user: "+currUser.getUsername(),e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,16 +134,7 @@ public class NotificationsWorkspaceUploaderProducer {
|
|||
this.notificationsMng = notificationMng;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the asl session.
|
||||
*
|
||||
* @return the asl session
|
||||
*/
|
||||
public ASLSession getAslSession() {
|
||||
return aslSession;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Runs a new thread to notify the contacts passed in input.
|
||||
*
|
||||
|
|
|
@ -64,7 +64,7 @@ public class WorkspaceUploaderMng {
|
|||
* @throws InternalErrorException the internal error exception
|
||||
* @throws IOException Signals that an I/O exception has occurred.
|
||||
*/
|
||||
private static WorkspaceUploaderItem createWorkspaceUploaderFile(HttpServletRequest request, final WorkspaceUploaderItem workspaceUploader, final HttpSession httpSession, final boolean isOvewrite, final Workspace wa, final InputStream uploadFile, final String itemName, final WorkspaceFolder destinationFolder, final String contentType, final long totalBytes) throws InternalErrorException, IOException{
|
||||
private static WorkspaceUploaderItem createWorkspaceUploaderFile(String scopeGroupId, HttpServletRequest request, final WorkspaceUploaderItem workspaceUploader, final HttpSession httpSession, final boolean isOvewrite, final Workspace wa, final InputStream uploadFile, final String itemName, final WorkspaceFolder destinationFolder, final String contentType, final long totalBytes) throws InternalErrorException, IOException{
|
||||
logger.debug("Creating WorkspaceUploaderFile...");
|
||||
|
||||
workspaceUploader.setUploadStatus(UPLOAD_STATUS.IN_PROGRESS);
|
||||
|
@ -88,7 +88,7 @@ public class WorkspaceUploaderMng {
|
|||
workspaceUploader.getFile().setParentId(createdItem.getParent().getId());//SET PARENT ID
|
||||
workspaceUploader.setStatusDescription("File \""+createdItem.getName()+"\" uploaded correctly in "+destinationFolder.getPath());
|
||||
workspaceUploader.setUploadStatus(UPLOAD_STATUS.COMPLETED);
|
||||
WorkspaceUploadServletStream.notifyUploadInSharedFolder(request, httpSession, wa, createdItem.getId(), createdItem.getParent().getId(), isOvewrite);
|
||||
WorkspaceUploadServletStream.notifyUploadInSharedFolder(scopeGroupId, request, httpSession, wa, createdItem.getId(), createdItem.getParent().getId(), isOvewrite);
|
||||
}else{
|
||||
workspaceUploader.setStatusDescription("An error occurred during upload: \""+itemName + "\". Try again");
|
||||
workspaceUploader.setUploadStatus(UPLOAD_STATUS.FAILED);
|
||||
|
@ -134,7 +134,7 @@ public class WorkspaceUploaderMng {
|
|||
}finally{
|
||||
try {
|
||||
// StreamUtils.deleteTempFile(uploadFile);
|
||||
WsUtil.setErasableWorkspaceUploaderInSession(httpSession, workspaceUploader.getIdentifier());
|
||||
WsUtil.setErasableWorkspaceUploaderInSession(request, workspaceUploader.getIdentifier());
|
||||
} catch (Exception e2) {
|
||||
logger.error("Error during setErasableWorkspaceUploaderInSession session update: ",e2);
|
||||
}
|
||||
|
@ -157,8 +157,8 @@ public class WorkspaceUploaderMng {
|
|||
* @throws InternalErrorException the internal error exception
|
||||
* @throws IOException Signals that an I/O exception has occurred.
|
||||
*/
|
||||
private static WorkspaceUploaderItem createWorkspaceUploaderArchive(final WorkspaceUploaderItem workspaceUploader, final HttpSession httpSession, final InputStream uploadFile, final String itemName, final WorkspaceFolder destinationFolder, final long totalBytes) throws InternalErrorException, IOException{
|
||||
|
||||
private static WorkspaceUploaderItem createWorkspaceUploaderArchive(final WorkspaceUploaderItem workspaceUploader, final HttpServletRequest request, final InputStream uploadFile, final String itemName, final WorkspaceFolder destinationFolder, final long totalBytes) throws InternalErrorException, IOException{
|
||||
HttpSession httpSession = request.getSession();
|
||||
logger.info("calling upload archive - [itemName: "+itemName+"]");
|
||||
try {
|
||||
workspaceUploader.setUploadStatus(UPLOAD_STATUS.IN_PROGRESS);
|
||||
|
@ -194,7 +194,7 @@ public class WorkspaceUploaderMng {
|
|||
}finally{
|
||||
try {
|
||||
// StreamUtils.deleteTempFile(uploadFile);
|
||||
WsUtil.setErasableWorkspaceUploaderInSession(httpSession, workspaceUploader.getIdentifier());
|
||||
WsUtil.setErasableWorkspaceUploaderInSession(request, workspaceUploader.getIdentifier());
|
||||
} catch (Exception e2) {
|
||||
// TODO: handle exception
|
||||
}
|
||||
|
@ -220,10 +220,10 @@ public class WorkspaceUploaderMng {
|
|||
* @return the workspace uploader item
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static WorkspaceUploaderItem uploadFile(HttpServletRequest request, WorkspaceUploaderItem workspaceUploader, HttpSession httpSession, Workspace wa, String itemName, InputStream file, WorkspaceFolder destinationFolder, String contentType, boolean isOverwrite, long totolaBytes) throws Exception {
|
||||
public static WorkspaceUploaderItem uploadFile(String scopeGroupId, HttpServletRequest request, WorkspaceUploaderItem workspaceUploader, HttpSession httpSession, Workspace wa, String itemName, InputStream file, WorkspaceFolder destinationFolder, String contentType, boolean isOverwrite, long totolaBytes) throws Exception {
|
||||
|
||||
try {
|
||||
return createWorkspaceUploaderFile(request, workspaceUploader, httpSession, isOverwrite, wa, file, itemName, destinationFolder, contentType, totolaBytes);
|
||||
return createWorkspaceUploaderFile(scopeGroupId, request, 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 during upload: "+itemName+". Try again");
|
||||
|
@ -243,10 +243,10 @@ public class WorkspaceUploaderMng {
|
|||
* @return the workspace uploader item
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static WorkspaceUploaderItem uploadArchive(WorkspaceUploaderItem workspaceUploader, HttpSession httpSession, String itemName, InputStream file, WorkspaceFolder destinationFolder, long totalBytes) throws Exception {
|
||||
public static WorkspaceUploaderItem uploadArchive(WorkspaceUploaderItem workspaceUploader, HttpServletRequest request, String itemName, InputStream file, WorkspaceFolder destinationFolder, long totalBytes) throws Exception {
|
||||
|
||||
try {
|
||||
return createWorkspaceUploaderArchive(workspaceUploader, httpSession, file, itemName, destinationFolder, totalBytes);
|
||||
return createWorkspaceUploaderArchive(workspaceUploader, request, file, itemName, destinationFolder, totalBytes);
|
||||
|
||||
} catch (Exception e) {
|
||||
logger.error("Error when uploading Archive to HL creation: ",e);
|
||||
|
@ -262,8 +262,8 @@ public class WorkspaceUploaderMng {
|
|||
* @return the workspace uploader item
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static WorkspaceUploaderItem uploadFileStatus(HttpSession httpSession, WorkspaceUploaderItem workspaceUploader) throws Exception {
|
||||
return WsUtil.getWorkspaceUploaderInSession(httpSession, workspaceUploader.getIdentifier());
|
||||
public static WorkspaceUploaderItem uploadFileStatus(HttpServletRequest request, WorkspaceUploaderItem workspaceUploader) throws Exception {
|
||||
return WsUtil.getWorkspaceUploaderInSession(request, workspaceUploader.getIdentifier());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -64,8 +64,6 @@ public class UserUtil {
|
|||
}
|
||||
}else{
|
||||
logger.trace("DEVELOPEMENT MODE ON");
|
||||
logger.trace("Returning "+WsUtil.TEST_USER_FULL_NAME +" full name for: "+portalLogin);
|
||||
return WsUtil.TEST_USER_FULL_NAME;
|
||||
}
|
||||
|
||||
logger.trace("Return portal login as full name for: "+portalLogin);
|
||||
|
|
|
@ -3,18 +3,18 @@
|
|||
*/
|
||||
package org.gcube.portlets.widgets.workspaceuploader.server.util;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.application.framework.core.session.SessionManager;
|
||||
|
||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||
import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException;
|
||||
import org.gcube.common.homelibrary.home.exceptions.InternalErrorException;
|
||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||
import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNotFoundException;
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
||||
import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem;
|
||||
|
||||
import com.liferay.portal.service.UserLocalServiceUtil;
|
||||
|
@ -28,15 +28,11 @@ import com.liferay.portal.service.UserLocalServiceUtil;
|
|||
*/
|
||||
public class WsUtil {
|
||||
|
||||
public static final String USERNAME_ATTRIBUTE = ScopeHelper.USERNAME_ATTRIBUTE;
|
||||
public static final String NOTIFICATION_MANAGER_UPLOADER = "WS_UPLOADER_NOTIFICATION_MANAGER";
|
||||
// public static final String NOTIFICATION_PRODUCER = "WORKSPACE_UPLOADER_NOTIFICATION_PRODUCER";
|
||||
// public static final String NOTIFICATION_PORTLET_CLASS_ID = WorkspaceUploadServletStream.class.getName(); //IN DEV
|
||||
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 = "test.user";
|
||||
public static String TEST_USER_FULL_NAME = "Test User";
|
||||
|
||||
|
||||
|
||||
protected static Logger logger = Logger.getLogger(WsUtil.class);
|
||||
|
@ -59,79 +55,6 @@ public class WsUtil {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the asl session.
|
||||
*
|
||||
* @param httpSession the http session
|
||||
* @return the asl session
|
||||
*/
|
||||
public static ASLSession getAslSession(HttpSession httpSession)
|
||||
{
|
||||
String sessionID = httpSession.getId();
|
||||
String user = (String) httpSession.getAttribute(USERNAME_ATTRIBUTE);
|
||||
ASLSession session;
|
||||
|
||||
if (user == null) {
|
||||
|
||||
/*USE ANOTHER ACCOUNT (OTHERWHISE BY TEST_USER) FOR RUNNING
|
||||
* COMMENT THIS IN DEVELOP ENVIROMENT (UNCOMMENT IN PRODUCTION)*/
|
||||
user=TEST_USER;
|
||||
|
||||
if (!isWithinPortal()) { //DEV MODE
|
||||
// user = "francesco.mangiacrapa";
|
||||
user=TEST_USER;
|
||||
TEST_USER_FULL_NAME = "Test User";
|
||||
}
|
||||
|
||||
logger.warn("WORKSPACE PORTLET STARTING IN TEST MODE - NO USER FOUND - PORTLETS STARTING WITH FOLLOWING SETTINGS:");
|
||||
logger.warn("session id: "+sessionID);
|
||||
logger.warn("TEST_USER: "+user);
|
||||
logger.warn("TEST_SCOPE: "+TEST_SCOPE);
|
||||
logger.warn("USERNAME_ATTRIBUTE: "+USERNAME_ATTRIBUTE);
|
||||
session = SessionManager.getInstance().getASLSession(sessionID, user);
|
||||
session.setScope(TEST_SCOPE);
|
||||
|
||||
//MANDATORY FOR SOCIAL LIBRARY
|
||||
session.setUserAvatarId(user + "Avatar");
|
||||
session.setUserFullName(TEST_USER_FULL_NAME);
|
||||
session.setUserEmailAddress(user + "@mail.test");
|
||||
|
||||
//SET HTTP SESSION ATTRIBUTE
|
||||
httpSession.setAttribute(USERNAME_ATTRIBUTE, user);
|
||||
return session;
|
||||
|
||||
}
|
||||
|
||||
return SessionManager.getInstance().getASLSession(sessionID, user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is session expired.
|
||||
*
|
||||
* @param httpSession the http session
|
||||
* @return true if current username into ASL session is WsUtil.TEST_USER, false otherwise
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static boolean isSessionExpired(HttpSession httpSession) throws Exception {
|
||||
logger.trace("workspace session validating...");
|
||||
//READING USERNAME FROM ASL SESSION
|
||||
String userUsername = getAslSession(httpSession).getUsername();
|
||||
boolean isTestUser = userUsername.compareTo(WsUtil.TEST_USER)==0;
|
||||
|
||||
//TODO UNCOMMENT THIS FOR RELEASE
|
||||
logger.trace("Is "+WsUtil.TEST_USER+" test user? "+isTestUser);
|
||||
|
||||
if(isTestUser){
|
||||
logger.error("workspace session is expired! username is: "+WsUtil.TEST_USER);
|
||||
return true; //is TEST_USER, session is expired
|
||||
}
|
||||
|
||||
logger.trace("workspace session is valid! current username is: "+userUsername);
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the workspace.
|
||||
*
|
||||
|
@ -141,39 +64,18 @@ public class WsUtil {
|
|||
* @throws HomeNotFoundException the home not found exception
|
||||
* @throws WorkspaceFolderNotFoundException the workspace folder not found exception
|
||||
*/
|
||||
public static Workspace getWorkspace(final HttpSession httpSession) throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException{
|
||||
public static Workspace getWorkspace(final HttpServletRequest request, String scopeGroupId) throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException{
|
||||
|
||||
logger.trace("Get Workspace");
|
||||
final ASLSession session = getAslSession(httpSession);
|
||||
logger.trace("ASLSession scope: "+session.getScope() + " username: "+session.getUsername());
|
||||
PortalContext pContext = PortalContext.getConfiguration();
|
||||
String username = pContext.getCurrentUser(request).getUsername();
|
||||
String scope = pContext.getCurrentScope(scopeGroupId);
|
||||
logger.trace("Client context scope: "+ scope + " username: "+username);
|
||||
|
||||
ScopeProvider.instance.set(session.getScope());
|
||||
logger.trace("Scope provider instancied");
|
||||
|
||||
return HomeLibrary.getUserWorkspace(session.getUsername());
|
||||
ScopeProvider.instance.set(scope);
|
||||
return HomeLibrary.getUserWorkspace(username);
|
||||
}
|
||||
|
||||
//
|
||||
// /**
|
||||
// * Gets the notification producer.
|
||||
// *
|
||||
// * @param session the session
|
||||
// * @param request the request
|
||||
// * @return the notification producer
|
||||
// */
|
||||
// public static NotificationsWorkspaceUploaderProducer getNotificationProducer(ASLSession session, HttpServletRequest request)
|
||||
// {
|
||||
//
|
||||
// NotificationsWorkspaceUploaderProducer notifProducer = (NotificationsWorkspaceUploaderProducer) session.getAttribute(NOTIFICATION_PRODUCER);
|
||||
//
|
||||
// if (notifProducer == null) {
|
||||
// logger.trace("Create new Notification Producer for user: "+session.getUsername());
|
||||
// notifProducer = new NotificationsWorkspaceUploaderProducer(session, request);
|
||||
// session.setAttribute(NOTIFICATION_PRODUCER, notifProducer);
|
||||
// }
|
||||
//
|
||||
// return notifProducer;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Put workspace uploader in session.
|
||||
|
@ -182,15 +84,14 @@ public class WsUtil {
|
|||
* @param uploader the uploader
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static void putWorkspaceUploaderInSession(final HttpSession httpSession, WorkspaceUploaderItem uploader) throws Exception
|
||||
{
|
||||
public static void putWorkspaceUploaderInSession(final HttpSession httpSession, WorkspaceUploaderItem uploader) throws Exception {
|
||||
logger.trace("Put workspace uploader in session: "+uploader.getIdentifier() + ", STATUS: "+uploader.getUploadStatus());
|
||||
final ASLSession session = getAslSession(httpSession);
|
||||
|
||||
|
||||
if(uploader.getIdentifier()==null || uploader.getIdentifier().isEmpty())
|
||||
throw new Exception("Invalid uploader");
|
||||
|
||||
session.setAttribute(uploader.getIdentifier(), uploader);
|
||||
httpSession.setAttribute(uploader.getIdentifier(), uploader);
|
||||
logger.debug("Added uploader: "+uploader.getIdentifier() +" in session");
|
||||
}
|
||||
|
||||
|
@ -201,15 +102,13 @@ public class WsUtil {
|
|||
* @param uploader the uploader
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static void forceEraseWorkspaceUploaderInSession(final HttpSession httpSession, WorkspaceUploaderItem uploader) throws Exception
|
||||
{
|
||||
public static void forceEraseWorkspaceUploaderInSession(final HttpSession httpSession, WorkspaceUploaderItem uploader) throws Exception {
|
||||
logger.trace("Force Erase WorkspaceUploader workspace uploader in session: "+uploader.getIdentifier());
|
||||
final ASLSession session = getAslSession(httpSession);
|
||||
|
||||
if(uploader==null || uploader.getIdentifier()==null || uploader.getIdentifier().isEmpty())
|
||||
throw new Exception("Invalid uploader");
|
||||
|
||||
session.removeAttribute(uploader.getIdentifier());
|
||||
httpSession.removeAttribute(uploader.getIdentifier());
|
||||
logger.info("Erased uploader: "+uploader.getIdentifier());
|
||||
|
||||
}
|
||||
|
@ -222,17 +121,19 @@ public class WsUtil {
|
|||
* @param uploader the uploader
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static void eraseWorkspaceUploaderInSession(final HttpSession httpSession, WorkspaceUploaderItem uploader) throws Exception
|
||||
public static void eraseWorkspaceUploaderInSession(final HttpServletRequest request, WorkspaceUploaderItem uploader) throws Exception
|
||||
{
|
||||
logger.trace("Erase WorkspaceUploader workspace uploader in session: "+uploader.getIdentifier() + ", erasable? "+uploader.isErasable());
|
||||
final ASLSession session = getAslSession(httpSession);
|
||||
|
||||
|
||||
if(uploader==null || uploader.getIdentifier()==null || uploader.getIdentifier().isEmpty())
|
||||
throw new Exception("Invalid uploader");
|
||||
|
||||
HttpSession httpSession = request.getSession();
|
||||
|
||||
if(uploader.isErasable()){
|
||||
// session.setAttribute(uploader.getIdentifier(), null);
|
||||
session.removeAttribute(uploader.getIdentifier());
|
||||
httpSession.removeAttribute(uploader.getIdentifier());
|
||||
logger.info("Erased uploader: "+uploader.getIdentifier());
|
||||
}
|
||||
}
|
||||
|
@ -246,14 +147,13 @@ public class WsUtil {
|
|||
* @return the workspace uploader in session
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static WorkspaceUploaderItem getWorkspaceUploaderInSession(final HttpSession httpSession, String uploaderIdentifier) throws Exception
|
||||
{
|
||||
final ASLSession session = getAslSession(httpSession);
|
||||
public static WorkspaceUploaderItem getWorkspaceUploaderInSession(final HttpServletRequest request, String uploaderIdentifier) throws Exception {
|
||||
HttpSession httpSession = request.getSession();
|
||||
|
||||
if(uploaderIdentifier==null || uploaderIdentifier.isEmpty())
|
||||
throw new Exception("Invalid uploader");
|
||||
|
||||
return (WorkspaceUploaderItem) session.getAttribute(uploaderIdentifier);
|
||||
return (WorkspaceUploaderItem) httpSession.getAttribute(uploaderIdentifier);
|
||||
|
||||
}
|
||||
|
||||
|
@ -266,9 +166,10 @@ public class WsUtil {
|
|||
* @return true, if successful
|
||||
* @throws Exception the exception
|
||||
*/
|
||||
public static boolean setErasableWorkspaceUploaderInSession(final HttpSession httpSession, String uploaderIdentifier) throws Exception
|
||||
{
|
||||
WorkspaceUploaderItem uploader = getWorkspaceUploaderInSession(httpSession, uploaderIdentifier);
|
||||
public static boolean setErasableWorkspaceUploaderInSession(final HttpServletRequest request, String uploaderIdentifier) throws Exception {
|
||||
|
||||
HttpSession httpSession = request.getSession();
|
||||
WorkspaceUploaderItem uploader = getWorkspaceUploaderInSession(request, uploaderIdentifier);
|
||||
|
||||
if(uploader!=null){
|
||||
/*TODO REMOVE SESSION KEY FROM SESSION MUST BE MANAGED IN ANOTHER WAY IN ORDER TO AVOID THATH IT'S REMOVED FROM SESSION BEFORE THAT
|
||||
|
@ -290,11 +191,11 @@ public class WsUtil {
|
|||
* @param httpSession the http session
|
||||
* @return the user id
|
||||
*/
|
||||
public static String getUserId(HttpSession httpSession) {
|
||||
|
||||
ASLSession session = getAslSession(httpSession);
|
||||
|
||||
return session.getUsername();
|
||||
public static String getUserId(HttpServletRequest request) {
|
||||
PortalContext pContext = PortalContext.getConfiguration();
|
||||
String username = pContext.getCurrentUser(request).getUsername();
|
||||
logger.debug("workspace upload UserId: "+username);
|
||||
return username;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue