shared idea completed
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/sbd-uploadshare-portlet@162894 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
0e78d11fab
commit
0295bb20cb
60
pom.xml
60
pom.xml
|
@ -17,9 +17,9 @@
|
|||
Upload Dataset And Share Idea Portlets
|
||||
</description>
|
||||
<scm>
|
||||
<connection>scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/${project.artifactId}</connection>
|
||||
<developerConnection>scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/${project.artifactId}</developerConnection>
|
||||
<url>http://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/${project.artifactId}</url>
|
||||
<connection>scm:svn:http://svn.d4science.research-infrastructures.eu/gcube/trunk/portal/${project.artifactId}</connection>
|
||||
<developerConnection>scm:https://svn.d4science.research-infrastructures.eu/gcube/trunk/portal/${project.artifactId}</developerConnection>
|
||||
<url>http://svn.d4science.research-infrastructures.eu/gcube/trunk/portal/${project.artifactId}</url>
|
||||
</scm>
|
||||
<profiles>
|
||||
<profile>
|
||||
|
@ -75,11 +75,59 @@
|
|||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.distribution</groupId>
|
||||
<artifactId>maven-portal-bom</artifactId>
|
||||
<version>LATEST</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>social-networking-library</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.applicationsupportlayer</groupId>
|
||||
<artifactId>aslsocial</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>notifications-common-library</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library-jcr</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common</groupId>
|
||||
<artifactId>home-library</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>social-networking-library</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common.portal</groupId>
|
||||
<artifactId>portal-manager</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.dvos</groupId>
|
||||
<artifactId>usermanagement-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.liferay.portal</groupId>
|
||||
<artifactId>portal-service</artifactId>
|
||||
<version>${liferay.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -97,13 +145,11 @@
|
|||
<dependency>
|
||||
<groupId>com.liferay.portal</groupId>
|
||||
<artifactId>util-java</artifactId>
|
||||
<version>${liferay.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.portlet</groupId>
|
||||
<artifactId>portlet-api</artifactId>
|
||||
<version>2.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -124,5 +170,5 @@
|
|||
<version>1.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
|
@ -1,14 +1,38 @@
|
|||
package org.gcube.portlets.user.sbdportlets;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.portlet.ActionRequest;
|
||||
import javax.portlet.ActionResponse;
|
||||
import javax.portlet.PortletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager;
|
||||
import org.gcube.applicationsupportlayer.social.NotificationsManager;
|
||||
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingSite;
|
||||
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser;
|
||||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.homelibrary.home.HomeLibrary;
|
||||
import org.gcube.common.homelibrary.home.workspace.Workspace;
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.portal.notifications.bean.GenericItemBean;
|
||||
import org.gcube.portal.notifications.thread.MessageNotificationsThread;
|
||||
import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager;
|
||||
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
||||
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||
|
||||
import com.liferay.portal.kernel.log.Log;
|
||||
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||
import com.liferay.portal.kernel.servlet.SessionErrors;
|
||||
import com.liferay.portal.kernel.servlet.SessionMessages;
|
||||
import com.liferay.portal.kernel.util.ParamUtil;
|
||||
import com.liferay.portal.kernel.util.WebKeys;
|
||||
import com.liferay.portal.model.User;
|
||||
import com.liferay.portal.theme.ThemeDisplay;
|
||||
import com.liferay.portal.util.PortalUtil;
|
||||
import com.liferay.util.bridges.mvc.MVCPortlet;
|
||||
|
||||
/**
|
||||
|
@ -17,19 +41,74 @@ import com.liferay.util.bridges.mvc.MVCPortlet;
|
|||
* Portlet implementation class CollaborateWithUs
|
||||
*/
|
||||
public class CollaborateWithUs extends MVCPortlet {
|
||||
private static Log _log = LogFactoryUtil.getLog(CollaborateWithUs.class);
|
||||
private static String SHARE_IDEA_ROLE_MANAGER_NAME = "UserIdea-Admin";
|
||||
|
||||
private LiferayRoleManager roleManager = new LiferayRoleManager();
|
||||
private LiferayUserManager userManager = new LiferayUserManager();
|
||||
|
||||
public void addIdea(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortletException {
|
||||
try{
|
||||
User currentUser = (User) actionRequest.getAttribute(WebKeys.USER);
|
||||
ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);
|
||||
long groupId = themeDisplay.getLayout().getGroupId();
|
||||
String experiment_name = ParamUtil.getString(actionRequest, "experiment_name");
|
||||
System.out.println("ex: " + experiment_name);
|
||||
String people_institutions = ParamUtil.getString(actionRequest, "people_institutions");
|
||||
String theAbstract = ParamUtil.getString(actionRequest, "abstract");
|
||||
String experiment_tags = ParamUtil.getString(actionRequest, "experiment_tags");
|
||||
|
||||
_log.debug("new experiment shared: " + experiment_name);
|
||||
SessionMessages.add(actionRequest.getPortletSession(), "experiment-form-success");
|
||||
actionResponse.setRenderParameter("mvcPath", "/html/collaboratewithus/view-experiment-inserted.jsp");
|
||||
|
||||
|
||||
|
||||
}catch(Exception e){
|
||||
|
||||
|
||||
long teamId = roleManager.getTeam(groupId, SHARE_IDEA_ROLE_MANAGER_NAME).getTeamId();
|
||||
List<GCubeUser> theManagers = userManager.listUsersByTeam(teamId);
|
||||
HttpServletRequest request = PortalUtil.getHttpServletRequest(actionRequest);
|
||||
boolean result = sendNotificationToUser(request, groupId, currentUser, theManagers, experiment_name, people_institutions, theAbstract, experiment_tags);
|
||||
if (result)
|
||||
actionResponse.setRenderParameter("mvcPath", "/html/collaboratewithus/view-experiment-inserted.jsp");
|
||||
else
|
||||
actionResponse.setRenderParameter("mvcPath", "/html/collaboratewithus/view-experiment-error.jsp");
|
||||
} catch(Exception e){
|
||||
SessionErrors.add(actionRequest.getPortletSession(),"experiment-form-error");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private boolean sendNotificationToUser(HttpServletRequest request, long groupId, User currentUser, List<GCubeUser> theManagers
|
||||
, String experiment_name, String people_institutions, String theAbstract, String experiment_tags) throws Exception {
|
||||
String scope = PortalContext.getConfiguration().getCurrentScope(""+groupId);
|
||||
_log.info("sendNotificationToUser Scope: " + scope);
|
||||
|
||||
String authorizationToken = PortalContext.getConfiguration().getCurrentUserToken(scope, currentUser.getScreenName());
|
||||
ScopeProvider.instance.set(scope);
|
||||
SecurityTokenProvider.instance.set(authorizationToken);
|
||||
Workspace workspace = HomeLibrary.getUserWorkspace(currentUser.getScreenName());
|
||||
|
||||
List<String> recipientIds = new ArrayList<String>();
|
||||
List<GenericItemBean> recipients = new ArrayList<GenericItemBean>();
|
||||
for (GCubeUser addressee : theManagers) {
|
||||
recipients.add(new GenericItemBean(addressee.getUsername(), addressee.getUsername(), addressee.getFullname(), ""));
|
||||
recipientIds.add(addressee.getUsername());
|
||||
}
|
||||
|
||||
String subject = "A new user shared an idea";
|
||||
StringBuilder sb = new StringBuilder("Hi, the following idea was shared by ").append(currentUser.getFullName())
|
||||
.append(" (").append(currentUser.getEmailAddress()).append(").")
|
||||
.append("\n\n").append("Experiment name: ").append(experiment_name).append("\n")
|
||||
.append("\n").append("Involved people and or institutions: ").append(people_institutions).append("\n")
|
||||
.append("\n").append("Abstract:\n").append(theAbstract).append("\n")
|
||||
.append("\n").append("Keywords (Comma separated): ").append(experiment_tags).append("\n");
|
||||
|
||||
String body = sb.toString();
|
||||
String messageId = workspace.getWorkspaceMessageManager().sendMessageToPortalLogins(subject, body, new ArrayList<String>(), recipientIds);
|
||||
|
||||
_log.debug("Sending message notification to: " + recipientIds.toString());
|
||||
NotificationsManager nm = new ApplicationNotificationsManager(new SocialNetworkingSite(request), scope, new SocialNetworkingUser(
|
||||
currentUser.getScreenName(), currentUser.getEmailAddress(), currentUser.getFullName(), ""));
|
||||
Thread thread = new Thread(new MessageNotificationsThread(recipients, messageId, subject, body, nm));
|
||||
thread.start();
|
||||
|
||||
return (messageId != null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>
|
||||
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
|
||||
<%@ taglib uri="http://liferay.com/tld/aui" prefix="aui"%>
|
||||
<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui"%>
|
||||
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme"%>
|
||||
<%@page import="com.liferay.portal.kernel.portlet.LiferayWindowState"%>
|
||||
<%@page import="com.liferay.portal.kernel.servlet.SessionErrors"%>
|
||||
<%@page import="com.liferay.portal.kernel.servlet.SessionMessages"%>
|
||||
<%@page import="com.liferay.portal.model.User"%>
|
||||
<%@page import="com.liferay.portal.kernel.util.WebKeys"%>
|
||||
<portlet:defineObjects />
|
||||
<liferay-theme:defineObjects />
|
||||
|
||||
<%
|
||||
User currentUser = (User) request.getAttribute(WebKeys.USER);
|
||||
%>
|
||||
|
||||
<portlet:renderURL var="normalState"
|
||||
windowState="<%=LiferayWindowState.NORMAL.toString()%>" />
|
||||
|
||||
<p class="lead">
|
||||
Thank you
|
||||
<%=currentUser.getFirstName()%>. There was an error submitting your request. Please report this issue.
|
||||
</p>
|
||||
|
||||
|
||||
<a class="btn btn-large btn-primary" href="${normalState}"><i
|
||||
class="icon icon-angle-left"></i> Close and return to home</a>
|
||||
<div
|
|
@ -6,22 +6,25 @@
|
|||
<%@page import="com.liferay.portal.kernel.portlet.LiferayWindowState"%>
|
||||
<%@page import="com.liferay.portal.kernel.servlet.SessionErrors"%>
|
||||
<%@page import="com.liferay.portal.kernel.servlet.SessionMessages"%>
|
||||
<%@page import="com.liferay.portal.model.User" %>
|
||||
<%@page import="com.liferay.portal.kernel.util.WebKeys" %>
|
||||
<%@page import="com.liferay.portal.model.User"%>
|
||||
<%@page import="com.liferay.portal.kernel.util.WebKeys"%>
|
||||
<portlet:defineObjects />
|
||||
<liferay-theme:defineObjects />
|
||||
|
||||
<%
|
||||
User currentUser = (User) request.getAttribute(WebKeys.USER);
|
||||
%>
|
||||
%>
|
||||
|
||||
<portlet:renderURL var="normalState"
|
||||
windowState="<%=LiferayWindowState.NORMAL.toString()%>" />
|
||||
|
||||
<p class="lead">Thank you <%=currentUser.getFirstName()%></p>
|
||||
<p class="lead">
|
||||
Thank you
|
||||
<%=currentUser.getFirstName()%>. We have been notified about your
|
||||
request, will get back to you shortly.
|
||||
</p>
|
||||
|
||||
|
||||
<a class="btn btn-link btn-large" href="${normalState}"><i
|
||||
class="icon icon-angle-left"></i> Back home</a>
|
||||
<div
|
||||
|
||||
<a class="btn btn-large btn-primary" href="${normalState}"><i
|
||||
class="icon icon-angle-left"></i> Close and return to home</a>
|
||||
<div
|
|
@ -10,7 +10,7 @@
|
|||
<liferay-theme:defineObjects />
|
||||
|
||||
<% if(SessionErrors.contains(renderRequest.getPortletSession(),"experiment-form-error")){%>
|
||||
<liferay-ui:error key="experiment-form-error" message="Experiment idea form Submitted had an issue, Please try again." />
|
||||
<liferay-ui:error key="experiment-form-error" message="Experiment idea form submit had an issue, Please try again." />
|
||||
<%} %>
|
||||
|
||||
<portlet:actionURL var="addIdeaActionURL" windowState="maximized" name="addIdea">
|
||||
|
|
Loading…
Reference in New Issue