fixed pom

This commit is contained in:
Massimiliano Assante 2021-11-04 10:41:09 +01:00
parent 2b3b273a6f
commit f348338c98
11 changed files with 249 additions and 81 deletions

View File

@ -1,50 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/aopalliance-repackaged-2.5.0-b32.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/common-gcube-calls-1.3.1-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/common-jaxrs-client-1.0.4-SNAPSHOT.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/detachedres-library-1.1.0.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/gcube-jackson-annotations-2.8.11.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/gcube-jackson-core-2.8.11.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/gcube-jackson-databind-2.8.11.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/gxHTTP-1.2.0.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/gxJRS-1.2.0.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/hk2-api-2.5.0-b32.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/hk2-locator-2.5.0-b32.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/hk2-utils-2.5.0-b32.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/jackson-annotations-2.8.11.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/jackson-core-2.8.4.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/jackson-databind-2.8.4.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/jackson-jaxrs-base-2.8.4.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/jackson-jaxrs-json-provider-2.8.4.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/jackson-module-jaxb-annotations-2.8.4.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/javassist-3.20.0-GA.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/javax.annotation-api-1.2.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/javax.inject-2.5.0-b32.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/javax.ws.rs-api-2.0.1.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/jersey-client-2.24.1.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/jersey-common-2.25.1.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/jersey-entity-filtering-2.25.1.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/jersey-guava-2.25.1.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/jersey-media-json-jackson-2.25.1.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/jersey-media-multipart-2.25.1.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/jstl-1.2.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/lombok-1.14.8.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/mimepull-1.9.6.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/osgi-resource-locator-1.0.1.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/storagehub-client-library-1.3.0.jar"/>
<classpathentry kind="lib" path="target/moving-map-forms-1.0.0-SNAPSHOT/WEB-INF/lib/storagehub-model-1.1.1.jar"/>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
@ -57,6 +18,11 @@
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>

View File

@ -1,4 +1,5 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8

View File

@ -1,18 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="moving-map-portlet">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<property name="java-output-path" value="/moving-map-forms/target/classes"/>
<property name="context-root" value="moving-map-portlet"/>
</wb-module>
<wb-module deploy-name="moving-map-portlet">
<wb-resource deploy-path="/" source-path="/target/m2e-wtp/web-resources"/>
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/test/java"/>
<property name="java-output-path" value="/moving-map-forms/target/classes"/>
<property name="context-root" value="moving-map-portlet"/>
</wb-module>
</project-modules>

17
pom.xml
View File

@ -60,11 +60,6 @@
<groupId>org.gcube.resources.discovery</groupId>
<artifactId>ic-client</artifactId>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.core</groupId>
<artifactId>common-encryption</artifactId>
@ -74,18 +69,6 @@
<artifactId>portal-service</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>authorization-client</artifactId>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>common-authorization</artifactId>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-service</artifactId>

View File

@ -5,8 +5,11 @@ import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import javax.mail.Message;
import javax.mail.MessagingException;
@ -20,10 +23,26 @@ import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.servlet.http.HttpServletRequest;
import org.gcube.common.portal.GCubePortalConstants;
import org.gcube.common.portal.PortalContext;
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
import org.gcube.vomanagement.usermanagement.model.GCubeGroup;
import org.gcube.vomanagement.usermanagement.model.GCubeRole;
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
import org.gcube.vomanagement.usermanagement.model.GatewayRolesNames;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.service.GroupLocalServiceUtil;
import com.liferay.portal.util.PortalUtil;
import com.liferay.util.bridges.mvc.MVCPortlet;
/**
@ -31,15 +50,22 @@ import com.liferay.util.bridges.mvc.MVCPortlet;
*/
public class CompileForm extends MVCPortlet {
private static com.liferay.portal.kernel.log.Log _log = LogFactoryUtil.getLog(CompileForm.class);
private static final String MANAGE_USERS_REQUESTS_FRIENDLY_URL = "/manage-expression-of-interest";
private static final String MAIL_FROM = "MOVING Gateway <moving@d4science.org>";
private static final String MAIL_SUBJECT = "MOVING EU Multi-Actor Platform: email confirmation";
private static final String MAIL_SUBJECT_VRE_MANAGER = "MOVING EU Multi-Actor Platform: new form submission notification";
private static final String MAIL_BODY = "Dear Sir/Madam,\n"
+ "Thank you for expressing your interest to join the MOVING EU-level Multi-Actor Platform (MAP). The MOVING team will carefully review the information provided and assess the suitability of your involvement to form a dynamic and relevant community.\n"
+ "Please receive below a copy of the information submitted. \n"
+ "\n"
+ "Best regards,\n"
+ "MOVING team\n";
private static final String MAIL_BODY_VRE_MANAGER = "Dear MOVING EU-MAP Manager,\n"
+ "A new request to join the MOVING EU-level Multi-Actor Platform (MAP) has been submitted.\n"
+ "\nPlease manage this request:\n";
private String mailServiceHost = "localhost";
private String mailServicePort = "25";
@Override
@ -83,6 +109,7 @@ public class CompileForm extends MVCPortlet {
String textareaMotivation = actionRequest.getParameter("textareaMotivation");
String elaborated_expertise = actionRequest.getParameter("textareaExperience");
String degree_of_participation = actionRequest.getParameter("commitment");
_log.debug("name:" + name);
_log.debug("surname:" + surname);
_log.debug("organisation:" + organisation);
@ -126,6 +153,34 @@ public class CompileForm extends MVCPortlet {
preparedStatement .executeUpdate();
_log.info("Inserting in DB done, sending confirmation to user and notification to managers via email");
String copySubmitted = new StringBuffer("\n\n\nCOPY OF INFORMATION SUBMITTED\n\n")
.append("\n").append("Name: ")
.append(name).append(" ").append(surname)
.append("\n").append("Organisation: ")
.append(organisation)
.append("\n").append("Organisation type: ")
.append(organisationType)
.append("\n").append("emailAddress: ")
.append("*** hidden on purpose ***")
.append("\n").append("Country: ")
.append(country)
.append("\n\n").append("Have you participated in the activities of any of our MOVING Regional Multi-Actors Platforms? ")
.append(participatedInActivities)
.append("\n\n").append("What is your main motivation for joining the EU MAP of MOVING? ")
.append(mainMotivation)
.append("\n\n").append("Please elaborate on your motivation expressed above so that we understand better your interest, and form a dynamic and relevant community. Vague explanations of the motivation might not be taken into consideration. ")
.append("\n\n").append(textareaMotivation).append("\n")
.append("\n\n").append("What is your main area of expertise in relation to mountain sustainability and resilience? (Multiple choice): ")
.append(areaOfExpertise)
.append("\n\n").append("Please elaborate on the relevant experience you can bring to mountain value chains and the resilience of these areas, so that we have more detailed information to be able to form a dynamic and relevant community: ")
.append("\n\n").append(elaborated_expertise)
.append("\n\n").append("As a starting point, the degree of participation you commit to is: ")
.append(degree_of_participation)
.append("\n").append("\n").append("Data Management: ")
.append("Agreed")
.append("\n\nEND COPY OF INFORMATION SUBMITTED\n\n").toString();
Properties props = System.getProperties();
Session session = null;
props.put("mail.smtp.host", mailServiceHost);
@ -133,30 +188,106 @@ public class CompileForm extends MVCPortlet {
//use localhost (probaly postfix instance)
session = Session.getDefaultInstance(props);
sendEmailConfirmationToUser(props, session, emailAddress);
sendEmailNotificationToVREManagers(props, session, emailAddress);
sendEmailConfirmationToUser(props, session, emailAddress, copySubmitted);
String groupIdVREforManagers = GetterUtil.getString(actionRequest.getPreferences().getValue("VREGroupId", StringPool.BLANK));
if (groupIdVREforManagers != null && groupIdVREforManagers.compareTo("") != 0) {
HttpServletRequest httpRequest = PortalUtil.getHttpServletRequest(actionRequest);
sendEmailNotificationToVREManagers(httpRequest, props, session, groupIdVREforManagers, copySubmitted);
}
else {
_log.warn("WARNING, non config found for groupId, no email will be send to VRE Managers");
}
} catch (Exception e) {
_log.error("Some error while trying to insert form");
e.printStackTrace();
}
}
private void sendEmailConfirmationToUser(Properties props, Session session, String emailadress) throws AddressException, MessagingException {
/**
*
* @param props
* @param session
* @param emailadress
* @throws AddressException
* @throws MessagingException
*/
private void sendEmailConfirmationToUser(Properties props, Session session, String emailadress, String copySubmitted) throws AddressException, MessagingException {
_log.info("Sending confirmation to user");
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(MAIL_FROM));
message.setRecipients(
Message.RecipientType.TO, InternetAddress.parse(emailadress));
message.setSubject(MAIL_SUBJECT);
message.setText(MAIL_BODY);
message.setText(MAIL_BODY+copySubmitted);
// Send message
Transport.send(message);
_log.info("Sending confirmation email done");
}
private void sendEmailNotificationToVREManagers(Properties props, Session session, String emailadress) {
/**
*
* @param props
* @param session
* @param groupId the groupid of the VRE where to find the managers to alert
* @throws MessagingException
* @throws AddressException
* @throws SystemException
* @throws PortalException
*/
private void sendEmailNotificationToVREManagers(HttpServletRequest httprequest , Properties props, Session session, String groupIdString, String copySubmitted) throws AddressException, MessagingException, PortalException, SystemException {
_log.info("Sending notification email to VRE-Managers");
long groupId = Long.parseLong(groupIdString);
List<String> vreManagersEmails = getAdministratorsEmails(groupId);
for (String emailadress : vreManagersEmails) {
_log.info("Sending notificsation to user");
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(MAIL_FROM));
message.setRecipients(
Message.RecipientType.TO, InternetAddress.parse(emailadress));
message.setSubject(MAIL_SUBJECT_VRE_MANAGER);
String vreName = GroupLocalServiceUtil.getGroup(groupId).getName();
String gatewayURL = PortalContext.getConfiguration().getGatewayURL(httprequest);
String manageRequestURL = new StringBuffer(gatewayURL)
.append(GCubePortalConstants.PREFIX_GROUP_URL)
.append("/").append(vreName.toLowerCase())
.append(MANAGE_USERS_REQUESTS_FRIENDLY_URL).toString();
message.setText(MAIL_BODY_VRE_MANAGER+manageRequestURL+copySubmitted);
// Send message
Transport.send(message);
_log.info("Sending notification email to VRE-Managers done");
}
}
/**
*
* @param groupId the VRE group id
* @return the VRE Managers emails of the VRE groupid passed in the parameter
*/
private static List<String> getAdministratorsEmails(long groupId) {
_log.debug("getAdministratorsEmails");
LiferayUserManager userManager = new LiferayUserManager();
Map<GCubeUser, List<GCubeRole>> usersAndRoles = null;
try {
usersAndRoles = userManager.listUsersAndRolesByGroup(groupId);
} catch (Exception e) {
e.printStackTrace();
}
Set<GCubeUser> users = usersAndRoles.keySet();
ArrayList<String> adminEmailsList = new ArrayList<String>();
for (GCubeUser usr:users) {
List<GCubeRole> roles = usersAndRoles.get(usr);
for (int i = 0; i < roles.size(); i++) {
if (roles.get(i).getRoleName().equals(GatewayRolesNames.VRE_MANAGER.getRoleName())) {
adminEmailsList.add(usr.getEmail());
_log.debug("Manager: " + usr.getFullname());
break;
}
}
}
return adminEmailsList;
}
private static List<String> getOrganisationTypes(Connection conn) throws Exception {
_log.debug("getting organisation_types ");

View File

@ -0,0 +1,37 @@
package org.gcube.portlets.user.moving;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletConfig;
import javax.portlet.PortletPreferences;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.portlet.DefaultConfigurationAction;
public class FormConfigurationAction extends DefaultConfigurationAction {
private static Log _log = LogFactoryUtil.getLog(FormConfigurationAction.class);
@Override
public void processAction(
PortletConfig portletConfig, ActionRequest actionRequest,
ActionResponse actionResponse) throws Exception {
super.processAction(portletConfig, actionRequest, actionResponse);
PortletPreferences prefs = actionRequest.getPreferences();
String VREGroupId = prefs.getValue("VREGroupId", "true");
_log.debug("VREGroupId = " + VREGroupId + " processAction().");
}
@Override
public String render(PortletConfig portletConfig,
RenderRequest renderRequest, RenderResponse renderResponse)
throws Exception {
return "/html/form-compile/config.jsp";
}
}

View File

@ -5,6 +5,8 @@
<portlet>
<portlet-name>moving-form-compile</portlet-name>
<icon>/icon.png</icon>
<configuration-action-class>org.gcube.portlets.user.moving.FormConfigurationAction</configuration-action-class>
<requires-namespaced-parameters>false</requires-namespaced-parameters>
<header-portlet-css>/css/main.css</header-portlet-css>
<footer-portlet-javascript>
/js/main.js

View File

@ -12,6 +12,10 @@
<name>view-jsp</name>
<value>/html/form-compile/form-map.jsp</value>
</init-param>
<init-param>
<name>config-template</name>
<value>/html/form-compile/config.jsp</value>
</init-param>
<expiration-cache>0</expiration-cache>
<supports>
<mime-type>text/html</mime-type>

View File

@ -1,12 +1,17 @@
#wrapper input[type=text] , #wrapper textarea {
#wrapper input[type=text] {
height: 25px;
}
#wrapper .form-inline .checkbox input[type=checkbox] {
margin-right: 10px;
height: 18px;
}
#wrapper label {
min-width: 200px;
}
#wrapper label {
display: inline-block;
max-width: 100%;
@ -17,4 +22,5 @@
font-size: 16px;
line-height: 1.5;
font-family: "Open Sans", Arial, sans-serif !important;
}
}

