started to merge with join new

git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/join-vre@125895 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2016-03-21 15:55:32 +00:00
parent 4c721fe489
commit 04d15cedce
18 changed files with 767 additions and 146 deletions

View File

@ -4,6 +4,9 @@
<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"/>
<dependent-module archiveName="invites-common-library-1.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/invites-common-library/invites-common-library">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
<property name="context-root" value="join-vre"/>
</wb-module>

View File

@ -16,6 +16,7 @@
<include>README</include>
<include>LICENSE</include>
<include>changelog.xml</include>
<include>profile.xml</include>
</includes>
<fileMode>755</fileMode>
<filtered>true</filtered>

19
pom.xml
View File

@ -16,13 +16,11 @@
<version>3.0.0-SNAPSHOT</version>
<name>gCube Join VRE Portlet</name>
<description>Display the available VRE to Join</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>
</scm>
<properties>
<!-- Convenience property to set the GWT version -->
<gwtVersion>2.7.0</gwtVersion>
@ -86,6 +84,16 @@
<artifactId>aslcore</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.portal</groupId>
<artifactId>invites-common-library</artifactId>
<version>[1.0.0-SNAPSHOT,)</version>
</dependency>
<dependency>
<groupId>org.gcube.portal</groupId>
<artifactId>social-networking-library</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.dvos</groupId>
<artifactId>usermanagement-core</artifactId>
@ -97,6 +105,12 @@
<version>${liferay.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.mail</groupId>
<artifactId>javax.mail-api</artifactId>
<version>1.4.5</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.portlet</groupId>
<artifactId>portlet-api</artifactId>
@ -213,6 +227,7 @@
</execution>
</executions>
</plugin>
</plugins>
</build>

View File

@ -2,7 +2,6 @@ package org.gcube.portlets.user.joinvre.client;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.TreeMap;
import org.gcube.portlets.user.joinvre.shared.VRE;
import org.gcube.portlets.user.joinvre.shared.VRECategory;
@ -13,13 +12,15 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
/**
* The client side stub for the RPC service.
* @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*/
@RemoteServiceRelativePath("JoinService")
public interface JoinService extends RemoteService {
LinkedHashMap<VRECategory, ArrayList<VRE>> getVREs();
Boolean joinVRE(Long vreID);
String joinVRE(Long vreId);
VRE getSelectedVRE(Long vreId);
void addMembershipRequest(String scope, String optionalMessage);
}

View File

@ -2,7 +2,6 @@ package org.gcube.portlets.user.joinvre.client;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.TreeMap;
import org.gcube.portlets.user.joinvre.shared.VRE;
import org.gcube.portlets.user.joinvre.shared.VRECategory;
@ -11,11 +10,15 @@ import com.google.gwt.user.client.rpc.AsyncCallback;
/**
* @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*/
public interface JoinServiceAsync {
void getVREs(AsyncCallback< LinkedHashMap<VRECategory, ArrayList<VRE>>> callback);
void joinVRE(Long vreID, AsyncCallback<Boolean> callback);
void joinVRE(Long vreId, AsyncCallback<String> callback);
void getSelectedVRE(Long vreId, AsyncCallback<VRE> callback);
void addMembershipRequest(String scope, String optionalMessage,
AsyncCallback<Void> callback);
}

View File

@ -1,19 +1,95 @@
package org.gcube.portlets.user.joinvre.client;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.gcube.portlets.user.joinvre.client.responsive.ResponsivePanel;
import org.gcube.portlets.user.joinvre.shared.UserBelonging;
import org.gcube.portlets.user.joinvre.shared.VRE;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.Window.Location;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.RootPanel;
/**
* @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
*/
public class JoinVRE implements EntryPoint {
Logger logger = Logger.getLogger(JoinVRE.class.getName());
public static final String GET_OID_PARAMETER = "siteId";
private final JoinServiceAsync joinService = GWT.create(JoinService.class);
public void onModuleLoad() {
GWT.log("onModuleLoad");
RootPanel.get("JoinVRE-Container").add(new ResponsivePanel());
checkIsReferral();
}
/**
* first async callback
*/
private void checkIsReferral() {
logger.log(Level.INFO,"checkIsReferral()");
if (getSiteLiferayId() == null) {
displayVREs();
}
else {
Long vreId = -1L;
try {
vreId = Long.parseLong(getSiteLiferayId());
}
catch (Exception ex) {
logger.log(Level.WARNING, "org id is not a number " + ex.getMessage());
return;
}
joinService.getSelectedVRE(vreId, new AsyncCallback<VRE>() {
@Override
public void onFailure(Throwable caught) {
logger.log(Level.SEVERE,"getSelectedVRE error " + caught.getMessage());
Window.alert("Server error");
}
@Override
public void onSuccess(final VRE vre) {
logger.log(Level.INFO, "A VRE was Returned");
if (vre == null) {
GWT.log("A VRE Returned is null");
displayVREs();
return;
}
else {
ResponsivePanel rp = null;
logger.log(Level.INFO, "A Valid VRE was Returned");
switch (vre.getUserBelonging()) {
case BELONGING:
logger.log(Level.INFO, "User is Belonging");
Location.assign(vre.getFriendlyURL());
break;
case PENDING:
logger.log(Level.INFO, "User is Pending");
rp = displayVREs();
rp.displayPending();
break;
default: //Not belonging
logger.log(Level.INFO, "User is NOT Belonging");
rp = displayVREs();
rp.requestMembership(vre);
break;
}
}
}
});
}
}
private ResponsivePanel displayVREs() {
ResponsivePanel toReturn = new ResponsivePanel();
RootPanel.get("JoinVRE-Container").add(toReturn);
return toReturn;
}
/**
* check if it has to show just one feed
* @return
*/
private String getSiteLiferayId() {
return Window.Location.getParameter(GET_OID_PARAMETER);
}
}

View File

@ -5,6 +5,7 @@ import java.util.LinkedHashMap;
import org.gcube.portlets.user.joinvre.client.JoinService;
import org.gcube.portlets.user.joinvre.client.JoinServiceAsync;
import org.gcube.portlets.user.joinvre.client.ui.RequestMembershipDialog;
import org.gcube.portlets.user.joinvre.client.ui.VreThumbnail;
import org.gcube.portlets.user.joinvre.shared.VRE;
import org.gcube.portlets.user.joinvre.shared.VRECategory;
@ -12,6 +13,7 @@ import org.gcube.portlets.user.joinvre.shared.VRECategory;
import com.github.gwtbootstrap.client.ui.PageHeader;
import com.github.gwtbootstrap.client.ui.Thumbnails;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
@ -41,6 +43,7 @@ public class ResponsivePanel extends Composite {
header.setSubtext(cat.getDescription());
mainPanel.add(header);
mainPanel.add(getVREThumbnails(categories, cat));
}
}
}
@ -69,6 +72,15 @@ public class ResponsivePanel extends Composite {
mainPanel.clear();
mainPanel.add(new HTML("<div class=\"frame\" style=\"font-size: 16px;\">" + message + ". Please <a href=\"javascript: location.reload();\">reload</a> this page.</div>"));
}
public void displayPending() {
Window.alert("Pending");
}
public void requestMembership(VRE vre) {
RequestMembershipDialog modal = new RequestMembershipDialog(vre);
modal.show();
}
}

