From 75b1336145d0cbeb32c215b416b3e98bd3855f7d Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Wed, 27 Apr 2016 12:35:28 +0000 Subject: [PATCH] partially ported to LR 6.2 git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/share-updates@128353 82a268e6-3cf1-43bd-a215-b396298e98cf --- .settings/org.eclipse.wst.common.component | 6 + pom.xml | 36 ++- .../shareupdates/client/ShareUpdates.java | 25 --- .../client/view/ShareUpdateForm.java | 1 - .../client/view/ShareUpdateForm.ui.xml | 7 +- .../server/ShareUpdateServiceImpl.java | 211 ++++++++---------- .../server/TextTransfromUtils.java | 14 +- .../shareupdates/shared/UserSettings.java | 5 +- src/main/webapp/ShareUpdates.css | 28 +-- .../webapp/WEB-INF/jsp/ShareUpdates_view.jsp | 2 - 10 files changed, 145 insertions(+), 190 deletions(-) diff --git a/.settings/org.eclipse.wst.common.component b/.settings/org.eclipse.wst.common.component index bbf0648..d851ee0 100644 --- a/.settings/org.eclipse.wst.common.component +++ b/.settings/org.eclipse.wst.common.component @@ -5,6 +5,12 @@ + + uses + + + uses + diff --git a/pom.xml b/pom.xml index 139d49d..4f28914 100644 --- a/pom.xml +++ b/pom.xml @@ -27,7 +27,7 @@ 2.7.0 distro - + 6.2.5 1.7 1.7 ${project.build.directory}/${project.build.finalName} @@ -59,7 +59,7 @@ ${gwtVersion} provided - + com.google.gwt gwt-dev ${gwtVersion} @@ -72,6 +72,7 @@ org.gcube.common.portal portal-manager + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) org.gcube.portal @@ -81,6 +82,8 @@ org.gcube.portal notifications-common-library + [1.3.0-SNAPSHOT, 2.0.0-SNAPSHOT) + provided org.gcube.applicationsupportlayer @@ -90,11 +93,13 @@ org.gcube.applicationsupportlayer aslsocial + [1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT) provided org.gcube.portlets.user gcube-widgets + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) compile @@ -160,12 +165,6 @@ org.gcube.common home-library provided - - - asm-all - asm - - org.gcube.common @@ -175,11 +174,13 @@ org.gcube.portal custom-portal-handler + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) provided org.gcube.dvos usermanagement-core + [2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT) provided @@ -215,6 +216,25 @@ com.liferay.portal portal-service + ${liferay.version} + provided + + + com.liferay.portal + util-bridges + ${liferay.version} + provided + + + com.liferay.portal + util-taglib + ${liferay.version} + provided + + + com.liferay.portal + util-java + ${liferay.version} provided diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/client/ShareUpdates.java b/src/main/java/org/gcube/portlets/user/shareupdates/client/ShareUpdates.java index 2880702..308d16a 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/client/ShareUpdates.java +++ b/src/main/java/org/gcube/portlets/user/shareupdates/client/ShareUpdates.java @@ -4,8 +4,6 @@ import org.gcube.portlets.user.gcubewidgets.client.ClientScopeHelper; import org.gcube.portlets.user.shareupdates.client.view.ShareUpdateForm; import com.google.gwt.core.client.EntryPoint; -import com.google.gwt.core.client.ScriptInjector; -import com.google.gwt.core.shared.GWT; import com.google.gwt.user.client.Window.Location; import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.RootPanel; @@ -18,18 +16,6 @@ import com.google.gwt.user.client.ui.RootPanel; public class ShareUpdates implements EntryPoint { public void onModuleLoad() { - - // check if jQuery is available - boolean jQueryLoaded = isjQueryLoaded(); - - if(jQueryLoaded) - GWT.log("Injecting : http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"); - else{ - ScriptInjector.fromUrl("http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js") - .setWindow(ScriptInjector.TOP_WINDOW) - .inject(); - } - // start UI and related stuff ClientScopeHelper.getService().setScope(Location.getHref(), new AsyncCallback() { @Override @@ -41,15 +27,4 @@ public class ShareUpdates implements EntryPoint { } }); } - - /** - * Checks if jQuery is loaded. - * - * @return true, if jQuery is loaded, false otherwise - */ - private native boolean isjQueryLoaded() /*-{ - - return (typeof $wnd['jQuery'] !== 'undefined'); - - }-*/; } diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/client/view/ShareUpdateForm.java b/src/main/java/org/gcube/portlets/user/shareupdates/client/view/ShareUpdateForm.java index 74f5727..2931916 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/client/view/ShareUpdateForm.java +++ b/src/main/java/org/gcube/portlets/user/shareupdates/client/view/ShareUpdateForm.java @@ -194,7 +194,6 @@ public class ShareUpdateForm extends Composite { //change css if deployed in VRE scope if (!userSettings.isInfrastructure()) { - mainPanel.addStyleName("framed"); notifyListbox.addItem("Share with: " + singleVREName); notifyListbox.addItem("Share with: " + singleVREName+" + Notification to members"); if (notificationEmail) { diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/client/view/ShareUpdateForm.ui.xml b/src/main/java/org/gcube/portlets/user/shareupdates/client/view/ShareUpdateForm.ui.xml index 317a929..37d8678 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/client/view/ShareUpdateForm.ui.xml +++ b/src/main/java/org/gcube/portlets/user/shareupdates/client/view/ShareUpdateForm.ui.xml @@ -37,8 +37,7 @@ - - + - - - diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java b/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java index cd4e55b..03bd307 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java +++ b/src/main/java/org/gcube/portlets/user/shareupdates/server/ShareUpdateServiceImpl.java @@ -22,6 +22,7 @@ import org.gcube.application.framework.core.session.SessionManager; import org.gcube.applicationsupportlayer.social.ApplicationNotificationsManager; import org.gcube.applicationsupportlayer.social.NotificationsManager; import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser; +import org.gcube.common.portal.GCubePortalConstants; import org.gcube.common.portal.PortalContext; import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.impl.ScopeBean; @@ -30,8 +31,6 @@ import org.gcube.contentmanagement.blobstorage.service.IClient; import org.gcube.contentmanager.storageclient.wrapper.AccessType; import org.gcube.contentmanager.storageclient.wrapper.MemoryType; import org.gcube.contentmanager.storageclient.wrapper.StorageClient; -import org.gcube.portal.custom.communitymanager.OrganizationsUtil; -import org.gcube.portal.custom.communitymanager.impl.OrganizationManagerImpl; import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper; import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl; import org.gcube.portal.databook.server.DatabookStore; @@ -55,38 +54,31 @@ import org.gcube.portlets.user.shareupdates.shared.UserSettings; import org.gcube.portlets.widgets.pickitem.shared.ItemBean; 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.GroupModel; -import org.gcube.vomanagement.usermanagement.model.UserModel; +import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault; +import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException; +import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager; +import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager; +import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager; +import org.gcube.vomanagement.usermanagement.model.CustomAttributeKeys; +import org.gcube.vomanagement.usermanagement.model.GCubeGroup; +import org.gcube.vomanagement.usermanagement.model.GCubeUser; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.google.gwt.user.server.rpc.RemoteServiceServlet; import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.exception.SystemException; -import com.liferay.portal.kernel.util.WebKeys; -import com.liferay.portal.model.Organization; -import com.liferay.portal.model.Role; -import com.liferay.portal.service.OrganizationLocalServiceUtil; import com.liferay.portal.service.UserLocalServiceUtil; -import com.liferay.portal.theme.ThemeDisplay; /** * The server side implementation of the RPC service. */ @SuppressWarnings("serial") public class ShareUpdateServiceImpl extends RemoteServiceServlet implements ShareUpdateService { - /** - * - */ - private static final String ADMIN_ROLE = "Administrator"; - public static final String TEST_USER = "test.user"; private static final String STORAGE_OWNER = "gCubeSocialFramework"; public static final String UPLOAD_DIR = "/social-framework-uploads"; private static final String NEWS_FEED_PORTLET_CLASSNAME = "org.gcube.portlets.user.newsfeed.server.NewsServiceImpl"; - private final static String ATTR_TO_CHECK = "Postnotificationviaemail"; /** * @@ -124,7 +116,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar } public String getDevelopmentUser() { String user = TEST_USER; - // user = "costantino.perciante"; +// user = "costantino.perciante"; return user; } /** @@ -161,7 +153,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar ArrayList mentionedUsers = null; if (mentionedUserFullNames != null && ! mentionedUserFullNames.isEmpty()) { mentionedUsers = getSelectedUserIds(mentionedUserFullNames); - escapedFeedText = TextTransfromUtils.convertMentionPeopleAnchorHTML(escapedFeedText, mentionedUsers); + escapedFeedText = TextTransfromUtils.convertMentionPeopleAnchorHTML(escapedFeedText, mentionedUsers, getThreadLocalRequest()); } // get session @@ -197,7 +189,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar //get the VRE scope if single channel post String vreScope2Set = ""; if (pLevel == PrivacyLevel.SINGLE_VRE && vreOrgId != null) { - vreScope2Set = (withinPortal) ? getScopeByOrganizationId(vreOrgId) : session.getScope(); + vreScope2Set = (withinPortal) ? getScopeByGroupId(vreOrgId) : session.getScope(); } // build the feed to share (and save on cassandra) @@ -211,15 +203,19 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar //need to put the feed into VRES Timeline too if (pLevel == PrivacyLevel.VRES) { _log.trace("PrivacyLevel was set to VRES attempting to write onto User's VRES Timelines"); - for (GroupModel vre : getUserVREs(username)) { - Long orgId = Long.parseLong(vre.getGroupId()); - String vreScope = getScopeByOrganizationId(orgId); - _log.trace("Attempting to write onto " + vreScope); + for (GCubeGroup vre : getUserVREs(username)) { + String vreScope = ""; try { + vreScope = new LiferayGroupManager().getInfrastructureScope(vre.getGroupId()); + _log.trace("Attempting to write onto " + vreScope); + store.saveFeedToVRETimeline(toShare.getKey(), vreScope); } catch (FeedIDNotFoundException e) { _log.error("Error writing onto VRES Time Line" + vreScope); - } //save the feed + } + catch (Exception e) { + _log.error("Error retrieving user VRES"); + }//save the feed _log.trace("Success writing onto " + vreScope); } @@ -247,7 +243,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar //send the notification about this posts to everyone in the group if notifyGroup is true if (pLevel == PrivacyLevel.SINGLE_VRE && vreOrgId != null && notifyGroup) { - NotificationsManager nm = new ApplicationNotificationsManager( + NotificationsManager nm = new ApplicationNotificationsManager(getThreadLocalRequest(), vreScope2Set, new SocialNetworkingUser(username, email, fullName, thumbnailAvatarURL), NEWS_FEED_PORTLET_CLASSNAME); @@ -257,7 +253,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar } //send the notification to the mentioned users if (mentionedUsers != null && mentionedUsers.size() > 0) { - NotificationsManager nm = new ApplicationNotificationsManager( + NotificationsManager nm = new ApplicationNotificationsManager(getThreadLocalRequest(), vreScope2Set, new SocialNetworkingUser(username, email, fullName, thumbnailAvatarURL), NEWS_FEED_PORTLET_CLASSNAME); @@ -292,7 +288,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar ArrayList mentionedUsers = null; if (mentionedUserFullNames != null && ! mentionedUserFullNames.isEmpty()) { mentionedUsers = getSelectedUserIds(mentionedUserFullNames); - escapedFeedText = TextTransfromUtils.convertMentionPeopleAnchorHTML(escapedFeedText, mentionedUsers); + escapedFeedText = TextTransfromUtils.convertMentionPeopleAnchorHTML(escapedFeedText, mentionedUsers, getThreadLocalRequest()); } ASLSession session = getASLSession(); @@ -382,7 +378,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar //get the VRE scope if single channel post String vreScope2Set = ""; if (pLevel == PrivacyLevel.SINGLE_VRE && vreOrgId != null ) { - vreScope2Set = (withinPortal) ? getScopeByOrganizationId(vreOrgId) : session.getScope(); + vreScope2Set = (withinPortal) ? getScopeByGroupId(vreOrgId) : session.getScope(); } Feed toShare = null; @@ -418,9 +414,8 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar //need to put the feed into VRES Timeline too if (pLevel == PrivacyLevel.VRES) { _log.trace("PrivacyLevel was set to VRES attempting to write onto User's VRES Timelines"); - for (GroupModel vre : getUserVREs(username)) { - Long orgId = Long.parseLong(vre.getGroupId()); - String vreScope = getScopeByOrganizationId(orgId); + for (GCubeGroup vre : getUserVREs(username)) { + String vreScope = getScopeByGroupId(vre.getGroupId()); _log.trace("Attempting to write onto " + vreScope); try { store.saveFeedToVRETimeline(toShare.getKey(), vreScope); @@ -453,7 +448,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar //send the notification about this posts to everyone in the group if notifyGroup is true if (pLevel == PrivacyLevel.SINGLE_VRE && vreOrgId != null && notifyGroup) { - NotificationsManager nm = new ApplicationNotificationsManager( + NotificationsManager nm = new ApplicationNotificationsManager(getThreadLocalRequest(), vreScope2Set, new SocialNetworkingUser(username, email, fullName, thumbnailAvatarURL), NEWS_FEED_PORTLET_CLASSNAME); @@ -463,7 +458,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar } //send the notification to the mentioned users if (mentionedUsers != null && mentionedUsers.size() > 0) { - NotificationsManager nm = new ApplicationNotificationsManager( + NotificationsManager nm = new ApplicationNotificationsManager(getThreadLocalRequest(), vreScope2Set, new SocialNetworkingUser(username, email, fullName, thumbnailAvatarURL), NEWS_FEED_PORTLET_CLASSNAME); @@ -499,25 +494,33 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar try { ASLSession session = getASLSession(); String username = session.getUsername(); + _log.debug("getUserSettings() for " + username); + String email = username+"@isti.cnr.it"; String fullName = username+" FULL"; String thumbnailURL = "images/Avatar_default.png"; if (isWithinPortal() && username.compareTo(TEST_USER) != 0) { - long companyId = OrganizationsUtil.getCompany().getCompanyId(); - com.liferay.portal.model.UserModel user = UserLocalServiceUtil.getUserByScreenName(companyId, 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(); + UserManager um = new LiferayUserManager(); + GCubeUser user = um.getUserByUsername(username); + + thumbnailURL = user.getUserAvatarURL(); + fullName = user.getFullname(); + email = user.getEmail(); + final String profilePageURL = + GCubePortalConstants.PREFIX_GROUP_URL + + PortalContext.getConfiguration().getSiteLandingPagePath(getThreadLocalRequest())+ + GCubePortalConstants.USER_PROFILE_FRIENDLY_URL; + String accountURL = profilePageURL; + try { + accountURL = ""; + }catch (NullPointerException e) { + e.printStackTrace(); + } HashMap vreNames = getUserVreNames(username); - - UserInfo userInfo = new UserInfo(username, fullName, thumbnailURL, user.getEmailAddress(), accountURL, true, isAdmin(), vreNames); - + UserInfo userInfo = new UserInfo(username, fullName, thumbnailURL, user.getEmail(), accountURL, true, isAdmin(), vreNames); UserSettings toReturn = new UserSettings(userInfo, 0, session.getScopeName(), isInfrastructureScope(), isNotificationViaEmailEnabled(session)); + _log.debug("getUserSettings() return " + toReturn); return toReturn; } else { @@ -536,11 +539,30 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar return new UserSettings(); } - private boolean isNotificationViaEmailEnabled(ASLSession session) throws PortalException, SystemException { - Organization currOrg = OrganizationLocalServiceUtil.getOrganization(session.getGroupId()); - return OrganizationManagerImpl.readOrganizationCustomAttribute(session.getUsername(), currOrg, ATTR_TO_CHECK); + private boolean isNotificationViaEmailEnabled(ASLSession session) throws UserManagementSystemException, GroupRetrievalFault { + GroupManager gm = new LiferayGroupManager(); + GCubeGroup group = gm.getGroup(session.getGroupId()); + return (Boolean) gm.readCustomAttr(group.getGroupId(), CustomAttributeKeys.POST_NOTIFICATION.getKeyName()); + } + /** + * tell if the user is a portal administrator or not + * @param username + * @return true if is admin + * @throws SystemException + * @throws PortalException + */ + private boolean isAdmin() throws PortalException, SystemException { + if (! isWithinPortal()) + return false; + try { + GCubeUser curUser = new LiferayUserManager().getUserByUsername(getASLSession().getUsername()); + return new LiferayRoleManager().isAdmin(curUser.getUserId()); + } + catch (Exception e) { + _log.error("Could not check if the user is an Administrator, returning false"); + return false; + } } - /** * generate a preview of the file, upload the file on the storage and shorts the link */ @@ -624,8 +646,6 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar * Open Graph protocol * Meta "title" and "description" tags * Best guess from page content (not recommended) - * - * Schema.org microdata <-- This is still a TODO */ @Override public LinkPreview checkLink(String linkToCheck) { @@ -647,15 +667,17 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar URL pageURL; URLConnection siteConnection = null; try { - pageURL = new URL(linkToCheck); + pageURL = new URL(null, linkToCheck, new sun.net.www.protocol.https.Handler()); if (pageURL.getProtocol().equalsIgnoreCase("https")) { System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol"); java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider()); TextTransfromUtils.trustAllHTTPSConnections(); siteConnection = (HttpsURLConnection) pageURL.openConnection(); } - else + else { + pageURL = new URL(linkToCheck); siteConnection = (HttpURLConnection) pageURL.openConnection(); + } } catch (MalformedURLException e) { _log.error("url is not valid"); return null; @@ -716,70 +738,27 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar */ private HashMap getUserVreNames(String username) { HashMap toReturn = new HashMap(); - for (GroupModel vre : getUserVREs(username)) { + for (GCubeGroup vre : getUserVREs(username)) { if (vre.getGroupName().compareTo(getASLSession().getGroupName())==0) - toReturn.put(vre.getGroupId(), vre.getGroupName()); + toReturn.put(vre.getGroupId()+"", vre.getGroupName()); } - // } - return toReturn; } - /** - * tell if the user is a portal administrator or not - * @param username - * @return true if is admin - * @throws SystemException - * @throws PortalException - */ - private boolean isAdmin() throws PortalException, SystemException { - com.liferay.portal.model.User currUser = OrganizationsUtil.validateUser(getASLSession().getUsername()); - List organizations = OrganizationLocalServiceUtil.getOrganizations(0, OrganizationLocalServiceUtil.getOrganizationsCount()); - Organization rootOrganization = null; - for (Organization organization : organizations) { - if (organization.getName().equals(OrganizationsUtil.getRootOrganizationName() ) ) { - rootOrganization = organization; - break; - } - } - try { - _log.trace("root: " + rootOrganization.getName() ); - return (hasRole(ADMIN_ROLE, rootOrganization.getName(), currUser)); - } - catch (NullPointerException e) { - _log.error("Cannot find root organziation, please check gcube-data.properties file in $CATALINA_HOME/conf folder"); - return false; - } - } - - /** - * - * @param rolename - * @param organizationName - * @param user - * @return - * @throws SystemException - */ - private boolean hasRole(String rolename, String organizationName, com.liferay.portal.model.User user) throws SystemException { - for (Role role : user.getRoles()) - if (role.getName().compareTo(rolename) == 0 ) - return true; - return false; - } /** * * @param username * @return */ - private ArrayList getUserVREs(String username) { - ArrayList toReturn = new ArrayList(); - com.liferay.portal.model.User currUser; + private ArrayList getUserVREs(String username) { + ArrayList toReturn = new ArrayList(); + GCubeUser currUser; try { GroupManager gm = new LiferayGroupManager(); - currUser = OrganizationsUtil.validateUser(username); - for (Organization org : currUser.getOrganizations()) - if (gm.isVRE(org.getOrganizationId()+"")) { - GroupModel toAdd = gm.getGroup(""+org.getOrganizationId()); - toReturn.add(toAdd); + currUser = new LiferayUserManager().getUserByUsername(username); + + for (GCubeGroup group : gm.listGroupsByUser(currUser.getUserId())) + if (gm.isVRE(group.getGroupId())) { + toReturn.add(group); } } catch (Exception e) { _log.error("Failed reading User VREs for : " + username); @@ -789,12 +768,11 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar return toReturn; } - private String getScopeByOrganizationId(Long vreOrgId) { - GroupManager gm = new LiferayGroupManager(); + private String getScopeByGroupId(Long vreGroupId) { try { - return gm.getScope(vreOrgId+""); + return new LiferayGroupManager().getInfrastructureScope(vreGroupId); } catch (Exception e) { - _log.error("Could not find a scope for this vreOrgId: " + vreOrgId); + _log.error("Could not find a scope for this vreGroupId: " + vreGroupId); return null; } } @@ -872,7 +850,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar UserManager um = new LiferayUserManager(); GroupManager gm = new LiferayGroupManager(); ScopeBean sb = new ScopeBean(scope); - List users = null; + List users = null; if (sb.is(Type.INFRASTRUCTURE)) users = um.listUsersByGroup(gm.getRootVO().getGroupId()); @@ -886,12 +864,9 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar _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 && user.getScreenName().compareTo(currUser) != 0) { //skip test.user & current user - String thumbnailURL = ""; - com.liferay.portal.model.UserModel lifeUser = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), user.getScreenName()); - thumbnailURL = "/image/user_male_portrait?img_id="+lifeUser.getPortraitId(); - portalUsers.add(new ItemBean(user.getUserId(), user.getScreenName(), user.getFullname(), thumbnailURL)); + for (GCubeUser user : users) { + if (user.getUsername().compareTo(TEST_USER) != 0 && user.getUsername().compareTo(currUser) != 0) { //skip test.user & current user + portalUsers.add(new ItemBean(user.getUserId()+"", user.getUsername(), user.getFullname(), user.getUserAvatarURL())); } } } diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/server/TextTransfromUtils.java b/src/main/java/org/gcube/portlets/user/shareupdates/server/TextTransfromUtils.java index bb5c8f0..d3e64f5 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/server/TextTransfromUtils.java +++ b/src/main/java/org/gcube/portlets/user/shareupdates/server/TextTransfromUtils.java @@ -15,8 +15,11 @@ import java.util.regex.Pattern; import javax.net.ssl.SSLContext; import javax.net.ssl.TrustManager; import javax.net.ssl.X509TrustManager; +import javax.servlet.http.HttpServletRequest; import org.apache.commons.codec.binary.Base64; +import org.gcube.common.portal.GCubePortalConstants; +import org.gcube.common.portal.PortalContext; import org.gcube.portal.databook.client.GCubeSocialNetworking; import org.gcube.portlets.user.shareupdates.server.metaseeker.MetaSeeker; import org.gcube.portlets.user.shareupdates.server.opengraph.OpenGraph; @@ -28,6 +31,8 @@ import org.htmlparser.beans.StringBean; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.liferay.portal.kernel.exception.PortalException; +import com.liferay.portal.kernel.exception.SystemException; import com.sun.net.ssl.HttpsURLConnection; /** * this class contains utility method for parsing and trasforming users pasted text containing URLs and other utility methods @@ -52,16 +57,18 @@ public class TextTransfromUtils { return sb.toString(); } - /** * convert the mentioned people in HTML anchor and also Encode the params Base64 * @param escapedFeedText * @param taggedPeople * @return */ - protected static String convertMentionPeopleAnchorHTML(String escapedFeedText, List taggedPeople) { + protected static String convertMentionPeopleAnchorHTML(String escapedFeedText, ArrayList taggedPeople, HttpServletRequest request) { + String userProfilePageURL = ""; + userProfilePageURL = PortalContext.getConfiguration().getSiteLandingPagePath(request)+GCubePortalConstants.USER_PROFILE_FRIENDLY_URL; + for (ItemBean tagged : taggedPeople) { - String taggedHTML = ""+tagged.getAlternativeName()+" "; @@ -69,7 +76,6 @@ public class TextTransfromUtils { } return escapedFeedText; } - /** * utility method that extract the hashtags from a text * @param postText diff --git a/src/main/java/org/gcube/portlets/user/shareupdates/shared/UserSettings.java b/src/main/java/org/gcube/portlets/user/shareupdates/shared/UserSettings.java index d052306..123e6b6 100644 --- a/src/main/java/org/gcube/portlets/user/shareupdates/shared/UserSettings.java +++ b/src/main/java/org/gcube/portlets/user/shareupdates/shared/UserSettings.java @@ -58,12 +58,15 @@ public class UserSettings implements Serializable { public void setInfrastructure(boolean isInfrastructure) { this.isInfrastructure = isInfrastructure; } + @Override public String toString() { return "UserSettings [userInfo=" + userInfo + ", refreshingTimeInMillis=" + refreshingTimeInMillis + ", currentScope=" + currentScope + ", isInfrastructure=" - + isInfrastructure + "]"; + + isInfrastructure + ", isNotificationViaEmailEnabled=" + + isNotificationViaEmailEnabled + "]"; } + } diff --git a/src/main/webapp/ShareUpdates.css b/src/main/webapp/ShareUpdates.css index 84b8e78..93092e0 100644 --- a/src/main/webapp/ShareUpdates.css +++ b/src/main/webapp/ShareUpdates.css @@ -3,19 +3,6 @@ td>form { margin-bottom: 0px !important; } -fieldset { - padding-bottom: 0px !important; - padding-left: 0px !important; -} - -fieldset .control-group { - margin-bottom: 0px; -} - -fieldset select { - margin-bottom: 0px; -} - .share-updates-table { border-collapse: collapse; width: 100%; @@ -79,7 +66,7 @@ fieldset select { /* this is very important when usere paste long links*/ } -.postTextArea { +div#inputContainer textarea.postTextArea { padding: 4px 2px; color: #999; background-color: transparent; @@ -145,17 +132,6 @@ fieldset select { background: #e3e8f3; } -.framed { - margin: 0 0 10px; - padding: 10px; - margin: 0px 5px; - background-color: #FFF; - border-radius: 6px !important; - -moz-border-radius: 6px !important; - -webkit-border-radius: 6px !important; - border: 1px solid #DBDBDB; -} - .buttonDiv { text-align: right; padding-top: 2px; @@ -286,7 +262,7 @@ a.link:hover { background-image: none; } -.wizardListbox { +select.wizardListbox { height: 25px; width: 372px; background: #F2F2F2 url(images/white-grad.png) repeat-x scroll left top; diff --git a/src/main/webapp/WEB-INF/jsp/ShareUpdates_view.jsp b/src/main/webapp/WEB-INF/jsp/ShareUpdates_view.jsp index 340c083..6dc7e55 100644 --- a/src/main/webapp/WEB-INF/jsp/ShareUpdates_view.jsp +++ b/src/main/webapp/WEB-INF/jsp/ShareUpdates_view.jsp @@ -13,8 +13,6 @@ window.PageBus = window.parent.PageBus; } - -