From e4aae540ef8bdf138ecfe86eea51fd5e62b06fc2 Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Mon, 14 Mar 2016 13:29:15 +0000 Subject: [PATCH] UPDATED distro folder git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portal/invites-common-library@125017 82a268e6-3cf1-43bd-a215-b396298e98cf --- distro/INSTALL | 1 - distro/MAINTAINERS | 2 - distro/README | 72 +++++++++++++++++-- distro/svnpath.txt | 1 - pom.xml | 10 ++- .../portal/invites/EmailNotification.java | 59 +-------------- .../gcube/portal/invites/InvitesManager.java | 32 +++++---- 7 files changed, 90 insertions(+), 87 deletions(-) delete mode 100644 distro/INSTALL delete mode 100644 distro/MAINTAINERS delete mode 100644 distro/svnpath.txt diff --git a/distro/INSTALL b/distro/INSTALL deleted file mode 100644 index 4af1832..0000000 --- a/distro/INSTALL +++ /dev/null @@ -1 +0,0 @@ -None \ No newline at end of file diff --git a/distro/MAINTAINERS b/distro/MAINTAINERS deleted file mode 100644 index d0b4c39..0000000 --- a/distro/MAINTAINERS +++ /dev/null @@ -1,2 +0,0 @@ -* Massimiliano Assante (massimiliano.assante@isti.cnr.it), CNR Pisa, - Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo" diff --git a/distro/README b/distro/README index 8487208..35c99c0 100644 --- a/distro/README +++ b/distro/README @@ -1,7 +1,67 @@ -The gCube System ------------------------------------------------------------- - -This work is partially funded by the European Commission in the -context of the iMarine project (www.i-marine.eu), under FP7 Programme. - +The gCube System - ${name} +-------------------------------------------------- + +${description} + + +${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. diff --git a/distro/svnpath.txt b/distro/svnpath.txt deleted file mode 100644 index edacb04..0000000 --- a/distro/svnpath.txt +++ /dev/null @@ -1 +0,0 @@ -${scm.url} \ No newline at end of file diff --git a/pom.xml b/pom.xml index a5197ec..3abffff 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ org.gcube.portal invites-common-library - 1.0.0-SNAPSHOT + 1.1.0-SNAPSHOT jar gCube Invites Common Library is a common library containing shared code for Inviting external users to portal VREs. @@ -45,11 +45,13 @@ org.gcube.portal custom-portal-handler + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) provided org.gcube.common.portal portal-manager + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) provided @@ -75,11 +77,7 @@ org.gcube.dvos usermanagement-core - provided - - - com.liferay.portal - portal-service + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) provided diff --git a/src/main/java/org/gcube/portal/invites/EmailNotification.java b/src/main/java/org/gcube/portal/invites/EmailNotification.java index 7e2dcbb..8259278 100644 --- a/src/main/java/org/gcube/portal/invites/EmailNotification.java +++ b/src/main/java/org/gcube/portal/invites/EmailNotification.java @@ -1,8 +1,5 @@ package org.gcube.portal.invites; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; import java.util.Date; import java.util.Properties; @@ -13,7 +10,7 @@ import javax.mail.Transport; import javax.mail.internet.InternetAddress; 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.LoggerFactory; @@ -25,8 +22,6 @@ import org.slf4j.LoggerFactory; * */ public class EmailNotification { - private static final String SENDER_EMAIL = "notificationSenderEmail"; - private static final String GATEWAY_NAME = "portalinstancename"; /** * The sender of the email */ @@ -61,11 +56,11 @@ public class EmailNotification { * @param body */ public EmailNotification(String sender, String recipients[], String subject, String body) { - this.emailSender = getNotificationSenderEmail(); + this.emailSender = PortalContext.getConfiguration().getSenderEmail(); this.emailrecipients = recipients; this.emailSubject = subject; this.emailBody = body; - this.portalName = getPortalInstanceName(); + this.portalName = PortalContext.getConfiguration().getGatewayName(); } 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; - } } diff --git a/src/main/java/org/gcube/portal/invites/InvitesManager.java b/src/main/java/org/gcube/portal/invites/InvitesManager.java index d237013..bd13baf 100644 --- a/src/main/java/org/gcube/portal/invites/InvitesManager.java +++ b/src/main/java/org/gcube/portal/invites/InvitesManager.java @@ -2,8 +2,8 @@ package org.gcube.portal.invites; import java.util.ArrayList; import java.util.Date; -import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Properties; import java.util.Set; import java.util.UUID; @@ -16,6 +16,7 @@ import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; 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.DatabookStore; 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.vomanagement.usermanagement.exception.GroupRetrievalFault; import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException; -import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayGroupManager; -import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayUserManager; -import org.gcube.vomanagement.usermanagement.model.RoleModel; -import org.gcube.vomanagement.usermanagement.model.UserModel; +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.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; @@ -85,7 +87,7 @@ public class InvitesManager { try { result = store.saveInvite(invite); 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) { _log.error("Email not valid " + e.getMessage()); @@ -237,14 +239,14 @@ public class InvitesManager { private static ArrayList getAdministratorsEmails(String scope) { LiferayUserManager userManager = new LiferayUserManager(); LiferayGroupManager groupManager = new LiferayGroupManager(); - String groupId = null; + long groupId = -1; try { - List allGroups = groupManager.listGroups(); + List allGroups = groupManager.listGroups(); _log.debug("Number of groups retrieved: " + allGroups.size()); for (int i = 0; i < allGroups.size(); i++) { - String grId = allGroups.get(i).getGroupId(); - String groupScope = groupManager.getScope(grId); - System.out.println("Comparing: " + groupScope + " " + scope); + long grId = allGroups.get(i).getGroupId(); + String groupScope = groupManager.getInfrastructureScope(grId); + _log.debug("Comparing: " + groupScope + " " + scope); if (groupScope.equals(scope)) { groupId = allGroups.get(i).getGroupId(); break; @@ -255,16 +257,16 @@ public class InvitesManager { } catch (GroupRetrievalFault e) { e.printStackTrace(); } - HashMap> usersAndRoles = null; + Map> usersAndRoles = null; try { usersAndRoles = userManager.listUsersAndRolesByGroup(groupId); } catch (Exception e) { e.printStackTrace(); } - Set users = usersAndRoles.keySet(); + Set users = usersAndRoles.keySet(); ArrayList adminEmailsList = new ArrayList(); - for (UserModel usr:users) { - List roles = usersAndRoles.get(usr); + for (GCubeUser usr:users) { + List roles = usersAndRoles.get(usr); for (int i = 0; i < roles.size(); i++) { if (roles.get(i).getRoleName().equals("VO-Admin") || roles.get(i).getRoleName().equals("VRE-Manager")) { adminEmailsList.add(usr.getEmail());