View File

@ -0,0 +1,74 @@
package org.gcube.portlets.user.joinvre.client.ui;
import org.gcube.portlets.user.joinvre.client.JoinService;
import org.gcube.portlets.user.joinvre.client.JoinServiceAsync;
import org.gcube.portlets.user.joinvre.shared.VRE;
import com.github.gwtbootstrap.client.ui.Button;
import com.github.gwtbootstrap.client.ui.HelpBlock;
import com.github.gwtbootstrap.client.ui.Modal;
import com.github.gwtbootstrap.client.ui.TextArea;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;
public class RequestMembershipDialog extends Composite {
private final JoinServiceAsync joinService = GWT.create(JoinService.class);
private static RequestAccessModalUiBinder uiBinder = GWT
.create(RequestAccessModalUiBinder.class);
interface RequestAccessModalUiBinder extends
UiBinder<Widget, RequestMembershipDialog> {
}
@UiField Modal m;
@UiField Button close;
@UiField Button confirmRequest;
@UiField TextArea optionalText;
@UiField HelpBlock helpBlock;
VRE myVRE = null;
public RequestMembershipDialog(VRE myVRE) {
initWidget(uiBinder.createAndBindUi(this));
this.myVRE = myVRE;
optionalText.setWidth("95%");
optionalText.setPlaceholder("You can add an optional comment here");
}
public void show() {
m.setTitle("Join request for " +myVRE.getName());
m.show();
}
@UiHandler("close")
void handleClick(ClickEvent e) {
m.hide();
}
@UiHandler("confirmRequest")
void confirm(ClickEvent e) {
String text = optionalText.getText() == null || optionalText.getText().equals("") ? " ": optionalText.getText();
joinService.addMembershipRequest(myVRE.getinfraScope(), text, new AsyncCallback<Void>() {
@Override
public void onSuccess(Void result) {
confirmRequest.removeFromParent();
optionalText.removeFromParent();
m.setTitle("Thank you, your request has been sent successfully");
helpBlock.setText("You will receive an email as soon as your request will be processed.");
}
@Override
public void onFailure(Throwable caught) {
confirmRequest.removeFromParent();
optionalText.removeFromParent();
m.setTitle("An error occurred! Your request has not been sent");
helpBlock.setText("An email with the cause of the error has been sent to the support team, we'll be back to you shortly.");
}
});
}
}

View File

