Converting VREMember Portlet to JoinVRE needs

git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/join-vre@112302 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2015-03-03 10:21:17 +00:00
parent ed2e2b8cee
commit e5e79fa0cb
37 changed files with 511 additions and 464 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<projectDescription> <projectDescription>
<name>vre-members</name> <name>join-vre</name>
<comment>vre-members project</comment> <comment>vre-members project</comment>
<projects> <projects>
</projects> </projects>

View File

@ -4,10 +4,7 @@
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/> <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/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/> <wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="gcube-widgets-1.9.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/gcube-widgets/gcube-widgets">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/> <property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
<property name="context-root" value="vre-members"/> <property name="context-root" value="join-vre"/>
</wb-module> </wb-module>
</project-modules> </project-modules>

View File

@ -4,3 +4,5 @@ Mantainers
* Massimiliano Assante (massimiliano.assante@isti.cnr.it), CNR Pisa, * Massimiliano Assante (massimiliano.assante@isti.cnr.it), CNR Pisa,
Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo". Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo".
* Luca Frosini (luca.frosini@isti.cnr.it), CNR Pisa,
Istituto di Scienza e Tecnologie dell'Informazione "A. Faedo".

View File

@ -6,7 +6,8 @@ context of the iMarine project (www.i-marine.eu), under the 1st call of FP7 IST
Authors Authors
------- -------
Massimiliano Assante Massimiliano Assante
Luca Frosini
* *
Version and Release Date Version and Release Date
------------------------ ------------------------
@ -20,7 +21,7 @@ Description
Download information Download information
-------------------- --------------------
Source code is available from SVN: Source code is available from SVN:
https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/notifications {$scm}
Binaries can be downloaded from: Binaries can be downloaded from:
http://software.d4science.research-infrastructures.eu/ http://software.d4science.research-infrastructures.eu/

View File

@ -1,11 +1,6 @@
<ReleaseNotes> <ReleaseNotes>
<Changeset component="org.gcube.portlet.user.vre-members.1-0-1" <Changeset component="org.gcube.portlet.user.joinvre.1-0-0"
date="2014-12-13"> date="2015-03-02">
<Change>Added Client scope handler, to set the scope from the client
and help preventing the browser back button cache problem</Change>
</Changeset>
<Changeset component="org.gcube.portlet.user.vre-members.1-0-0"
date="2014-09-09">
<Change>First Release</Change> <Change>First Release</Change>
</Changeset> </Changeset>
</ReleaseNotes> </ReleaseNotes>

View File

@ -3,7 +3,7 @@
<ID></ID> <ID></ID>
<Type>Service</Type> <Type>Service</Type>
<Profile> <Profile>
<Description>gCube VRE Members Portlet</Description> <Description>gCube Join VRE Portlet</Description>
<Class>PortletUser</Class> <Class>PortletUser</Class>
<Name>${artifactId}</Name> <Name>${artifactId}</Name>
<Version>${version}</Version> <Version>${version}</Version>

View File

@ -11,7 +11,7 @@
</parent> </parent>
<groupId>org.gcube.portlets.user</groupId> <groupId>org.gcube.portlets.user</groupId>
<artifactId>vre-members</artifactId> <artifactId>join-vre</artifactId>
<packaging>war</packaging> <packaging>war</packaging>
<version>1.0.1-SNAPSHOT</version> <version>1.0.1-SNAPSHOT</version>
<name>gCube VRE Members Portlet</name> <name>gCube VRE Members Portlet</name>
@ -49,12 +49,14 @@
<dependency> <dependency>
<groupId>com.google.gwt</groupId> <groupId>com.google.gwt</groupId>
<artifactId>gwt-user</artifactId> <artifactId>gwt-user</artifactId>
<version>2.7.0</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.google.gwt</groupId> <groupId>com.google.gwt</groupId>
<artifactId>gwt-servlet</artifactId> <artifactId>gwt-servlet</artifactId>
<scope>provided</scope> <version>2.7.0</version>
<scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.portlets.user</groupId> <groupId>org.gcube.portlets.user</groupId>

View File

@ -0,0 +1,20 @@
package org.gcube.portlets.user.joinvre.client;
import java.util.ArrayList;
import org.gcube.portlets.user.vremembers.shared.VRE;
import com.google.gwt.user.client.rpc.RemoteService;
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("memberservice")
public interface JoinService extends RemoteService {
ArrayList<VRE> getVREs();
}

View File

@ -0,0 +1,16 @@
package org.gcube.portlets.user.joinvre.client;
import java.util.ArrayList;
import org.gcube.portlets.user.vremembers.shared.VRE;
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<ArrayList<VRE>> callback);
}

View File

