From 1c1b765ea44a8f569bff4d50dc40aa459e1fdaef Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Tue, 29 Mar 2016 09:23:59 +0000 Subject: [PATCH] ported to liferay 6.2 git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/user/social-profile@126340 82a268e6-3cf1-43bd-a215-b396298e98cf --- .classpath | 4 +- .settings/org.eclipse.wst.common.component | 3 - ....eclipse.wst.common.project.facet.core.xml | 2 +- pom.xml | 24 ++++--- .../client/ui/DisplayProfile.java | 4 +- .../server/SocialServiceImpl.java | 62 ++++++++++--------- .../user/socialprofile/SocialProfile.gwt.xml | 2 +- src/main/webapp/SocialProfile.css | 2 +- src/main/webapp/WEB-INF/liferay-display.xml | 2 +- src/main/webapp/WEB-INF/liferay-portlet.xml | 2 +- src/main/webapp/WEB-INF/portlet.xml | 6 +- src/main/webapp/WEB-INF/web.xml | 38 ++++++------ 12 files changed, 78 insertions(+), 73 deletions(-) diff --git a/.classpath b/.classpath index 75d870a..92436b5 100644 --- a/.classpath +++ b/.classpath @@ -1,6 +1,6 @@ - + @@ -35,5 +35,5 @@ - + diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index 086e16d..0b07bb5 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -4,9 +4,6 @@ - - uses - diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml index afd5d47..c57a49e 100644 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -2,7 +2,7 @@ - + diff --git a/pom.xml b/pom.xml index abd5938..001d4e3 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ org.gcube.portlets.user social-profile war - 1.1.0-SNAPSHOT + 2.0.0-SNAPSHOT gCube Social Profile Portlet Social Profile @@ -30,7 +30,7 @@ 1.7 1.7 ${project.build.directory}/${project.build.finalName} - + 6.2.5 UTF-8 UTF-8 @@ -72,8 +72,10 @@ org.gcube.portal custom-portal-handler + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) provided + commons-io commons-io @@ -112,20 +114,26 @@ gwt-jsonmaker provided - - org.gcube.portlets.widgets - wsmail-widget - [1.4.0-SNAPSHOT, 2.0.0-SNAPSHOT) - compile - + + + + + + org.apache.httpcomponents httpclient 4.3.5 + + org.gcube.dvos + usermanagement-core + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) + com.liferay.portal portal-service + ${liferay.version} provided diff --git a/src/main/java/org/gcube/portlets/user/socialprofile/client/ui/DisplayProfile.java b/src/main/java/org/gcube/portlets/user/socialprofile/client/ui/DisplayProfile.java index 1a198f1..248f2b1 100644 --- a/src/main/java/org/gcube/portlets/user/socialprofile/client/ui/DisplayProfile.java +++ b/src/main/java/org/gcube/portlets/user/socialprofile/client/ui/DisplayProfile.java @@ -8,7 +8,6 @@ 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.google.gwt.core.client.GWT; import com.google.gwt.core.client.RunAsyncCallback; @@ -286,7 +285,8 @@ public class DisplayProfile extends Composite { GWT.runAsync(new RunAsyncCallback() { @Override public void onSuccess() { - new MailForm(listToLogin); + //TODO: +// new MailForm(listToLogin); } public void onFailure(Throwable reason) { Window.alert("Could not load this component: " + reason.getMessage()); diff --git a/src/main/java/org/gcube/portlets/user/socialprofile/server/SocialServiceImpl.java b/src/main/java/org/gcube/portlets/user/socialprofile/server/SocialServiceImpl.java index 67a4ccd..94c4840 100644 --- a/src/main/java/org/gcube/portlets/user/socialprofile/server/SocialServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/socialprofile/server/SocialServiceImpl.java @@ -34,13 +34,16 @@ import org.gcube.common.resources.gcore.utils.XPathHelper; import org.gcube.common.scope.api.ScopeProvider; 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.communitymanager.SiteManagerUtil; 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.UserContext; import org.gcube.resources.discovery.client.api.DiscoveryClient; import org.gcube.resources.discovery.client.queries.api.SimpleQuery; +import org.gcube.vomanagement.usermanagement.UserManager; +import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager; +import org.gcube.vomanagement.usermanagement.model.GCubeUser; import org.json.simple.parser.ContainerFactory; import org.json.simple.parser.JSONParser; import org.slf4j.Logger; @@ -128,16 +131,17 @@ public class SocialServiceImpl extends RemoteServiceServlet implements SocialSer String thumbnailURL = "images/Avatar_default.png"; if (isWithinPortal()) { 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(); - fullName = user.getFirstName() + " " + user.getLastName(); - email = user.getEmailAddress(); + UserManager um = new LiferayUserManager(); + GCubeUser user = um.getUserByUsername(username); + thumbnailURL = user.getUserAvatarURL(); + fullName = user.getFullname(); + email = user.getEmail(); HashMap vreNames = new HashMap(); - UserInfo userInfo = new UserInfo(username, fullName, thumbnailURL, user.getEmailAddress(), "", true, false, vreNames); - User theUser = OrganizationsUtil.validateUser(username); - String headline = theUser.getJobTitle(); - String company = theUser.getOpenId(); - String summary = getSummary(theUser); + UserInfo userInfo = new UserInfo(username, fullName, thumbnailURL, user.getEmail(), "", true, false, vreNames); + + String headline = user.getJobTitle(); + String company = user.getLocation_industry(); + String summary = transformSummary(um.getUserProfessionalBackground(user.getUserId())); return new UserContext(userInfo, headline, company, summary, session.getScopeName(), true, isInfrastructureScope()); @@ -168,19 +172,19 @@ public class SocialServiceImpl extends RemoteServiceServlet implements SocialSer if (isWithinPortal()) { - 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(); - fullName = user.getFirstName() + " " + user.getLastName(); - email = user.getEmailAddress(); - ThemeDisplay themeDisplay = (ThemeDisplay) this.getThreadLocalRequest().getSession().getAttribute(WebKeys.THEME_DISPLAY); - String accountURL = themeDisplay.getURLMyAccount().toString(); + UserManager um = new LiferayUserManager(); + GCubeUser user = um.getUserByUsername(username); + 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(); HashMap vreNames = new HashMap(); - UserInfo userInfo = new UserInfo(username, fullName, thumbnailURL, user.getEmailAddress(), accountURL, true, false, vreNames); - User theUser = OrganizationsUtil.validateUser(session.getUsername()); - String headline = theUser.getJobTitle(); - String company = theUser.getOpenId(); - String summary = getSummary(theUser); + UserInfo userInfo = new UserInfo(username, fullName, thumbnailURL, user.getEmail(), accountURL, true, false, vreNames); + String headline = user.getJobTitle(); + String company = user.getLocation_industry(); + String summary = transformSummary(um.getUserProfessionalBackground(user.getUserId())); return new UserContext(userInfo, headline, company, summary, session.getScopeName(), true, isInfrastructureScope() ); } @@ -203,8 +207,8 @@ public class SocialServiceImpl extends RemoteServiceServlet implements SocialSer } - private String getSummary(User theUser) { - String toReturn = escapeHtml(theUser.getComments()); + private String transformSummary(String professionalBackground) { + String toReturn = escapeHtml(professionalBackground); // replace all the line breaks by
toReturn = toReturn.replaceAll("(\r\n|\n)","
"); // then replace all the double spaces by the html version   @@ -216,9 +220,8 @@ public class SocialServiceImpl extends RemoteServiceServlet implements SocialSer public Boolean saveHeadline(String newHeadline) { com.liferay.portal.model.User user; try { - user = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), getASLSession().getUsername()); - user.setJobTitle(escapeHtml(newHeadline)); - return (UserLocalServiceUtil.updateUser(user) != null); + //TODO: + return false; } catch (Exception e) { e.printStackTrace(); return false; @@ -229,9 +232,8 @@ public class SocialServiceImpl extends RemoteServiceServlet implements SocialSer public Boolean saveIsti(String institution) { com.liferay.portal.model.User user; try { - user = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), getASLSession().getUsername()); - user.setOpenId(escapeHtml(institution)); - return (UserLocalServiceUtil.updateUser(user) != null); + //TODO: + return false; } catch (Exception e) { e.printStackTrace(); return false; @@ -417,7 +419,7 @@ public class SocialServiceImpl extends RemoteServiceServlet implements SocialSer if (isWithinPortal()) { _log.debug("LinkedIn Profile gotten correctly for " + getASLSession().getUsername() + " attempting to write into DB ..."); com.liferay.portal.model.User user; - user = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), getASLSession().getUsername()); + user = UserLocalServiceUtil.getUserByScreenName(SiteManagerUtil.getCompany().getCompanyId(), getASLSession().getUsername()); //headline if (headline.compareTo("") != 0) { String checkedHeadline = headline; diff --git a/src/main/resources/org/gcube/portlets/user/socialprofile/SocialProfile.gwt.xml b/src/main/resources/org/gcube/portlets/user/socialprofile/SocialProfile.gwt.xml index a529bfc..47760e2 100644 --- a/src/main/resources/org/gcube/portlets/user/socialprofile/SocialProfile.gwt.xml +++ b/src/main/resources/org/gcube/portlets/user/socialprofile/SocialProfile.gwt.xml @@ -7,7 +7,7 @@ - + diff --git a/src/main/webapp/SocialProfile.css b/src/main/webapp/SocialProfile.css index 2785970..1814a5e 100644 --- a/src/main/webapp/SocialProfile.css +++ b/src/main/webapp/SocialProfile.css @@ -40,7 +40,7 @@ .user-details { padding: 5px; } -.user-photo { +img.user-photo { display: block; padding: 2px; border: 1px solid #E6E6E6; diff --git a/src/main/webapp/WEB-INF/liferay-display.xml b/src/main/webapp/WEB-INF/liferay-display.xml index 1911d58..9ce3a26 100644 --- a/src/main/webapp/WEB-INF/liferay-display.xml +++ b/src/main/webapp/WEB-INF/liferay-display.xml @@ -1,5 +1,5 @@ - + diff --git a/src/main/webapp/WEB-INF/liferay-portlet.xml b/src/main/webapp/WEB-INF/liferay-portlet.xml index 3549dfd..5e31aa6 100644 --- a/src/main/webapp/WEB-INF/liferay-portlet.xml +++ b/src/main/webapp/WEB-INF/liferay-portlet.xml @@ -1,5 +1,5 @@ - + diff --git a/src/main/webapp/WEB-INF/portlet.xml b/src/main/webapp/WEB-INF/portlet.xml index 098d012..26f35b2 100644 --- a/src/main/webapp/WEB-INF/portlet.xml +++ b/src/main/webapp/WEB-INF/portlet.xml @@ -1,11 +1,9 @@ - + version="2.0"> SocialProfile User Profile diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml index cc0f35a..627b4ad 100644 --- a/src/main/webapp/WEB-INF/web.xml +++ b/src/main/webapp/WEB-INF/web.xml @@ -1,8 +1,8 @@ - + http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" + version="3.0"> @@ -15,23 +15,23 @@ /socialprofile/socialService - - mailWisdgetServlet - org.gcube.portlets.widgets.wsmail.server.WsMailServiceImpl - + + + + - - mailWisdgetServlet - /socialprofile/mailWisdgetServlet - - - workspaceServiceImpl - org.gcube.portlets.widgets.lighttree.server.WorkspaceServiceImpl - - - workspaceServiceImpl - /socialprofile/WorkspaceLightService - + + + + + + + + + + + + SocialProfile.html