This commit is contained in:
Massimiliano Assante 2013-05-08 16:16:43 +00:00
parent 4f4cb4f7b1
commit faa32cdb41
13 changed files with 222 additions and 60 deletions

View File

@ -63,6 +63,12 @@
<version>[1.4.0,1.6.0]</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>gcube-widgets</artifactId>
<version>[1.4.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.portal</groupId>
<artifactId>custom-portal-handler</artifactId>

View File

@ -1,5 +1,7 @@
package org.gcube.portlets.user.socialprofile.client;
import org.gcube.portal.databook.shared.UserInfo;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@ -8,5 +10,5 @@ import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
*/
@RemoteServiceRelativePath("greet")
public interface SocialService extends RemoteService {
UserInfo getUserInfo();
}

View File

@ -1,7 +1,11 @@
package org.gcube.portlets.user.socialprofile.client;
import org.gcube.portal.databook.shared.UserInfo;
import com.google.gwt.user.client.rpc.AsyncCallback;
public interface SocialServiceAsync {
void getUserInfo(AsyncCallback<UserInfo> callback);
}

View File

@ -1,12 +1,15 @@
package org.gcube.portlets.user.socialprofile.client.ui;
import org.gcube.portal.databook.shared.UserInfo;
import org.gcube.portlets.user.socialprofile.client.SocialService;
import org.gcube.portlets.user.socialprofile.client.SocialServiceAsync;
import com.google.gwt.core.client.GWT;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.user.client.rpc.AsyncCallback;
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;
@ -17,13 +20,38 @@ public class DisplayProfile extends Composite {
interface DisplayProfileUiBinder extends UiBinder<Widget, DisplayProfile> {
}
public static final String avatar_default = GWT.getModuleBaseURL() + "../images/Avatar_default.png";
public static final String loading = GWT.getModuleBaseURL() + "../images/avatarLoader.gif";
private final SocialServiceAsync socialService = GWT.create(SocialService.class);
@UiField HTMLPanel mainPanel;
@UiField Image avatarImage;
private UserInfo myUserInfo;
public DisplayProfile() {
initWidget(uiBinder.createAndBindUi(this));
avatarImage.setUrl(loading);
mainPanel.addStyleName("framed");
socialService.getUserInfo(new AsyncCallback<UserInfo>() {
@Override
public void onSuccess(UserInfo result) {
myUserInfo = result;
avatarImage.getElement().getParentElement().setAttribute("href", myUserInfo.getAccountURL());
avatarImage.setSize("60px", "60px");
avatarImage.setUrl(myUserInfo.getAvatarId());
}
@Override
public void onFailure(Throwable caught) {
avatarImage.setSize("120px", "120px");
avatarImage.setUrl(avatar_default);
}
});
}
}

View File

@ -1,19 +1,20 @@
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder"
xmlns:g="urn:import:com.google.gwt.user.client.ui">
<g:HTMLPanel>
<g:HTMLPanel ui:field="mainPanel">
<table class="">
<tr>
<td width="150px;" align="middle">
<a href="">
<g:Image title="Edit Profile Picture" styleName="member-photo"
url="" ui:field="avatarImage" width="150" height="150" />
<g:Image title="Edit Profile Picture" styleName="user-photo"
url="" ui:field="avatarImage" width="120" height="120" />
</a>
</td>
<td>
<td width="350px;" valign="top">
<div class="">
SSSSSS
<div class="full-name">Massimiliano Assante</div>
<div class="headline">Researcher</div>
</div>
</td>
</tr>

View File

@ -1,14 +1,90 @@
package org.gcube.portlets.user.socialprofile.server;
import java.util.HashMap;
import org.gcube.application.framework.core.session.ASLSession;
import org.gcube.application.framework.core.session.SessionManager;
import org.gcube.common.core.utils.logging.GCUBEClientLog;
import org.gcube.portal.custom.communitymanager.OrganizationsUtil;
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
import org.gcube.portal.databook.shared.UserInfo;
import org.gcube.portlets.user.socialprofile.client.SocialService;
import org.gcube.portlets.user.socialprofile.shared.FieldVerifier;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.liferay.portal.kernel.util.WebKeys;
import com.liferay.portal.service.UserLocalServiceUtil;
import com.liferay.portal.theme.ThemeDisplay;
/**
* The server side implementation of the RPC service.
*/
@SuppressWarnings("serial")
public class SocialServiceImpl extends RemoteServiceServlet implements SocialService {
/**
*
*/
private static GCUBEClientLog _log = new GCUBEClientLog(SocialServiceImpl.class);
/**
* used for debugging in eclipse
*/
private boolean withinPortal = false;
/**
* 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 = "test.user";
// user = "massimiliano.assante";
// SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube/devsec/devVRE");
withinPortal = false;
}
else {
withinPortal = true;
}
return SessionManager.getInstance().getASLSession(sessionID, user);
}
@Override
public UserInfo getUserInfo() {
try {
ASLSession session = getASLSession();
String username = session.getUsername();
String email = username+"@isti.cnr.it";
String fullName = username+" FULL";
String thumbnailURL = "images/Avatar_default.png";
if (withinPortal) {
com.liferay.portal.model.UserModel user = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), username);
thumbnailURL = "/image/user_male_portrait?img_id="+user.getPortraitId();
fullName = user.getFirstName() + " " + user.getLastName();
email = user.getEmailAddress();
ThemeDisplay themeDisplay = (ThemeDisplay) this.getThreadLocalRequest().getSession().getAttribute(WebKeys.THEME_DISPLAY);
String accountURL = themeDisplay.getURLMyAccount().toString();
HashMap<String, String> vreNames = new HashMap<String, String>();
UserInfo userInfo = new UserInfo(username, fullName, thumbnailURL, user.getEmailAddress(), accountURL, true, false, vreNames);
return userInfo;
}
else {
_log.info("Returning test USER");
HashMap<String, String> fakeVreNames = new HashMap<String, String>();
fakeVreNames.put("/gcube/devsec/devVRE","devVRE");
//fakeVreNames.put("/gcube/devNext/NexNext","NexNext");
UserInfo user = new UserInfo(getASLSession().getUsername(), fullName, thumbnailURL, email, "fakeAccountUrl", true, false, fakeVreNames);
return (user);
}
} catch (Exception e) {
e.printStackTrace();
}
return new UserInfo();
}
}

View File

@ -1,42 +0,0 @@
package org.gcube.portlets.user.socialprofile.shared;
/**
* <p>
* FieldVerifier validates that the name the user enters is valid.
* </p>
* <p>
* This class is in the <code>shared</code> packing because we use it in both
* the client code and on the server. On the client, we verify that the name is
* valid before sending an RPC request so the user doesn't have to wait for a
* network round trip to get feedback. On the server, we verify that the name is
* correct to ensure that the input is correct regardless of where the RPC
* originates.
* </p>
* <p>
* When creating a class that is used on both the client and the server, be sure
* that all code is translatable and does not use native JavaScript. Code that
* is note translatable (such as code that interacts with a database or the file
* system) cannot be compiled into client side JavaScript. Code that uses native
* JavaScript (such as Widgets) cannot be run on the server.
* </p>
*/
public class FieldVerifier {
/**
* Verifies that the specified name is valid for our service.
*
* In this example, we only require that the name is at least four
* characters. In your application, you can use more complex checks to ensure
* that usernames, passwords, email addresses, URLs, and other fields have the
* proper syntax.
*
* @param name the name to validate
* @return true if valid, false if invalid
*/
public static boolean isValidName(String name) {
if (name == null) {
return false;
}
return name.length() > 3;
}
}

View File

@ -0,0 +1,56 @@
package org.gcube.portlets.user.socialprofile.shared;
import java.io.Serializable;
import org.gcube.portal.databook.shared.UserInfo;
@SuppressWarnings("serial")
public class UserSettings implements Serializable {
private UserInfo userInfo;
private int refreshingTimeInMillis;
private String currentScope;
boolean isInfrastructure;
public UserSettings() {
super();
}
public UserSettings(UserInfo userInfo, int refreshingTimeInMillis,
String currentScope, boolean isInfrastructure) {
super();
this.userInfo = userInfo;
this.refreshingTimeInMillis = refreshingTimeInMillis;
this.currentScope = currentScope;
this.isInfrastructure = isInfrastructure;
}
public UserInfo getUserInfo() {
return userInfo;
}
public void setUserInfo(UserInfo userInfo) {
this.userInfo = userInfo;
}
public int getRefreshingTimeInMillis() {
return refreshingTimeInMillis;
}
public void setRefreshingTimeInMillis(int refreshingTimeInMillis) {
this.refreshingTimeInMillis = refreshingTimeInMillis;
}
public String getCurrentScope() {
return currentScope;
}
public void setCurrentScope(String currentScope) {
this.currentScope = currentScope;
}
public boolean isInfrastructure() {
return isInfrastructure;
}
public void setInfrastructure(boolean isInfrastructure) {
this.isInfrastructure = isInfrastructure;
}
@Override
public String toString() {
return "UserSettings [userInfo=" + userInfo
+ ", refreshingTimeInMillis=" + refreshingTimeInMillis
+ ", currentScope=" + currentScope + ", isInfrastructure="
+ isInfrastructure + "]";
}
}

View File

@ -1,15 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<module rename-to='socialprofile'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' />
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' />
<!-- Other module inherits -->
<!-- Other module inherits -->
<!-- inherits GCUBE Widgets -->
<inherits name='org.gcube.portlets.user.gcubewidgets.WidgetFactory' />
<inherits name='org.gcube.portal.databook.GCubeSocialNetworking' />
<!-- Specify the app entry point class. -->
<entry-point
class='org.gcube.portlets.user.socialprofile.client.SocialProfile' />
<!-- Specify the app entry point class. -->
<entry-point class='org.gcube.portlets.user.socialprofile.client.SocialProfile' />
<!-- Specify the paths for translatable code -->
<source path='client' />
<source path='shared' />
<!-- Specify the paths for translatable code -->
<source path='client' />
<source path='shared' />
</module>

View File

@ -0,0 +1,28 @@
.framed {
margin: 0 0 10px;
padding: 10px;
margin: 0px 5px;
background: #FFF url(images/vre_bg_gray.png) repeat-x left bottom;
border-radius: 6px !important;
-moz-border-radius: 6px !important;
-webkit-border-radius: 6px !important;
border: 1px solid #DBDBDB;
}
.user-photo {
display: block;
padding: 2px;
border: 1px solid #E6E6E6;
}
.full-name {
font-family: Helvetica, Arial, sans-serif;
font-size: 24px;
font-weight: bold;
}
.headline {
font-family: Helvetica, Arial, sans-serif;
font-size: 16px;
color: red;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 997 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB