Browse Source

support for invites invites management alpha version is complete

git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portal/invites-common-library@115672 82a268e6-3cf1-43bd-a215-b396298e98cf
master
Massimiliano Assante 7 years ago
parent
commit
6b490ae31d
  1. 1
      .classpath
  2. 13
      .project
  3. 3
      .settings/org.eclipse.jdt.core.prefs
  4. 5
      .settings/org.eclipse.wst.common.component
  5. 5
      .settings/org.eclipse.wst.common.project.facet.core.xml
  6. 2
      .settings/org.eclipse.wst.validation.prefs
  7. 5
      pom.xml
  8. 52
      src/main/java/org/gcube/portal/invites/InvitesManager.java

1
.classpath

@ -15,6 +15,7 @@
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="org.eclipse.jst.component.nondependency" value=""/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">

13
.project

@ -5,11 +5,21 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
@ -17,7 +27,10 @@
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>
</projectDescription>

3
.settings/org.eclipse.jdt.core.prefs

@ -1,5 +1,8 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.7

5
.settings/org.eclipse.wst.common.component

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="invites-common-library">
<wb-resource deploy-path="/" source-path="/src/main/java"/>
</wb-module>
</project-modules>

5
.settings/org.eclipse.wst.common.project.facet.core.xml

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<installed facet="java" version="1.7"/>
<installed facet="jst.utility" version="1.0"/>
</faceted-project>

2
.settings/org.eclipse.wst.validation.prefs

@ -0,0 +1,2 @@
disabled=06target
eclipse.preferences.version=1

5
pom.xml

@ -53,6 +53,11 @@
<artifactId>aslcore</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.portal</groupId>
<artifactId>social-networking-library</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.sun.mail</groupId>
<artifactId>javax.mail</artifactId>

52
src/main/java/org/gcube/portal/invites/InvitesManager.java

@ -1,14 +1,22 @@
package org.gcube.portal.invites;
import java.util.Date;
import java.util.Properties;
import java.util.UUID;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
import org.gcube.portal.databook.server.DatabookStore;
import org.gcube.portal.databook.shared.Invite;
import org.gcube.portal.databook.shared.InviteOperationResult;
import org.gcube.portal.databook.shared.InviteStatus;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
@ -28,16 +36,56 @@ public class InvitesManager {
private final static String MAIL_SERVICE_PORT = "25";
private static InvitesManager instance;
private static DatabookStore store;
private InvitesManager() { }
public static InvitesManager getInstance(){
instance = new InvitesManager();
initStore();
return instance;
}
/**
*
* @return the unique instance of the store
*/
public static synchronized DatabookStore initStore() {
if (store == null) {
store = new DBCassandraAstyanaxImpl();
}
return store;
}
public InviteOperationResult sendInvite(
ASLSession aslSession,
String portalSenderEmail,
String portalURL,
String name,
String lastName,
String email,
String vreDescription) {
String username = aslSession.getUsername();
String fromFullName = aslSession.getUserFullName();
String controlcode = UUID.randomUUID().toString();
Invite invite = new Invite(UUID.randomUUID().toString(), username, aslSession.getScopeName(), email, controlcode, InviteStatus.PENDING, new Date(), fromFullName);
InviteOperationResult result = null;
boolean emailResult = false;
try {
result = store.saveInvite(invite);
emailResult = sendInviteEmail(aslSession, portalSenderEmail, portalURL, fromFullName, lastName, email, vreDescription);
} catch (AddressException e) {
_log.error("Email not valid " + e.getMessage());
e.printStackTrace();
return InviteOperationResult.FAILED;
}
return (emailResult) ? result : InviteOperationResult.FAILED;
}
public Boolean sendInviteEmail(
private Boolean sendInviteEmail(
ASLSession aslSession,
String portalSenderEmail,
String portalURL,

Loading…
Cancel
Save