@ -0,0 +1,20 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:b="urn:import:com.github.gwtbootstrap.client.ui">
<g:HTMLPanel>
<b:Modal ui:field="m" title="My Modal" backdrop="STATIC"
keyboard="true" animation="true">
<b:ControlGroup>
<b:Controls>
<b:HelpBlock ui:field="helpBlock">Please confirm your request</b:HelpBlock>
<b:TextArea ui:field="optionalText" alternateSize="XLARGE"/>
</b:Controls>
</b:ControlGroup>
<b:ModalFooter>
<b:Button type="PRIMARY" ui:field="confirmRequest">Confirm Request</b:Button>
<b:Button type="DEFAULT" ui:field="close">Close</b:Button>
</b:ModalFooter>
</b:Modal>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -2,6 +2,7 @@ package org.gcube.portlets.user.joinvre.client.ui;
import org.gcube.portlets.user.joinvre.client.JoinService;
import org.gcube.portlets.user.joinvre.client.JoinServiceAsync;
import org.gcube.portlets.user.joinvre.client.JoinVRE;
import org.gcube.portlets.user.joinvre.shared.VRE;
import com.github.gwtbootstrap.client.ui.Button;
@ -14,6 +15,7 @@ import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.Window.Location;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Widget;
@ -58,20 +60,21 @@ public class VreThumbnail extends Composite {
modal.show();
}
else {
joinService.joinVRE(myVre.getId(), new AsyncCallback<Boolean>() {
joinService.joinVRE(myVre.getId(), new AsyncCallback<String>() {
@Override
public void onFailure(Throwable caught) {
String errorDescription = "Error while trying to join to"
+ myVre.getName() + " VRE. Please Try again later. "
+ "If the problem persist contact system administrator";
+ "If the problem persist please contact us at www.gcube-system.org";
Window.alert(errorDescription);
}
@Override
public void onSuccess(Boolean result) {
Window.open("/group/data-e-infrastructure-gateway/join-new?orgid="+myVre.getId(), "_self", "");
public void onSuccess(String currentGroupName) {
Location.assign("/group/" +currentGroupName +"/explore?"+JoinVRE.GET_OID_PARAMETER+"="+myVre.getId());
//RequestMembershipDialog modal = new RequestMembershipDialog(currentGroupName);
//modal.show();
}
});
}
}

View File

@ -0,0 +1,106 @@
package org.gcube.portlets.user.joinvre.server;
import java.util.Date;
import java.util.Properties;
import javax.mail.Address;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import org.gcube.common.portal.PortalContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* A class for sending email
*
* @author M. Assante
*
*/
public class EmailNotification {
private static final String SENDER_EMAIL = "notificationSenderEmail";
private static final String GATEWAY_NAME = "portalinstancename";
/**
* The sender of the email
*/
private String emailSender;
/**
* The recipients of the email
*/
private String emailrecipients[];
/**
* Email's subject
*/
private String emailSubject;
/**
* Email's body message
*/
private String emailBody;
private String portalName;
/** Logger */
private static Logger _log = LoggerFactory.getLogger(EmailNotification.class);
/**
* Class's constructor
*
* @param sender
* @param recipients
* @param subject
* @param body
*/
public EmailNotification(String sender, String recipients[], String subject, String body) {
this.emailSender = PortalContext.getConfiguration().getSenderEmail();
this.emailrecipients = recipients;
this.emailSubject = subject;
this.emailBody = body;
this.portalName = PortalContext.getConfiguration().getGatewayName();
}
public void sendEmail() {
Properties props = System.getProperties();
String mailServiceHost = "localhost";
props.put("mail.smtp.host", mailServiceHost);
String mailServicePort = "25";
props.put("mail.smtp.port", mailServicePort);
Session session = Session.getDefaultInstance(props, null);
session.setDebug(true);
Message mimeMessage = new MimeMessage(session);
try {
// EMAIL SENDER
Address from = new InternetAddress(emailSender, portalName);
mimeMessage.setHeader("Content-Type", "text/html; charset=UTF-8");
mimeMessage.setFrom(from);
// EMAIL RECIPIENTS
for (int i=0; i<emailrecipients.length; i++) {
Address address = new InternetAddress(emailrecipients[i]);
mimeMessage.addRecipient(Message.RecipientType.TO, address);
}
mimeMessage.setSubject(emailSubject);
// mimeMessage.setText(emailBody);
mimeMessage.setContent(emailBody, "text/html; charset=UTF-8");
mimeMessage.setSentDate(new Date());
Transport.send(mimeMessage);
} catch (Exception e) {
e.printStackTrace();
_log.error("Failed to send the email message.", e);
}
}
}

View File

@ -5,12 +5,11 @@ import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.session.SessionManager;
import org.gcube.common.portal.CustomAttributeKeys;
import org.gcube.common.portal.GCubePortalConstants;
import org.gcube.common.portal.PortalContext;
import org.gcube.portal.custom.communitymanager.impl.GCubeSiteManagerImpl;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
import org.gcube.portlets.user.joinvre.client.JoinService;
@ -19,9 +18,17 @@ import org.gcube.portlets.user.joinvre.shared.VRE;
import org.gcube.portlets.user.joinvre.shared.VRECategory;
import org.gcube.portlets.user.joinvre.shared.VRECustomAttributes;
import org.gcube.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.UserManager;
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
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.GCubeMembershipRequest;
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
import org.gcube.vomanagement.usermanagement.model.MembershipRequestStatus;
import org.gcube.vomanagement.usermanagement.model.VirtualGroup;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.liferay.portal.kernel.exception.PortalException;
@ -29,20 +36,17 @@ import com.liferay.portal.kernel.exception.SystemException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.model.Group;
import com.liferay.portal.security.auth.PrincipalThreadLocal;
import com.liferay.portal.security.permission.PermissionChecker;
import com.liferay.portal.security.permission.PermissionCheckerFactoryUtil;
import com.liferay.portal.security.permission.PermissionThreadLocal;
import com.liferay.portal.service.GroupLocalServiceUtil;
import com.liferay.portal.model.VirtualHost;
import com.liferay.portal.service.LayoutSetLocalServiceUtil;
import com.liferay.portal.service.UserLocalServiceUtil;
import com.liferay.portal.service.VirtualHostLocalServiceUtil;
import com.liferay.portal.util.PortalUtil;
/**
* @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*/
@SuppressWarnings("serial")
public class JoinServiceImpl extends RemoteServiceServlet implements JoinService {
private static Log _log = LogFactoryUtil.getLog(JoinServiceImpl.class);
/**
* the current ASLSession
@ -81,6 +85,39 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
return false;
}
}
@Override
public String joinVRE(Long vreID) {
try {
return getCurrGroupFromURL().getName();
} catch (Exception e) {
e.printStackTrace();
}
return "";
}
/**
*
* @return the Liferay Group of the Site corresponding to the virtualhost being used to access the portal
* e.g. if i-marine.d4science.org it would return the Liferay Group i-marine, if services.d4science.org it would return the Liferay Group services
* it assums that you have a Site defined for each virtual host supported
* @throws Exception
*/
private Group getCurrGroupFromURL() throws Exception {
Group site = null;
String currentVirtualHost = this.getThreadLocalRequest().getServerName();
_log.debug("currentHost is " + currentVirtualHost);
List<VirtualHost> vHosts = VirtualHostLocalServiceUtil.getVirtualHosts(0, VirtualHostLocalServiceUtil.getVirtualHostsCount());
for (VirtualHost virtualHost : vHosts) {
_log.debug("Found " + virtualHost.getHostname());
if (virtualHost.getHostname().compareTo("localhost") != 0 &&
virtualHost.getLayoutSetId() != 0 &&
virtualHost.getHostname().compareTo(currentVirtualHost) == 0) {
long layoutSetId = virtualHost.getLayoutSetId();
site = LayoutSetLocalServiceUtil.getLayoutSet(layoutSetId).getGroup();
return site;
}
}
return null;
}
/**
*
* @param session the Asl Session
@ -93,60 +130,9 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
try {
if (isWithinPortal()) {
toReturn = getPortalOrganizationMappedToVRE();
toReturn = getPortalSitesMappedToVRE();
} else {
VRECategory devsecCategory = new VRECategory(1, "Z_Development", "designed to apply Data Mining techniques to biological data. "
+ "The algorithms are executed in a distributed fashion on the e-Infrastructure nodes or on local multi-core machines.");
ArrayList<VRE> vres = new ArrayList<VRE>();
vres.add(new VRE(0, "BiodiversityLab", ""
+ "<h2>BiodiversityLab</h2>"
+ "The BiodiversityLab is a VRE designed to provide a collection of applications that allow scholars to perform complete experiments about "
+ "single individuals or groups of marine species. The VRE allows to: <ul> <li> inspect species maps;<li> produce a species distribution map by means of either an expert system (AquaMaps) or a machine learning model (e.g. Neural Networks);"
+ "<li> analyse species observation trends;"
+ "<li> inspect species occurrence data;"
+ "<li> inspect species descriptions and characteristics;"
+ "<li> perform analysis of climatic changes and of their effects on species distribution;"
+ "<li> produce GIS maps for geo-spatial datasets;"
+ "<li> discover Taxa names;"
+ "<li> cluster occurrence data;"
+ "<li> estimate similarities among habitats."
+ "</ul>"
+ "", "", "http://placehold.it/200x200", "/group/devsec", UserBelonging.NOT_BELONGING, false));
vres.add(new VRE(0, "Scalable Data", ""
+ "<h2>Scalable Data Mining</h2>"
+ "The Scalable Data Mining is a VRE designed to apply Data Mining techniques to biological data. The algorithms are executed in a distributed fashion on the e-Infrastructure nodes or on local multi-core machines. Scalability is thus meant as distributed data processing but even as services dynamically provided to the users. The system is scalable in the number of users and in the size of the data to process. Statistical data processing can be applied to perform Niche Modelling or Ecological Modelling experiments. Other applications can use general purpose techniques like Bayesian models. Time series of observations can be managed as well, in order to classify trends, catch anomaly patterns and perform simulations. The idea under the distributed computation for data mining techniques is to overcome common limitations that can happen when using statistical algorithms: "
+ "single individuals or groups of marine species. The VRE allows to: <ul> <li> inspect species maps;<li> produce a species distribution map by means of either an expert system (AquaMaps) or a machine learning model (e.g. Neural Networks);"
+ "<li> analyse species observation trends;"
+ "<li> inspect species occurrence data;"
+ "<li> inspect species descriptions and characteristics;"
+ "<li> perform analysis of climatic changes and of their effects on species distribution;"
+ "<li> produce GIS maps for geo-spatial datasets;"
+ "<li> discover Taxa names;"
+ "<li> cluster occurrence data;"
+ "<li> estimate similarities among habitats."
+ "</ul>"
+ "", "", "http://placehold.it/200x200", "/group/devsec", UserBelonging.NOT_BELONGING, true));
toReturn.put(devsecCategory, vres);
devsecCategory = new VRECategory(2, "Sailing", "Sailing prod desc");
vres = new ArrayList<VRE>();
vres.add(new VRE(1, "PerformanceEvaluationInAquaculture", "devVRE VRE description", "http://placehold.it/200x100", "http://placehold.it/200x100", "/group/devVRE", UserBelonging.NOT_BELONGING, false, true, "http://i-marine.d4science.org"));
vres.add(new VRE(2, "devmode", "devmode VRE description", "http://placehold.it/200x100", "https://placeholdit.imgix.net/~text?txtsize=19&txt=200%C3%97100&w=200&h=100", "/group/devmode", UserBelonging.NOT_BELONGING, true));
vres.add(new VRE(1, "StrategicInvestmentAnalysis", "devVRE VRE description", "", "https://placeholdit.imgix.net/~text?txtsize=19&txt=200%C3%97100&w=200&h=100", "/group/devVRE", UserBelonging.NOT_BELONGING, false));
vres.add(new VRE(2, "devmode2", "devmode VRE description", "http://placehold.it/200x100", "", "/group/devmode", UserBelonging.NOT_BELONGING, true));
vres.add(new VRE(1, "devVR3E", "devVRE VRE description", "http://placehold.it/200x200", "aaaa", "/group/devVRE", UserBelonging.NOT_BELONGING, false));
vres.add(new VRE(2, "devmode3", "devmode VRE description", "http://placehold.it/200x200", "", "/group/devmode", UserBelonging.NOT_BELONGING, true));
vres.add(new VRE(1, "devVRE4", "devVRE VRE description", "", "http://placehold.it/200x200", "/group/devVRE", UserBelonging.NOT_BELONGING, false));
vres.add(new VRE(2, "devmode4", "devmode VRE description", "", "http://placehold.it/200x200", "/group/devmode", UserBelonging.NOT_BELONGING, true));
vres.add(new VRE(1, "devVRE5", "devVRE VRE description", "", "http://placehold.it/200x200", "/group/devVRE", UserBelonging.NOT_BELONGING, false));
vres.add(new VRE(2, "devmode5", "devmode VRE description", "", "http://placehold.it/200x200", "/group/devmode", UserBelonging.NOT_BELONGING, true));
vres.add(new VRE(1, "devVRE6", "devVRE VRE description", "", "http://placehold.it/200x200", "/group/devVRE", UserBelonging.NOT_BELONGING, false));
vres.add(new VRE(2, "devmode6", "devmode VRE description", "", "http://placehold.it/200x200", "/group/devmode", UserBelonging.NOT_BELONGING, true));
vres.add(new VRE(1, "devVRE7", "devVRE VRE description", "", "http://placehold.it/200x200", "/group/devVRE", UserBelonging.NOT_BELONGING, false));
vres.add(new VRE(2, "devmod76", "devmode VRE description", "", "http://placehold.it/200x200", "/group/devmode", UserBelonging.NOT_BELONGING, true));
toReturn.put(devsecCategory, vres);
}
toReturn = getFakePortalVREs(); }
} catch (Exception e) {
_log.error("Error getting VREs", e);
}
@ -155,14 +141,6 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
return toReturn;
}
private String getPortalBasicUrl() {
HttpServletRequest request = this.getThreadLocalRequest();
String protocol = (request.isSecure()) ? "https://" : "http://" ;
String port = (request.getServerPort() == 80) ? "" : String.format(":%d", request.getServerPort());
String portalBasicUrl = String.format("%s%s%s", protocol, request.getServerName(), port);
_log.debug(String.format("getPortalBasicUrl : %s", portalBasicUrl));
return portalBasicUrl;
}
public VRECustomAttributes getVRECustomAttr(GCubeGroup group) throws PortalException, SystemException {
VRECustomAttributes toReturn = new VRECustomAttributes();
@ -184,52 +162,23 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
_log.trace("RETURNING VRECustomAttributes:\n" + toReturn.toString());
return toReturn;
}
//TODO: put it in users mana
private String getVirtualGroupName(Group site){
try {
_log.debug("Setting Thread Permission");
long userId = LiferayUserManager.getAdmin().getUserId();
PrincipalThreadLocal.setName(userId);
PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(UserLocalServiceUtil.getUser(userId));
PermissionThreadLocal.setPermissionChecker(permissionChecker);
if (site.getExpandoBridge().getAttribute(CustomAttributeKeys.VIRTUAL_GROUP.getKeyName()) == null || site.getExpandoBridge().getAttribute(CustomAttributeKeys.VIRTUAL_GROUP.getKeyName()).equals("")) {
_log.warn(String.format("Attribute %s not initialized.", CustomAttributeKeys.VIRTUAL_GROUP.getKeyName()));
return null;
} else {
String[] values = (String[]) site.getExpandoBridge().getAttribute(CustomAttributeKeys.VIRTUAL_GROUP.getKeyName());
if (values != null)
return values[0];
else return "";
}
} catch (Exception e) {
e.printStackTrace();
return "Exception ";
}
}
/**
*
* @return the Virtual groups with their VREs in the order estabilished in the LR Control Panel
* @throws SystemException
* @throws PortalException
*/
public LinkedHashMap<VRECategory, ArrayList<VRE>> getPortalOrganizationMappedToVRE() throws Exception {
public LinkedHashMap<VRECategory, ArrayList<VRE>> getPortalSitesMappedToVRE() throws Exception {
GroupManager gm = new LiferayGroupManager();
LinkedHashMap<VRECategory, ArrayList<VRE>> toReturn = new LinkedHashMap<VRECategory, ArrayList<VRE>>();
//before iterating the actual groups create the virtualGroups in the correct order
List<String> virtualGroups = GCubeSiteManagerImpl.getVirtualGroups();
for (String vg : virtualGroups) {
String[] splits = vg.split("\\|");
String gName = splits[0];
String gDescription = splits[1];
List<VirtualGroup> virtualGroups = gm.getVirtualGroups();
for (VirtualGroup vg : virtualGroups) {
ArrayList<VRE> toCreate = new ArrayList<VRE>();
VRECategory cat = new VRECategory(1L, gName, gDescription);
VRECategory cat = new VRECategory(1L, vg.getName(), vg.getDescription());
toReturn.put(cat, toCreate);
}
GroupManager gm = new LiferayGroupManager();
GCubeGroup rootGroupVO = gm.getRootVO();
@ -244,7 +193,7 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
for (GCubeGroup vOrg : rootGroupVO.getChildren()) {
for (GCubeGroup vreOrganization : vOrg.getChildren()) {
long vreID = vreOrganization.getGroupId();
String vreName = vreOrganization.getName();
String vreName = vreOrganization.getGroupName();
String vreDescription = vreOrganization.getDescription();
long logoId = vreOrganization.getLogoId();
@ -259,10 +208,7 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
boolean isExternal = attrs.isExternal();
String urlIfAny = attrs.getUrlIfAny();
Group theLRGroup = GroupLocalServiceUtil.getGroup(vreID);
String catName = getVirtualGroupName(theLRGroup);
String[] splits = catName.split("\\|");
catName = splits[0];
String catName = gm.getVirtualGroup(vreID).getName();
VRECategory toLookFor = null;
for (VRECategory vre : toReturn.keySet()) {
@ -285,9 +231,131 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
}
/**
* useful method for development purpose
* @return
*/
private LinkedHashMap<VRECategory, ArrayList<VRE>> getFakePortalVREs() {
LinkedHashMap<VRECategory, ArrayList<VRE>> toReturn = new LinkedHashMap<VRECategory, ArrayList<VRE>>();
VRECategory devsecCategory = new VRECategory(1, "Z_Development", "designed to apply Data Mining techniques to biological data. "
+ "The algorithms are executed in a distributed fashion on the e-Infrastructure nodes or on local multi-core machines.");
ArrayList<VRE> vres = new ArrayList<VRE>();
vres.add(new VRE(0, "BiodiversityLab", ""
+ "<h2>BiodiversityLab</h2>"
+ "The BiodiversityLab is a VRE designed to provide a collection of applications that allow scholars to perform complete experiments about "
+ "single individuals or groups of marine species. The VRE allows to: <ul> <li> inspect species maps;<li> produce a species distribution map by means of either an expert system (AquaMaps) or a machine learning model (e.g. Neural Networks);"
+ "<li> analyse species observation trends;"
+ "<li> inspect species occurrence data;"
+ "<li> inspect species descriptions and characteristics;"
+ "<li> perform analysis of climatic changes and of their effects on species distribution;"
+ "<li> produce GIS maps for geo-spatial datasets;"
+ "<li> discover Taxa names;"
+ "<li> cluster occurrence data;"
+ "<li> estimate similarities among habitats."
+ "</ul>"
+ "", "", "http://placehold.it/200x200", "/group/devsec", UserBelonging.NOT_BELONGING, false));
vres.add(new VRE(0, "Scalable Data", ""
+ "<h2>Scalable Data Mining</h2>"
+ "The Scalable Data Mining is a VRE designed to apply Data Mining techniques to biological data. The algorithms are executed in a distributed fashion on the e-Infrastructure nodes or on local multi-core machines. Scalability is thus meant as distributed data processing but even as services dynamically provided to the users. The system is scalable in the number of users and in the size of the data to process. Statistical data processing can be applied to perform Niche Modelling or Ecological Modelling experiments. Other applications can use general purpose techniques like Bayesian models. Time series of observations can be managed as well, in order to classify trends, catch anomaly patterns and perform simulations. The idea under the distributed computation for data mining techniques is to overcome common limitations that can happen when using statistical algorithms: "
+ "single individuals or groups of marine species. The VRE allows to: <ul> <li> inspect species maps;<li> produce a species distribution map by means of either an expert system (AquaMaps) or a machine learning model (e.g. Neural Networks);"
+ "<li> analyse species observation trends;"
+ "<li> inspect species occurrence data;"
+ "<li> inspect species descriptions and characteristics;"
+ "<li> perform analysis of climatic changes and of their effects on species distribution;"
+ "<li> produce GIS maps for geo-spatial datasets;"
+ "<li> discover Taxa names;"
+ "<li> cluster occurrence data;"
+ "<li> estimate similarities among habitats."
+ "</ul>"
+ "", "", "http://placehold.it/200x200", "/group/devsec", UserBelonging.NOT_BELONGING, true));
toReturn.put(devsecCategory, vres);
devsecCategory = new VRECategory(2, "Sailing", "Sailing prod desc");
vres = new ArrayList<VRE>();
vres.add(new VRE(1, "PerformanceEvaluationInAquaculture", "devVRE VRE description", "http://placehold.it/200x100", "http://placehold.it/200x100", "/group/devVRE", UserBelonging.NOT_BELONGING, false, true, "http://i-marine.d4science.org"));
vres.add(new VRE(2, "devmode", "devmode VRE description", "http://placehold.it/200x100", "https://placeholdit.imgix.net/~text?txtsize=19&txt=200%C3%97100&w=200&h=100", "/group/devmode", UserBelonging.NOT_BELONGING, true));
vres.add(new VRE(1, "StrategicInvestmentAnalysis", "devVRE VRE description", "", "https://placeholdit.imgix.net/~text?txtsize=19&txt=200%C3%97100&w=200&h=100", "/group/devVRE", UserBelonging.NOT_BELONGING, false));
vres.add(new VRE(2, "devmode2", "devmode VRE description", "http://placehold.it/200x100", "", "/group/devmode", UserBelonging.NOT_BELONGING, true));
vres.add(new VRE(1, "devVR3E", "devVRE VRE description", "http://placehold.it/200x200", "aaaa", "/group/devVRE", UserBelonging.NOT_BELONGING, false));
vres.add(new VRE(2, "devmode3", "devmode VRE description", "http://placehold.it/200x200", "", "/group/devmode", UserBelonging.NOT_BELONGING, true));
vres.add(new VRE(1, "devVRE4", "devVRE VRE description", "", "http://placehold.it/200x200", "/group/devVRE", UserBelonging.NOT_BELONGING, false));
vres.add(new VRE(2, "devmode4", "devmode VRE description", "", "http://placehold.it/200x200", "/group/devmode", UserBelonging.NOT_BELONGING, true));
vres.add(new VRE(1, "devVRE5", "devVRE VRE description", "", "http://placehold.it/200x200", "/group/devVRE", UserBelonging.NOT_BELONGING, false));
vres.add(new VRE(2, "devmode5", "devmode VRE description", "", "http://placehold.it/200x200", "/group/devmode", UserBelonging.NOT_BELONGING, true));
vres.add(new VRE(1, "devVRE6", "devVRE VRE description", "", "http://placehold.it/200x200", "/group/devVRE", UserBelonging.NOT_BELONGING, false));
vres.add(new VRE(2, "devmode6", "devmode VRE description", "", "http://placehold.it/200x200", "/group/devmode", UserBelonging.NOT_BELONGING, true));
vres.add(new VRE(1, "devVRE7", "devVRE VRE description", "", "http://placehold.it/200x200", "/group/devVRE", UserBelonging.NOT_BELONGING, false));
vres.add(new VRE(2, "devmod76", "devmode VRE description", "", "http://placehold.it/200x200", "/group/devmode", UserBelonging.NOT_BELONGING, true));
toReturn.put(devsecCategory, vres);
return toReturn;
}
@Override
public Boolean joinVRE(Long vreID) {
// Here for future improvement
return new Boolean(true);
public VRE getSelectedVRE(Long groupId) {
_log.debug("*getting Selected Research Environment from referral, site id = " + groupId);
ASLSession session = getASLSession();
VRE toReturn = null;
try {
GroupManager gm = new LiferayGroupManager();
UserManager um = new LiferayUserManager();
GCubeGroup selectedVRE = gm.getGroup(groupId);
String vreName = selectedVRE.getGroupName();
String vreDescription = selectedVRE.getDescription();
long logoId = selectedVRE.getLogoId();
String vreLogoURL = "/image/layout_set_logo?img_id="+ logoId;
String infraScope = gm.getInfrastructureScope(selectedVRE.getGroupId());
String friendlyURL = GCubePortalConstants.PREFIX_GROUP_URL+selectedVRE.getFriendlyURL();
VRECustomAttributes attrs = getVRECustomAttr(selectedVRE);
boolean requireAccessGrant = attrs.isUponRequest();
boolean isExternal = attrs.isExternal();
String urlIfAny = attrs.getUrlIfAny();
GCubeUser currUser = um.getUserByUsername(session.getUsername());
//check if the user belongs to it
UserBelonging belongEnum = UserBelonging.NOT_BELONGING;
if (gm.listGroupsByUser(currUser.getUserId()).contains(selectedVRE))
belongEnum = UserBelonging.BELONGING;
else if (checkPending(session.getUsername(), selectedVRE.getGroupId()))
belongEnum = UserBelonging.PENDING;
//return the selected VRE for this user
toReturn = new VRE(groupId, vreName, vreDescription, vreLogoURL, infraScope, friendlyURL, belongEnum, requireAccessGrant, isExternal, urlIfAny);
} catch (Exception e) {
_log.error("Something wrong happened while trying to getSite by id, probably the group id is wrong. " + e.getMessage());
}
return toReturn;
}
/**
*
* @param screenName
* @param groupId
* @return
* @throws UserRetrievalFault
* @throws GroupRetrievalFault
* @throws UserManagementSystemException
*/
private static boolean checkPending(String screenName, long groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault {
UserManager um = new LiferayUserManager();
List<GCubeMembershipRequest> requests = um.listMembershipRequestsByGroup(groupId);
for (GCubeMembershipRequest r : requests) {
if ( r.getStatus() == MembershipRequestStatus.REQUEST && (r.getRequestingUser().getUsername().compareTo(screenName)==0))
return true;
}
return false;
}
@Override
public void addMembershipRequest(String scope, String optionalMessage) {
String username = getASLSession().getUsername();
try {
LoginServiceUtil.addMembershipRequest(username, scope, optionalMessage, getPortalUrl(), PortalContext.getConfiguration().getGatewayName());
} catch (Exception e) {
e.printStackTrace();
}
}
public String getPortalUrl() throws PortalException, SystemException {
return PortalUtil.getPortalURL(this.getThreadLocalRequest());
}
}

View File

@ -0,0 +1,235 @@
package org.gcube.portlets.user.joinvre.server;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.gcube.common.portal.PortalContext;
import org.gcube.portal.databook.shared.Invite;
import org.gcube.portlets.user.joinvre.shared.VO;
import org.gcube.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.UserManager;
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.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author Massimiliano Assante ISTI-CNR
*
*/
public class LoginServiceUtil {
/**
*
*/
public static final String ROOT_ORG = "rootorganization";
/**
*
*/
public static final String PUBLIC_LAYOUT_NAME = " Data e-Infrastructure gateway";
/**
*
*/
public static final String GUEST_COMMUNITY_NAME = "Guest";
private static Logger _log = LoggerFactory.getLogger(LoginServiceUtil.class);
protected static ArrayList<String> getAdministratorsEmails(String scope) {
LiferayUserManager userManager = new LiferayUserManager();
LiferayGroupManager groupManager = new LiferayGroupManager();
long groupId = -1;
try {
List<GCubeGroup> allGroups = groupManager.listGroups();
_log.debug("Number of groups retrieved: " + allGroups.size());
for (int i = 0; i < allGroups.size(); i++) {
long grId = allGroups.get(i).getGroupId();
String groupScope = groupManager.getInfrastructureScope(grId);
System.out.println("Comparing: " + groupScope + " " + scope);
if (groupScope.equals(scope)) {
groupId = allGroups.get(i).getGroupId();
break;
}
}
} catch (UserManagementSystemException e) {
e.printStackTrace();
} catch (GroupRetrievalFault e) {
e.printStackTrace();
}
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("VO-Admin") || roles.get(i).getRoleName().equals("VRE-Manager")) {
adminEmailsList.add(usr.getEmail());
_log.debug("Admin: " + usr.getFullname());
break;
}
}
}
return adminEmailsList;
}
/**
*
* @param scope .
* @param optionalMessage .
*/
public static void addMembershipRequest(String username, String scope, String optionalMessage,String portalbasicurl, String gatewayName) throws Exception{
_log.info("gatewayName = " + gatewayName + " Message=" + optionalMessage);
ArrayList<String> adminEmails = LoginServiceUtil.getAdministratorsEmails(scope);
UserManager um = new LiferayUserManager();
GCubeUser currUser = um.getUserByUsername(username);
String name = currUser.getFirstName();
String lastname = currUser.getLastName();
String selectedVRE = scope.substring(scope.lastIndexOf("/")+1, scope.length());
_log.info("Requested MEMBERSHIP for: " + selectedVRE + " scope: " + scope);
GroupManager gm = new LiferayGroupManager();
um.requestMembership(currUser.getUserId(), gm.getGroupIdFromInfrastructureScope(scope), optionalMessage);
StringBuffer body = new StringBuffer();
body.append("<p>Dear manager of "+ scope +",<br />this email message was automatically generated by " + portalbasicurl +" to inform you that ");
body.append("</p>");
body.append("<p>");
body.append("<b>"+name + " " + lastname +"</b> has requested access to the following environment: ");
body.append("<br /><br />");
body.append("<b>" + scope+"</b>");
body.append("<br />");
body.append("<br />");
body.append("<b>Username: </b>" + username);
body.append("<br />");
body.append("<b>e-mail: </b>" + currUser.getEmail());
body.append("</p>");
body.append("<p>");
body.append("The request is annotated with the following text: " + optionalMessage);
body.append("</p>");
body.append("<p>");
body.append("You are kindly asked to manage such request by either approving or rejecting it through the user management " +
"facilities available at ");
body.append("<br />" + portalbasicurl);
body.append("</p>");
body.append("<p>");
body.append("WARNING / LEGAL TEXT: This message is intended only for the use of the individual or entity to which it is addressed and may contain"+
" information which is privileged, confidential, proprietary, or exempt from disclosure under applicable law. " +
"If you are not the intended recipient or the person responsible for delivering the message to the intended recipient, you are strictly prohibited from disclosing, distributing, copying, or in any way using this message.");
body.append("</p>");
String[] allMails = new String[adminEmails.size()];
adminEmails.toArray(allMails);
EmailNotification mailToAdmin = new EmailNotification(PortalContext.getConfiguration().getSenderEmail(), allMails , "[" + gatewayName + "] - Join Request", body.toString());
mailToAdmin.sendEmail();
}
/**
*
* @param scope .
* @param optionalMessage .
*/
public static void notifyUserSelfRegistration(String username, VO rootVO, String scope, String portalbasicurl, String gatewayName) throws Exception {
ArrayList<String> adminEmails = LoginServiceUtil.getAdministratorsEmails(scope);
LiferayUserManager um = new LiferayUserManager();
GCubeUser currUser = um.getUserByUsername(username);
String name = currUser.getFirstName();
String lastname = currUser.getLastName();
StringBuffer body = new StringBuffer();
body.append("<p>Dear manager of "+ scope +",<br />this email message was automatically generated by " + portalbasicurl +" to inform you that ");
body.append("</p>");
body.append("<p>");
body.append("<b>"+name + " " + lastname +"</b> has self registered to the following environment: ");
body.append("<br /><br />");
body.append("<b>" + scope+"</b>");
body.append("<br />");
body.append("<br />");
body.append("<b>Username: </b>" + username);
body.append("<br />");
body.append("<b>e-mail: </b>" + currUser.getEmail());
body.append("</p>");
body.append("<p>");
body.append("<br />" + portalbasicurl);
body.append("</p>");
body.append("<p>");
body.append("WARNING / LEGAL TEXT: This message is intended only for the use of the individual or entity to which it is addressed and may contain"+
" information which is privileged, confidential, proprietary, or exempt from disclosure under applicable law. " +
"If you are not the intended recipient or the person responsible for delivering the message to the intended recipient, you are strictly prohibited from disclosing, distributing, copying, or in any way using this message.");
body.append("</p>");
String[] allMails = new String[adminEmails.size()];
adminEmails.toArray(allMails);
EmailNotification mailToAdmin = new EmailNotification("no-reply@d4science.org", allMails , "[" + gatewayName + "] - Self Registration", body.toString());
mailToAdmin.sendEmail();
}
/**
*
* @param scope .
* @param optionalMessage .
*/
public static void notifyUserAcceptedInvite(String username, VO rootVO, String scope, String portalbasicurl, String gatewayName, Invite invite) throws Exception {
ArrayList<String> adminEmails = LoginServiceUtil.getAdministratorsEmails(scope);
LiferayUserManager um = new LiferayUserManager();
GCubeUser currUser = um.getUserByUsername(username);
String name = currUser.getFirstName();
String lastname = currUser.getLastName();
StringBuffer body = new StringBuffer();
body.append("<p>Dear manager of "+ scope +",<br />this email message was automatically generated by " + portalbasicurl +" to inform you that ");
body.append("</p>");
body.append("<p>");
body.append("<b>"+name + " " + lastname +"</b> has accepted an invitation to the following environment: ");
body.append("<br /><br />");
body.append("<b>" + scope+"</b>");
body.append("<br />");
body.append("<br />");
body.append("<b>Username: </b>" + username);
body.append("<br />");
body.append("<b>e-mail: </b>" + currUser.getEmail());
body.append("</p>");
body.append("<p>");
body.append("<b>The invitation was sent by " + invite.getSenderFullName() +" (" + invite.getSenderUserId()+") on " + invite.getTime()+"</b>");
body.append("</p>");
body.append("<p>");
body.append("WARNING / LEGAL TEXT: This message is intended only for the use of the individual or entity to which it is addressed and may contain"+
" information which is privileged, confidential, proprietary, or exempt from disclosure under applicable law. " +
"If you are not the intended recipient or the person responsible for delivering the message to the intended recipient, you are strictly prohibited from disclosing, distributing, copying, or in any way using this message.");
body.append("</p>");
String[] allMails = new String[adminEmails.size()];
adminEmails.toArray(allMails);
EmailNotification mailToAdmin = new EmailNotification("no-reply@d4science.org", allMails , "[" + gatewayName + "] - Accepted Invitation", body.toString());
mailToAdmin.sendEmail();
}
}

View File

@ -12,7 +12,7 @@ public class ResearchEnvironment implements Serializable {
private String imageURL;
private String groupName;
private String infraScope;
private String friendlyURL;
@ -23,13 +23,13 @@ public class ResearchEnvironment implements Serializable {
}
public ResearchEnvironment(String name, String description,
String imageURL, String groupName, String friendlyURL,
String imageURL, String infraScope, String friendlyURL,
UserBelonging userBelonging) {
super();
this.name = name;
this.description = description;
this.imageURL = imageURL;
this.groupName = groupName;
this.infraScope = infraScope;
this.friendlyURL = friendlyURL;
this.userBelonging = userBelonging;
}
@ -58,12 +58,12 @@ public class ResearchEnvironment implements Serializable {
this.imageURL = imageURL;
}
public String getGroupName() {
return groupName;
public String getinfraScope() {
return infraScope;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
public void setinfraScope(String infraScope) {
this.infraScope = infraScope;
}
public String getFriendlyURL() {

View File

@ -30,9 +30,9 @@ public class VO extends ResearchEnvironment implements Comparable<VO>, Serializa
* @param vres .
*/
public VO(String voName, String description, String imageURL,
String vomsGroupName, String friendlyURL,
String infraScope, String friendlyURL,
UserBelonging userBelonging, boolean isRoot, ArrayList<VRE> vres) {
super(voName, description, imageURL, vomsGroupName, friendlyURL, userBelonging);
super(voName, description, imageURL, infraScope, friendlyURL, userBelonging);
this.isRoot = isRoot;
this.vres = vres;
}

View File

@ -23,15 +23,15 @@ public class VRE extends ResearchEnvironment implements Serializable, Comparable
* @param vreName
* @param description
* @param imageURL
* @param vomsGroupName
* @param groupName
* @param friendlyURL
* @param categories
* @param userBelonging
* @param uponRequest
*/
public VRE(long id, String vreName, String description, String imageURL,
String vomsGroupName, String friendlyURL, UserBelonging userBelonging, boolean uponRequest) {
super(vreName, description, imageURL, vomsGroupName, friendlyURL, userBelonging);
String infraScope, String friendlyURL, UserBelonging userBelonging, boolean uponRequest) {
super(vreName, description, imageURL, infraScope, friendlyURL, userBelonging);
this.uponRequest = uponRequest;
this.id = id;
isExternal = false;
@ -39,8 +39,8 @@ public class VRE extends ResearchEnvironment implements Serializable, Comparable
}
public VRE(long id, String vreName, String description, String imageURL,
String vomsGroupName, String friendlyURL, UserBelonging userBelonging, boolean uponRequest, boolean isExternal, String url) {
super(vreName, description, imageURL, vomsGroupName, friendlyURL, userBelonging);
String infraScope, String friendlyURL, UserBelonging userBelonging, boolean uponRequest, boolean isExternal, String url) {
super(vreName, description, imageURL, infraScope, friendlyURL, userBelonging);
this.uponRequest = uponRequest;
this.id = id;
this.isExternal = isExternal;

View File

@ -1,14 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='JoinVRE'>
<inherits name='com.google.gwt.user.User' />
<inherits name="com.google.gwt.logging.Logging" />
<inherits name='com.google.gwt.activity.Activity' />
<inherits name="com.github.gwtbootstrap.Bootstrap" />
<!-- <set-property name="user.agent" value="gecko1_8,safari" /> -->
<!-- <set-property name="user.agent" value="gecko1_8,safari" /> -->
<!-- Specify the app entry point class. -->
<entry-point class='org.gcube.portlets.user.joinvre.client.JoinVRE' />
<set-property name="gwt.logging.enabled" value="TRUE" />
<!-- Specify the paths for translatable code -->
<source path='client' />
<source path='shared' />

View File

@ -4,6 +4,6 @@ module-incremental-version=1
tags=
short-description=
change-log=
page-url=http://www.d4science.org
author=D4Science Org.
licenses=EUPL
page-url=http://www.gcube-system.org
author=Massimiliano Assante
licenses=EUPL