Changed visbility of users depending on the gateway

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/admin/register-vre-users@131378 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2016-09-15 12:27:15 +00:00
parent ec1c282688
commit 4dab4c016b
13 changed files with 177 additions and 81 deletions

View File

@ -1,19 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/register-vre-users-2.0.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/register-vre-users-2.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry including="**/*.java" kind="src" output="src/main/webapp/WEB-INF/classes" path="src/main/resources"/>
<classpathentry excluding="**" kind="src" output="target/register-vre-users-2.1.0-SNAPSHOT/WEB-INF/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry including="**/*.java" kind="src" output="target/test-classes" path="src/test/resources"/>
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="com.google.gwt.eclipse.core.GWT_CONTAINER"/>
<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
@ -31,5 +39,5 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/register-vre-users-2.0.0-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="output" path="target/register-vre-users-2.1.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

View File

@ -55,5 +55,6 @@
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
<nature>com.google.gwt.eclipse.core.gwtNature</nature>
<nature>com.liferay.ide.core.liferayNature</nature>
</natures>
</projectDescription>

View File

@ -5,9 +5,6 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="invites-common-library-1.2.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="register-vre-users"/>
</wb-module>

View File

@ -1,4 +1,8 @@
<ReleaseNotes>
<Changeset component="org.gcube.portlets-admin.register-vre-users.2-1-0"
date="2016-09-08">
<Change>Changed visbility of users depending on the gateway</Change>
</Changeset>
<Changeset component="org.gcube.portlets-admin.register-vre-users.2-0-0"
date="2016-06-08">
<Change>Ported to Liferay 6.2</Change>

16
pom.xml
View File

@ -12,7 +12,7 @@
<groupId>org.gcube.portlets.admin</groupId>
<artifactId>register-vre-users</artifactId>
<packaging>war</packaging>
<version>2.0.0-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
<name>Register VRE Users</name>
<description>
Register VRE Users Portlet allow to select a user from the portal and add her to the VRE.
@ -98,16 +98,6 @@
<artifactId>home-library</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>invite-friends-widget</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.portal</groupId>
<artifactId>invites-common-library</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.portal</groupId>
<artifactId>social-networking-library</artifactId>
@ -133,6 +123,10 @@
<artifactId>usermanagement-core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.common.portal</groupId>
<artifactId>portal-manager</artifactId>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-service</artifactId>

View File

@ -6,7 +6,6 @@ import java.util.List;
import org.gcube.portlets.admin.manageusers.client.ManageUsersServiceAsync;
import org.gcube.portlets.admin.manageusers.client.view.Display;
import org.gcube.portlets.admin.manageusers.shared.PortalUserDTO;
import org.gcube.portlets.widgets.inviteswidget.client.ui.InviteWidget;
import com.extjs.gxt.ui.client.event.ButtonEvent;
import com.extjs.gxt.ui.client.event.ComponentEvent;
@ -16,13 +15,9 @@ import com.extjs.gxt.ui.client.event.SelectionChangedEvent;
import com.extjs.gxt.ui.client.event.SelectionChangedListener;
import com.extjs.gxt.ui.client.event.SelectionListener;
import com.extjs.gxt.ui.client.widget.MessageBox;
import com.extjs.gxt.ui.client.widget.Window;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.google.gwt.event.shared.HandlerManager;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HasWidgets;
import com.google.gwt.user.client.ui.SimplePanel;
import com.google.gwt.user.client.ui.VerticalPanel;
/**
*
* @author Massimiliano Assante (assante@isti.cnr.it)
@ -56,16 +51,11 @@ public class VREDeploymentPresenter implements Presenter {
}
};
///*** BUTTONS & Menu
SelectionListener inviteButtonListener = new SelectionListener<ComponentEvent>() {
public void componentSelected(ComponentEvent ce) {
doOpenInviteWidget();
}
};
display.getApproveButton().addSelectionListener(approvesl);
display.getApproveMenu().addSelectionListener(approvesl);
display.getInviteButton().addSelectionListener(inviteButtonListener);
// REFRESH
display.getRefreshButton().addSelectionListener( new SelectionListener<ButtonEvent>() {
@ -114,16 +104,13 @@ public class VREDeploymentPresenter implements Presenter {
});
}
private void doOpenInviteWidget() {
display.displayInviteUsersPanel();
}
private void doApprove(final List<PortalUserDTO> selectedUsers) {
if (selectedUsers != null) {
String users = "";
for (int i = 0; i < selectedUsers.size(); i++) {
PortalUserDTO user = selectedUsers.get(i);
users += user.getLastName() + ", ";
users += user.getName() + " " + user.getLastName() + ", ";
}
MessageBox.confirm("Please Confirm", "You are about to register: " +users+ "?", new Listener<MessageBoxEvent>() {

View File

@ -18,12 +18,12 @@ public interface Display {
void setGridContextMenu() ;
Button getApproveButton();
Button getInviteButton();
Button getRefreshButton();
MenuItem getApproveMenu();
GridSelectionModel<PortalUserDTO> getGridSelectionModel();
void displayInviteUsersPanel();
}

View File

@ -6,7 +6,6 @@ import java.util.List;
import org.gcube.portlets.admin.manageusers.client.ManageVreUsers;
import org.gcube.portlets.admin.manageusers.shared.PortalUserDTO;
import org.gcube.portlets.user.gcubewidgets.client.GCubePanel;
import org.gcube.portlets.widgets.inviteswidget.client.ui.InviteWidget;
import com.extjs.gxt.ui.client.Style.HorizontalAlignment;
import com.extjs.gxt.ui.client.Style.SelectionMode;
@ -51,7 +50,7 @@ public class VREDeploymentView extends Composite implements Display {
private Button approveButton;
private Button refreshButton;
private Button inviteButton;
private MenuItem approveMenu;
private final CheckBoxSelectionModel<PortalUserDTO> sm = new CheckBoxSelectionModel<PortalUserDTO>();
@ -170,24 +169,12 @@ public class VREDeploymentView extends Composite implements Display {
approveButton.setEnabled(false);
inviteButton = new Button("Invite a user by email");
initWidget(mainPanel);
updateSize();
}
@Override
public void displayInviteUsersPanel() {
VerticalPanel sp = new VerticalPanel();
sp.getElement().getStyle().setMarginTop(10, Unit.PX);
sp.getElement().getStyle().setMarginBottom(10, Unit.PX);
sp.setSpacing(10);
InviteWidget iw = new InviteWidget();
sp.add(iw);
mainPanel.setHorizontalAlignment(HasAlignment.ALIGN_CENTER);
mainPanel.add(sp);
}
/**
* display the list of wfDocuments
@ -207,7 +194,7 @@ public class VREDeploymentView extends Composite implements Display {
gridPanel.setButtonAlign(HorizontalAlignment.CENTER);
gridPanel.addButton(approveButton);
gridPanel.addButton(refreshButton);
gridPanel.addButton(inviteButton);
gridPanel.setBorders(false);
tablePanel.add(gridPanel);
tablePanel.setLayout(new FitLayout());
@ -243,8 +230,8 @@ public class VREDeploymentView extends Composite implements Display {
int rightScrollBar = 17;
int rootHeight = Window.getClientHeight() - (topBorder + 150);
int rootWidth = Window.getClientWidth() - 2*leftBorder - rightScrollBar;
tablePanel.setPixelSize(rootWidth+15, rootHeight+30);
mainPanel.setPixelSize(rootWidth+15, rootHeight+10);
tablePanel.setPixelSize(rootWidth, rootHeight);
mainPanel.setPixelSize(rootWidth, rootHeight);
}
@ -339,8 +326,5 @@ public class VREDeploymentView extends Composite implements Display {
public MenuItem getApproveMenu() { return approveMenu;
}
@Override
public Button getInviteButton() {
return inviteButton;
}
}

View File

@ -3,6 +3,8 @@ package org.gcube.portlets.admin.manageusers.server;
import java.util.ArrayList;
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.applicationsupportlayer.social.ApplicationNotificationsManager;
@ -11,6 +13,7 @@ import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingSite;
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser;
import org.gcube.common.homelibrary.home.HomeLibrary;
import org.gcube.common.homelibrary.home.workspace.Workspace;
import org.gcube.common.portal.PortalContext;
import org.gcube.common.scope.impl.ScopeBean;
import org.gcube.common.scope.impl.ScopeBean.Type;
import org.gcube.portal.custom.communitymanager.SiteManagerUtil;
@ -30,11 +33,15 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.liferay.portal.model.Group;
import com.liferay.portal.model.User;
import com.liferay.portal.model.VirtualHost;
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.LayoutSetLocalServiceUtil;
import com.liferay.portal.service.UserLocalServiceUtil;
import com.liferay.portal.service.VirtualHostLocalServiceUtil;
@SuppressWarnings("serial")
public class ManageUsersServiceImpl extends RemoteServiceServlet implements ManageUsersService {
@ -108,7 +115,29 @@ public class ManageUsersServiceImpl extends RemoteServiceServlet implements Man
}
}
/**
*
* @param request
* @return the current Group instance based on the request
* @throws PortalException
* @throws SystemException
*/
private Group getSiteFromServletRequest(final HttpServletRequest request) throws Exception {
String serverName = request.getServerName();
Group site = null;
List<VirtualHost> vHosts = VirtualHostLocalServiceUtil.getVirtualHosts(0, VirtualHostLocalServiceUtil.getVirtualHostsCount());
for (VirtualHost virtualHost : vHosts) {
if (virtualHost.getHostname().compareTo("localhost") != 0 &&
virtualHost.getLayoutSetId() != 0 &&
virtualHost.getHostname().compareTo(serverName) == 0) {
long layoutSetId = virtualHost.getLayoutSetId();
site = LayoutSetLocalServiceUtil.getLayoutSet(layoutSetId).getGroup();
return site;
}
}
_log.warn("serverName is " + serverName + " but i could not find any virtualHost associated to it");
return null;
}
/**
* Retrieves all the users that are registered to portal but are not registered to the current VO
*
@ -126,8 +155,13 @@ public class ManageUsersServiceImpl extends RemoteServiceServlet implements Man
_log.trace("Setting Permission ok!");
ArrayList<PortalUserDTO> unregisteredUsers = new ArrayList<PortalUserDTO>();
List<GCubeUser> notBelongingUsers = userM.listUnregisteredUsersByGroup(getCurrentGroupID());
for (GCubeUser u : notBelongingUsers) {
//List<GCubeUser> notBelongingUsers = userM.listUnregisteredUsersByGroup(getCurrentGroupID());
long currSiteGroupId = getSiteFromServletRequest(getThreadLocalRequest()).getGroupId();
List<GCubeUser> nonBelongingUsers = userM.listUsersByGroup(currSiteGroupId); //the users of i-marine or services etc
nonBelongingUsers.removeAll(userM.listUsersByGroup(getCurrentGroupID()));
for (GCubeUser u : nonBelongingUsers) {
String id = u.getUsername();
User user = UserLocalServiceUtil.getUserByScreenName(companyId, id);
String position = "";
@ -170,10 +204,11 @@ public class ManageUsersServiceImpl extends RemoteServiceServlet implements Man
public boolean registerUsers(List<PortalUserDTO> users2Register) {
for (PortalUserDTO user : users2Register) {
try {
long vreGroupId = getCurrentGroupID();
//add the user to the VRE
userM.assignUserToGroup(getCurrentGroupID(), userM.getUserId(user.getId()));
userM.assignUserToGroup(vreGroupId, userM.getUserId(user.getId()));
//send notification
sendNotificationToUser(user);
sendNotificationToUser(vreGroupId, user);
}
catch (Exception e) {
e.printStackTrace();
@ -188,7 +223,7 @@ public class ManageUsersServiceImpl extends RemoteServiceServlet implements Man
* @return
* @throws Exception
*/
private boolean sendNotificationToUser(PortalUserDTO addressee) throws Exception {
private boolean sendNotificationToUser(long groupId, PortalUserDTO addressee) throws Exception {
ASLSession session = getASLSession();
Workspace workspace = HomeLibrary.getUserWorkspace(session.getUsername());
@ -198,8 +233,13 @@ public class ManageUsersServiceImpl extends RemoteServiceServlet implements Man
List<GenericItemBean> recipients = new ArrayList<GenericItemBean>();
recipients.add(new GenericItemBean(addressee.getId(), addressee.getId(), addressee.getName() + " " + addressee.getLastName(), ""));
String subject = "Registration to Group Notification";
String body = "Dear "+addressee.getName()+", \n\n" + session.getUserFullName() + " has registered you to the group " + session.getGroupName()+".";
String gatewayName = PortalContext.getConfiguration().getGatewayName(getThreadLocalRequest());
String gatewayURL = PortalContext.getConfiguration().getGatewayURL(getThreadLocalRequest());
String vreURL = gatewayURL + "/group" + new LiferayGroupManager().getGroup(groupId).getFriendlyURL();
String subject = "Registration to VRE notification";
String body = "Dear "+addressee.getName()+", \n\n I just registered you to the VRE " + session.getGroupName()+" on the " + gatewayName + ". \n\n";
body += "Please, click here to access the VRE: " + vreURL;
String messageId = workspace.getWorkspaceMessageManager().sendMessageToPortalLogins(subject, body, new ArrayList<String>(), recipientIds);
_log.debug("Sending message notification to: " + recipientIds.toString());

View File

@ -9,10 +9,6 @@
<!-- Other module inherits -->
<inherits name='com.extjs.gxt.ui.GXT' />
<inherits name='com.extjs.gxt.themes.Themes' />
<!-- Specify the app entry point class. -->
<inherits name='com.google.gwt.activity.Activity' />
<inherits name="com.github.gwtbootstrap.Bootstrap" />
<inherits name="org.gcube.portlets.widgets.inviteswidget.InvitesWidget"/>
<!-- inherits GCUBE Widgets -->
<inherits name='org.gcube.portlets.user.gcubewidgets.WidgetFactory' />

View File

@ -1,5 +1,5 @@
@import url(newtheme.css);
@import url(coherence.css);
.approve-icon {
background-image:url(images/vre_approve.png) !important;
}

View File

@ -9,19 +9,11 @@
<servlet-class>org.gcube.portlets.admin.manageusers.server.ManageUsersServiceImpl</servlet-class>
</servlet>
<!-- Servlets -->
<servlet>
<servlet-name>greetServlet</servlet-name>
<servlet-class>org.gcube.portlets.widgets.inviteswidget.server.InviteServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>manageUsersServlet</servlet-name>
<url-pattern>/managevreusers/manageUsersServlet</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>greetServlet</servlet-name>
<url-pattern>/managevreusers/greet</url-pattern>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>

View File

@ -0,0 +1,93 @@
#bottombar {
width: 100% !important;
}
.x-menubar {
background-image: none;
background-color: #FFF;
}
.x-panel-body-noheader {
border-radius: 5px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
}
.x-border-layout-ct {
background-color: transparent;
border-color: transparent;
}
.x-toolbar {
border-color: transparent;
background-image: none;
background-color: #FFF;
}
.x-panel-header {
background-image: none;
background-color: #FFF;
}
.x-toolbar .xtb-sep {
background-image: none !important;
background-color: transparent;
}
.x-accordion-hd {
background-position: 0 0px;
}
.x-status-text,.x-tree3-node-text,.x-status .x-status-text,.x-toolbar label,.x-component,.x-btn button
{
color: #4c68a6;
font-family: "HelveticaNeue-Light", "Helvetica Neue Light",
"Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-weight: 300;
font-size: 12px !important;
}
.x-grid-group-hd .x-grid-group-div {
color: #4c68a6;
font-family: "HelveticaNeue-Light", "Helvetica Neue Light",
"Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-weight: normal;
font-size: 12px !important;
}
.x-status-text-panel {
border-color: transparent;
}
.x-panel-mc {
padding-top: 5px;
background: #FFF url(images/bg-pattern.png) repeat;
border-color: #226599;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
.ext-el-mask-msg {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
border-width: 2px;
background-color: #FFF;
background-image: none;
}
.ext-el-mask-msg div {
color: #4c68a6;
font-family: "HelveticaNeue-Light", "Helvetica Neue Light",
"Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-weight: 300;
font-size: 12px !important;
border-color: transparent;
background-color: transparent;
}
.loading-indicator {
background-position: 5px 50%;
background-image: url("images/loader.gif");
}