Portlet's name changed to Settings. It now contains also the leave group option (if available)
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/questions@128511 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
9397eb4fe6
commit
dd3300fb24
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" output="target/questions-1.2.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<classpathentry kind="src" output="target/questions-2.0.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
|
@ -31,5 +31,5 @@
|
|||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/questions-1.2.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
<classpathentry kind="output" path="target/questions-2.0.0-SNAPSHOT/WEB-INF/classes"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
eclipse.preferences.version=1
|
||||
jarsExcludedFromWebInfLib=
|
||||
lastWarOutDir=/Users/massi/Documents/workspace/questions/target/questions-1.0.0-SNAPSHOT
|
||||
lastWarOutDir=/home/costantino/workspace/questions/target/questions-2.0.0-SNAPSHOT
|
||||
warSrcDir=src/main/webapp
|
||||
warSrcDirIsOutput=false
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<faceted-project>
|
||||
<fixed facet="wst.jsdt.web"/>
|
||||
<installed facet="jst.web" version="2.3"/>
|
||||
<installed facet="jst.web" version="3.0"/>
|
||||
<installed facet="wst.jsdt.web" version="1.0"/>
|
||||
<installed facet="java" version="1.7"/>
|
||||
<installed facet="liferay.portlet" version="6.0"/>
|
||||
|
|
20
pom.xml
20
pom.xml
|
@ -13,7 +13,7 @@
|
|||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>questions</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>1.2.0-SNAPSHOT</version>
|
||||
<version>2.0.0-SNAPSHOT</version>
|
||||
<name>gCube Questions Ask Managers Portlet</name>
|
||||
<description>
|
||||
gCube Questions Ask Managers Portlet
|
||||
|
@ -27,6 +27,7 @@
|
|||
<!-- Convenience property to set the GWT version -->
|
||||
<gwtVersion>2.7.0</gwtVersion>
|
||||
<distroDirectory>distro</distroDirectory>
|
||||
<liferay.version>6.2.5</liferay.version>
|
||||
<maven.compiler.source>1.7</maven.compiler.source>
|
||||
<maven.compiler.target>1.7</maven.compiler.target>
|
||||
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
|
||||
|
@ -72,17 +73,24 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.portlets.user</groupId>
|
||||
<artifactId>gcube-widgets</artifactId>
|
||||
<scope>provided</scope>
|
||||
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portal</groupId>
|
||||
<artifactId>custom-portal-handler</artifactId>
|
||||
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
<artifactId>commons-io</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.common.portal</groupId>
|
||||
<artifactId>portal-manager</artifactId>
|
||||
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.core</groupId>
|
||||
<artifactId>common-encryption</artifactId>
|
||||
|
@ -130,7 +138,7 @@
|
|||
<dependency>
|
||||
<groupId>org.gcube.portlets.widgets</groupId>
|
||||
<artifactId>wsmail-widget</artifactId>
|
||||
<version>[1.4.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
|
||||
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
@ -139,6 +147,11 @@
|
|||
<version>[2.13.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.gcube.portlets.widgets</groupId>
|
||||
<artifactId>session-checker</artifactId>
|
||||
<version>[1.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
|
@ -147,6 +160,7 @@
|
|||
<dependency>
|
||||
<groupId>com.liferay.portal</groupId>
|
||||
<artifactId>portal-service</artifactId>
|
||||
<version>${liferay.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
|
|
@ -7,8 +7,6 @@ import com.google.gwt.user.client.ui.RootPanel;
|
|||
* Entry point classes define <code>onModuleLoad()</code>.
|
||||
*/
|
||||
public class Questions implements EntryPoint {
|
||||
|
||||
|
||||
public void onModuleLoad() {
|
||||
RootPanel.get("questionsManagersDiv").add(new VREManagersPanel());
|
||||
}
|
||||
|
|
|
@ -13,4 +13,6 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
|||
@RemoteServiceRelativePath("greet")
|
||||
public interface QuestionsService extends RemoteService {
|
||||
ArrayList<UserInfo> getManagers();
|
||||
String removeUserFromVRE();
|
||||
boolean isLeaveButtonAvailable(String currentUrl);
|
||||
}
|
||||
|
|
|
@ -7,7 +7,8 @@ import org.gcube.portal.databook.shared.UserInfo;
|
|||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
|
||||
public interface QuestionsServiceAsync {
|
||||
|
||||
void getManagers(AsyncCallback<ArrayList<UserInfo>> callback);
|
||||
|
||||
void removeUserFromVRE(AsyncCallback<String> callback);
|
||||
void isLeaveButtonAvailable(String currentUrl,
|
||||
AsyncCallback<Boolean> callback);
|
||||
}
|
||||
|
|
|
@ -4,68 +4,113 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.gcube.portal.databook.shared.UserInfo;
|
||||
import org.gcube.portlets.user.gcubewidgets.client.elements.Span;
|
||||
import org.gcube.portlets.user.questions.client.resources.Images;
|
||||
import org.gcube.portlets.user.questions.client.ui.DisplayBadge;
|
||||
import org.gcube.portlets.widgets.sessionchecker.client.CheckSession;
|
||||
import org.gcube.portlets.widgets.wsmail.client.forms.MailForm;
|
||||
|
||||
import com.github.gwtbootstrap.client.ui.AlertBlock;
|
||||
import com.github.gwtbootstrap.client.ui.Button;
|
||||
import com.github.gwtbootstrap.client.ui.Label;
|
||||
import com.github.gwtbootstrap.client.ui.constants.AlertType;
|
||||
import com.github.gwtbootstrap.client.ui.constants.ButtonType;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.core.client.RunAsyncCallback;
|
||||
import com.google.gwt.event.dom.client.ClickEvent;
|
||||
import com.google.gwt.event.dom.client.ClickHandler;
|
||||
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.HTML;
|
||||
import com.google.gwt.user.client.ui.HasAlignment;
|
||||
import com.google.gwt.user.client.ui.HasVerticalAlignment;
|
||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||
import com.google.gwt.user.client.ui.Image;
|
||||
import com.google.gwt.user.client.ui.SimplePanel;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
|
||||
public class VREManagersPanel extends Composite {
|
||||
|
||||
|
||||
private final QuestionsServiceAsync service = GWT.create(QuestionsService.class);
|
||||
public static final String DISPLAY_NAME = "Questions? Ask the managers";
|
||||
|
||||
private Image loadingImage;
|
||||
private Image postToImage;
|
||||
private Button messageManagers = new Button();
|
||||
private Button leaveVreButton = new Button("Leave Group");
|
||||
private AlertBlock alertBlockOnLeave = new AlertBlock();
|
||||
|
||||
private static final String leaveAlertMessage = "Are you sure you want to leave this group? "
|
||||
+ "By leaving this group you will no longer receive updates and lose the workspace folder related to the group.";
|
||||
|
||||
// main panel
|
||||
private VerticalPanel mainPanel = new VerticalPanel();
|
||||
|
||||
// panel for Questions? Ask the managers option
|
||||
private VerticalPanel askManagersOption = new VerticalPanel();
|
||||
|
||||
// panel for leave group option
|
||||
private VerticalPanel leaveVREOption = new VerticalPanel();
|
||||
|
||||
// list of managers
|
||||
private ArrayList<UserInfo> managers;
|
||||
|
||||
public VREManagersPanel() {
|
||||
super();
|
||||
initWidget(mainPanel);
|
||||
|
||||
Images images = GWT.create(Images.class);
|
||||
loadingImage = new Image(images.membersLoader().getSafeUri());
|
||||
postToImage = new Image(images.postToIcon().getSafeUri());
|
||||
|
||||
mainPanel.add(loadingImage);
|
||||
showLoader();
|
||||
|
||||
// add options subpanels to the main one
|
||||
mainPanel.add(askManagersOption); // this is always present ...
|
||||
|
||||
// more options label to show the other ones (if present)
|
||||
final Button showMoreOptions = new Button("Show more options ...");
|
||||
showMoreOptions.setType(ButtonType.LINK);
|
||||
|
||||
// handler
|
||||
showMoreOptions.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
// hide the button itself
|
||||
showMoreOptions.setVisible(false);
|
||||
|
||||
// show other options
|
||||
leaveVREOption.setVisible(true);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
mainPanel.add(showMoreOptions);
|
||||
mainPanel.add(leaveVREOption);
|
||||
|
||||
// hide options but askManagersOption
|
||||
leaveVREOption.setVisible(false);
|
||||
|
||||
// show loaders for the panels
|
||||
showLoader(askManagersOption);
|
||||
showLoader(leaveVREOption);
|
||||
|
||||
service.getManagers(new AsyncCallback<ArrayList<UserInfo>>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(ArrayList<UserInfo> users) {
|
||||
askManagersOption.clear();
|
||||
managers = users;
|
||||
mainPanel.clear();
|
||||
mainPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
|
||||
mainPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
|
||||
mainPanel.setStyleName("questions-frame");
|
||||
HTML name = new HTML(DISPLAY_NAME);
|
||||
|
||||
name.setStyleName("questions-title");
|
||||
HorizontalPanel hp = new HorizontalPanel();
|
||||
hp.add(name);
|
||||
askManagersOption.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
|
||||
askManagersOption.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
|
||||
askManagersOption.setStyleName("questions-frame");
|
||||
postToImage.setStyleName("manager-post-image");
|
||||
postToImage.setTitle("Message privately to the Managers");
|
||||
// hp.add(postToImage);
|
||||
mainPanel.add(hp);
|
||||
if (users == null || users.isEmpty()) {
|
||||
mainPanel.add(new HTML("<div class=\"frame\" style=\"font-size: 16px;\">Ops, something went wrong. Please <a href=\"javascript: location.reload();\">reload<a/> this page.</div>"));
|
||||
askManagersOption.add(new HTML("<div class=\"frame\" style=\"font-size: 16px;\">Ops, something went wrong. Please <a href=\"javascript: location.reload();\">reload<a/> this page.</div>"));
|
||||
} else {
|
||||
for (int i = 0; i < users.size(); i++) {
|
||||
mainPanel.add(new DisplayBadge(users.get(i)));
|
||||
askManagersOption.add(new DisplayBadge(users.get(i)));
|
||||
}
|
||||
if (users.size() > 1)
|
||||
messageManagers.setText("Message managers");
|
||||
|
@ -75,18 +120,18 @@ public class VREManagersPanel extends Composite {
|
|||
SimplePanel bPanel = new SimplePanel();
|
||||
bPanel.setStyleName("manager-action");
|
||||
bPanel.setWidget(messageManagers);
|
||||
mainPanel.add(bPanel);
|
||||
askManagersOption.add(bPanel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
mainPanel.add(new HTML("<div class=\"nofeed-message\">" +
|
||||
askManagersOption.clear();
|
||||
askManagersOption.add(new HTML("<div class=\"nofeed-message\">" +
|
||||
"Sorry, looks like something is broken with the server connection<br> " +
|
||||
"Please check your connection and try refresh this page.</div>"));
|
||||
|
||||
}
|
||||
});
|
||||
initWidget(mainPanel);
|
||||
|
||||
messageManagers.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
|
@ -95,7 +140,7 @@ public class VREManagersPanel extends Composite {
|
|||
for (UserInfo user : managers) {
|
||||
listToLogin.add(user.getUsername());
|
||||
}
|
||||
|
||||
|
||||
GWT.runAsync(new RunAsyncCallback() {
|
||||
@Override
|
||||
public void onSuccess() {
|
||||
|
@ -107,14 +152,96 @@ public class VREManagersPanel extends Composite {
|
|||
});
|
||||
}
|
||||
});
|
||||
|
||||
service.isLeaveButtonAvailable(Location.getHref(), new AsyncCallback<Boolean>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(Boolean result) {
|
||||
leaveVREOption.clear();
|
||||
leaveVREOption.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
|
||||
if(!result)
|
||||
addLeaveVREButton();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
leaveVREOption.clear();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addLeaveVREButton(){
|
||||
|
||||
private void showLoader() {
|
||||
mainPanel.clear();
|
||||
mainPanel.setWidth("100%");
|
||||
mainPanel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
|
||||
mainPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
|
||||
mainPanel.add(loadingImage);
|
||||
// add leave VRE button
|
||||
leaveVreButton.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
// show alert block
|
||||
alertBlockOnLeave.setVisible(true);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
// Add Cancel and Confirm Leave buttons
|
||||
Span cancel = new Span("Cancel");
|
||||
Span confirmLeave = new Span("Confirm Leave");
|
||||
cancel.setStyleName("cancel-leave-button");
|
||||
confirmLeave.setStyleName("cancel-leave-button");
|
||||
|
||||
// add to main panel
|
||||
alertBlockOnLeave.setHTML(leaveAlertMessage + "<br><br>");
|
||||
alertBlockOnLeave.add(cancel);
|
||||
alertBlockOnLeave.add(new Label(" or "));
|
||||
alertBlockOnLeave.add(confirmLeave);
|
||||
alertBlockOnLeave.setType(AlertType.WARNING);
|
||||
alertBlockOnLeave.setHeading("WARNING!");
|
||||
alertBlockOnLeave.setClose(false);
|
||||
alertBlockOnLeave.setVisible(false);
|
||||
leaveVREOption.add(alertBlockOnLeave);
|
||||
leaveVREOption.add(leaveVreButton);
|
||||
|
||||
// add handlers
|
||||
cancel.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
|
||||
// just hide alertBlock
|
||||
alertBlockOnLeave.setVisible(false);
|
||||
}
|
||||
});
|
||||
|
||||
confirmLeave.addClickHandler(new ClickHandler() {
|
||||
|
||||
@Override
|
||||
public void onClick(ClickEvent event){
|
||||
service.removeUserFromVRE(new AsyncCallback<String>() {
|
||||
@Override
|
||||
public void onSuccess(String result) {
|
||||
if (result != null)
|
||||
Location.assign(result);
|
||||
else
|
||||
CheckSession.showLogoutDialog();
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Window.alert("We're sorry we couldn't reach the server, try again later ... " + caught.getMessage());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void showLoader(VerticalPanel panel) {
|
||||
panel.clear();
|
||||
panel.setWidth("100%");
|
||||
panel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
|
||||
panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
|
||||
panel.add(loadingImage);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,24 +3,26 @@ package org.gcube.portlets.user.questions.server;
|
|||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.gcube.application.framework.core.session.ASLSession;
|
||||
import org.gcube.application.framework.core.session.SessionManager;
|
||||
import org.gcube.portal.custom.communitymanager.OrganizationsUtil;
|
||||
import org.gcube.common.portal.PortalContext;
|
||||
import org.gcube.common.portal.mailing.EmailNotification;
|
||||
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
||||
import org.gcube.portal.databook.client.GCubeSocialNetworking;
|
||||
import org.gcube.portal.databook.shared.UserInfo;
|
||||
import org.gcube.portlets.user.gcubewidgets.server.ScopeServiceImpl;
|
||||
import org.gcube.portlets.user.questions.client.QuestionsService;
|
||||
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.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.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -70,24 +72,24 @@ public class QuestionsServiceImpl extends RemoteServiceServlet implements Questi
|
|||
if (isWithinPortal()) {
|
||||
_log.trace("Asking user and roles ...");
|
||||
UserManager userM = new LiferayUserManager();
|
||||
HashMap<UserModel, List<RoleModel>> usersAndRoles = null;
|
||||
Map<GCubeUser, List<GCubeRole>> usersAndRoles = null;
|
||||
try {
|
||||
usersAndRoles = userM.listUsersAndRolesByGroup(getCurrentGroupID());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Set<UserModel> users = usersAndRoles.keySet();
|
||||
for (UserModel usr:users) {
|
||||
List<RoleModel> roles = usersAndRoles.get(usr);
|
||||
Set<GCubeUser> users = usersAndRoles.keySet();
|
||||
for (GCubeUser usr:users) {
|
||||
List<GCubeRole> roles = usersAndRoles.get(usr);
|
||||
for (int i = 0; i < roles.size(); i++) {
|
||||
if (roles.get(i).getRoleName().equals("VRE-Manager")) {
|
||||
String username = usr.getScreenName();
|
||||
String username = usr.getUsername();
|
||||
_log.trace("Found Manager ... " + username);
|
||||
String fullName = usr.getFullname();
|
||||
String thumbnailURL = "images/Avatar_default.png";
|
||||
try {
|
||||
com.liferay.portal.model.User user = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), username);
|
||||
thumbnailURL = user.isMale() ? "/image/user_male_portrait?img_id="+user.getPortraitId() : "/image/user_female_portrait?img_id="+user.getPortraitId();
|
||||
GCubeUser user = userM.getUserByUsername(username);
|
||||
thumbnailURL = user.getUserAvatarURL();
|
||||
HashMap<String, String> vreNames = new HashMap<String, String>();
|
||||
String headline = user.getJobTitle();
|
||||
UserInfo userInfo = new UserInfo(username, fullName, thumbnailURL, headline, getUserProfileLink(username), user.isMale(), false, vreNames);
|
||||
|
@ -110,6 +112,58 @@ public class QuestionsServiceImpl extends RemoteServiceServlet implements Questi
|
|||
return toReturn;
|
||||
}
|
||||
|
||||
/**
|
||||
*@return the redirect url if everything goes ok, null otherwise
|
||||
*/
|
||||
@Override
|
||||
public String removeUserFromVRE() {
|
||||
String username = getASLSession().getUsername();
|
||||
if (username.compareTo("test.user") == 0)
|
||||
return null;
|
||||
_log.debug("Going to remove user from the current Group: " + getCurrentGroupID() + ". Username is: " + username);
|
||||
UserManager userM = new LiferayUserManager();
|
||||
try {
|
||||
userM.dismissUserFromGroup(getCurrentGroupID(), userM.getUserId(username));
|
||||
sendUserUnregisteredNotification(username, getASLSession().getScope(),
|
||||
PortalContext.getConfiguration().getGatewayURL(getThreadLocalRequest()),
|
||||
PortalContext.getConfiguration().getGatewayName(getThreadLocalRequest()));
|
||||
return "/";
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean isLeaveButtonAvailable(String portalURL) {
|
||||
|
||||
if(isWithinPortal()){
|
||||
String friendlyURL = ScopeServiceImpl.extractOrgFriendlyURL(portalURL);
|
||||
GroupManager gm = new LiferayGroupManager();
|
||||
GCubeGroup currSite = null;
|
||||
try {
|
||||
List<GCubeGroup> groups = gm.listGroups();
|
||||
for (GCubeGroup g : groups) {
|
||||
if (g.getFriendlyURL().compareTo(friendlyURL) == 0) {
|
||||
long groupId = g.getGroupId();
|
||||
String scopeToSet = gm.getInfrastructureScope(groupId);
|
||||
getASLSession().setScope(scopeToSet);
|
||||
_log.info("GOT Selected Research Environment: " + scopeToSet);
|
||||
currSite = g;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Boolean isMandatory = false;
|
||||
try{
|
||||
isMandatory = (Boolean) gm.readCustomAttr(currSite.getGroupId(), org.gcube.vomanagement.usermanagement.model.CustomAttributeKeys.MANDATORY.getKeyName());
|
||||
}catch(Exception e){
|
||||
_log.error("Unable to evaluate if the leave button can be added for the current group " + currSite.getGroupName(), e);
|
||||
}
|
||||
_log.debug("Is Leave button available in vre " + currSite.getGroupName() + " ? " + isMandatory);
|
||||
return isMandatory;
|
||||
}else return true;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @return true if you're running into the portal, false if in development
|
||||
|
@ -131,22 +185,99 @@ public class QuestionsServiceImpl extends RemoteServiceServlet implements Questi
|
|||
* @throws Exception
|
||||
* @throws CurrentGroupRetrievalException
|
||||
*/
|
||||
private String getCurrentGroupID() throws Exception {
|
||||
private long getCurrentGroupID(){
|
||||
GroupManager groupM = new LiferayGroupManager();
|
||||
ASLSession session = getASLSession();
|
||||
_log.debug("The current group NAME is --> " + session.getGroupName());
|
||||
try {
|
||||
return groupM.getGroupId(session.getGroupName());
|
||||
} catch (GroupRetrievalFault e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
private String getUserProfileLink(String username) {
|
||||
return "profile?"+ new String(Base64.encodeBase64(GCubeSocialNetworking.USER_PROFILE_OID.getBytes()))+"="+new String(Base64.encodeBase64(username.getBytes()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param scope .
|
||||
* @param optionalMessage .
|
||||
*/
|
||||
public void sendUserUnregisteredNotification(String username, String scope, String portalbasicurl, String gatewayName) {
|
||||
ArrayList<String> adminEmails = getAdministratorsEmails(scope);
|
||||
UserManager um = new LiferayUserManager();
|
||||
GCubeUser currUser = null;
|
||||
try {
|
||||
currUser = um.getUserByUsername(username);
|
||||
} catch (Exception 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());
|
||||
|
||||
mailToAdmin.sendEmail();
|
||||
}
|
||||
|
||||
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);
|
||||
_log.debug("Comparing: " + groupScope + " " + scope);
|
||||
if (groupScope.equals(scope)) {
|
||||
groupId = allGroups.get(i).getGroupId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Exception 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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,11 +8,6 @@
|
|||
|
||||
.questions-frame {
|
||||
padding: 10px;
|
||||
background-color: #FFF;
|
||||
border-radius: 6px !important;
|
||||
-moz-border-radius: 6px !important;
|
||||
-webkit-border-radius: 6px !important;
|
||||
border: 1px solid #DBDBDB;
|
||||
}
|
||||
|
||||
.manager-user-photo {
|
||||
|
@ -49,7 +44,7 @@ a.manager-person-link {
|
|||
line-height: 18px;
|
||||
}
|
||||
|
||||
a.manager-person-link,a.manager-person-link:visited {
|
||||
a.manager-person-link, a.manager-person-link:visited {
|
||||
cursor: pointer;
|
||||
cursor: hand;
|
||||
font-size: 16x;
|
||||
|
@ -63,7 +58,6 @@ a.manager-person-link:hover {
|
|||
text-decoration: underline;
|
||||
}
|
||||
|
||||
|
||||
.manager-headline {
|
||||
font-size: 13px;
|
||||
color: #444444;
|
||||
|
@ -74,4 +68,14 @@ a.manager-person-link:hover {
|
|||
.manager-institution {
|
||||
font-size: 11px;
|
||||
color: #444444;
|
||||
}
|
||||
|
||||
.cancel-leave-button {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.cancel-leave-button:hover {
|
||||
cursor: pointer;
|
||||
cursor: hand;
|
||||
text-decoration: underline;
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE display PUBLIC "-//Liferay//DTD Display 6.0.0//EN" "http://www.liferay.com/dtd/liferay-display_6_0_0.dtd">
|
||||
<!DOCTYPE display PUBLIC "-//Liferay//DTD Display 6.2.0//EN" "http://www.liferay.com/dtd/liferay-display_6_2_0.dtd">
|
||||
|
||||
<display>
|
||||
<category name="gCube Social Apps">
|
||||
<portlet id="VREManagers" />
|
||||
<portlet id="VRESettings" />
|
||||
</category>
|
||||
</display>
|
|
@ -1,4 +1,4 @@
|
|||
name=VREManagers
|
||||
name=VRESettings
|
||||
module-group-id=liferay
|
||||
module-incremental-version=1
|
||||
tags=
|
||||
|
@ -6,4 +6,4 @@ short-description=
|
|||
change-log=
|
||||
page-url=http://www.d4science.org
|
||||
author=D4Science.org
|
||||
licenses=EUPL
|
||||
licenses=EUPL
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 5.2.0//EN" "http://www.liferay.com/dtd/liferay-portlet-app_6_0_0.dtd">
|
||||
|
||||
<!DOCTYPE liferay-portlet-app PUBLIC "-//Liferay//DTD Portlet Application 6.2.0//EN" "http://www.liferay.com/dtd/liferay-portlet-app_6_2_0.dtd">
|
||||
<liferay-portlet-app>
|
||||
<portlet>
|
||||
<portlet-name>VREManagers</portlet-name>
|
||||
<portlet-name>VRESettings</portlet-name>
|
||||
<layout-cacheable>false</layout-cacheable>
|
||||
<instanceable>false</instanceable>
|
||||
<ajaxable>false</ajaxable>
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
|
||||
>
|
||||
<portlet>
|
||||
<portlet-name>VREManagers</portlet-name>
|
||||
<display-name>VRE Managers</display-name>
|
||||
<portlet-name>VRESettings</portlet-name>
|
||||
<display-name>VRE Settings</display-name>
|
||||
<portlet-class>org.gcube.portlets.user.questions.server.portlet.VREManagersPortlet</portlet-class>
|
||||
<init-param>
|
||||
<name>view-jsp</name>
|
||||
|
@ -19,9 +19,9 @@
|
|||
<mime-type>text/html</mime-type>
|
||||
</supports>
|
||||
<portlet-info>
|
||||
<title>Questions? Ask the Managers</title>
|
||||
<short-title>VRE Managers</short-title>
|
||||
<keywords>VRE Managers</keywords>
|
||||
<title>Settings</title>
|
||||
<short-title>Settings</short-title>
|
||||
<keywords>vre settings</keywords>
|
||||
</portlet-info>
|
||||
<security-role-ref>
|
||||
<role-name>administrator</role-name>
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE web-app
|
||||
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
|
||||
"http://java.sun.com/dtd/web-app_2_3.dtd">
|
||||
|
||||
<web-app>
|
||||
<web-app xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
|
||||
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
|
||||
version="3.0">
|
||||
|
||||
<!-- Servlets -->
|
||||
<servlet>
|
||||
|
|
Loading…
Reference in New Issue