View File

@ -0,0 +1,29 @@
<%@include file="../init.jsp"%>
<liferay-portlet:actionURL portletConfiguration="true"
var="configurationURL" />
<%
String VREGroupId_cfg = GetterUtil.getString(portletPreferences.getValue("VREGroupId", StringPool.BLANK));
%>
<aui:form action="<%=configurationURL%>" method="post" name="fm">
<aui:input name="<%=Constants.CMD%>" type="hidden"
value="<%=Constants.UPDATE%>" />
<!-- Application URL -->
<aui:field-wrapper cssClass="field-group">
<aui:input style="width: 100%;" name="preferences--VREGroupId--"
type="text" cssClass="text long-field" showRequiredLabel="true"
label="VRE GroupId" inlineField="true" inlineLabel="left"
placeholder="12345"
helpMessage="Il groupId della VRE dove cercare i VRE Managers da notificare quando nuove form"
value="<%=VREGroupId_cfg%>" required="true" />
</aui:field-wrapper>
<aui:button-row>
<aui:button type="submit" />
</aui:button-row>
</aui:form>

View File

@ -6,6 +6,9 @@
<%@ taglib uri="http://liferay.com/tld/security" prefix="liferay-security" %>
<%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>
<%@ taglib uri="http://liferay.com/tld/util" prefix="liferay-util" %>
<%@ page import="com.liferay.portal.kernel.util.Constants" %>
<%@ page import="com.liferay.portal.kernel.util.GetterUtil" %>
<%@ page import="com.liferay.portal.kernel.util.StringPool" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page import="javax.portlet.PortletURL" %>