removed ws amil widget dependency and implement private message through Messages App Redirect

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/social-profile@169240 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2018-06-15 10:45:54 +00:00
parent ae6d1e5461
commit 4e4d1b6d3c
8 changed files with 72 additions and 75 deletions

View File

@ -8,12 +8,6 @@
<dependent-module archiveName="gcube-widgets-2.2.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/gcube-widgets/gcube-widgets">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="workspace-explorer-2.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/workspace-explorer-TRUNK-1.5.0-SNAPSHOT/workspace-explorer-TRUNK-1.5.0-SNAPSHOT">
<dependency-type>uses</dependency-type>
</dependent-module>
<dependent-module archiveName="storagehub-icons-library-1.0.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/storagehub-icons-library/storagehub-icons-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="social-profile"/>
</wb-module>

View File

@ -71,7 +71,6 @@
<dependency>
<groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>aslsocial</artifactId>
<version>[1.3.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
@ -109,12 +108,6 @@
<artifactId>gwt-jsonmaker</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.portlets.widgets</groupId>
<artifactId>wsmail-widget</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
<artifactId>home-library</artifactId>

View File

@ -94,7 +94,7 @@ public class SocialProfile implements EntryPoint {
* display the profile of the user
*/
private void displayProfile() {
socialService.getUserContext(getUserToShowId(), new AsyncCallback<UserContext>() {
socialService.getUserContext(getUserToShowId(true), new AsyncCallback<UserContext>() {
@Override
public void onSuccess(UserContext result) {
mainPanel.add(dispProfile);
@ -149,12 +149,12 @@ public class SocialProfile implements EntryPoint {
* decode the userid from the location param
* @return the decoded (base64) userid
*/
public static String getUserToShowId() {
public static String getUserToShowId(boolean decode) {
String encodedOid = Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID);
if (Window.Location.getParameter(encodedOid) == null)
return null;
String encodedUserId = Window.Location.getParameter(encodedOid);
return Encoder.decode(encodedUserId);
return decode ? Encoder.decode(encodedUserId) : encodedUserId;
}
/**
*

View File

@ -1,18 +1,15 @@
package org.gcube.portlets.user.socialprofile.client.ui;
import java.util.ArrayList;
import java.util.List;
import org.gcube.portal.databook.client.GCubeSocialNetworking;
import org.gcube.portal.databook.client.util.Encoder;
import org.gcube.portal.databook.shared.UserInfo;
import org.gcube.portlets.user.socialprofile.client.SocialProfile;
import org.gcube.portlets.user.socialprofile.client.SocialService;
import org.gcube.portlets.user.socialprofile.client.SocialServiceAsync;
import org.gcube.portlets.user.socialprofile.shared.UserContext;
import org.gcube.portlets.widgets.wsmail.client.forms.MailForm;
import com.github.gwtbootstrap.client.ui.Alert;
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.uibinder.client.UiBinder;
@ -82,6 +79,7 @@ public class DisplayProfile extends Composite {
private String currInstitution;
private UserInfo myUserInfo;
private String messageAppURL;
private DisplaySummary summarySibling;
public DisplayProfile() {
@ -94,12 +92,11 @@ public class DisplayProfile extends Composite {
*
* @param result
*/
public void show(UserContext result) {
public void show(UserContext result) {
myUserInfo = result.getUserInfo();
avatarImage.setUrl(myUserInfo.getAvatarId());
userFullName.setText(myUserInfo.getFullName());
messageAppURL = result.getSendMessageURL();
/*
* Here we check that:
* 1) the user is the owner of the profile;
@ -170,7 +167,6 @@ public class DisplayProfile extends Composite {
avatarImage.getElement().getParentElement().setAttribute("href", "");
avatarImage.setTitle(myUserInfo.getFullName());
messageButton.setVisible(true);
// check if the current user is the owner but he is looking at his own profile as if it was the profile of another vre member
if(result.isOwner()){
// TODO get the address of the My Profile page and add a link to redirect the user
@ -186,8 +182,7 @@ public class DisplayProfile extends Composite {
* @return
*/
private boolean showAsOwner(UserContext result) {
if((SocialProfile.getUserToShowId() == null && result.isOwner()))
if((SocialProfile.getUserToShowId(true) == null && result.isOwner()))
return true;
return false;
@ -311,17 +306,9 @@ public class DisplayProfile extends Composite {
@UiHandler("messageButton")
void onSendPrivateMessageClick(ClickEvent e) {
final List<String> listToLogin = new ArrayList<String>();
listToLogin.add(SocialProfile.getUserToShowId() );
GWT.runAsync(new RunAsyncCallback() {
@Override
public void onSuccess() {
new MailForm(listToLogin);
}
public void onFailure(Throwable reason) {
Window.alert("Could not load this component: " + reason.getMessage());
}
});
String encodedOid = Encoder.encode(GCubeSocialNetworking.USER_PROFILE_OID);
String urlToOpen = messageAppURL + "?"+ encodedOid + "=" + SocialProfile.getUserToShowId(false);
Window.open(urlToOpen,"_blank","");
}
private void cancelHeadline() {

View File

@ -26,6 +26,7 @@ import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.gcube.common.encryption.StringEncrypter;
import org.gcube.common.portal.GCubePortalConstants;
import org.gcube.common.portal.PortalContext;
import org.gcube.common.resources.gcore.ServiceEndpoint;
import org.gcube.common.resources.gcore.ServiceEndpoint.AccessPoint;
@ -51,8 +52,6 @@ import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.model.Contact;
import com.liferay.portal.service.ContactLocalServiceUtil;
import com.liferay.portal.service.UserLocalServiceUtil;
@ -64,7 +63,6 @@ import com.liferay.portal.service.UserLocalServiceUtil;
public class SocialServiceImpl extends RemoteServiceServlet implements SocialService {
private static final Logger logger = LoggerFactory.getLogger(SocialServiceImpl.class);
//private static final Log logger = LogFactoryUtil.getLog(SocialServiceImpl.class);
private static final String LINKEDIN_HOST_SERVICE_NAME = "host";
private static final String LINKEDIN_CLIEND_ID_PROPNAME = "client_id";
@ -121,13 +119,11 @@ public class SocialServiceImpl extends RemoteServiceServlet implements SocialSer
@Override
public UserContext getUserContext(String userid) {
if (userid == null || userid.equals("") || userid.equals(getCurrentUser(this.getThreadLocalRequest()).getUsername())) {
System.out.println("Own Profile");
logger.info("Own Profile");
logger.debug("Own Profile");
return getOwnProfile();
}
else {
System.out.println("Reading Profile");
logger.info(userid + " Reading Profile");
logger.debug(userid + " Reading Profile of " + userid);
return getUserProfile(userid);
}
}
@ -172,7 +168,12 @@ public class SocialServiceImpl extends RemoteServiceServlet implements SocialSer
String company = user.getLocation_industry();
String summary = transformSummary(um.getUserProfessionalBackground(user.getUserId()));
return new UserContext(userInfo, headline, company, summary, contextName, false, isInfrastructureScope());
final String MessageAppPageURL =
new StringBuilder(PortalContext.getConfiguration().getSiteLandingPagePath(getThreadLocalRequest()))
.append(GCubePortalConstants.USER_MESSAGES_FRIENDLY_URL)
.toString();
return new UserContext(userInfo, headline, company, summary, contextName, isInfrastructureScope(), false, MessageAppPageURL);
} catch (Exception e) {
e.printStackTrace();
@ -187,7 +188,7 @@ public class SocialServiceImpl extends RemoteServiceServlet implements SocialSer
UserInfo user = new UserInfo(username, username+ "FULL", thumbnailURL, email, "fakeAccountUrl", true, false, fakeVreNames);
return new UserContext(user, "", "", ""
+ "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam."
+ "", contextName, false, isInfrastructureScope());
+ "", contextName, false, isInfrastructureScope(), "URLFINTO");
}
}
@ -207,8 +208,7 @@ public class SocialServiceImpl extends RemoteServiceServlet implements SocialSer
thumbnailURL = user.getUserAvatarURL();
fullName = user.getFullname();
email = user.getEmail();
// ThemeDisplay themeDisplay = (ThemeDisplay) this.getThreadLocalRequest().getSession().getAttribute(WebKeys.THEME_DISPLAY);
String accountURL = "TODO"; //TODO: //themeDisplay.getURLMyAccount().toString();
String accountURL = "";
HashMap<String, String> vreNames = new HashMap<String, String>();
UserInfo userInfo = new UserInfo(username, fullName, thumbnailURL, user.getEmail(), accountURL, true, false, vreNames);
@ -216,7 +216,7 @@ public class SocialServiceImpl extends RemoteServiceServlet implements SocialSer
String company = user.getLocation_industry();
String summary = transformSummary(um.getUserProfessionalBackground(user.getUserId()));
return new UserContext(userInfo, headline, company, summary, contextName, true, isInfrastructureScope() );
return new UserContext(userInfo, headline, company, summary, contextName, isInfrastructureScope(), true, "");
}
else {
logger.info("Returning test USER");
@ -227,7 +227,7 @@ public class SocialServiceImpl extends RemoteServiceServlet implements SocialSer
UserInfo user = new UserInfo(username, fullName, thumbnailURL, email, "fakeAccountUrl", true, false, fakeVreNames);
return new UserContext(user, "", "", ""
+ "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam."
+ "", contextName, true, isInfrastructureScope() );
+ "", contextName, isInfrastructureScope(), true, "");
}
} catch (Exception e) {

View File

@ -13,24 +13,29 @@ public class UserContext implements Serializable {
private String currentScope;
private boolean isInfrastructure;
private boolean isOwner;
private String sendMessageURL;
public UserContext() {
super();
}
public UserContext(UserInfo userInfo, String headline, String institution,
String summary, String currentScope, boolean isOwner, boolean isInfrastructure) {
public UserContext(UserInfo userInfo, String headline, String institution, String summary, String currentScope,
boolean isInfrastructure, boolean isOwner, String sendMessageURL) {
super();
this.userInfo = userInfo;
this.headline = headline;
this.institution = institution;
this.summary = summary;
this.currentScope = currentScope;
this.isOwner = isOwner;
this.isInfrastructure = isInfrastructure;
this.isOwner = isOwner;
this.sendMessageURL = sendMessageURL;
}
public UserInfo getUserInfo() {
return userInfo;
}
@ -77,4 +82,43 @@ public class UserContext implements Serializable {
public void setInfrastructure(boolean isInfrastructure) {
this.isInfrastructure = isInfrastructure;
}
public String getSendMessageURL() {
return sendMessageURL;
}
public void setSendMessageURL(String sendMessageURL) {
this.sendMessageURL = sendMessageURL;
}
@Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("UserContext [userInfo=");
builder.append(userInfo);
builder.append(", headline=");
builder.append(headline);
builder.append(", institution=");
builder.append(institution);
builder.append(", summary=");
builder.append(summary);
builder.append(", currentScope=");
builder.append(currentScope);
builder.append(", isInfrastructure=");
builder.append(isInfrastructure);
builder.append(", isOwner=");
builder.append(isOwner);
builder.append(", sendMessageURL=");
builder.append(sendMessageURL);
builder.append("]");
return builder.toString();
}
}

View File

@ -7,7 +7,6 @@
<!-- Other module inherits -->
<!-- inherits GCUBE Widgets -->
<inherits name='org.gcube.portlets.user.gcubewidgets.WidgetFactory' />
<inherits name='org.gcube.portlets.widgets.wsmail.WsMail_Widget' />
<inherits name='org.gcube.portal.databook.GCubeSocialNetworking' />
<inherits name="net.eliasbalasis.tibcopagebus4gwt.tibcopagebus4gwt" />
<inherits name="org.jsonmaker.gwt.Gwt_jsonmaker" />

View File

@ -14,26 +14,6 @@
<servlet-name>socialService</servlet-name>
<url-pattern>/socialprofile/socialService</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>mailWisdgetServlet</servlet-name>
<servlet-class>org.gcube.portlets.widgets.wsmail.server.WsMailServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>mailWisdgetServlet</servlet-name>
<url-pattern>/socialprofile/mailWisdgetServlet</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>workspaceExplorer</servlet-name>
<servlet-class>org.gcube.portlets.widgets.wsexplorer.server.WorkspaceExplorerServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>workspaceExplorer</servlet-name>
<url-pattern>/socialprofile/WorkspaceExplorerService</url-pattern>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>