UPDATED distro folder
git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portal/invites-common-library@125017 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
8ec0b10fae
commit
e4aae540ef
|
@ -1 +0,0 @@
|
||||||
None
|
|
|
@ -1,2 +0,0 @@
|
||||||
* Massimiliano Assante (massimiliano.assante@isti.cnr.it), CNR Pisa,
|
|
||||||
Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo"
|
|
|
@ -1,7 +1,67 @@
|
||||||
The gCube System
|
The gCube System - ${name}
|
||||||
------------------------------------------------------------
|
--------------------------------------------------
|
||||||
|
|
||||||
This work is partially funded by the European Commission in the
|
${description}
|
||||||
context of the iMarine project (www.i-marine.eu), under FP7 Programme.
|
|
||||||
|
|
||||||
|
|
||||||
|
${gcube.description}
|
||||||
|
|
||||||
|
${gcube.funding}
|
||||||
|
|
||||||
|
|
||||||
|
Version
|
||||||
|
--------------------------------------------------
|
||||||
|
|
||||||
|
${version} (${buildDate})
|
||||||
|
|
||||||
|
Please see the file named "changelog.xml" in this directory for the release notes.
|
||||||
|
|
||||||
|
|
||||||
|
Authors
|
||||||
|
--------------------------------------------------
|
||||||
|
|
||||||
|
* Massimiliano Assante (massimiliano.assante-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy).
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Maintainers
|
||||||
|
-----------
|
||||||
|
|
||||||
|
* Massimiliano Assante (massimiliano.assante-AT-isti.cnr.it), Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" - CNR, Pisa (Italy).
|
||||||
|
|
||||||
|
|
||||||
|
Download information
|
||||||
|
--------------------------------------------------
|
||||||
|
|
||||||
|
Source code is available from SVN:
|
||||||
|
${scm.url}
|
||||||
|
|
||||||
|
Binaries can be downloaded from the gCube website:
|
||||||
|
${gcube.website}
|
||||||
|
|
||||||
|
|
||||||
|
Installation
|
||||||
|
--------------------------------------------------
|
||||||
|
|
||||||
|
Installation documentation is available on-line in the gCube Wiki:
|
||||||
|
${gcube.wikiRoot}/
|
||||||
|
|
||||||
|
|
||||||
|
Documentation
|
||||||
|
--------------------------------------------------
|
||||||
|
|
||||||
|
Documentation is available on-line in the gCube Wiki:
|
||||||
|
${gcube.wikiRoot}/
|
||||||
|
${gcube.wikiRoot}/
|
||||||
|
|
||||||
|
Support
|
||||||
|
--------------------------------------------------
|
||||||
|
|
||||||
|
Bugs and support requests can be reported in the gCube issue tracking tool:
|
||||||
|
${gcube.issueTracking}
|
||||||
|
|
||||||
|
|
||||||
|
Licensing
|
||||||
|
--------------------------------------------------
|
||||||
|
|
||||||
|
This software is licensed under the terms you may find in the file named "LICENSE" in this directory.
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
${scm.url}
|
|
10
pom.xml
10
pom.xml
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
<groupId>org.gcube.portal</groupId>
|
<groupId>org.gcube.portal</groupId>
|
||||||
<artifactId>invites-common-library</artifactId>
|
<artifactId>invites-common-library</artifactId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.1.0-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<description>
|
<description>
|
||||||
gCube Invites Common Library is a common library containing shared code for Inviting external users to portal VREs.
|
gCube Invites Common Library is a common library containing shared code for Inviting external users to portal VREs.
|
||||||
|
@ -45,11 +45,13 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.portal</groupId>
|
<groupId>org.gcube.portal</groupId>
|
||||||
<artifactId>custom-portal-handler</artifactId>
|
<artifactId>custom-portal-handler</artifactId>
|
||||||
|
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.common.portal</groupId>
|
<groupId>org.gcube.common.portal</groupId>
|
||||||
<artifactId>portal-manager</artifactId>
|
<artifactId>portal-manager</artifactId>
|
||||||
|
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
@ -75,11 +77,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.gcube.dvos</groupId>
|
<groupId>org.gcube.dvos</groupId>
|
||||||
<artifactId>usermanagement-core</artifactId>
|
<artifactId>usermanagement-core</artifactId>
|
||||||
<scope>provided</scope>
|
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.liferay.portal</groupId>
|
|
||||||
<artifactId>portal-service</artifactId>
|
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
package org.gcube.portal.invites;
|
package org.gcube.portal.invites;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
|
@ -13,7 +10,7 @@ import javax.mail.Transport;
|
||||||
import javax.mail.internet.InternetAddress;
|
import javax.mail.internet.InternetAddress;
|
||||||
import javax.mail.internet.MimeMessage;
|
import javax.mail.internet.MimeMessage;
|
||||||
|
|
||||||
import org.gcube.portal.custom.communitymanager.OrganizationsUtil;
|
import org.gcube.common.portal.PortalContext;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
@ -25,8 +22,6 @@ import org.slf4j.LoggerFactory;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class EmailNotification {
|
public class EmailNotification {
|
||||||
private static final String SENDER_EMAIL = "notificationSenderEmail";
|
|
||||||
private static final String GATEWAY_NAME = "portalinstancename";
|
|
||||||
/**
|
/**
|
||||||
* The sender of the email
|
* The sender of the email
|
||||||
*/
|
*/
|
||||||
|
@ -61,11 +56,11 @@ public class EmailNotification {
|
||||||
* @param body
|
* @param body
|
||||||
*/
|
*/
|
||||||
public EmailNotification(String sender, String recipients[], String subject, String body) {
|
public EmailNotification(String sender, String recipients[], String subject, String body) {
|
||||||
this.emailSender = getNotificationSenderEmail();
|
this.emailSender = PortalContext.getConfiguration().getSenderEmail();
|
||||||
this.emailrecipients = recipients;
|
this.emailrecipients = recipients;
|
||||||
this.emailSubject = subject;
|
this.emailSubject = subject;
|
||||||
this.emailBody = body;
|
this.emailBody = body;
|
||||||
this.portalName = getPortalInstanceName();
|
this.portalName = PortalContext.getConfiguration().getGatewayName();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendEmail() {
|
public void sendEmail() {
|
||||||
|
@ -102,55 +97,7 @@ public class EmailNotification {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* read the portal instance name from a property file and returns it
|
|
||||||
*/
|
|
||||||
protected static String getPortalInstanceName() {
|
|
||||||
//get the portles to look for from the property file
|
|
||||||
Properties props = new Properties();
|
|
||||||
String toReturn = "";
|
|
||||||
|
|
||||||
try {
|
|
||||||
String propertyfile = OrganizationsUtil.getTomcatFolder()+"conf/gcube-data.properties";
|
|
||||||
File propsFile = new File(propertyfile);
|
|
||||||
FileInputStream fis = new FileInputStream(propsFile);
|
|
||||||
props.load( fis);
|
|
||||||
toReturn = props.getProperty(GATEWAY_NAME);
|
|
||||||
}
|
|
||||||
//catch exception in case properties file does not exist
|
|
||||||
catch(IOException e) {
|
|
||||||
toReturn = "Gateway support";
|
|
||||||
_log.error("gcube-data.properties file not found under $CATALINA_HOME/conf dir, returning default Portal Name " + toReturn);
|
|
||||||
return toReturn;
|
|
||||||
}
|
|
||||||
_log.debug("Returning Gateway Name: " + toReturn );
|
|
||||||
return toReturn;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* read the sender email for notifications name from a property file and returns it
|
|
||||||
*/
|
|
||||||
private static String getNotificationSenderEmail() {
|
|
||||||
//get the portles to look for from the property file
|
|
||||||
Properties props = new Properties();
|
|
||||||
String toReturn = "";
|
|
||||||
|
|
||||||
try {
|
|
||||||
String propertyfile = OrganizationsUtil.getTomcatFolder()+"conf/gcube-data.properties";
|
|
||||||
File propsFile = new File(propertyfile);
|
|
||||||
FileInputStream fis = new FileInputStream(propsFile);
|
|
||||||
props.load( fis);
|
|
||||||
toReturn = props.getProperty(SENDER_EMAIL);
|
|
||||||
}
|
|
||||||
//catch exception in case properties file does not exist
|
|
||||||
catch(IOException e) {
|
|
||||||
toReturn = "do-not-reply@d4science.org";
|
|
||||||
_log.error("gcube-data.properties file not found under $CATALINA_HOME/conf dir, returning default Email" + toReturn);
|
|
||||||
return toReturn;
|
|
||||||
}
|
|
||||||
_log.debug("Returning SENDER_EMAIL: " + toReturn );
|
|
||||||
return toReturn;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,8 +2,8 @@ package org.gcube.portal.invites;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -16,6 +16,7 @@ import javax.mail.internet.InternetAddress;
|
||||||
import javax.mail.internet.MimeMessage;
|
import javax.mail.internet.MimeMessage;
|
||||||
|
|
||||||
import org.gcube.application.framework.core.session.ASLSession;
|
import org.gcube.application.framework.core.session.ASLSession;
|
||||||
|
import org.gcube.common.portal.PortalContext;
|
||||||
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
|
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
|
||||||
import org.gcube.portal.databook.server.DatabookStore;
|
import org.gcube.portal.databook.server.DatabookStore;
|
||||||
import org.gcube.portal.databook.shared.Invite;
|
import org.gcube.portal.databook.shared.Invite;
|
||||||
|
@ -23,10 +24,11 @@ import org.gcube.portal.databook.shared.InviteOperationResult;
|
||||||
import org.gcube.portal.databook.shared.InviteStatus;
|
import org.gcube.portal.databook.shared.InviteStatus;
|
||||||
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
|
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
|
||||||
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
|
||||||
import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayGroupManager;
|
import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
|
||||||
import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayUserManager;
|
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
|
||||||
import org.gcube.vomanagement.usermanagement.model.RoleModel;
|
import org.gcube.vomanagement.usermanagement.model.GCubeGroup;
|
||||||
import org.gcube.vomanagement.usermanagement.model.UserModel;
|
import org.gcube.vomanagement.usermanagement.model.GCubeRole;
|
||||||
|
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
import org.jsoup.nodes.Element;
|
import org.jsoup.nodes.Element;
|
||||||
|
@ -85,7 +87,7 @@ public class InvitesManager {
|
||||||
try {
|
try {
|
||||||
result = store.saveInvite(invite);
|
result = store.saveInvite(invite);
|
||||||
emailResult = sendInviteEmail(aslSession, portalSenderEmail, portalURL, name, lastName, email, vreDescription);
|
emailResult = sendInviteEmail(aslSession, portalSenderEmail, portalURL, name, lastName, email, vreDescription);
|
||||||
notifyInviteSent(username, aslSession.getScopeName(), portalURL, EmailNotification.getPortalInstanceName(), invite);
|
notifyInviteSent(username, aslSession.getScopeName(), portalURL, PortalContext.getConfiguration().getGatewayName(), invite);
|
||||||
|
|
||||||
} catch (AddressException e) {
|
} catch (AddressException e) {
|
||||||
_log.error("Email not valid " + e.getMessage());
|
_log.error("Email not valid " + e.getMessage());
|
||||||
|
@ -237,14 +239,14 @@ public class InvitesManager {
|
||||||
private static ArrayList<String> getAdministratorsEmails(String scope) {
|
private static ArrayList<String> getAdministratorsEmails(String scope) {
|
||||||
LiferayUserManager userManager = new LiferayUserManager();
|
LiferayUserManager userManager = new LiferayUserManager();
|
||||||
LiferayGroupManager groupManager = new LiferayGroupManager();
|
LiferayGroupManager groupManager = new LiferayGroupManager();
|
||||||
String groupId = null;
|
long groupId = -1;
|
||||||
try {
|
try {
|
||||||
List<org.gcube.vomanagement.usermanagement.model.GroupModel> allGroups = groupManager.listGroups();
|
List<GCubeGroup> allGroups = groupManager.listGroups();
|
||||||
_log.debug("Number of groups retrieved: " + allGroups.size());
|
_log.debug("Number of groups retrieved: " + allGroups.size());
|
||||||
for (int i = 0; i < allGroups.size(); i++) {
|
for (int i = 0; i < allGroups.size(); i++) {
|
||||||
String grId = allGroups.get(i).getGroupId();
|
long grId = allGroups.get(i).getGroupId();
|
||||||
String groupScope = groupManager.getScope(grId);
|
String groupScope = groupManager.getInfrastructureScope(grId);
|
||||||
System.out.println("Comparing: " + groupScope + " " + scope);
|
_log.debug("Comparing: " + groupScope + " " + scope);
|
||||||
if (groupScope.equals(scope)) {
|
if (groupScope.equals(scope)) {
|
||||||
groupId = allGroups.get(i).getGroupId();
|
groupId = allGroups.get(i).getGroupId();
|
||||||
break;
|
break;
|
||||||
|
@ -255,16 +257,16 @@ public class InvitesManager {
|
||||||
} catch (GroupRetrievalFault e) {
|
} catch (GroupRetrievalFault e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
HashMap<UserModel, List<RoleModel>> usersAndRoles = null;
|
Map<GCubeUser, List<GCubeRole>> usersAndRoles = null;
|
||||||
try {
|
try {
|
||||||
usersAndRoles = userManager.listUsersAndRolesByGroup(groupId);
|
usersAndRoles = userManager.listUsersAndRolesByGroup(groupId);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
Set<UserModel> users = usersAndRoles.keySet();
|
Set<GCubeUser> users = usersAndRoles.keySet();
|
||||||
ArrayList<String> adminEmailsList = new ArrayList<String>();
|
ArrayList<String> adminEmailsList = new ArrayList<String>();
|
||||||
for (UserModel usr:users) {
|
for (GCubeUser usr:users) {
|
||||||
List<RoleModel> roles = usersAndRoles.get(usr);
|
List<GCubeRole> roles = usersAndRoles.get(usr);
|
||||||
for (int i = 0; i < roles.size(); i++) {
|
for (int i = 0; i < roles.size(); i++) {
|
||||||
if (roles.get(i).getRoleName().equals("VO-Admin") || roles.get(i).getRoleName().equals("VRE-Manager")) {
|
if (roles.get(i).getRoleName().equals("VO-Admin") || roles.get(i).getRoleName().equals("VRE-Manager")) {
|
||||||
adminEmailsList.add(usr.getEmail());
|
adminEmailsList.add(usr.getEmail());
|
||||||
|
|
Loading…
Reference in New Issue