From 77a34755ab1f07ecfd379be93da6782d49a8cce9 Mon Sep 17 00:00:00 2001 From: Francesco Mangiacrapa Date: Tue, 31 May 2016 13:53:54 +0000 Subject: [PATCH] Migrated to Liferay 6.2 Updated pom version at 1.4.0 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/widgets/workspace-uploader@128922 82a268e6-3cf1-43bd-a215-b396298e98cf --- distro/changelog.xml | 4 + pom.xml | 22 ++- .../server/WorkspaceUploadServlet.java | 183 +++++++++--------- .../server/WorkspaceUploadServletStream.java | 26 +-- .../NotificationsWorkspaceUploader.java | 103 +++++----- ...otificationsWorkspaceUploaderProducer.java | 45 +++-- .../server/upload/WorkspaceUploaderMng.java | 11 +- .../server/util/UserUtil.java | 75 ++++--- .../workspaceuploader/server/util/WsUtil.java | 13 +- 9 files changed, 252 insertions(+), 230 deletions(-) diff --git a/distro/changelog.xml b/distro/changelog.xml index 1cf77b8..e039e5d 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -1,4 +1,8 @@ + + [Feature #4128] Migration to Liferay 6.2 + [Feature #4055] DnD multiple instances diff --git a/pom.xml b/pom.xml index bc8b927..543b9aa 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ org.gcube.portlets.widgets workspace-uploader jar - 1.3.0-SNAPSHOT + 1.4.0-SNAPSHOT Workspace Uploader Widget Workspace Uploader Widget allows your application to upload file/s in the gCube Workspace @@ -37,7 +37,7 @@ org.gcube.distribution maven-portal-bom - 2.6.0-SNAPSHOT + LATEST pom import @@ -59,13 +59,6 @@ - - - - - - - com.google.gwt @@ -87,6 +80,7 @@ gcube-widgets provided + org.gcube.resources.discovery @@ -100,9 +94,18 @@ + org.gcube.dvos usermanagement-core + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) + provided + + + + + com.liferay.portal + portal-service provided @@ -181,6 +184,7 @@ social-networking-library provided + org.gcube.applicationsupportlayer aslsocial diff --git a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/WorkspaceUploadServlet.java b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/WorkspaceUploadServlet.java index 6cfc387..6cdb627 100644 --- a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/WorkspaceUploadServlet.java +++ b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/WorkspaceUploadServlet.java @@ -1,5 +1,5 @@ /** - * + * */ package org.gcube.portlets.widgets.workspaceuploader.server; @@ -40,7 +40,7 @@ import org.gcube.portlets.widgets.workspaceuploader.shared.WorkspaceUploaderItem import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * + * * @author Francesco Mangiacrapa francesco.mangiacrapa@isti.cnr.it * @Jan 21, 2014 * @@ -48,7 +48,7 @@ import org.slf4j.LoggerFactory; public class WorkspaceUploadServlet extends HttpServlet { /** - * + * */ private static final long serialVersionUID = -7861878364437065019L; @@ -61,16 +61,16 @@ public class WorkspaceUploadServlet extends HttpServlet { public static final String UPLOAD_FORM_ELEMENT = ConstantsWorkspaceUploader.UPLOAD_FORM_ELEMENT; public static final String CLIENT_UPLOAD_KEY = ConstantsWorkspaceUploader.CLIENT_UPLOAD_KEYS; - + public static final String IS_OVERWRITE = ConstantsWorkspaceUploader.IS_OVERWRITE; - + public static final String FILE = "File"; public static final String D4ST = Extensions.REPORT_TEMPLATE.getName(); //extension of Report Template type public static final String D4SR = Extensions.REPORT.getName(); //extension of Report type - + public static Logger logger = LoggerFactory.getLogger(WorkspaceUploadServlet.class); - + /*private static String UPLOAD_LOCATION = System.getProperty("java.io.tmpdir"); @Override public void init() throws ServletException { @@ -81,7 +81,7 @@ public class WorkspaceUploadServlet extends HttpServlet { UPLOAD_LOCATION = System.getenv("CATALINA_TMPDIR"); } super.init(); - + }catch(Exception e){ e.printStackTrace(); } @@ -96,7 +96,7 @@ public class WorkspaceUploadServlet extends HttpServlet { System.out.println("GET method in WorkspaceUploadServlet is running"); sendError(response, "Internal error: GET method not supported"); } - + /** * {@inheritDoc} */ @@ -105,49 +105,49 @@ public class WorkspaceUploadServlet extends HttpServlet { // System.out.println("POST on UploadServlet"); // logger.info("POST on UploadServlet"); -// +// // if (!ServletFileUpload.isMultipartContent(request)) { // logger.error("ERROR: multipart request not found"); // sendError(response, "ERROR: multipart request not found"); // } -// +// // String destinationId = null; // String uploadType = null; // boolean isOverwrite = false; // String clientUploadKey = null; // FileItemStream uploadItem = null; -// +// // FileItemFactory factory = new DiskFileItemFactory(); // ServletFileUpload servletFileUpload = new ServletFileUpload(factory); // // try { -// +// // FileItemIterator fileItemIterator = servletFileUpload.getItemIterator(request); -// +// // //GET FILE STREAM // while (fileItemIterator.hasNext()) { // FileItemStream item = fileItemIterator.next(); -// +// // if (item.isFormField() && ID_FOLDER.equals(item.getFieldName())){ // destinationId = Streams.asString(item.openStream()); // logger.debug("ID_FOLDER OK"); // } -// +// // if (item.isFormField() && UPLOAD_TYPE.equals(item.getFieldName())){ // uploadType = Streams.asString(item.openStream()); // logger.debug("UPLOAD_TYPE OK"); // } -// +// // if (item.isFormField() && IS_OVERWRITE.equals(item.getFieldName())){ -// isOverwrite = Boolean.parseBoolean(Streams.asString(item.openStream())); +// isOverwrite = Boolean.parseBoolean(Streams.asString(item.openStream())); // logger.debug("IS_OVERWRITE OK"); // } -// +// // if(item.isFormField() && CLIENT_UPLOAD_KEY.equals(item.getFieldName())){ // clientUploadKey = Streams.asString(item.openStream()); // logger.debug("CLIENT_UPLOAD_KEY OK"); // } -// +// // //MUST BE THE LAST PARAMETER TRASMITTED // if (UPLOAD_FORM_ELEMENT.equals(item.getFieldName())){ // logger.debug(UPLOAD_FORM_ELEMENT); @@ -162,20 +162,20 @@ public class WorkspaceUploadServlet extends HttpServlet { // return; // } } - - - + + + private void uploadData(HttpServletRequest request, HttpServletResponse response, 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+"]"); -// +// // if (uploadType == null || uploadType.isEmpty()) { // logger.error("Error processing request in upload servlet: No upload type found"); // sendError(response, "Internal error: No upload type found"); // return; // } -// +// // if(clientUploadKey==null || clientUploadKey.isEmpty()){ // logger.error("Error processing request in upload servlet: No client upload key found"); // sendError(response, "Internal error: No client upload key found"); @@ -220,16 +220,16 @@ public class WorkspaceUploadServlet extends HttpServlet { // try { // //we calculate an unique name for the current destination // String itemName = ""; -// +// // logger.debug("getItemName from HL"); // if(!isOverwrite) // itemName = WorkspaceUtil.getUniqueName(fileName, destinationFolder); // else // itemName = fileName; -// +// // Long size = Long.parseLong(request.getHeader("Content-Length")); // logger.debug("size: " + size + " bytes"); -// +// // // //Create Item Uploader to read progress // WorkspaceUploadFile wsUploadFile = new WorkspaceUploadFile(destinationFolder.getId(), itemName); @@ -239,17 +239,17 @@ public class WorkspaceUploadServlet extends HttpServlet { // workspaceUploader.setFile(wsUploadFile); // workspaceUploader.setStatusDescription("Uploading "+itemName+" at 0%"); // workspaceUploader.setClientUploadKey(clientUploadKey); -// +// // //instanciate the progress listener // AbstractUploadProgressListener uploadProgressListener = new AbstractUploadProgressListener(request, new UploadProgress(), 0, 70); // final UploadProgressInputStream inputStream = new UploadProgressInputStream(uploadItem.openStream(), size); // inputStream.addListener(uploadProgressListener); // workspaceUploader.setUploadProgress(uploadProgressListener.getUploadProgress()); // saveWorkspaceUploaderInSession(workspaceUploader, request.getSession()); -// +// // printStartTime(); // File file = StreamUtils.stream2file(inputStream, uploadItem.getName()+UUID.randomUUID(), ".tmp"); -// +// // logger.debug("getMimeType from HL"); // String contentType = MimeTypeUtil.getMimeType(itemName, StreamUtils.openInputStream(file)); // logger.debug("Content type (mime type): "+contentType + " unique name: "+itemName); @@ -258,46 +258,46 @@ public class WorkspaceUploadServlet extends HttpServlet { // logger.debug("extension: "+extension); // // if(uploadType.compareTo(FILE)==0) {//IS FILE UPLOAD -// +// // boolean isZipFile = MimeTypeUtil.isZipContentType(contentType); -// +// // if(isZipFile && (extension.compareToIgnoreCase(D4ST)==0)){ //Create REPORT TEMPLATE // // String newItemName = itemName; // logger.debug("createTemplate: "+newItemName); // createTemplate(request.getSession(), wa, newItemName, file, destinationFolder, response, isOverwrite); -// +// // }else if(isZipFile && (extension.compareToIgnoreCase(D4SR)==0)){ //Create REPORT // // String newItemName = itemName; // logger.debug("createReport: "+newItemName); // createReport(request.getSession(), wa, newItemName, file, destinationFolder, response, isOverwrite); // }else{ //CREATE AN EXTERNAL FILE -// +// // workspaceUploader = WorkspaceUploaderManager.uploadFile(request, workspaceUploader, wa, itemName, file, destinationFolder, contentType, isOverwrite, size); -// +// // if(workspaceUploader==null) // throw new Exception("Error when creating uploader, it is null!"); -// +// // sendMessage(response, workspaceUploader.getIdentifier()); // } -// +// // }else {//IS ARCHIVE UPLOAD -// +// // if (MimeTypeUtil.isZipContentType(contentType)){ // logger.debug("Unziping content"); // workspaceUploader = WorkspaceUploaderManager.uploadArchive(request, workspaceUploader, itemName, file, destinationFolder, size); -// +// // if(workspaceUploader==null) // throw new Exception("Error when creating uploader, it is null!"); -// +// // sendMessage(response, workspaceUploader.getIdentifier()); // } else{ // workspaceUploader = WorkspaceUploaderManager.uploadFile(request, workspaceUploader, wa, itemName, file, destinationFolder, contentType, isOverwrite, size); -// +// // if(workspaceUploader==null) // throw new Exception("Error when creating uploader, it is null!"); -// +// // sendMessage(response, workspaceUploader.getIdentifier()); // } // } @@ -322,7 +322,7 @@ public class WorkspaceUploadServlet extends HttpServlet { // } } - + public static WorkspaceUploaderItem saveWorkspaceUploaderInSession(WorkspaceUploaderItem workspaceUploader, HttpSession httpSession) throws Exception { if(workspaceUploader!=null){ @@ -336,7 +336,7 @@ public class WorkspaceUploadServlet extends HttpServlet { } throw new Exception("An error occurredin the upload. Workspace Uploader not found. Abort and try again"); } - + /** * Gets the random. * @@ -346,7 +346,7 @@ public class WorkspaceUploadServlet extends HttpServlet { Random randomGenerator = new Random(); return randomGenerator.nextInt(Integer.MAX_VALUE); } - + //TEST TIME public static Long startTime = new Long(0); //TEST TIME @@ -364,14 +364,17 @@ public class WorkspaceUploadServlet extends HttpServlet { /** - * - * @param httpSession - * @param workspace - * @param itemId - * @param destinationFolderId + * Notify upload in shared folder. + * + * @param request the request + * @param httpSession the http session + * @param workspace the workspace + * @param itemId the item id + * @param destinationFolderId the destination folder id + * @param isOverwrite the is overwrite */ - public static void notifyUploadInSharedFolder(final HttpSession httpSession, final Workspace workspace, final String itemId, final String destinationFolderId, final boolean isOverwrite){ - + public static void notifyUploadInSharedFolder(final HttpServletRequest request, final HttpSession httpSession, final Workspace workspace, final String itemId, final String destinationFolderId, final boolean isOverwrite){ + new Thread(){ public void run() { WorkspaceItem sourceItem; @@ -379,20 +382,20 @@ public class WorkspaceUploadServlet extends HttpServlet { sourceItem = workspace.getItem(itemId); String sourceSharedId = sourceItem.getIdSharedFolder(); WorkspaceItem folderDestinationItem = workspace.getItem(destinationFolderId); - NotificationsWorkspaceUploader.checkSendNotifyChangedItemToShare(httpSession, sourceItem, sourceSharedId, folderDestinationItem,isOverwrite); + NotificationsWorkspaceUploader.checkSendNotifyChangedItemToShare(request, httpSession, sourceItem, sourceSharedId, folderDestinationItem,isOverwrite); } catch (Exception e) { logger.error("Error in notifyUploadInSharedFolder", e); - } + } }; - - }.start(); + + }.start(); } - - + + private FolderItem overwriteItem(Workspace wa, String itemName, InputStream fileData, WorkspaceFolder destinationFolder){ - + FolderItem overwriteItem = null; - + try { logger.debug("case overwriting item.. "+itemName); overwriteItem = (FolderItem) wa.find(itemName, destinationFolder.getId()); @@ -416,30 +419,30 @@ public class WorkspaceUploadServlet extends HttpServlet { }catch (Exception e) { logger.error("Error in createExternalFile, Exception", e); } - - return overwriteItem; + + return overwriteItem; } - - private void createReport(HttpSession httpSession, Workspace wa, String itemName, File file, WorkspaceFolder destinationFolder, HttpServletResponse response, boolean isOverwrite) throws InsufficientPrivilegesException, ItemAlreadyExistException, InternalErrorException, IOException{ - + + 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{ + try { - + Report report = null; - + if(!isOverwrite){ itemName = WorkspaceUtil.getUniqueName(itemName, destinationFolder); report = wa.createReport(itemName, "", Calendar.getInstance(), Calendar.getInstance(), "", "", "", 0, "", StreamUtils.openInputStream(file), destinationFolder.getId()); - - notifyUploadInSharedFolder(httpSession,wa,report.getId(),destinationFolder.getId(), isOverwrite); + + notifyUploadInSharedFolder(request, httpSession,wa,report.getId(),destinationFolder.getId(), isOverwrite); sendMessage(response, "File "+report.getName()+" imported correctly in "+destinationFolder.getPath()); } else{ //CASE OVERWRITE FolderItem rep = overwriteItem(wa, itemName, StreamUtils.openInputStream(file), destinationFolder); - + if(rep!=null){ - - notifyUploadInSharedFolder(httpSession,wa,rep.getId(),destinationFolder.getId(), isOverwrite); + + notifyUploadInSharedFolder(request, httpSession,wa,rep.getId(),destinationFolder.getId(), isOverwrite); sendMessage(response, "File "+rep.getName()+" imported correctly in "+destinationFolder.getPath()); } else @@ -458,28 +461,28 @@ public class WorkspaceUploadServlet extends HttpServlet { // TODO: handle exception } } - + } - - private void createTemplate(HttpSession httpSession, Workspace wa, String itemName, File file, WorkspaceFolder destinationFolder, HttpServletResponse response, boolean isOverwrite) throws InsufficientPrivilegesException, ItemAlreadyExistException, InternalErrorException, IOException{ - + + 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{ + try { - + ReportTemplate template = null; - + if(!isOverwrite){ itemName = WorkspaceUtil.getUniqueName(itemName, destinationFolder); template = wa.createReportTemplate(itemName, "", Calendar.getInstance(), Calendar.getInstance(), "", "", 0, "", StreamUtils.openInputStream(file), destinationFolder.getId()); - - notifyUploadInSharedFolder(httpSession,wa,template.getId(),destinationFolder.getId(), isOverwrite); + + notifyUploadInSharedFolder(request, httpSession,wa,template.getId(),destinationFolder.getId(), isOverwrite); sendMessage(response, "File "+template.getName()+" imported correctly in "+destinationFolder.getPath()); - + }else{ //CASE OVERWRITE FolderItem rep = overwriteItem(wa, itemName, StreamUtils.openInputStream(file), destinationFolder); - + if(rep!=null){ - - notifyUploadInSharedFolder(httpSession,wa,rep.getId(),destinationFolder.getId(), isOverwrite); + + notifyUploadInSharedFolder(request, httpSession,wa,rep.getId(),destinationFolder.getId(), isOverwrite); sendMessage(response, "File "+rep.getName()+" imported correctly in "+destinationFolder.getPath()); } else @@ -499,10 +502,10 @@ public class WorkspaceUploadServlet extends HttpServlet { // TODO: handle exception } } - + } - - + + protected void sendError(HttpServletResponse response, String message) throws IOException{ try { response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); @@ -519,7 +522,7 @@ public class WorkspaceUploadServlet extends HttpServlet { throw e; //Sending Exceptions } } - + protected void sendMessage(HttpServletResponse response, String message) throws IOException{ try { response.setStatus(HttpServletResponse.SC_ACCEPTED); @@ -536,7 +539,7 @@ public class WorkspaceUploadServlet extends HttpServlet { throw e; //Sending Exceptions } } - + protected void sendWarnMessage(HttpServletResponse response, String message) throws IOException{ try { response.setStatus(HttpServletResponse.SC_ACCEPTED); diff --git a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/WorkspaceUploadServletStream.java b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/WorkspaceUploadServletStream.java index 038be37..f08f7a6 100644 --- a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/WorkspaceUploadServletStream.java +++ b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/WorkspaceUploadServletStream.java @@ -459,16 +459,16 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet String newItemName = itemName; logger.debug("createTemplate: "+newItemName); - createTemplate(workspaceUploader, request.getSession(), wa, newItemName, inputStream, destinationFolder, response, isOverwrite); + createTemplate(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(workspaceUploader, request.getSession(), wa, newItemName, inputStream, destinationFolder, response, isOverwrite); + createReport(request, workspaceUploader, request.getSession(), wa, newItemName, inputStream, destinationFolder, response, isOverwrite); }else{ //CREATE AN EXTERNAL FILE - workspaceUploader = WorkspaceUploaderMng.uploadFile(workspaceUploader, request.getSession(), wa, itemName, inputStream, destinationFolder, contentType, isOverwrite, size); + workspaceUploader = WorkspaceUploaderMng.uploadFile(request, workspaceUploader, request.getSession(), wa, itemName, inputStream, destinationFolder, contentType, isOverwrite, size); if(workspaceUploader==null) throw new Exception("Error when creating uploader, it is null!"); @@ -489,7 +489,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet sendMessage(response, workspaceUploader.getIdentifier()); } else{ - workspaceUploader = WorkspaceUploaderMng.uploadFile(workspaceUploader, request.getSession(), wa, itemName, inputStream, destinationFolder, contentType, isOverwrite, size); + workspaceUploader = WorkspaceUploaderMng.uploadFile(request, workspaceUploader, request.getSession(), wa, itemName, inputStream, destinationFolder, contentType, isOverwrite, size); if(workspaceUploader==null) throw new Exception("Error when creating uploader, it is null!"); @@ -630,13 +630,14 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet /** * Notify upload in shared folder. * + * @param request the request * @param httpSession the http session * @param workspace the workspace * @param itemId the item id * @param destinationFolderId the destination folder id * @param isOverwrite the is overwrite */ - public static void notifyUploadInSharedFolder(final HttpSession httpSession, final Workspace workspace, final String itemId, final String destinationFolderId, final boolean isOverwrite){ + public static void notifyUploadInSharedFolder(final HttpServletRequest request, final HttpSession httpSession, final Workspace workspace, final String itemId, final String destinationFolderId, final boolean isOverwrite){ new Thread(){ public void run() { @@ -645,7 +646,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet sourceItem = workspace.getItem(itemId); String sourceSharedId = sourceItem.getIdSharedFolder(); WorkspaceItem folderDestinationItem = workspace.getItem(destinationFolderId); - NotificationsWorkspaceUploader.checkSendNotifyChangedItemToShare(httpSession, sourceItem, sourceSharedId, folderDestinationItem,isOverwrite); + NotificationsWorkspaceUploader.checkSendNotifyChangedItemToShare(request, httpSession, sourceItem, sourceSharedId, folderDestinationItem,isOverwrite); } catch (Exception e) { logger.error("Error in notifyUploadInSharedFolder", e); } @@ -698,6 +699,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet /** * Creates the report. * + * @param request the request * @param workspaceUploader the workspace uploader * @param httpSession the http session * @param wa the wa @@ -711,7 +713,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(WorkspaceUploaderItem workspaceUploader, HttpSession httpSession, Workspace wa, String itemName, InputStream fileInputStream, WorkspaceFolder destinationFolder, HttpServletResponse response, boolean isOverwrite) throws InsufficientPrivilegesException, ItemAlreadyExistException, InternalErrorException, IOException{ + 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{ try { @@ -721,7 +723,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(httpSession,wa,report.getId(),destinationFolder.getId(), isOverwrite); + notifyUploadInSharedFolder(request, httpSession,wa,report.getId(),destinationFolder.getId(), isOverwrite); sendMessage(response, "File "+report.getName()+" imported correctly in "+destinationFolder.getPath()); } else{ //CASE OVERWRITE @@ -729,7 +731,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet if(rep!=null){ - notifyUploadInSharedFolder(httpSession,wa,rep.getId(),destinationFolder.getId(), isOverwrite); + notifyUploadInSharedFolder(request, httpSession,wa,rep.getId(),destinationFolder.getId(), isOverwrite); sendMessage(response, "File "+rep.getName()+" imported correctly in "+destinationFolder.getPath()); } else @@ -772,7 +774,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(WorkspaceUploaderItem workspaceUploader, HttpSession httpSession, Workspace wa, String itemName, InputStream fileInputStream, WorkspaceFolder destinationFolder, HttpServletResponse response, boolean isOverwrite) throws InsufficientPrivilegesException, ItemAlreadyExistException, InternalErrorException, IOException{ + 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{ try { @@ -782,7 +784,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(httpSession,wa,template.getId(),destinationFolder.getId(), isOverwrite); + notifyUploadInSharedFolder(request, httpSession,wa,template.getId(),destinationFolder.getId(), isOverwrite); sendMessage(response, "File "+template.getName()+" imported correctly in "+destinationFolder.getPath()); }else{ //CASE OVERWRITE @@ -790,7 +792,7 @@ public class WorkspaceUploadServletStream extends HttpServlet implements Servlet if(rep!=null){ - notifyUploadInSharedFolder(httpSession,wa,rep.getId(),destinationFolder.getId(), isOverwrite); + notifyUploadInSharedFolder(request, httpSession,wa,rep.getId(),destinationFolder.getId(), isOverwrite); sendMessage(response, "File "+rep.getName()+" imported correctly in "+destinationFolder.getPath()); } else diff --git a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/notification/NotificationsWorkspaceUploader.java b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/notification/NotificationsWorkspaceUploader.java index d91b426..1bd6777 100644 --- a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/notification/NotificationsWorkspaceUploader.java +++ b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/notification/NotificationsWorkspaceUploader.java @@ -1,11 +1,12 @@ /** - * + * */ package org.gcube.portlets.widgets.workspaceuploader.server.notification; import java.util.ArrayList; import java.util.List; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import org.apache.log4j.Logger; @@ -23,10 +24,10 @@ import org.gcube.portlets.widgets.workspaceuploader.shared.ContactModel; * */ public class NotificationsWorkspaceUploader { - - + + protected static Logger logger = Logger.getLogger(NotificationsWorkspaceUploader.class); - + /** * Send a notification if an item is added or updated to sharing folder * @param httpSession @@ -34,101 +35,101 @@ public class NotificationsWorkspaceUploader { * @param sourceSharedId * @param folderDestinationItem */ - public static void checkSendNotifyChangedItemToShare(HttpSession httpSession, final WorkspaceItem sourceItem, final String sourceSharedId, final WorkspaceItem folderDestinationItem, boolean isOverwrite) { - + public static void checkSendNotifyChangedItemToShare(HttpServletRequest request, HttpSession httpSession, final WorkspaceItem sourceItem, final String sourceSharedId, final WorkspaceItem folderDestinationItem, boolean isOverwrite) { + logger.trace("checkSendNotifyAddItemToShare"); - - if(folderDestinationItem!=null){ - + + if(folderDestinationItem!=null){ + try{ if(folderDestinationItem.isShared()){ //Notify Added Item To Sharing? - + logger.trace("checkNotifyAddItemToShare source item: "+sourceItem.getName()+" sourceSharedId: "+sourceSharedId + " folder destination: "+folderDestinationItem.getName() + " folder destination shared folder id: "+folderDestinationItem.getIdSharedFolder()); - + //share condition is true if source shared folder is not null boolean shareChangeCondition = sourceSharedId==null?false:true; - + //System.out.println("shareChangeCondition add item: "+ shareChangeCondition); - + logger.trace("shareChangeCondition add item: "+shareChangeCondition); - + //if shareChangeCondition is true.. notifies added item to sharing - if(shareChangeCondition){ + if(shareChangeCondition){ Workspace workspace = WsUtil.getWorkspace(httpSession); - + List listContacts = getListUserSharedByFolderSharedId(workspace, folderDestinationItem.getIdSharedFolder()); - + WorkspaceItem destinationSharedFolder = workspace.getItem(folderDestinationItem.getIdSharedFolder()); - NotificationsWorkspaceUploaderProducer np = new NotificationsWorkspaceUploaderProducer(WsUtil.getAslSession(httpSession)); - + NotificationsWorkspaceUploaderProducer np = new NotificationsWorkspaceUploaderProducer(WsUtil.getAslSession(httpSession),request); + if(destinationSharedFolder instanceof WorkspaceSharedFolder){ //SWITCH BEETWEEN ADDED OR UPDATED if(!isOverwrite) - np.notifyAddedItemToSharing(listContacts, sourceItem, (WorkspaceSharedFolder) destinationSharedFolder); + np.notifyAddedItemToSharing(listContacts, sourceItem, (WorkspaceSharedFolder) destinationSharedFolder); else - np.notifyUpdatedItemToSharing(listContacts, sourceItem, (WorkspaceSharedFolder) destinationSharedFolder); - - + np.notifyUpdatedItemToSharing(listContacts, sourceItem, (WorkspaceSharedFolder) destinationSharedFolder); + + logger.trace("The notifies was sent correctly"); }else logger.trace("The notifies doesn't sent because "+destinationSharedFolder+ " is not instance of WorkspaceSharedFolder"); -// np.notifyAddedItemToSharing(listContacts, (WorkspaceFolder) folderDestinationItem); - } +// np.notifyAddedItemToSharing(listContacts, (WorkspaceFolder) folderDestinationItem); + } } else logger.trace("folder destination is not shared"); - + }catch (Exception e) { logger.error("An error occurred in checkSendNotifyAddItemToShare ",e); } }else - logger.warn("The notifies is failure in checkSendNotifyAddItemToShare because folder destination item is null"); + logger.warn("The notifies is failure in checkSendNotifyAddItemToShare because folder destination item is null"); } - + /** - * + * * @param workspace * @param idSharedFolder * @return * @throws Exception */ public static List getListUserSharedByFolderSharedId(Workspace workspace, String idSharedFolder) throws Exception { - + logger.trace("getListUserSharedByFolderSharedId "+ idSharedFolder); try { WorkspaceItem wsItem = workspace.getItem(idSharedFolder); - + if(isASharedFolder(wsItem)){ - + WorkspaceSharedFolder wsFolder = (WorkspaceSharedFolder) wsItem; List listPortalLogin = wsFolder.getUsers(); - + ArrayList users = new ArrayList(listPortalLogin.size()); - + for (String login : listPortalLogin) { users.add(new ContactModel(login, login, false, UserUtil.getUserFullName(login))); } - + return users; } else{ logger.info("the item with id: "+idSharedFolder+ " is not "+WorkspaceItemType.SHARED_FOLDER); } return new ArrayList(); - + } catch (Exception e) { logger.error("Error in getListUserSharedByItemId ", e); throw new Exception(e.getMessage()); } } - + /** - * + * * @param wsItem * @return */ @@ -137,51 +138,51 @@ public class NotificationsWorkspaceUploader { return wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER); return false; } - + /** - * + * * @param wsItem * @return */ public static boolean isASharedFolderForId(HttpSession httpSession, String itemId){ - + if(itemId==null || itemId.isEmpty()) return false; - + try { - + Workspace workspace = WsUtil.getWorkspace(httpSession); WorkspaceItem wsItem = workspace.getItem(itemId); - + if(wsItem!=null) return wsItem.getType().equals(WorkspaceItemType.SHARED_FOLDER); return false; - + } catch (Exception e) { logger.error("An errror occurred in isASharedFolderForId", e); return false; } } - + /** - * + * * @param itemId * @param rootFolderSharedId * @return */ public static boolean checkIsRootFolderShared(String itemId, String rootFolderSharedId) { - + logger.trace("checkIsRootFolderShared between [itemid: "+itemId +", rootFolderSharedId: "+rootFolderSharedId+"]"); if(itemId==null) return false; - + if(rootFolderSharedId==null) return false; - + if(itemId.compareTo(rootFolderSharedId)==0) return true; - + return false; } } diff --git a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/notification/NotificationsWorkspaceUploaderProducer.java b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/notification/NotificationsWorkspaceUploaderProducer.java index 7a68bf6..f533649 100644 --- a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/notification/NotificationsWorkspaceUploaderProducer.java +++ b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/notification/NotificationsWorkspaceUploaderProducer.java @@ -1,10 +1,12 @@ /** - * + * */ package org.gcube.portlets.widgets.workspaceuploader.server.notification; import java.util.List; +import javax.servlet.http.HttpServletRequest; + import org.apache.log4j.Logger; import org.gcube.application.framework.core.session.ASLSession; import org.gcube.applicationsupportlayer.social.NotificationsManager; @@ -24,9 +26,9 @@ import org.gcube.portlets.widgets.workspaceuploader.shared.ContactModel; public class NotificationsWorkspaceUploaderProducer { protected ScopeBean scope; - + protected static Logger logger = Logger.getLogger(NotificationsWorkspaceUploaderProducer.class); - + protected NotificationsManager notificationsMng; protected ASLSession aslSession; protected String userId; @@ -35,9 +37,10 @@ public class NotificationsWorkspaceUploaderProducer { * Instantiates a new notifications producer. * * @param aslSession the asl session + * @param request the request */ - public NotificationsWorkspaceUploaderProducer(ASLSession aslSession) { - this.notificationsMng = WsUtil.getNotificationManager(aslSession); + public NotificationsWorkspaceUploaderProducer(ASLSession aslSession, HttpServletRequest request) { + this.notificationsMng = WsUtil.getNotificationManager(aslSession, request); this.aslSession = aslSession; this.userId = aslSession.getUsername(); } @@ -68,8 +71,8 @@ public class NotificationsWorkspaceUploaderProducer { public ASLSession getAslSession() { return aslSession; } - - + + /** * Runs a new thread to notify the contacts passed in input. * @@ -82,19 +85,19 @@ public class NotificationsWorkspaceUploaderProducer { new Thread() { @Override public void run() { - + // printContacts(listContacts); logger.info("Send notifies added item in sharedfolder is running..."); - + //DEBUG System.out.println("Send notifies added item in sharedfolder is running..."); - + for (ContactModel infoContactModel : listContacts) { try{ //NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER - if(infoContactModel.getLogin().compareTo(userId)!=0){ - + if(infoContactModel.getLogin().compareTo(userId)!=0){ + logger.info("Sending notification to user "+infoContactModel.getLogin() +" added item "+workspaceItem.getName()+" in shared folder "+sharedFolder.getName()); boolean notify = notificationsMng.notifyAddedItem(infoContactModel.getLogin(), workspaceItem, sharedFolder); @@ -106,14 +109,14 @@ public class NotificationsWorkspaceUploaderProducer { logger.error("An error occured in notifyAddedItemToSharing ", e); } } - + logger.trace("notifies of added item in shared folder is completed"); } }.start(); } - - + + /** * Runs a new thread to notify the contacts passed in input. * @@ -126,16 +129,16 @@ public class NotificationsWorkspaceUploaderProducer { new Thread() { @Override public void run() { - + // printContacts(listContacts); logger.info("Send notifies updated item in shared folder is running..."); - + for (ContactModel infoContactModel : listContacts) { try{ //NOTIFIES ONLY THE USERS THAT ARE DIFFERENT FROM CURRENT USER - if(infoContactModel.getLogin().compareTo(userId)!=0){ - + if(infoContactModel.getLogin().compareTo(userId)!=0){ + 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); @@ -148,11 +151,11 @@ public class NotificationsWorkspaceUploaderProducer { e.printStackTrace(); } } - + logger.trace("notifies of updated item in shared folder is completed"); } }.start(); } - + } \ No newline at end of file diff --git a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/upload/WorkspaceUploaderMng.java b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/upload/WorkspaceUploaderMng.java index ac6f151..6186eca 100644 --- a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/upload/WorkspaceUploaderMng.java +++ b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/upload/WorkspaceUploaderMng.java @@ -6,6 +6,7 @@ package org.gcube.portlets.widgets.workspaceuploader.server.upload; import java.io.IOException; import java.io.InputStream; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import org.gcube.common.homelibrary.home.exceptions.InternalErrorException; @@ -49,6 +50,7 @@ public class WorkspaceUploaderMng { /** * Creates the workspace uploader file. * + * @param request the request * @param workspaceUploader the workspace uploader * @param httpSession the http session * @param isOvewrite the is ovewrite @@ -62,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(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(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); @@ -86,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(httpSession, wa, createdItem.getId(), createdItem.getParent().getId(), isOvewrite); + WorkspaceUploadServletStream.notifyUploadInSharedFolder(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); @@ -205,6 +207,7 @@ public class WorkspaceUploaderMng { /** * Upload file. * + * @param request the request * @param workspaceUploader the workspace uploader * @param httpSession the http session * @param wa the wa @@ -217,10 +220,10 @@ public class WorkspaceUploaderMng { * @return the workspace uploader item * @throws Exception the exception */ - public static WorkspaceUploaderItem uploadFile(WorkspaceUploaderItem workspaceUploader, HttpSession httpSession, Workspace wa, String itemName, InputStream file, WorkspaceFolder destinationFolder, String contentType, boolean isOverwrite, long totolaBytes) throws 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 { try { - return createWorkspaceUploaderFile(workspaceUploader, httpSession, isOverwrite, wa, file, itemName, destinationFolder, contentType, totolaBytes); + return createWorkspaceUploaderFile(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"); diff --git a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/util/UserUtil.java b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/util/UserUtil.java index 9355bd5..347ca8a 100644 --- a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/util/UserUtil.java +++ b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/util/UserUtil.java @@ -6,11 +6,10 @@ import java.util.List; import org.apache.log4j.Logger; import org.gcube.portlets.widgets.workspaceuploader.shared.ContactModel; import org.gcube.vomanagement.usermanagement.UserManager; -import org.gcube.vomanagement.usermanagement.exception.UserManagementPortalException; import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException; import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault; -import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayUserManager; -import org.gcube.vomanagement.usermanagement.model.UserModel; +import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager; +import org.gcube.vomanagement.usermanagement.model.GCubeUser; @@ -21,11 +20,11 @@ import org.gcube.vomanagement.usermanagement.model.UserModel; * Aug 3, 2015 */ public class UserUtil { - + static UserManager um = new LiferayUserManager(); protected static Logger logger = Logger.getLogger(UserUtil.class); - + /** * Gets the user full name. * @@ -35,46 +34,44 @@ public class UserUtil { public static String getUserFullName(String portalLogin){ if(portalLogin==null) return ""; - + if (WsUtil.isWithinPortal()) { //INTO PORTAL - - UserModel curr = null; - + + GCubeUser curr = null; + try { try { - curr = um.getUserByScreenName(portalLogin); - + curr = um.getUserByUsername(portalLogin); + } catch (UserManagementSystemException e) { - - logger.error("An error occurred in getUserFullName "+e,e); + + logger.error("An error occurred in getUserByUsername "+e,e); } catch (UserRetrievalFault e) { - - logger.error("An error occurred in getUserFullName "+e,e); + + logger.error("An error occurred in getUserByUsername "+e,e); } - } catch (UserManagementPortalException ume) { - logger.error("An error occurred in getUserFullName "+ume,ume); }catch (Exception e) { - logger.error("An error occurred in getUserFullName "+e,e); + logger.error("An error occurred in getUserByUsername "+e,e); logger.warn("Return portal login "+portalLogin); return portalLogin; } - + if (curr != null){ - + // logger.trace("Return "+curr.getFullname() +" full name for: "+portalLogin); return curr.getFullname(); - + } }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); return portalLogin; } - + /** * Gets the list login by info contact model. * @@ -82,16 +79,16 @@ public class UserUtil { * @return the list login by info contact model */ public static List getListLoginByInfoContactModel(List listContacts){ - + List listUsers = new ArrayList(); - + for (ContactModel infoContactModel : listContacts) { listUsers.add(infoContactModel.getLogin()); } - + return listUsers; } - + /** * Separate users names to comma. * @@ -99,20 +96,20 @@ public class UserUtil { * @return the string */ public static String separateUsersNamesToComma(List listContacts){ - + String users = ""; - + for (int i = 0; i < listContacts.size()-1; i++) { users+= listContacts.get(i).getFullName() + ", "; } - + if(listContacts.size()>1) users += listContacts.get(listContacts.size()-1).getFullName(); - + return users; } - - + + /** * Separate full name to comma for portal login. * @@ -120,25 +117,25 @@ public class UserUtil { * @return the string */ public static String separateFullNameToCommaForPortalLogin(List listLogin){ - + String users = ""; - + logger.trace("SeparateFullNameToCommaForPortalLogin converting: "+listLogin); - + //N-1 MEMBERS for (int i = 0; i < listLogin.size()-1; i++) { // logger.trace("Converting: "+i+") "+listLogin.get(i)); users+= getUserFullName(listLogin.get(i)) + ", "; } - + //LAST MEMBER if(listLogin.size()>=1){ // logger.trace("Converting: "+(listLogin.size()-1)+") " +listLogin.get(listLogin.size()-1)); users += getUserFullName(listLogin.get(listLogin.size()-1)); } - + logger.trace("SeparateFullNameToCommaForPortalLogin returning: "+users); - + return users; } } diff --git a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/util/WsUtil.java b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/util/WsUtil.java index 0b6b094..9be2002 100644 --- a/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/util/WsUtil.java +++ b/src/main/java/org/gcube/portlets/widgets/workspaceuploader/server/util/WsUtil.java @@ -3,6 +3,7 @@ */ package org.gcube.portlets.widgets.workspaceuploader.server.util; +import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import org.apache.log4j.Logger; @@ -10,6 +11,7 @@ import org.gcube.application.framework.core.session.ASLSession; import org.gcube.application.framework.core.session.SessionManager; import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager; import org.gcube.applicationsupportlayer.social.NotificationsManager; +import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingSite; import org.gcube.common.homelibrary.home.HomeLibrary; import org.gcube.common.homelibrary.home.exceptions.HomeNotFoundException; import org.gcube.common.homelibrary.home.exceptions.InternalErrorException; @@ -162,9 +164,10 @@ public class WsUtil { * Gets the notification manager. * * @param session the session + * @param request the request * @return the notification manager */ - public static NotificationsManager getNotificationManager(ASLSession session) + public static NotificationsManager getNotificationManager(ASLSession session, HttpServletRequest request) { NotificationsManager notifMng = (NotificationsManager) session.getAttribute(NOTIFICATION_MANAGER); @@ -173,7 +176,8 @@ public class WsUtil { try{ logger.trace("Create new NotificationsManager for user: "+session.getUsername()); logger.trace("New ApplicationNotificationsManager with portlet class name: "+NOTIFICATION_PORTLET_CLASS_ID); - notifMng = new ApplicationNotificationsManager(session, NOTIFICATION_PORTLET_CLASS_ID); + SocialNetworkingSite site = new SocialNetworkingSite(request); + notifMng = new ApplicationNotificationsManager(site, session.getScope(), null, NOTIFICATION_PORTLET_CLASS_ID); session.setAttribute(NOTIFICATION_MANAGER, notifMng); }catch (Exception e) { logger.error("An error occurred instancing ApplicationNotificationsManager for user: "+session.getUsername(),e); @@ -187,16 +191,17 @@ public class WsUtil { * Gets the notification producer. * * @param session the session + * @param request the request * @return the notification producer */ - public static NotificationsWorkspaceUploaderProducer getNotificationProducer(ASLSession session) + 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); + notifProducer = new NotificationsWorkspaceUploaderProducer(session, request); session.setAttribute(NOTIFICATION_PRODUCER, notifProducer); }