|
|
|
@ -7,6 +7,9 @@ import java.util.Set;
|
|
|
|
|
|
|
|
|
|
import org.gcube.common.portal.PortalContext;
|
|
|
|
|
import org.gcube.common.portal.mailing.EmailNotification;
|
|
|
|
|
import org.gcube.portal.mailing.message.Recipient;
|
|
|
|
|
import org.gcube.portal.mailing.service.EmailTemplateService;
|
|
|
|
|
import org.gcube.portal.mailing.templates.TemplateUserHasLeftVRE;
|
|
|
|
|
import org.gcube.portlets.user.gcubeloggedin.client.LoggedinService;
|
|
|
|
|
import org.gcube.portlets.user.gcubeloggedin.shared.VObject;
|
|
|
|
|
import org.gcube.portlets.user.gcubeloggedin.shared.VObject.UserBelongingClient;
|
|
|
|
@ -220,41 +223,31 @@ public class LoggedinServiceImpl extends RemoteServiceServlet implements Loggedi
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
* @param scope .
|
|
|
|
|
* @param optionalMessage .
|
|
|
|
|
* @param username
|
|
|
|
|
* @param scope
|
|
|
|
|
* @param portalbasicurl
|
|
|
|
|
* @param gatewayName
|
|
|
|
|
*/
|
|
|
|
|
public void sendUserUnregisteredNotification(String username, String scope, String portalbasicurl, String gatewayName) {
|
|
|
|
|
ArrayList<String> adminEmails = getAdministratorsEmails(scope);
|
|
|
|
|
ArrayList<Recipient> recipients = new ArrayList<>();
|
|
|
|
|
for (String email : adminEmails) {
|
|
|
|
|
recipients.add(new Recipient(email));
|
|
|
|
|
}
|
|
|
|
|
UserManager um = new LiferayUserManager();
|
|
|
|
|
GCubeUser currUser = null;
|
|
|
|
|
try {
|
|
|
|
|
currUser = um.getUserByUsername(username);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
|
|
_log.trace("Error getUserByUsername", e);
|
|
|
|
|
}
|
|
|
|
|
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 left 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>");
|
|
|
|
|
|
|
|
|
|
String[] allMails = new String[adminEmails.size()];
|
|
|
|
|
|
|
|
|
|
adminEmails.toArray(allMails);
|
|
|
|
|
|
|
|
|
|
EmailNotification mailToAdmin = new EmailNotification(allMails , "Unregistration from VRE", body.toString(), getThreadLocalRequest());
|
|
|
|
|
String selectedVRE = scope.substring(scope.lastIndexOf("/")+1, scope.length());
|
|
|
|
|
|
|
|
|
|
EmailTemplateService.send("Unregistration from VRE",
|
|
|
|
|
new TemplateUserHasLeftVRE(currUser, selectedVRE, gatewayName, portalbasicurl),
|
|
|
|
|
getThreadLocalRequest(),
|
|
|
|
|
recipients.toArray(new Recipient[recipients.size()]));
|
|
|
|
|
|
|
|
|
|
mailToAdmin.sendEmail();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|