@ -1,7 +1,7 @@
package org.gcube.portlets.user.vremembers.client; package org.gcube.portlets.user.joinvre.client;
import org.gcube.portlets.user.gcubewidgets.client.ClientScopeHelper; import org.gcube.portlets.user.gcubewidgets.client.ClientScopeHelper;
import org.gcube.portlets.user.vremembers.client.panels.VREMembersPanel; import org.gcube.portlets.user.joinvre.client.panels.JoinVREPanel;
import com.google.gwt.core.client.EntryPoint; import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Window.Location; import com.google.gwt.user.client.Window.Location;
@ -10,14 +10,18 @@ import com.google.gwt.user.client.ui.RootPanel;
/** /**
* Entry point classes define <code>onModuleLoad()</code>. * Entry point classes define <code>onModuleLoad()</code>.
* @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*/ */
public class VreMembers implements EntryPoint { public class JoinVRE implements EntryPoint {
public void onModuleLoad() { public void onModuleLoad() {
ClientScopeHelper.getService().setScope(Location.getHref(), new AsyncCallback<Boolean>() { ClientScopeHelper.getService().setScope(Location.getHref(), new AsyncCallback<Boolean>() {
@Override @Override
public void onSuccess(Boolean result) { public void onSuccess(Boolean result) {
RootPanel.get("VRE-Members-Container").add(new VREMembersPanel()); // TODO
RootPanel.get("JoinVRE-Container").add(new JoinVREPanel());
} }
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {

View File

@ -1,16 +1,15 @@
package org.gcube.portlets.user.vremembers.client.panels; package org.gcube.portlets.user.joinvre.client.panels;
import java.util.ArrayList; import java.util.ArrayList;
import org.gcube.portlets.user.vremembers.client.MembersService; import org.gcube.portlets.user.joinvre.client.JoinService;
import org.gcube.portlets.user.vremembers.client.MembersServiceAsync; import org.gcube.portlets.user.joinvre.client.JoinServiceAsync;
import org.gcube.portlets.user.vremembers.client.ui.DisplayBadge; import org.gcube.portlets.user.joinvre.client.ui.DisplayVRE;
import org.gcube.portlets.user.vremembers.shared.BelongingUser; import org.gcube.portlets.user.vremembers.shared.VRE;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Composite; import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Grid; import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HTML; import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasAlignment; import com.google.gwt.user.client.ui.HasAlignment;
@ -18,39 +17,49 @@ import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.user.client.ui.VerticalPanel;
public class VREMembersPanel extends Composite { /**
* @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*/
public class JoinVREPanel extends Composite {
/** /**
* Create a remote service proxy to talk to the server-side Greeting service. * Create a remote service proxy to talk to the server-side Greeting service.
*/ */
private final MembersServiceAsync vreMemberService = GWT.create(MembersService.class); private final JoinServiceAsync joinService = GWT.create(JoinService.class);
public static final String loading = GWT.getModuleBaseURL() + "../images/members-loader.gif"; public static final String loading = GWT.getModuleBaseURL() + "../images/members-loader.gif";
private Image loadingImage; private Image loadingImage;
private VerticalPanel mainPanel = new VerticalPanel(); private VerticalPanel mainPanel = new VerticalPanel();
public VREMembersPanel() { public JoinVREPanel() {
super(); super();
loadingImage = new Image(loading); loadingImage = new Image(loading);
mainPanel.add(loadingImage); mainPanel.add(loadingImage);
showLoader(); showLoader();
vreMemberService.getOrganizationUsers(new AsyncCallback<ArrayList<BelongingUser>>() { joinService.getVREs(new AsyncCallback<ArrayList<VRE>>() {
@Override @Override
public void onSuccess(ArrayList<BelongingUser> users) { public void onSuccess(ArrayList<VRE> vres) {
mainPanel.clear(); mainPanel.clear();
mainPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT); mainPanel.setHorizontalAlignment(HasAlignment.ALIGN_LEFT);
mainPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP); mainPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_TOP);
if (users == null || users.isEmpty()) {
// TODO
if (vres == null || vres.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>")); 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>"));
} else { } else {
Grid grid = new Grid(users.size()/4+1, 4); Grid grid = new Grid(vres.size()/4+1, 4);
mainPanel.add(grid); mainPanel.add(grid);
for (int i = 0; i < users.size(); i++) { for (int i = 0; i < vres.size(); i++) {
grid.setWidget(i/4, i%4, new DisplayBadge(users.get(i))); grid.setWidget(i/4, i%4, new DisplayVRE(vres.get(i)));
} }
} }
} }
@Override @Override

View File

@ -0,0 +1,64 @@
package org.gcube.portlets.user.joinvre.client.ui;
import org.gcube.portlets.user.vremembers.shared.VRE;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.AnchorElement;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Widget;
/**
* @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*
*/
public class DisplayVRE extends Composite {
protected final static String HEADLINE_TEXT = "Professional Headline";
protected final static String ISTI_TEXT = "Company";
private static DisplayBadgeUiBinder uiBinder = GWT.create(DisplayBadgeUiBinder.class);
interface DisplayBadgeUiBinder extends UiBinder<Widget, DisplayVRE> {}
// TODO Change This
public static final String avatar_default = GWT.getModuleBaseURL() + "../images/Avatar_default.png";
public static final String loading = GWT.getModuleBaseURL() + "../images/avatarLoader.gif";
@UiField HTMLPanel mainPanel;
@UiField Image vreImage;
@UiField AnchorElement vreName;
public DisplayVRE(VRE vre) {
vreImage.setUrl(loading);
initWidget(uiBinder.createAndBindUi(this));
vreImage.setUrl(loading);
vreImage.setUrl(vre.getImageURL());
vreImage.setTitle(vre.getName());
vreName.setTitle(vre.getName());
vreName.setHref(vre.getFriendlyURL());
vreName.setInnerText(vre.getName());
}
public void showError(String message) {
Window.alert("Failure: " + message);
vreImage.setSize("100px", "100px");
vreImage.setUrl(avatar_default);
}
}

View File

@ -0,0 +1,16 @@
<!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:m="urn:import:org.gcube.portlets.user.gcubewidgets.client.elements">
<g:HTMLPanel ui:field="mainPanel" styleName="framed">
<div class="vreImageDetails">
<g:Image title="VRE Image" styleName="vreImage" url=""
ui:field="vreImage" />
</div>
<div class="vreDetails">
<a href="" styleName="vreName" ui:field="vreName"></a>
</div>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -1,15 +0,0 @@
package org.gcube.portlets.user.vremembers.client;
import java.util.ArrayList;
import org.gcube.portlets.user.vremembers.shared.BelongingUser;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
/**
* The client side stub for the RPC service.
*/
@RemoteServiceRelativePath("memberservice")
public interface MembersService extends RemoteService {
ArrayList<BelongingUser> getOrganizationUsers();
}

View File

@ -1,13 +0,0 @@
package org.gcube.portlets.user.vremembers.client;
import java.util.ArrayList;
import org.gcube.portlets.user.vremembers.shared.BelongingUser;
import com.google.gwt.user.client.rpc.AsyncCallback;
public interface MembersServiceAsync {
void getOrganizationUsers(AsyncCallback<ArrayList<BelongingUser>> callback);
}

View File

@ -1,72 +0,0 @@
package org.gcube.portlets.user.vremembers.client.ui;
import org.gcube.portlets.user.vremembers.shared.BelongingUser;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.AnchorElement;
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.Window;
import com.google.gwt.user.client.Window.Location;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HTMLPanel;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Widget;
public class DisplayBadge extends Composite {
protected final static String HEADLINE_TEXT = "Professional Headline";
protected final static String ISTI_TEXT = "Company";
private static DisplayBadgeUiBinder uiBinder = GWT.create(DisplayBadgeUiBinder.class);
interface DisplayBadgeUiBinder extends UiBinder<Widget, DisplayBadge> {
}
public static final String avatar_default = GWT.getModuleBaseURL() + "../images/Avatar_default.png";
public static final String loading = GWT.getModuleBaseURL() + "../images/avatarLoader.gif";
@UiField HTMLPanel mainPanel;
@UiField Image avatarImage;
@UiField HTML userFullName;
@UiField HTML headlineLabel;
@UiField HTML institutionLabel;
@UiField AnchorElement imageRedirect;
private BelongingUser myUserInfo;
public DisplayBadge(BelongingUser user) {
initWidget(uiBinder.createAndBindUi(this));
avatarImage.setUrl(loading);
mainPanel.addStyleName("profile-section");
myUserInfo = user;
avatarImage.getElement().getParentElement().setAttribute("href", myUserInfo.getAvatarId());
avatarImage.setUrl(myUserInfo.getAvatarId());
userFullName.setHTML("<a class=\"person-link\" href=\""+user.getProfileLink()+"\">"+myUserInfo.getFullName()+"</a>");
String head = (user.getHeadline() == null || user.getHeadline().compareTo("") == 0) ? "" : user.getHeadline();
String isti = (user.getInstitution() == null || user.getInstitution().compareTo("") == 0) ? "" : user.getInstitution();
headlineLabel.setText(head);
institutionLabel.setText(isti);
imageRedirect.setHref(user.getProfileLink());
String title = "See profile of " + myUserInfo.getFullName();
avatarImage.setTitle(title);
userFullName.setTitle(title);
}
public void showError(String message) {
Window.alert("Failure: " + message);
avatarImage.setSize("100px", "100px");
avatarImage.setUrl(avatar_default);
}
}

View File

@ -1,18 +0,0 @@
<!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:m="urn:import:org.gcube.portlets.user.gcubewidgets.client.elements">
<g:HTMLPanel ui:field="mainPanel" styleName="framed">
<div class="photo-details">
<a ui:field="imageRedirect" href="">
<g:Image title="Profile Picture" styleName="user-photo" url=""
ui:field="avatarImage" />
</a>
</div>
<div class="user-details">
<g:HTML styleName="fullName" ui:field="userFullName"></g:HTML>
<g:HTML styleName="headline" ui:field="headlineLabel"></g:HTML>
<g:HTML styleName="institution" ui:field="institutionLabel"></g:HTML>
</div>
</g:HTMLPanel>
</ui:UiBinder>

View File

@ -0,0 +1,91 @@
package org.gcube.portlets.user.vremembers.server;
import java.util.ArrayList;
import java.util.Collections;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.session.SessionManager;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
import org.gcube.portlets.user.joinvre.client.JoinService;
import org.gcube.portlets.user.vremembers.shared.UserBelonging;
import org.gcube.portlets.user.vremembers.shared.VRE;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.liferay.portal.service.UserLocalServiceUtil;
/**
* @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 final Logger _log = LoggerFactory.getLogger(JoinServiceImpl.class);
/**
* the current ASLSession
* @return the session
*/
private ASLSession getASLSession() {
String sessionID = this.getThreadLocalRequest().getSession().getId();
String user = (String) this.getThreadLocalRequest().getSession().getAttribute(ScopeHelper.USERNAME_ATTRIBUTE);
if (user == null) {
_log.warn("USER IS NULL setting test.user and Running OUTSIDE PORTAL");
user = getDevelopmentUser();
SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube");
}
return SessionManager.getInstance().getASLSession(sessionID, user);
}
/**
* when packaging test will fail if the user is not set to test.user
* @return .
*/
public String getDevelopmentUser() {
String user = "test.user";
return user;
}
/**
*
* @return true if you're running into the portal, false if in development
*/
private boolean isWithinPortal() {
try {
UserLocalServiceUtil.getService();
return true;
} catch (com.liferay.portal.kernel.bean.BeanLocatorException ex) {
_log.trace("Development Mode ON");
return false;
}
}
/**
*
* @param session the Asl Session
* @param withinPortal true when is on Liferay portal
* @return the users belonging to the current organization (scope)
*/
@Override
public ArrayList<VRE> getVREs() {
ArrayList<VRE> vres = new ArrayList<VRE>();
try {
if (isWithinPortal()) {
} else {
vres.add(new VRE(0, "devsec", "devsec VRE", "", "", "/group/devsec", UserBelonging.NOT_BELONGING, false));
vres.add(new VRE(0, "devVRE", "devVRE VRE", "", "", "/group/devVRE", UserBelonging.NOT_BELONGING, false));
vres.add(new VRE(0, "devmode", "devmode VRE", "", "", "/group/devmode", UserBelonging.NOT_BELONGING, true));
}
} catch (Exception e) {
_log.error("Error in server get all contacts ", e);
}
// Ordering VREs by Name
Collections.sort(vres);
return vres;
}
}

View File

@ -1,143 +0,0 @@
package org.gcube.portlets.user.vremembers.server;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
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.common.scope.impl.ScopeBean;
import org.gcube.common.scope.impl.ScopeBean.Type;
import org.gcube.portal.custom.communitymanager.OrganizationsUtil;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
import org.gcube.portal.databook.client.GCubeSocialNetworking;
import org.gcube.portlets.user.vremembers.client.MembersService;
import org.gcube.portlets.user.vremembers.shared.BelongingUser;
import org.gcube.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.UserManager;
import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayGroupManager;
import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayUserManager;
import org.gcube.vomanagement.usermanagement.model.UserModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.liferay.portal.service.UserLocalServiceUtil;
/**
* @author Massimiliano Assante, ISTI-CNR
*/
@SuppressWarnings("serial")
public class MembersServiceImpl extends RemoteServiceServlet implements MembersService {
private static final Logger _log = LoggerFactory.getLogger(MembersServiceImpl.class);
/**
* the current ASLSession
* @return the session
*/
private ASLSession getASLSession() {
String sessionID = this.getThreadLocalRequest().getSession().getId();
String user = (String) this.getThreadLocalRequest().getSession().getAttribute(ScopeHelper.USERNAME_ATTRIBUTE);
if (user == null) {
_log.warn("USER IS NULL setting test.user and Running OUTSIDE PORTAL");
user = getDevelopmentUser();
SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube");
}
return SessionManager.getInstance().getASLSession(sessionID, user);
}
/**
* when packaging test will fail if the user is not set to test.user
* @return .
*/
public String getDevelopmentUser() {
String user = "test.user";
//user = "massimiliano.assante";
return user;
}
/**
*
* @return true if you're running into the portal, false if in development
*/
private boolean isWithinPortal() {
try {
UserLocalServiceUtil.getService();
return true;
}
catch (com.liferay.portal.kernel.bean.BeanLocatorException ex) {
_log.trace("Development Mode ON");
return false;
}
}
/**
*
* @param session the Asl Session
* @param withinPortal true when is on Liferay portal
* @return the users belonging to the current organization (scope)
*/
@Override
public ArrayList<BelongingUser> getOrganizationUsers() {
ArrayList<BelongingUser> portalUsers = new ArrayList<BelongingUser>();
String scope = getASLSession().getScope();
if (scope == null)
return portalUsers;
try {
if (isWithinPortal()) {
UserManager um = new LiferayUserManager();
GroupManager gm = new LiferayGroupManager();
ScopeBean sb = new ScopeBean(scope);
List<UserModel> users = null;
if (sb.is(Type.INFRASTRUCTURE)) {
users = new ArrayList<UserModel>();
return new ArrayList<BelongingUser>();
}
else if (sb.is(Type.VRE)) { //must be in VRE
//get the name from the scope
String orgName = scope.substring(scope.lastIndexOf("/")+1, scope.length());
//ask the users
users = um.listUsersByGroup(gm.getGroupId(orgName));
}
else {
_log.error("Error, you must be in SCOPE VRE OR INFRASTURCTURE, you are in VO SCOPE returning no users");
return portalUsers;
}
for (UserModel user : users) {
if (user.getScreenName().compareTo("test.user") != 0) { //skip test.user
String thumbnailURL = "";
com.liferay.portal.model.User lifeUser = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), user.getScreenName());
thumbnailURL = lifeUser.isMale() ? "/image/user_male_portrait?img_id="+lifeUser.getPortraitId() : "/image/user_female_portrait?img_id="+lifeUser.getPortraitId();
portalUsers.add(new BelongingUser(user.getScreenName(), user.getFullname(), thumbnailURL, lifeUser.getJobTitle(), lifeUser.getOpenId(), getUserProfileLink(user.getScreenName() ),lifeUser.getPortraitId() != 0));
}
}
}
else { //test users
portalUsers.add(new BelongingUser("massimiliano.assante", "Test User #1", "1111", "headline", "isti", "",false));
portalUsers.add(new BelongingUser("pino.assante", "Test Second User #2", "1111", "headline1", "istitution complex", "",false));
portalUsers.add(new BelongingUser("pino.pino", "With Photo Third User", "1111", "hard worker", "acme Ltd", "",true));
portalUsers.add(new BelongingUser("giorgi.giorgi", "Test Fourth User", "1111", "hard worker 3", "isti3", "",false));
portalUsers.add(new BelongingUser("pinetti.giorgi", "Test Fifth User", "1111", "hard worker 4", "super acme Inc.", "",false));
portalUsers.add(new BelongingUser("massimiliano.pinetti", "Test Sixth User", "1111", "hard worker the5th", "istiw", "", false));
portalUsers.add(new BelongingUser("giorgi.assante", "Ninth Testing User", "1111", "hard worker the9th", "istiw9", "",false));
portalUsers.add(new BelongingUser("massimiliano.giorgi", "Eighth Testing User", "1111", "hard worker the8th", "istiw56", "", false));
portalUsers.add(new BelongingUser("giogio.giorgi", "Seventh Test User", "1111", "hard worker the7th", "istiw7", "", false));
portalUsers.add(new BelongingUser("pino.pinetti", "Tenth Testing User Photoed", "1111", "hard worker the10th", "istiw777", "",true));
}
} catch (Exception e) {
_log.error("Error in server get all contacts ", e);
}
//users having photo go first
Collections.sort(portalUsers);
return portalUsers;
}
private String getUserProfileLink(String username) {
return (username.compareTo(getASLSession().getUsername()) != 0) ?
"profile?"+ new String(Base64.encodeBase64(GCubeSocialNetworking.USER_PROFILE_OID.getBytes()))+"="+new String(Base64.encodeBase64(username.getBytes()))
: GCubeSocialNetworking.USER_PROFILE_LINK;
}
}

View File

@ -13,14 +13,15 @@ import javax.portlet.PortletRequestDispatcher;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
/** /**
*
* @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it * @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*/ */
public class VREMembersPortlet extends GenericPortlet { public class JoinVREPortlet extends GenericPortlet {
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException { public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
response.setContentType("text/html"); response.setContentType("text/html");
ScopeHelper.setContext(request); ScopeHelper.setContext(request);
PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/VREMembers_view.jsp"); PortletRequestDispatcher dispatcher = getPortletContext().getRequestDispatcher("/WEB-INF/jsp/JoinVRE_view.jsp");
dispatcher.include(request, response); dispatcher.include(request, response);
} }

View File

@ -1,126 +0,0 @@
package org.gcube.portlets.user.vremembers.shared;
import java.io.Serializable;
import java.util.Comparator;
@SuppressWarnings("serial")
public class BelongingUser implements Serializable, Comparable<BelongingUser> {
private String username;
private String fullName;
private String avatarId;
private String headline;
private String institution;
private String profileLink;
private boolean hasPhoto;
public BelongingUser(String username, String fullName, String avatarId,
String headline, String institution, String profileLink, boolean hasPhoto) {
super();
this.username = username;
this.fullName = fullName;
this.avatarId = avatarId;
this.headline = headline;
this.institution = institution;
this.hasPhoto = hasPhoto;
this.profileLink = profileLink;
}
public BelongingUser() {
super();
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public String getAvatarId() {
return avatarId;
}
public void setAvatarId(String avatarId) {
this.avatarId = avatarId;
}
public String getHeadline() {
return headline;
}
public void setHeadline(String headline) {
this.headline = headline;
}
public String getInstitution() {
return institution;
}
public void setInstitution(String institution) {
this.institution = institution;
}
public boolean hasPhoto() {
return hasPhoto;
}
public void setHasPhoto(boolean hasPhoto) {
this.hasPhoto = hasPhoto;
}
public String getProfileLink() {
return profileLink;
}
public void setProfileLink(String profileLink) {
this.profileLink = profileLink;
}
@Override
public int compareTo(BelongingUser o) {
if (this.hasHeadline() && !o.hasHeadline()) {
return -1;
}
if (!this.hasHeadline() && o.hasHeadline())
return 1;
if ( (this.hasHeadline() && o.hasHeadline()) || ((!this.hasHeadline() && !o.hasHeadline())) ) {
if (this.hasPhoto && !o.hasPhoto)
return -1;
if (!this.hasPhoto && o.hasPhoto)
return 1;
return 0;
}
return 0;
}
private boolean hasHeadline() {
return (headline != null && headline.compareTo("") != 0);
}
}

View File

@ -0,0 +1,84 @@
package org.gcube.portlets.user.vremembers.shared;
import java.io.Serializable;
/**
* @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
*/
@SuppressWarnings("serial")
public class ResearchEnvironment implements Serializable {
private String name;
private String description;
private String imageURL;
private String groupName;
private String friendlyURL;
private UserBelonging userBelonging;
public ResearchEnvironment() {
super();
}
public ResearchEnvironment(String name, String description,
String imageURL, String groupName, String friendlyURL,
UserBelonging userBelonging) {
super();
this.name = name;
this.description = description;
this.imageURL = imageURL;
this.groupName = groupName;
this.friendlyURL = friendlyURL;
this.userBelonging = userBelonging;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getImageURL() {
return imageURL;
}
public void setImageURL(String imageURL) {
this.imageURL = imageURL;
}
public String getGroupName() {
return groupName;
}
public void setGroupName(String groupName) {
this.groupName = groupName;
}
public String getFriendlyURL() {
return friendlyURL;
}
public void setFriendlyURL(String friendlyURL) {
this.friendlyURL = friendlyURL;
}
public UserBelonging getUserBelonging() {
return userBelonging;
}
public void setUserBelonging(UserBelonging userBelonging) {
this.userBelonging = userBelonging;
}
}

View File

@ -0,0 +1,8 @@
package org.gcube.portlets.user.vremembers.shared;
/**
* @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
*/
public enum UserBelonging {
BELONGING, NOT_BELONGING, PENDING
}

View File

@ -0,0 +1,68 @@
package org.gcube.portlets.user.vremembers.shared;
import java.io.Serializable;
import java.util.ArrayList;
/**
* @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
*/
@SuppressWarnings("serial")
public class VO extends ResearchEnvironment implements Comparable<VO>, Serializable{
private boolean isRoot;
private ArrayList<VRE> vres = new ArrayList<VRE>();
/**
*
*/
public VO() {
super();
}
/**
*
* @param voName .
* @param description .
* @param imageURL .
* @param vomsGroupName .
* @param friendlyURL .
* @param userBelonging .
* @param isRoot .
* @param vres .
*/
public VO(String voName, String description, String imageURL,
String vomsGroupName, String friendlyURL,
UserBelonging userBelonging, boolean isRoot, ArrayList<VRE> vres) {
super(voName, description, imageURL, vomsGroupName, friendlyURL, userBelonging);
this.isRoot = isRoot;
this.vres = vres;
}
public boolean isRoot() {
return isRoot;
}
public void setRoot(boolean isRoot) {
this.isRoot = isRoot;
}
public ArrayList<VRE> getVres() {
return vres;
}
public void setVres(ArrayList<VRE> vres) {
this.vres = vres;
}
/**
*
* @param toAdd
*/
public void addVRE(VRE toAdd) {
if (vres == null)
vres = new ArrayList<VRE>();
vres.add(toAdd);
}
/**
* compare the number of vres
*/
public int compareTo(VO voToCompare) {
return (this.vres.size() >= voToCompare.getVres().size()) ? 1 : -1;
}
}

View File

@ -0,0 +1,64 @@
package org.gcube.portlets.user.vremembers.shared;
import java.io.Serializable;
/**
* @author Massimiliano Assante, ISTI-CNR - massimiliano.assante@isti.cnr.it
* @author Luca Frosini (ISTI - CNR) http://www.lucafrosini.com/
*/
@SuppressWarnings("serial")
public class VRE extends ResearchEnvironment implements Serializable, Comparable<VRE> {
private boolean uponRequest;
private long id;
public VRE() {
super();
this.uponRequest = true;
}
/**
*
* @param vreName
* @param description
* @param imageURL
* @param vomsGroupName
* @param friendlyURL
* @param userBelonging
*/
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);
this.uponRequest = uponRequest;
this.id = id;
}
public boolean isUponRequest() {
return uponRequest;
}
public void setUponRequest(boolean uponRequest) {
this.uponRequest = uponRequest;
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
@Override
public String toString() {
return "VRE [getName()=" + getName()
+ ", uponRequest=" + uponRequest+"]";
}
@Override
public int compareTo(VRE o) {
return this.getName().compareTo(o.getName());
}
}

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<module rename-to='vremembers'> <module rename-to='joinvre'>
<!-- Inherit the core Web Toolkit stuff. --> <!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' /> <inherits name='com.google.gwt.user.User' />
@ -10,7 +10,7 @@
<!-- Other module inherits --> <!-- Other module inherits -->
<!-- Specify the app entry point class. --> <!-- Specify the app entry point class. -->
<entry-point class='org.gcube.portlets.user.vremembers.client.VreMembers' /> <entry-point class='org.gcube.portlets.user.joinvre.client.JoinVRE' />
<!-- Specify the paths for translatable code --> <!-- Specify the paths for translatable code -->
<source path='client' /> <source path='client' />

View File

@ -1,5 +1,4 @@
.framed { .framed {
font-family: 'Helvetica Neue', Arial, sans-serif;
width: 200px; width: 200px;
height: 290px; height: 290px;
padding: 10px; padding: 10px;
@ -12,7 +11,6 @@
} }
.frame { .frame {
font-family: 'Helvetica Neue', Arial, sans-serif;
padding: 10px; padding: 10px;
margin: 10px; margin: 10px;
background: #FFF; background: #FFF;
@ -22,31 +20,30 @@
border: 1px solid #DBDBDB; border: 1px solid #DBDBDB;
} }
.user-photo { .vreImage {
padding: 5px; padding: 5px;
border: 1px solid #E6E6E6; border: 1px solid #E6E6E6;
width: 180px; width: 180px;
height: 175px; height: 175px;
} }
.user-details { .vreImageDetails {
padding: 5px;
}
.photo-details {
width: 200px; width: 200px;
text-align: center; text-align: center;
} }
.vreDetails {
padding: 5px;
}
a.person-link { a.vreName {
color: #444444; color: #444444;
font-size: 15px; font-size: 15px;
font-weight: bold; font-weight: bold;
line-height: 18px; line-height: 18px;
} }
a.person-link,a.person-link:visited { a.vreName, a.vreName:visited {
cursor: pointer; cursor: pointer;
cursor: hand; cursor: hand;
font-size: 16x; font-size: 16x;
@ -54,20 +51,15 @@ a.person-link,a.person-link:visited {
color: #3B5998; color: #3B5998;
} }
a.person-link:hover { a.vreName:hover {
opacity: 0.8; opacity: 0.8;
font-size: 16x; font-size: 16x;
text-decoration: underline; text-decoration: underline;
} }
.headline { .vreDescription {
font-size: 13px; font-size: 13px;
color: #444444; color: #444444;
line-height: 16px; line-height: 16px;
}
.institution {
font-size: 11px;
color: #444444;
} }

View File

@ -12,11 +12,11 @@
<!-- --> <!-- -->
<!-- Consider inlining CSS to reduce the number of requested files --> <!-- Consider inlining CSS to reduce the number of requested files -->
<!-- --> <!-- -->
<link type="text/css" rel="stylesheet" href="VreMembers.css"> <link type="text/css" rel="stylesheet" href="JoinVRE.css">
<title>Vre Members Project</title> <title>Vre Members Project</title>
<script type="text/javascript" src="vremembers/vremembers.nocache.js"></script> <script type="text/javascript" src="joinvre/joinvre.nocache.js"></script>
</head> </head>
<body> <body>
@ -27,7 +27,7 @@
Your web browser must have JavaScript enabled in order for this Your web browser must have JavaScript enabled in order for this
application to display correctly.</div> application to display correctly.</div>
</noscript> </noscript>
<div id="VRE-Members-Container"></div> <div id="JoinVRE-Container"></div>
</body> </body>
</html> </html>

View File

@ -2,5 +2,5 @@
<%@page pageEncoding="UTF-8"%> <%@page pageEncoding="UTF-8"%>
<script type="text/javascript" language="javascript" src="<%=request.getContextPath()%>/vremembers/vremembers.nocache.js""></script> <script type="text/javascript" language="javascript" src="<%=request.getContextPath()%>/joinvre/joinvre.nocache.js""></script>
<div id="VRE-Members-Container"></div> <div id="JoinVRE-Container"></div>

View File

@ -3,6 +3,6 @@
<display> <display>
<category name="gCube Social Apps"> <category name="gCube Social Apps">
<portlet id="VREMembers" /> <portlet id="joinVRE" />
</category> </category>
</display> </display>

View File

@ -1,4 +1,4 @@
name=VREMembers name=JoinVRE
module-group-id=liferay module-group-id=liferay
module-incremental-version=1 module-incremental-version=1
tags= tags=

View File

@ -3,11 +3,11 @@
<liferay-portlet-app> <liferay-portlet-app>
<portlet> <portlet>
<portlet-name>VREMembers</portlet-name> <portlet-name>JoinVRE</portlet-name>
<layout-cacheable>false</layout-cacheable> <layout-cacheable>false</layout-cacheable>
<instanceable>false</instanceable> <instanceable>false</instanceable>
<ajaxable>false</ajaxable> <ajaxable>false</ajaxable>
<header-portlet-css>/VreMembers.css</header-portlet-css> <header-portlet-css>/JoinVRE.css</header-portlet-css>
</portlet> </portlet>
<role-mapper> <role-mapper>
<role-name>administrator</role-name> <role-name>administrator</role-name>

View File

@ -7,9 +7,9 @@
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" 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>
<portlet-name>VREMembers</portlet-name> <portlet-name>JoinVRE</portlet-name>
<display-name>VRE Members</display-name> <display-name>Join VRE</display-name>
<portlet-class>org.gcube.portlets.user.vremembers.server.portlet.VREMembersPortlet</portlet-class> <portlet-class>org.gcube.portlets.user.joinvre.server.portlet.JoinVREPortlet</portlet-class>
<init-param> <init-param>
<name>view-jsp</name> <name>view-jsp</name>
<value>/view.jsp</value> <value>/view.jsp</value>
@ -19,9 +19,9 @@
<mime-type>text/html</mime-type> <mime-type>text/html</mime-type>
</supports> </supports>
<portlet-info> <portlet-info>
<title>VRE Members</title> <title>Join VRE</title>
<short-title>VRE Members</short-title> <short-title>Join VRE</short-title>
<keywords>VRE Members</keywords> <keywords>Join VRE</keywords>
</portlet-info> </portlet-info>
<security-role-ref> <security-role-ref>
<role-name>administrator</role-name> <role-name>administrator</role-name>

View File

@ -8,7 +8,7 @@
<!-- Servlets --> <!-- Servlets -->
<servlet> <servlet>
<servlet-name>greetServlet</servlet-name> <servlet-name>greetServlet</servlet-name>
<servlet-class>org.gcube.portlets.user.vremembers.server.MembersServiceImpl</servlet-class> <servlet-class>org.gcube.portlets.user.joinvre.server.JoinServiceImpl</servlet-class>
</servlet> </servlet>
<servlet> <servlet>
@ -18,17 +18,17 @@
<servlet-mapping> <servlet-mapping>
<servlet-name>greetServlet</servlet-name> <servlet-name>greetServlet</servlet-name>
<url-pattern>/vremembers/memberservice</url-pattern> <url-pattern>/joinvre/joinservice</url-pattern>
</servlet-mapping> </servlet-mapping>
<servlet-mapping> <servlet-mapping>
<servlet-name>scopeService</servlet-name> <servlet-name>scopeService</servlet-name>
<url-pattern>/vremembers/scopeService</url-pattern> <url-pattern>/joinvre/scopeService</url-pattern>
</servlet-mapping> </servlet-mapping>
<!-- Default page to serve --> <!-- Default page to serve -->
<welcome-file-list> <welcome-file-list>
<welcome-file>VreMembers.html</welcome-file> <welcome-file>JoinVRE.html</welcome-file>
</welcome-file-list> </welcome-file-list>
</web-app> </web-app>