Removed currUserId parameter from client-side required by external servlets
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-uploader@141665 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
285221c644
commit
e37f8b2dd6
|
@ -1,6 +1,12 @@
|
||||||
<ReleaseNotes>
|
<ReleaseNotes>
|
||||||
<Changeset component="org.gcube.portlets-widgets.workspace-uploader.1-6-0" date="2016-12-01">
|
<Changeset component="org.gcube.portlets-widgets.workspace-uploader.1-6-1"
|
||||||
<Change>Feature #5901 Remove ASL Dependency from workspace-uploader Widget</Change>
|
date="2016-01-20">
|
||||||
|
<Change>Removed currUserId parameter from client-side</Change>
|
||||||
|
</Changeset>
|
||||||
|
<Changeset component="org.gcube.portlets-widgets.workspace-uploader.1-6-0"
|
||||||
|
date="2016-12-01">
|
||||||
|
<Change>Feature #5901 Remove ASL Dependency from workspace-uploader
|
||||||
|
Widget</Change>
|
||||||
<Change>Bug #6096 Fixed</Change>
|
<Change>Bug #6096 Fixed</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portlets-widgets.workspace-uploader.1-4-0"
|
<Changeset component="org.gcube.portlets-widgets.workspace-uploader.1-4-0"
|
||||||
|
|
2
pom.xml
2
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.6.0-SNAPSHOT</version>
|
<version>1.6.1-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>
|
||||||
|
|
|
@ -3,11 +3,12 @@ package org.gcube.portlets.widgets.workspaceuploader.client;
|
||||||
import com.google.gwt.core.client.GWT;
|
import com.google.gwt.core.client.GWT;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class ConstantsWorkspaceUploader.
|
* The Class ConstantsWorkspaceUploader.
|
||||||
*
|
*
|
||||||
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
* @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it
|
||||||
* Aug 3, 2015
|
* Jan 20, 2017
|
||||||
*/
|
*/
|
||||||
public class ConstantsWorkspaceUploader {
|
public class ConstantsWorkspaceUploader {
|
||||||
|
|
||||||
|
@ -24,7 +25,7 @@ public class ConstantsWorkspaceUploader {
|
||||||
|
|
||||||
// UPLOAD SERVLET PARAMETERS
|
// UPLOAD SERVLET PARAMETERS
|
||||||
public static final String CURR_GROUP_ID = "currGroupId";
|
public static final String CURR_GROUP_ID = "currGroupId";
|
||||||
public static final String CURR_USER_ID = "currUserId";
|
//public static final String CURR_USER_ID = "currUserId";
|
||||||
public static final String IS_OVERWRITE = "isOverwrite";
|
public static final String IS_OVERWRITE = "isOverwrite";
|
||||||
public static final String UPLOAD_TYPE = "uploadType";
|
public static final String UPLOAD_TYPE = "uploadType";
|
||||||
public static final String ID_FOLDER = "idFolder";
|
public static final String ID_FOLDER = "idFolder";
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
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.portal.clientcontext.client.GCubeClientContext;
|
|
||||||
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;
|
||||||
|
|
||||||
|
|
|
@ -105,7 +105,7 @@ public class DialogUpload extends ClosableDialog implements HasWorskpaceUploadNo
|
||||||
|
|
||||||
// Add hidden parameters
|
// Add hidden parameters
|
||||||
panel.add(new Hidden(ConstantsWorkspaceUploader.CURR_GROUP_ID, GCubeClientContext.getCurrentContextId()));
|
panel.add(new Hidden(ConstantsWorkspaceUploader.CURR_GROUP_ID, GCubeClientContext.getCurrentContextId()));
|
||||||
panel.add(new Hidden(ConstantsWorkspaceUploader.CURR_USER_ID, GCubeClientContext.getCurrentUserId()));
|
//panel.add(new Hidden(ConstantsWorkspaceUploader.CURR_USER_ID, GCubeClientContext.getCurrentUserId()));
|
||||||
panel.add(new Hidden(ConstantsWorkspaceUploader.ID_FOLDER,parentId));
|
panel.add(new Hidden(ConstantsWorkspaceUploader.ID_FOLDER,parentId));
|
||||||
panel.add(new Hidden(ConstantsWorkspaceUploader.UPLOAD_TYPE,uploadType.toString()));
|
panel.add(new Hidden(ConstantsWorkspaceUploader.UPLOAD_TYPE,uploadType.toString()));
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,6 @@ 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.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;
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class MultipleDNDUpload extends LayoutPanel implements HasWorskpaceUpload
|
||||||
private String folder_parent_id = ConstantsWorkspaceUploader.FOLDER_PARENT_ID;
|
private String folder_parent_id = ConstantsWorkspaceUploader.FOLDER_PARENT_ID;
|
||||||
private String item_name = ConstantsWorkspaceUploader.ITEM_NAME;
|
private String item_name = ConstantsWorkspaceUploader.ITEM_NAME;
|
||||||
private String scopeGroupId = ConstantsWorkspaceUploader.CURR_GROUP_ID;
|
private String scopeGroupId = ConstantsWorkspaceUploader.CURR_GROUP_ID;
|
||||||
private String currUserId = ConstantsWorkspaceUploader.CURR_USER_ID;
|
//private String currUserId = ConstantsWorkspaceUploader.CURR_USER_ID;
|
||||||
|
|
||||||
public static final String FILE_DELEMITER = ";";
|
public static final String FILE_DELEMITER = ";";
|
||||||
private Widget onlyChild;
|
private Widget onlyChild;
|
||||||
|
@ -74,7 +74,7 @@ public class MultipleDNDUpload extends LayoutPanel implements HasWorskpaceUpload
|
||||||
HTML html = new HTML(dnd);
|
HTML html = new HTML(dnd);
|
||||||
this.add(html);
|
this.add(html);
|
||||||
scopeGroupId = GCubeClientContext.getCurrentContextId();
|
scopeGroupId = GCubeClientContext.getCurrentContextId();
|
||||||
currUserId = GCubeClientContext.getCurrentUserId();
|
//currUserId = GCubeClientContext.getCurrentUserId();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Instantiates a new multiple dnd upload.
|
* Instantiates a new multiple dnd upload.
|
||||||
|
@ -89,7 +89,7 @@ public class MultipleDNDUpload extends LayoutPanel implements HasWorskpaceUpload
|
||||||
HTML html = new HTML(dnd);
|
HTML html = new HTML(dnd);
|
||||||
this.add(html);
|
this.add(html);
|
||||||
scopeGroupId = GCubeClientContext.getCurrentContextId();
|
scopeGroupId = GCubeClientContext.getCurrentContextId();
|
||||||
currUserId = GCubeClientContext.getCurrentUserId();
|
//currUserId = GCubeClientContext.getCurrentUserId();
|
||||||
setParameters(parentId, uploadType);
|
setParameters(parentId, uploadType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,7 +138,7 @@ public class MultipleDNDUpload extends LayoutPanel implements HasWorskpaceUpload
|
||||||
this.idFolder = parentId;
|
this.idFolder = parentId;
|
||||||
this.type = uploadType;
|
this.type = uploadType;
|
||||||
this.scopeGroupId = GCubeClientContext.getCurrentContextId();
|
this.scopeGroupId = GCubeClientContext.getCurrentContextId();
|
||||||
this.currUserId = GCubeClientContext.getCurrentUserId();
|
//this.currUserId = GCubeClientContext.getCurrentUserId();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -572,8 +572,8 @@ public class MultipleDNDUpload extends LayoutPanel implements HasWorskpaceUpload
|
||||||
var scopeGroupId = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::scopeGroupId;
|
var scopeGroupId = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::scopeGroupId;
|
||||||
console.log("scopeGroupId: " + scopeGroupId);
|
console.log("scopeGroupId: " + scopeGroupId);
|
||||||
|
|
||||||
var currUserId = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::currUserId;
|
//var currUserId = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::currUserId;
|
||||||
console.log("currUserId: " + currUserId);
|
//console.log("currUserId: " + currUserId);
|
||||||
|
|
||||||
if (idfolder === null || idfolder === undefined
|
if (idfolder === null || idfolder === undefined
|
||||||
|| uploadType === null
|
|| uploadType === null
|
||||||
|
@ -651,7 +651,7 @@ public class MultipleDNDUpload extends LayoutPanel implements HasWorskpaceUpload
|
||||||
formdata.append("uploadType", uploadType);
|
formdata.append("uploadType", uploadType);
|
||||||
formdata.append("idFolder", idfolder);
|
formdata.append("idFolder", idfolder);
|
||||||
formdata.append("currGroupId", scopeGroupId);
|
formdata.append("currGroupId", scopeGroupId);
|
||||||
formdata.append("currUserId", currUserId);
|
//formdata.append("currUserId", currUserId);
|
||||||
|
|
||||||
var overwrite = false;
|
var overwrite = false;
|
||||||
formdata.append("isOverwrite", overwrite);
|
formdata.append("isOverwrite", overwrite);
|
||||||
|
@ -677,7 +677,8 @@ public class MultipleDNDUpload extends LayoutPanel implements HasWorskpaceUpload
|
||||||
//var scopegroupid = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::scopeGroupId;
|
//var scopegroupid = instance.@org.gcube.portlets.widgets.workspaceuploader.client.uploader.dragdrop.MultipleDNDUpload::scopeGroupId;
|
||||||
|
|
||||||
console.log("item_name: " + item_name);
|
console.log("item_name: " + item_name);
|
||||||
var params = folder_parent_id+"="+idfolder+"&"+item_name+"="+files[i].name+"&currGroupId="+scopeGroupId+"&currUserId="+currUserId;
|
var params = folder_parent_id+"="+idfolder+"&"+item_name+"="+files[i].name+"&currGroupId="+scopeGroupId;
|
||||||
|
//var params = folder_parent_id+"="+idfolder+"&"+item_name+"="+files[i].name+"&currGroupId="+scopeGroupId+"&currUserId="+currUserId;
|
||||||
console.log("params: " + params);
|
console.log("params: " + params);
|
||||||
var response = isFileOverwrite(wsUtil, params, "");
|
var response = isFileOverwrite(wsUtil, params, "");
|
||||||
console.log("response overwrite: " + response);
|
console.log("response overwrite: " + response);
|
||||||
|
|
|
@ -60,6 +60,7 @@ import org.gcube.portlets.widgets.workspaceuploader.shared.HandlerResultMessage;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploadFile;
|
import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploadFile;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem;
|
import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem.UPLOAD_STATUS;
|
import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem.UPLOAD_STATUS;
|
||||||
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
import org.json.JSONArray;
|
import org.json.JSONArray;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
@ -85,7 +86,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
public static final String VRE_ID_ATTR_NAME = "gcube-vreid";
|
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 CURR_GROUP_ID = ConstantsWorkspaceUploader.CURR_GROUP_ID;
|
||||||
|
|
||||||
public static final String CURR_USER_ID = ConstantsWorkspaceUploader.CURR_USER_ID;
|
//public static final String CURR_USER_ID = ConstantsWorkspaceUploader.CURR_USER_ID;
|
||||||
|
|
||||||
public static final String UPLOAD_TYPE = ConstantsWorkspaceUploader.UPLOAD_TYPE;
|
public static final String UPLOAD_TYPE = ConstantsWorkspaceUploader.UPLOAD_TYPE;
|
||||||
|
|
||||||
|
@ -183,12 +184,12 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
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");
|
if(WsUtil.isSessionExpired(request)){
|
||||||
// sendSessionExpired(response, "SESSION_EXPIRED: session is expired");
|
logger.error("SESSION_EXPIRED: session is expired");
|
||||||
// return;
|
sendSessionExpired(response, "SESSION_EXPIRED: session is expired");
|
||||||
//// sendError(response, "SESSION_EXPIRED: session is expired");
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
String destinationId = null;
|
String destinationId = null;
|
||||||
String uploadType = null;
|
String uploadType = null;
|
||||||
|
@ -196,7 +197,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
// String clientUploadKey = null;
|
// String clientUploadKey = null;
|
||||||
FileItemStream uploadItem = null;
|
FileItemStream uploadItem = null;
|
||||||
ArrayList<String> listClientUploadKeys = null;
|
ArrayList<String> listClientUploadKeys = null;
|
||||||
|
GCubeUser user = PortalContext.getConfiguration().getCurrentUser(request);
|
||||||
FileItemFactory factory = new DiskFileItemFactory();
|
FileItemFactory factory = new DiskFileItemFactory();
|
||||||
ServletFileUpload servletFileUpload = new ServletFileUpload(factory);
|
ServletFileUpload servletFileUpload = new ServletFileUpload(factory);
|
||||||
|
|
||||||
|
@ -211,6 +212,8 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
String scopeGroupId = "";
|
String scopeGroupId = "";
|
||||||
String currUserId = "";
|
String currUserId = "";
|
||||||
//GET FILE STREAM
|
//GET FILE STREAM
|
||||||
|
|
||||||
|
|
||||||
while (fileItemIterator.hasNext()) {
|
while (fileItemIterator.hasNext()) {
|
||||||
FileItemStream item = fileItemIterator.next();
|
FileItemStream item = fileItemIterator.next();
|
||||||
|
|
||||||
|
@ -249,18 +252,18 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
logger.debug("currentGroupId into PortalContext scope= " + PortalContext.getConfiguration().getCurrentScope(scopeGroupId));
|
logger.debug("currentGroupId into PortalContext scope= " + PortalContext.getConfiguration().getCurrentScope(scopeGroupId));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.isFormField() && CURR_USER_ID.equals(item.getFieldName())){
|
// if (item.isFormField() && CURR_USER_ID.equals(item.getFieldName())){
|
||||||
currUserId = Streams.asString(item.openStream());
|
// currUserId = Streams.asString(item.openStream());
|
||||||
logger.debug("currUserId passed as parameter = " + currUserId);
|
// logger.debug("currUserId passed as parameter = " + currUserId);
|
||||||
logger.debug("currUserinto PortalContext = " + PortalContext.getConfiguration().getCurrentUser(request));
|
// logger.debug("currUserinto PortalContext = " + PortalContext.getConfiguration().getCurrentUser(request));
|
||||||
}
|
// }
|
||||||
|
|
||||||
//MUST BE THE LAST PARAMETER TRASMITTED
|
//MUST BE THE LAST PARAMETER TRASMITTED
|
||||||
if (UPLOAD_FORM_ELEMENT.equals(item.getFieldName())){
|
if (UPLOAD_FORM_ELEMENT.equals(item.getFieldName())){
|
||||||
uploadItem = item;
|
uploadItem = item;
|
||||||
logger.debug("UPLOAD_FORM_ELEMENT OK "+uploadItem.getName() + " scopeGroupId="+scopeGroupId);
|
logger.debug("UPLOAD_FORM_ELEMENT OK "+uploadItem.getName() + " scopeGroupId="+scopeGroupId);
|
||||||
// break;
|
// break;
|
||||||
uploadData(currUserId, scopeGroupId, request, response, uploadItem, destinationId, uploadType, listClientUploadKeys.get(uploadItemsCnt), isOverwrite);
|
uploadData(user, scopeGroupId, request, response, uploadItem, destinationId, uploadType, listClientUploadKeys.get(uploadItemsCnt), isOverwrite);
|
||||||
uploadItemsCnt++;
|
uploadItemsCnt++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -350,7 +353,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
/**
|
/**
|
||||||
* Upload data.
|
* Upload data.
|
||||||
*
|
*
|
||||||
* @param currUserId the curr user id
|
* @param user the user
|
||||||
* @param scopeGroupId the scope group id
|
* @param scopeGroupId the scope group id
|
||||||
* @param request the request
|
* @param request the request
|
||||||
* @param response the response
|
* @param response the response
|
||||||
|
@ -362,7 +365,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
* @throws ServletException the servlet exception
|
* @throws ServletException the servlet exception
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
* @throws IOException Signals that an I/O exception has occurred.
|
||||||
*/
|
*/
|
||||||
private void uploadData(String currUserId, String scopeGroupId, HttpServletRequest request, final HttpServletResponse response, final FileItemStream uploadItem, String destinationId,String uploadType,String clientUploadKey, boolean isOverwrite) throws ServletException, IOException{
|
private void uploadData(GCubeUser user, 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();
|
String fileName = uploadItem.getName();
|
||||||
logger.info("Upload servlet parameters: [fileName: "+fileName+ ", destinationId: "+destinationId +", uploadType: "+uploadType+", isOverwrite: "+isOverwrite+", clientUploadKey: "+clientUploadKey+"]");
|
logger.info("Upload servlet parameters: [fileName: "+fileName+ ", destinationId: "+destinationId +", uploadType: "+uploadType+", isOverwrite: "+isOverwrite+", clientUploadKey: "+clientUploadKey+"]");
|
||||||
|
@ -402,9 +405,11 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
// return;
|
// return;
|
||||||
|
|
||||||
Workspace wa = null;
|
Workspace wa = null;
|
||||||
|
GCubeUser currUser;
|
||||||
try {
|
try {
|
||||||
logger.debug("getWorkspace from HL scopeGroupId="+scopeGroupId +", userId="+currUserId);
|
logger.debug("getWorkspace from HL scopeGroupId="+scopeGroupId +", userId="+user);
|
||||||
wa = WsUtil.getWorkspace(request, scopeGroupId, currUserId);
|
currUser = PortalContext.getConfiguration().getCurrentUser(request);
|
||||||
|
wa = WsUtil.getWorkspace(request, scopeGroupId, currUser);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error during workspace retrieving", 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());
|
saveWorkspaceUploaderStatus(workspaceUploader, UPLOAD_STATUS.FAILED, "An error occurred during upload: "+fileName+". Error processing request in upload servlet", request.getSession());
|
||||||
|
@ -490,16 +495,16 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
String newItemName = itemName;
|
String newItemName = itemName;
|
||||||
logger.debug("createTemplate: "+newItemName);
|
logger.debug("createTemplate: "+newItemName);
|
||||||
|
|
||||||
createTemplate(currUserId, scopeGroupId, request, workspaceUploader, request.getSession(), wa, newItemName, inputStream, destinationFolder, response, isOverwrite);
|
createTemplate(user, scopeGroupId, request, workspaceUploader, request.getSession(), wa, newItemName, inputStream, destinationFolder, response, isOverwrite);
|
||||||
|
|
||||||
}else if(isZipFile && extension.compareToIgnoreCase(D4SR)==0){ //Create REPORT
|
}else if(isZipFile && extension.compareToIgnoreCase(D4SR)==0){ //Create REPORT
|
||||||
|
|
||||||
String newItemName = itemName;
|
String newItemName = itemName;
|
||||||
logger.debug("createReport: "+newItemName);
|
logger.debug("createReport: "+newItemName);
|
||||||
createReport(currUserId, scopeGroupId, request, workspaceUploader, request.getSession(), wa, newItemName, inputStream, destinationFolder, response, isOverwrite);
|
createReport(user, scopeGroupId, request, workspaceUploader, request.getSession(), wa, newItemName, inputStream, destinationFolder, response, isOverwrite);
|
||||||
}else{ //CREATE AN EXTERNAL FILE
|
}else{ //CREATE AN EXTERNAL FILE
|
||||||
|
|
||||||
workspaceUploader = WorkspaceUploaderMng.uploadFile(currUserId, scopeGroupId, request, workspaceUploader, request.getSession(), wa, itemName, inputStream, destinationFolder, contentType, isOverwrite, size);
|
workspaceUploader = WorkspaceUploaderMng.uploadFile(user, scopeGroupId, request, workspaceUploader, request.getSession(), wa, itemName, inputStream, destinationFolder, contentType, isOverwrite, size);
|
||||||
|
|
||||||
if(workspaceUploader==null)
|
if(workspaceUploader==null)
|
||||||
throw new Exception("Error when creating uploader, it is null!");
|
throw new Exception("Error when creating uploader, it is null!");
|
||||||
|
@ -514,7 +519,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
if (MimeTypeUtil.isZipContentType(uploadItem.getContentType())){ //UNZIP??
|
if (MimeTypeUtil.isZipContentType(uploadItem.getContentType())){ //UNZIP??
|
||||||
logger.debug("Unziping content");
|
logger.debug("Unziping content");
|
||||||
//THE WORKSPACE HAS BEEN INSTANCIED ABOVE
|
//THE WORKSPACE HAS BEEN INSTANCIED ABOVE
|
||||||
workspaceUploader = WorkspaceUploaderMng.uploadArchive(currUserId, scopeGroupId, workspaceUploader, request, itemName, inputStream, destinationFolder, size);
|
workspaceUploader = WorkspaceUploaderMng.uploadArchive(user, scopeGroupId, workspaceUploader, request, itemName, inputStream, destinationFolder, size);
|
||||||
|
|
||||||
if(workspaceUploader==null)
|
if(workspaceUploader==null)
|
||||||
throw new Exception("Error when creating uploader, it is null!");
|
throw new Exception("Error when creating uploader, it is null!");
|
||||||
|
@ -522,7 +527,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
sendMessage(response, workspaceUploader.getIdentifier());
|
sendMessage(response, workspaceUploader.getIdentifier());
|
||||||
} else{
|
} else{
|
||||||
//THE WORKSPACE HAS BEEN INSTANCIED ABOVE
|
//THE WORKSPACE HAS BEEN INSTANCIED ABOVE
|
||||||
workspaceUploader = WorkspaceUploaderMng.uploadFile(currUserId, scopeGroupId, request, workspaceUploader, request.getSession(), wa, itemName, inputStream, destinationFolder, contentType, isOverwrite, size);
|
workspaceUploader = WorkspaceUploaderMng.uploadFile(user, scopeGroupId, request, workspaceUploader, request.getSession(), wa, itemName, inputStream, destinationFolder, contentType, isOverwrite, size);
|
||||||
|
|
||||||
if(workspaceUploader==null)
|
if(workspaceUploader==null)
|
||||||
throw new Exception("Error when creating uploader, it is null!");
|
throw new Exception("Error when creating uploader, it is null!");
|
||||||
|
@ -664,7 +669,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
/**
|
/**
|
||||||
* Notify upload in shared folder.
|
* Notify upload in shared folder.
|
||||||
*
|
*
|
||||||
* @param currUserId the curr user id
|
* @param currUser the curr user
|
||||||
* @param scopeGroupId the scope group id
|
* @param scopeGroupId the scope group id
|
||||||
* @param request the request
|
* @param request the request
|
||||||
* @param httpSession the http session
|
* @param httpSession the http session
|
||||||
|
@ -673,7 +678,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
* @param destinationFolderId the destination folder id
|
* @param destinationFolderId the destination folder id
|
||||||
* @param isOverwrite the is overwrite
|
* @param isOverwrite the is overwrite
|
||||||
*/
|
*/
|
||||||
public static void notifyUploadInSharedFolder(final String currUserId, final String scopeGroupId, final HttpServletRequest request, final HttpSession httpSession, final Workspace workspace, final String itemId, final String destinationFolderId, final boolean isOverwrite){
|
public static void notifyUploadInSharedFolder(final GCubeUser currUser, 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());
|
logger.trace("[2] HttpServletRequest is: URI: "+request.getRequestURI() +", ServerName: "+request.getServerName());
|
||||||
final NotificationsWorkspaceUploaderProducer np = new NotificationsWorkspaceUploaderProducer(scopeGroupId, httpSession,request);
|
final NotificationsWorkspaceUploaderProducer np = new NotificationsWorkspaceUploaderProducer(scopeGroupId, httpSession,request);
|
||||||
new Thread(){
|
new Thread(){
|
||||||
|
@ -684,7 +689,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
String sourceSharedId = sourceItem.getIdSharedFolder();
|
String sourceSharedId = sourceItem.getIdSharedFolder();
|
||||||
WorkspaceItem folderDestinationItem = workspace.getItem(destinationFolderId);
|
WorkspaceItem folderDestinationItem = workspace.getItem(destinationFolderId);
|
||||||
logger.trace("[3] HttpServletRequest is: URI: "+request.getRequestURI() +", ServerName: "+request.getServerName());
|
logger.trace("[3] HttpServletRequest is: URI: "+request.getRequestURI() +", ServerName: "+request.getServerName());
|
||||||
NotificationsWorkspaceUploader.checkSendNotifyChangedItemToShare(request, currUserId, scopeGroupId, np, httpSession, sourceItem, sourceSharedId, folderDestinationItem,isOverwrite);
|
NotificationsWorkspaceUploader.checkSendNotifyChangedItemToShare(request, currUser, scopeGroupId, np, httpSession, sourceItem, sourceSharedId, folderDestinationItem,isOverwrite);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error in notifyUploadInSharedFolder", e);
|
logger.error("Error in notifyUploadInSharedFolder", e);
|
||||||
}
|
}
|
||||||
|
@ -737,7 +742,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
/**
|
/**
|
||||||
* Creates the report.
|
* Creates the report.
|
||||||
*
|
*
|
||||||
* @param currUserId the curr user id
|
* @param currUser the curr user
|
||||||
* @param scopeGroupId the scope group id
|
* @param scopeGroupId the scope group id
|
||||||
* @param request the request
|
* @param request the request
|
||||||
* @param workspaceUploader the workspace uploader
|
* @param workspaceUploader the workspace uploader
|
||||||
|
@ -753,7 +758,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
* @throws InternalErrorException the internal error exception
|
* @throws InternalErrorException the internal error exception
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
* @throws IOException Signals that an I/O exception has occurred.
|
||||||
*/
|
*/
|
||||||
private void createReport(String currUserId, 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{
|
private void createReport(GCubeUser currUser, 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 {
|
try {
|
||||||
|
|
||||||
|
@ -763,7 +768,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
itemName = WorkspaceUtil.getUniqueName(itemName, destinationFolder);
|
itemName = WorkspaceUtil.getUniqueName(itemName, destinationFolder);
|
||||||
report = wa.createReport(itemName, "", Calendar.getInstance(), Calendar.getInstance(), "", "", "", 0, "",fileInputStream, destinationFolder.getId());
|
report = wa.createReport(itemName, "", Calendar.getInstance(), Calendar.getInstance(), "", "", "", 0, "",fileInputStream, destinationFolder.getId());
|
||||||
|
|
||||||
notifyUploadInSharedFolder(currUserId, scopeGroupId, request, httpSession,wa,report.getId(),destinationFolder.getId(), isOverwrite);
|
notifyUploadInSharedFolder(currUser, scopeGroupId, request, httpSession,wa,report.getId(),destinationFolder.getId(), isOverwrite);
|
||||||
sendMessage(response, "File "+report.getName()+" imported correctly in "+destinationFolder.getPath());
|
sendMessage(response, "File "+report.getName()+" imported correctly in "+destinationFolder.getPath());
|
||||||
}
|
}
|
||||||
else{ //CASE OVERWRITE
|
else{ //CASE OVERWRITE
|
||||||
|
@ -771,7 +776,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
|
|
||||||
if(rep!=null){
|
if(rep!=null){
|
||||||
|
|
||||||
notifyUploadInSharedFolder(currUserId, scopeGroupId, request, httpSession,wa,rep.getId(),destinationFolder.getId(), isOverwrite);
|
notifyUploadInSharedFolder(currUser, scopeGroupId, request, httpSession,wa,rep.getId(),destinationFolder.getId(), isOverwrite);
|
||||||
sendMessage(response, "File "+rep.getName()+" imported correctly in "+destinationFolder.getPath());
|
sendMessage(response, "File "+rep.getName()+" imported correctly in "+destinationFolder.getPath());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -799,10 +804,11 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the template.
|
* Creates the template.
|
||||||
*
|
*
|
||||||
* @param currUserId the curr user id
|
* @param currUser the curr user
|
||||||
* @param scopeGroupId the scope group id
|
* @param scopeGroupId the scope group id
|
||||||
* @param request the request
|
* @param request the request
|
||||||
* @param workspaceUploader the workspace uploader
|
* @param workspaceUploader the workspace uploader
|
||||||
|
@ -818,7 +824,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
* @throws InternalErrorException the internal error exception
|
* @throws InternalErrorException the internal error exception
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
* @throws IOException Signals that an I/O exception has occurred.
|
||||||
*/
|
*/
|
||||||
private void createTemplate(String currUserId, 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{
|
private void createTemplate(GCubeUser currUser, 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 {
|
try {
|
||||||
|
|
||||||
|
@ -828,7 +834,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
itemName = WorkspaceUtil.getUniqueName(itemName, destinationFolder);
|
itemName = WorkspaceUtil.getUniqueName(itemName, destinationFolder);
|
||||||
template = wa.createReportTemplate(itemName, "", Calendar.getInstance(), Calendar.getInstance(), "", "", 0, "", fileInputStream, destinationFolder.getId());
|
template = wa.createReportTemplate(itemName, "", Calendar.getInstance(), Calendar.getInstance(), "", "", 0, "", fileInputStream, destinationFolder.getId());
|
||||||
|
|
||||||
notifyUploadInSharedFolder(currUserId, scopeGroupId, request, httpSession,wa,template.getId(),destinationFolder.getId(), isOverwrite);
|
notifyUploadInSharedFolder(currUser, scopeGroupId, request, httpSession,wa,template.getId(),destinationFolder.getId(), isOverwrite);
|
||||||
sendMessage(response, "File "+template.getName()+" imported correctly in "+destinationFolder.getPath());
|
sendMessage(response, "File "+template.getName()+" imported correctly in "+destinationFolder.getPath());
|
||||||
|
|
||||||
}else{ //CASE OVERWRITE
|
}else{ //CASE OVERWRITE
|
||||||
|
@ -836,7 +842,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet
|
||||||
|
|
||||||
if(rep!=null){
|
if(rep!=null){
|
||||||
|
|
||||||
notifyUploadInSharedFolder(currUserId, scopeGroupId, request, httpSession,wa,rep.getId(),destinationFolder.getId(), isOverwrite);
|
notifyUploadInSharedFolder(currUser, scopeGroupId, request, httpSession,wa,rep.getId(),destinationFolder.getId(), isOverwrite);
|
||||||
sendMessage(response, "File "+rep.getName()+" imported correctly in "+destinationFolder.getPath());
|
sendMessage(response, "File "+rep.getName()+" imported correctly in "+destinationFolder.getPath());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -110,7 +110,7 @@ public class WorkspaceUploaderServiceImpl extends RemoteServiceServlet implement
|
||||||
try {
|
try {
|
||||||
String scopeGroupId = ""+PortalContext.getConfiguration().getCurrentGroupId(getThreadLocalRequest());
|
String scopeGroupId = ""+PortalContext.getConfiguration().getCurrentGroupId(getThreadLocalRequest());
|
||||||
GCubeUser currUser = PortalContext.getConfiguration().getCurrentUser(getThreadLocalRequest());
|
GCubeUser currUser = PortalContext.getConfiguration().getCurrentUser(getThreadLocalRequest());
|
||||||
workspace = WsUtil.getWorkspace(getThreadLocalRequest(), scopeGroupId, currUser.getUserId()+"");
|
workspace = WsUtil.getWorkspace(getThreadLocalRequest(), scopeGroupId, currUser);
|
||||||
if(workspace!=null)
|
if(workspace!=null)
|
||||||
return workspace.getRoot().getId();
|
return workspace.getRoot().getId();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -132,8 +132,7 @@ public class WorkspaceUploaderServiceImpl extends RemoteServiceServlet implement
|
||||||
try {
|
try {
|
||||||
String scopeGroupId = ""+PortalContext.getConfiguration().getCurrentGroupId(getThreadLocalRequest());
|
String scopeGroupId = ""+PortalContext.getConfiguration().getCurrentGroupId(getThreadLocalRequest());
|
||||||
GCubeUser currUser = PortalContext.getConfiguration().getCurrentUser(getThreadLocalRequest());
|
GCubeUser currUser = PortalContext.getConfiguration().getCurrentUser(getThreadLocalRequest());
|
||||||
String currUserId = currUser!=null?currUser.getUserId()+"":null;
|
Workspace workspace = WsUtil.getWorkspace(getThreadLocalRequest(), scopeGroupId, currUser);
|
||||||
Workspace workspace = WsUtil.getWorkspace(getThreadLocalRequest(), scopeGroupId, currUserId);
|
|
||||||
WorkspaceItem wsItem = workspace.getItem(parentId); //GET PARENT
|
WorkspaceItem wsItem = workspace.getItem(parentId); //GET PARENT
|
||||||
|
|
||||||
if(wsItem.getType().equals(WorkspaceItemType.FOLDER) || wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
|
if(wsItem.getType().equals(WorkspaceItemType.FOLDER) || wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
|
||||||
|
|
|
@ -10,8 +10,10 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
import org.gcube.common.homelibary.model.items.type.WorkspaceItemType;
|
||||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||||
import org.gcube.common.homelibrary.home.workspace.WorkspaceItem;
|
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.client.ConstantsWorkspaceUploader;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.server.util.WsUtil;
|
import org.gcube.portlets.widgets.workspaceuploader.server.util.WsUtil;
|
||||||
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -34,14 +36,14 @@ public class WorkspaceUploaderWsUtil extends HttpServlet {
|
||||||
String folderParentId = req.getParameter(ConstantsWorkspaceUploader.FOLDER_PARENT_ID);
|
String folderParentId = req.getParameter(ConstantsWorkspaceUploader.FOLDER_PARENT_ID);
|
||||||
String itemName = req.getParameter(ConstantsWorkspaceUploader.ITEM_NAME);
|
String itemName = req.getParameter(ConstantsWorkspaceUploader.ITEM_NAME);
|
||||||
String currGroupId = req.getParameter(ConstantsWorkspaceUploader.CURR_GROUP_ID);
|
String currGroupId = req.getParameter(ConstantsWorkspaceUploader.CURR_GROUP_ID);
|
||||||
String currUserId = req.getParameter(ConstantsWorkspaceUploader.CURR_USER_ID);
|
//String currUserId = req.getParameter(ConstantsWorkspaceUploader.CURR_USER_ID);
|
||||||
logger.debug("folderParentId: "+folderParentId);
|
logger.debug("folderParentId: "+folderParentId);
|
||||||
logger.debug("itemName: "+itemName);
|
logger.debug("itemName: "+itemName);
|
||||||
logger.debug("currGroupId: "+currGroupId);
|
logger.debug("currGroupId: "+currGroupId);
|
||||||
logger.debug("currUserId: "+currUserId);
|
//logger.debug("currUserId: "+currUserId);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
String itemId = itemExistsInWorkpaceFolder(currUserId, currGroupId, req, folderParentId, itemName);
|
String itemId = itemExistsInWorkpaceFolder(currGroupId, req, folderParentId, itemName);
|
||||||
sendOKMessage(resp, itemId);
|
sendOKMessage(resp, itemId);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
|
@ -50,10 +52,10 @@ public class WorkspaceUploaderWsUtil extends HttpServlet {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Item exists in workpace folder.
|
* Item exists in workpace folder.
|
||||||
*
|
*
|
||||||
* @param currUserId the curr user id
|
|
||||||
* @param currGroupId the curr group id
|
* @param currGroupId the curr group id
|
||||||
* @param req the req
|
* @param req the req
|
||||||
* @param parentId the parent id
|
* @param parentId the parent id
|
||||||
|
@ -61,10 +63,15 @@ public class WorkspaceUploaderWsUtil extends HttpServlet {
|
||||||
* @return the string
|
* @return the string
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
public String itemExistsInWorkpaceFolder(String currUserId, String currGroupId, HttpServletRequest req, String parentId, String itemName) throws Exception {
|
public String itemExistsInWorkpaceFolder(String currGroupId, HttpServletRequest req, String parentId, String itemName) throws Exception {
|
||||||
logger.trace("get itemExistsInWorkpace for name: "+itemName+", by parentId: "+parentId);
|
logger.trace("get itemExistsInWorkpace for name: "+itemName+", by parentId: "+parentId);
|
||||||
try {
|
try {
|
||||||
Workspace workspace = WsUtil.getWorkspace(req, currGroupId, currUserId);
|
GCubeUser gcubeUser = PortalContext.getConfiguration().getCurrentUser(req);
|
||||||
|
//IN THIS CASE THE SESSION EXPIRED IS MANAGED BY UPLOAD SERVLET
|
||||||
|
if(gcubeUser==null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
Workspace workspace = WsUtil.getWorkspace(req, currGroupId, gcubeUser);
|
||||||
WorkspaceItem wsItem = workspace.getItem(parentId); //GET PARENT
|
WorkspaceItem wsItem = workspace.getItem(parentId); //GET PARENT
|
||||||
|
|
||||||
if(wsItem.getType().equals(WorkspaceItemType.FOLDER) || wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
|
if(wsItem.getType().equals(WorkspaceItemType.FOLDER) || wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER)){
|
||||||
|
|
|
@ -17,6 +17,7 @@ import org.gcube.common.homelibrary.home.workspace.WorkspaceSharedFolder;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.server.util.UserUtil;
|
import org.gcube.portlets.widgets.workspaceuploader.server.util.UserUtil;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.server.util.WsUtil;
|
import org.gcube.portlets.widgets.workspaceuploader.server.util.WsUtil;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.shared.ContactModel;
|
import org.gcube.portlets.widgets.workspaceuploader.shared.ContactModel;
|
||||||
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class NotificationsWorkspaceUploader.
|
* The Class NotificationsWorkspaceUploader.
|
||||||
|
@ -29,12 +30,11 @@ public class NotificationsWorkspaceUploader {
|
||||||
|
|
||||||
protected static Logger logger = Logger.getLogger(NotificationsWorkspaceUploader.class);
|
protected static Logger logger = Logger.getLogger(NotificationsWorkspaceUploader.class);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check send notify changed item to share.
|
* Check send notify changed item to share.
|
||||||
*
|
*
|
||||||
* @param request the request
|
* @param request the request
|
||||||
* @param currUserId the curr user id
|
* @param currUser the curr user
|
||||||
* @param scopeGroupId the scope group id
|
* @param scopeGroupId the scope group id
|
||||||
* @param np the np
|
* @param np the np
|
||||||
* @param httpSession the http session
|
* @param httpSession the http session
|
||||||
|
@ -43,7 +43,7 @@ public class NotificationsWorkspaceUploader {
|
||||||
* @param folderDestinationItem the folder destination item
|
* @param folderDestinationItem the folder destination item
|
||||||
* @param isOverwrite the is overwrite
|
* @param isOverwrite the is overwrite
|
||||||
*/
|
*/
|
||||||
public static void checkSendNotifyChangedItemToShare(HttpServletRequest request, String currUserId, String scopeGroupId, NotificationsWorkspaceUploaderProducer np, HttpSession httpSession, final WorkspaceItem sourceItem, final String sourceSharedId, final WorkspaceItem folderDestinationItem, boolean isOverwrite) {
|
public static void checkSendNotifyChangedItemToShare(HttpServletRequest request, GCubeUser currUser, String scopeGroupId, NotificationsWorkspaceUploaderProducer np, HttpSession httpSession, final WorkspaceItem sourceItem, final String sourceSharedId, final WorkspaceItem folderDestinationItem, boolean isOverwrite) {
|
||||||
|
|
||||||
logger.trace("checkSendNotifyAddItemToShare");
|
logger.trace("checkSendNotifyAddItemToShare");
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ public class NotificationsWorkspaceUploader {
|
||||||
//if shareChangeCondition is true.. notifies added item to sharing
|
//if shareChangeCondition is true.. notifies added item to sharing
|
||||||
if(shareChangeCondition){
|
if(shareChangeCondition){
|
||||||
|
|
||||||
Workspace workspace = WsUtil.getWorkspace(request, scopeGroupId, currUserId);
|
Workspace workspace = WsUtil.getWorkspace(request, scopeGroupId, currUser);
|
||||||
|
|
||||||
List<ContactModel> listContacts = getListUserSharedByFolderSharedId(workspace, folderDestinationItem.getIdSharedFolder());
|
List<ContactModel> listContacts = getListUserSharedByFolderSharedId(workspace, folderDestinationItem.getIdSharedFolder());
|
||||||
|
|
||||||
|
@ -151,20 +151,20 @@ public class NotificationsWorkspaceUploader {
|
||||||
/**
|
/**
|
||||||
* Checks if is a shared folder for id.
|
* Checks if is a shared folder for id.
|
||||||
*
|
*
|
||||||
* @param currUserId the curr user id
|
* @param user the user
|
||||||
* @param scopeGroupId the scope group id
|
* @param scopeGroupId the scope group id
|
||||||
* @param request the request
|
* @param request the request
|
||||||
* @param itemId the item id
|
* @param itemId the item id
|
||||||
* @return true, if is a shared folder for id
|
* @return true, if is a shared folder for id
|
||||||
*/
|
*/
|
||||||
public static boolean isASharedFolderForId(String currUserId, String scopeGroupId, HttpServletRequest request, String itemId){
|
public static boolean isASharedFolderForId(GCubeUser user, String scopeGroupId, HttpServletRequest request, String itemId){
|
||||||
|
|
||||||
if(itemId==null || itemId.isEmpty())
|
if(itemId==null || itemId.isEmpty())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Workspace workspace = WsUtil.getWorkspace(request, scopeGroupId, currUserId);
|
Workspace workspace = WsUtil.getWorkspace(request, scopeGroupId, user);
|
||||||
WorkspaceItem wsItem = workspace.getItem(itemId);
|
WorkspaceItem wsItem = workspace.getItem(itemId);
|
||||||
|
|
||||||
if(wsItem!=null)
|
if(wsItem!=null)
|
||||||
|
|
|
@ -53,30 +53,6 @@ public class NotificationsWorkspaceUploaderProducer {
|
||||||
this.username = currUser.getUsername();
|
this.username = currUser.getUsername();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the notification manager.
|
|
||||||
*
|
|
||||||
* @param httpSession the http session
|
|
||||||
* @param session the session
|
|
||||||
* @param request the request
|
|
||||||
* @return the notification manager
|
|
||||||
*/
|
|
||||||
/*public NotificationsManager getNotificationManager(ASLSession session, HttpServletRequest request) {
|
|
||||||
try{
|
|
||||||
logger.trace("Create new NotificationsManager for user: "+session.getUsername());
|
|
||||||
logger.trace("New ApplicationNotificationsManager with portlet class name: "+WsUtil.NOTIFICATION_PORTLET_CLASS_ID);
|
|
||||||
boolean isRequestNull = request==null;
|
|
||||||
// logger.info("The request is null? "+isRequestNull +", request URL: "+request.getRequestURL());
|
|
||||||
logger.info("The request is null? "+isRequestNull);
|
|
||||||
SocialNetworkingSite site = new SocialNetworkingSite(request);
|
|
||||||
SocialNetworkingUser curser = new SocialNetworkingUser(session.getUsername(), session.getUserEmailAddress(), session.getUserFullName(), session.getUserAvatarId());
|
|
||||||
return new ApplicationNotificationsManager(site, session.getScope(), curser, WsUtil.NOTIFICATION_PORTLET_CLASS_ID);
|
|
||||||
}catch (Exception e) {
|
|
||||||
logger.error("An error occurred instancing ApplicationNotificationsManager for user: "+session.getUsername(),e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the notification manager.
|
* Gets the notification manager.
|
||||||
*
|
*
|
||||||
|
@ -108,13 +84,6 @@ public class NotificationsWorkspaceUploaderProducer {
|
||||||
}
|
}
|
||||||
|
|
||||||
return notifMng;
|
return notifMng;
|
||||||
/*logger.trace("Create new NotificationsManager for user: "+session.getUsername());
|
|
||||||
logger.trace("New ApplicationNotificationsManager with portlet class name: "+WsUtil.NOTIFICATION_PORTLET_CLASS_ID);
|
|
||||||
boolean requestIsNull = request==null;
|
|
||||||
logger.info("[5] HttpServletRequest is: null? "+requestIsNull+", URI: "+request.getRequestURI() +", ServerName: "+request.getServerName());
|
|
||||||
SocialNetworkingSite site = new SocialNetworkingSite(request);
|
|
||||||
SocialNetworkingUser curser = new SocialNetworkingUser(session.getUsername(), session.getUserEmailAddress(), session.getUserFullName(), session.getUserAvatarId());
|
|
||||||
return new ApplicationNotificationsManager(site, session.getScope(), curser, WsUtil.NOTIFICATION_PORTLET_CLASS_ID);*/
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Gets the notifications mng.
|
* Gets the notifications mng.
|
||||||
|
@ -147,16 +116,12 @@ public class NotificationsWorkspaceUploaderProducer {
|
||||||
new Thread() {
|
new Thread() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
// printContacts(listContacts);
|
// printContacts(listContacts);
|
||||||
logger.info("Send notifies added item in sharedfolder is running...");
|
logger.info("Send notifies added item in sharedfolder is running...");
|
||||||
|
|
||||||
//DEBUG
|
//DEBUG
|
||||||
System.out.println("Send notifies added item in sharedfolder is running...");
|
//System.out.println("Send notifies added item in sharedfolder is running...");
|
||||||
|
|
||||||
for (ContactModel infoContactModel : listContacts) {
|
for (ContactModel infoContactModel : listContacts) {
|
||||||
try{
|
try{
|
||||||
|
|
||||||
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
||||||
if(infoContactModel.getLogin().compareTo(username)!=0){
|
if(infoContactModel.getLogin().compareTo(username)!=0){
|
||||||
|
|
||||||
|
@ -191,16 +156,12 @@ public class NotificationsWorkspaceUploaderProducer {
|
||||||
new Thread() {
|
new Thread() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
||||||
// printContacts(listContacts);
|
// printContacts(listContacts);
|
||||||
logger.info("Send notifies updated item in shared folder is running...");
|
logger.info("Send notifies updated item in shared folder is running...");
|
||||||
|
|
||||||
for (ContactModel infoContactModel : listContacts) {
|
for (ContactModel infoContactModel : listContacts) {
|
||||||
try{
|
try{
|
||||||
|
|
||||||
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
//NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER
|
||||||
if(infoContactModel.getLogin().compareTo(username)!=0){
|
if(infoContactModel.getLogin().compareTo(username)!=0){
|
||||||
|
|
||||||
logger.info("Sending notification to user "+infoContactModel.getLogin() +" updated item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
|
logger.info("Sending notification to user "+infoContactModel.getLogin() +" updated item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName());
|
||||||
boolean notify = notificationsMng.notifyUpdatedItem(infoContactModel.getLogin(), workspaceItem, sharedFolder);
|
boolean notify = notificationsMng.notifyUpdatedItem(infoContactModel.getLogin(), workspaceItem, sharedFolder);
|
||||||
|
|
||||||
|
@ -210,10 +171,8 @@ public class NotificationsWorkspaceUploaderProducer {
|
||||||
}
|
}
|
||||||
}catch (Exception e) {
|
}catch (Exception e) {
|
||||||
logger.error("An error updated in notifyAddedItemToSharing ", e);
|
logger.error("An error updated in notifyAddedItemToSharing ", e);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.trace("notifies of updated item in shared folder is completed");
|
logger.trace("notifies of updated item in shared folder is completed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.gcube.portlets.widgets.workspaceuploader.server.WorkspaceUploadServle
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.server.util.WsUtil;
|
import org.gcube.portlets.widgets.workspaceuploader.server.util.WsUtil;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem;
|
import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem.UPLOAD_STATUS;
|
import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem.UPLOAD_STATUS;
|
||||||
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -50,7 +51,7 @@ public class WorkspaceUploaderMng {
|
||||||
/**
|
/**
|
||||||
* Creates the workspace uploader file.
|
* Creates the workspace uploader file.
|
||||||
*
|
*
|
||||||
* @param currUserId the curr user id
|
* @param currUser the curr user
|
||||||
* @param scopeGroupId the scope group id
|
* @param scopeGroupId the scope group id
|
||||||
* @param request the request
|
* @param request the request
|
||||||
* @param workspaceUploader the workspace uploader
|
* @param workspaceUploader the workspace uploader
|
||||||
|
@ -66,7 +67,7 @@ public class WorkspaceUploaderMng {
|
||||||
* @throws InternalErrorException the internal error exception
|
* @throws InternalErrorException the internal error exception
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
* @throws IOException Signals that an I/O exception has occurred.
|
||||||
*/
|
*/
|
||||||
private static WorkspaceUploaderItem createWorkspaceUploaderFile(String currUserId, 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{
|
private static WorkspaceUploaderItem createWorkspaceUploaderFile(final GCubeUser currUser, final String scopeGroupId, final 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...");
|
logger.debug("Creating WorkspaceUploaderFile...");
|
||||||
|
|
||||||
workspaceUploader.setUploadStatus(UPLOAD_STATUS.IN_PROGRESS);
|
workspaceUploader.setUploadStatus(UPLOAD_STATUS.IN_PROGRESS);
|
||||||
|
@ -90,7 +91,7 @@ public class WorkspaceUploaderMng {
|
||||||
workspaceUploader.getFile().setParentId(createdItem.getParent().getId());//SET PARENT ID
|
workspaceUploader.getFile().setParentId(createdItem.getParent().getId());//SET PARENT ID
|
||||||
workspaceUploader.setStatusDescription("File \""+createdItem.getName()+"\" uploaded correctly in "+destinationFolder.getPath());
|
workspaceUploader.setStatusDescription("File \""+createdItem.getName()+"\" uploaded correctly in "+destinationFolder.getPath());
|
||||||
workspaceUploader.setUploadStatus(UPLOAD_STATUS.COMPLETED);
|
workspaceUploader.setUploadStatus(UPLOAD_STATUS.COMPLETED);
|
||||||
WorkspaceUploadServletStream.notifyUploadInSharedFolder(currUserId, scopeGroupId, request, httpSession, wa, createdItem.getId(), createdItem.getParent().getId(), isOvewrite);
|
WorkspaceUploadServletStream.notifyUploadInSharedFolder(currUser, scopeGroupId, request, httpSession, wa, createdItem.getId(), createdItem.getParent().getId(), isOvewrite);
|
||||||
}else{
|
}else{
|
||||||
workspaceUploader.setStatusDescription("An error occurred during upload: \""+itemName + "\". Try again");
|
workspaceUploader.setStatusDescription("An error occurred during upload: \""+itemName + "\". Try again");
|
||||||
workspaceUploader.setUploadStatus(UPLOAD_STATUS.FAILED);
|
workspaceUploader.setUploadStatus(UPLOAD_STATUS.FAILED);
|
||||||
|
@ -146,10 +147,11 @@ public class WorkspaceUploaderMng {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the workspace uploader archive.
|
* Creates the workspace uploader archive.
|
||||||
*
|
*
|
||||||
* @param currUserId the curr user id
|
* @param currUser the curr user
|
||||||
* @param scopeGroupId the scope group id
|
* @param scopeGroupId the scope group id
|
||||||
* @param workspaceUploader the workspace uploader
|
* @param workspaceUploader the workspace uploader
|
||||||
* @param request the request
|
* @param request the request
|
||||||
|
@ -161,7 +163,7 @@ public class WorkspaceUploaderMng {
|
||||||
* @throws InternalErrorException the internal error exception
|
* @throws InternalErrorException the internal error exception
|
||||||
* @throws IOException Signals that an I/O exception has occurred.
|
* @throws IOException Signals that an I/O exception has occurred.
|
||||||
*/
|
*/
|
||||||
private static WorkspaceUploaderItem createWorkspaceUploaderArchive(String currUserId, String scopeGroupId, final WorkspaceUploaderItem workspaceUploader, final HttpServletRequest request, final InputStream uploadFile, final String itemName, final WorkspaceFolder destinationFolder, final long totalBytes) throws InternalErrorException, IOException{
|
private static WorkspaceUploaderItem createWorkspaceUploaderArchive(final GCubeUser currUser, final String scopeGroupId, 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();
|
HttpSession httpSession = request.getSession();
|
||||||
logger.info("calling upload archive - [itemName: "+itemName+"]");
|
logger.info("calling upload archive - [itemName: "+itemName+"]");
|
||||||
try {
|
try {
|
||||||
|
@ -210,7 +212,7 @@ public class WorkspaceUploaderMng {
|
||||||
/**
|
/**
|
||||||
* Upload file.
|
* Upload file.
|
||||||
*
|
*
|
||||||
* @param currUserId the curr user id
|
* @param currUser the curr user
|
||||||
* @param scopeGroupId the scope group id
|
* @param scopeGroupId the scope group id
|
||||||
* @param request the request
|
* @param request the request
|
||||||
* @param workspaceUploader the workspace uploader
|
* @param workspaceUploader the workspace uploader
|
||||||
|
@ -225,10 +227,10 @@ public class WorkspaceUploaderMng {
|
||||||
* @return the workspace uploader item
|
* @return the workspace uploader item
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
public static WorkspaceUploaderItem uploadFile(String currUserId, String scopeGroupId, 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(GCubeUser currUser, 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 {
|
try {
|
||||||
return createWorkspaceUploaderFile(currUserId, scopeGroupId, request, workspaceUploader, httpSession, isOverwrite, wa, file, itemName, destinationFolder, contentType, totolaBytes);
|
return createWorkspaceUploaderFile(currUser, scopeGroupId, request, workspaceUploader, httpSession, isOverwrite, wa, file, itemName, destinationFolder, contentType, totolaBytes);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error when uploading file to HL : ",e);
|
logger.error("Error when uploading file to HL : ",e);
|
||||||
throw new Exception("An error occurred during upload: "+itemName+". Try again");
|
throw new Exception("An error occurred during upload: "+itemName+". Try again");
|
||||||
|
@ -239,7 +241,7 @@ public class WorkspaceUploaderMng {
|
||||||
/**
|
/**
|
||||||
* Upload archive.
|
* Upload archive.
|
||||||
*
|
*
|
||||||
* @param currUserId the curr user id
|
* @param currUser the curr user
|
||||||
* @param scopeGroupId the scope group id
|
* @param scopeGroupId the scope group id
|
||||||
* @param workspaceUploader the workspace uploader
|
* @param workspaceUploader the workspace uploader
|
||||||
* @param request the request
|
* @param request the request
|
||||||
|
@ -250,10 +252,10 @@ public class WorkspaceUploaderMng {
|
||||||
* @return the workspace uploader item
|
* @return the workspace uploader item
|
||||||
* @throws Exception the exception
|
* @throws Exception the exception
|
||||||
*/
|
*/
|
||||||
public static WorkspaceUploaderItem uploadArchive(String currUserId, String scopeGroupId, WorkspaceUploaderItem workspaceUploader, HttpServletRequest request, String itemName, InputStream file, WorkspaceFolder destinationFolder, long totalBytes) throws Exception {
|
public static WorkspaceUploaderItem uploadArchive(GCubeUser currUser, String scopeGroupId, WorkspaceUploaderItem workspaceUploader, HttpServletRequest request, String itemName, InputStream file, WorkspaceFolder destinationFolder, long totalBytes) throws Exception {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
return createWorkspaceUploaderArchive(currUserId, scopeGroupId, workspaceUploader, request, file, itemName, destinationFolder, totalBytes);
|
return createWorkspaceUploaderArchive(currUser, scopeGroupId, workspaceUploader, request, file, itemName, destinationFolder, totalBytes);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("Error when uploading Archive to HL creation: ",e);
|
logger.error("Error when uploading Archive to HL creation: ",e);
|
||||||
|
|
|
@ -15,7 +15,6 @@ import org.gcube.common.homelibrary.home.workspace.exceptions.WorkspaceFolderNot
|
||||||
import org.gcube.common.portal.PortalContext;
|
import org.gcube.common.portal.PortalContext;
|
||||||
import org.gcube.common.scope.api.ScopeProvider;
|
import org.gcube.common.scope.api.ScopeProvider;
|
||||||
import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem;
|
import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem;
|
||||||
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
|
||||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
|
|
||||||
import com.liferay.portal.service.UserLocalServiceUtil;
|
import com.liferay.portal.service.UserLocalServiceUtil;
|
||||||
|
@ -51,6 +50,19 @@ public class WsUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if is session expired.
|
||||||
|
*
|
||||||
|
* @param httpServletRequest the http servlet request
|
||||||
|
* @return true, if is session expired
|
||||||
|
* @throws Exception the exception
|
||||||
|
*/
|
||||||
|
public static boolean isSessionExpired(HttpServletRequest request) throws Exception {
|
||||||
|
logger.debug("workspace session validating...");
|
||||||
|
return PortalContext.getConfiguration().getCurrentUser(request)==null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the workspace.
|
* Gets the workspace.
|
||||||
*
|
*
|
||||||
|
@ -62,30 +74,17 @@ public class WsUtil {
|
||||||
* @throws HomeNotFoundException the home not found exception
|
* @throws HomeNotFoundException the home not found exception
|
||||||
* @throws WorkspaceFolderNotFoundException the workspace folder not found exception
|
* @throws WorkspaceFolderNotFoundException the workspace folder not found exception
|
||||||
*/
|
*/
|
||||||
public static Workspace getWorkspace(final HttpServletRequest request, String scopeGroupId, String currUserId) throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException{
|
public static Workspace getWorkspace(final HttpServletRequest request, String scopeGroupId, GCubeUser user) throws InternalErrorException, HomeNotFoundException, WorkspaceFolderNotFoundException, Exception{
|
||||||
|
|
||||||
|
if(user==null || user.getUsername().isEmpty())
|
||||||
|
throw new Exception("Session expired");
|
||||||
|
|
||||||
logger.trace("Get Workspace");
|
logger.trace("Get Workspace");
|
||||||
PortalContext pContext = PortalContext.getConfiguration();
|
PortalContext pContext = PortalContext.getConfiguration();
|
||||||
String scope = pContext.getCurrentScope(scopeGroupId);
|
String scope = pContext.getCurrentScope(scopeGroupId);
|
||||||
ScopeProvider.instance.set(scope);
|
ScopeProvider.instance.set(scope);
|
||||||
|
String username = user.getUsername();
|
||||||
String username = null;
|
|
||||||
try {
|
|
||||||
GCubeUser gCubeUser = new LiferayUserManager().getUserById(Long.valueOf(currUserId));
|
|
||||||
logger.debug("Gcube user read from liferay: "+gCubeUser);
|
|
||||||
if(gCubeUser!=null && gCubeUser.getUsername()!=null)
|
|
||||||
username = gCubeUser.getUsername();
|
|
||||||
} catch (Exception e) {
|
|
||||||
String error = "Error retrieving gCubeUser for: [userId= "
|
|
||||||
+ currUserId + ", scope: " + scope + "]";
|
|
||||||
logger.error(error, e);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(username==null || username.isEmpty())
|
|
||||||
username = pContext.getCurrentUser(request).getUsername();
|
|
||||||
|
|
||||||
logger.info("Client context scope: "+ scope + " username: "+username);
|
logger.info("Client context scope: "+ scope + " username: "+username);
|
||||||
|
|
||||||
return HomeLibrary.getUserWorkspace(username);
|
return HomeLibrary.getUserWorkspace(username);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue