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
This commit is contained in:
Massimiliano Assante 2016-04-27 12:35:28 +00:00
parent 91bafd17da
commit 75b1336145
10 changed files with 145 additions and 190 deletions

View File

@ -5,6 +5,12 @@
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/target/generated-sources/gwt"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/>
<dependent-module archiveName="gcube-widgets-2.0.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="pickitem-widget-1.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/pickitem-widget/pickitem-widget">
<dependency-type>uses</dependency-type>
</dependent-module>
<property name="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
<property name="context-root" value="share-updates"/>
</wb-module>

36
pom.xml
View File

@ -27,7 +27,7 @@
<!-- Convenience property to set the GWT version -->
<gwtVersion>2.7.0</gwtVersion>
<distroDirectory>distro</distroDirectory>
<liferay.version>6.2.5</liferay.version>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
@ -59,7 +59,7 @@
<version>${gwtVersion}</version>
<scope>provided</scope>
</dependency>
<dependency>
<dependency>
<groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId>
<version>${gwtVersion}</version>
@ -72,6 +72,7 @@
<dependency>
<groupId>org.gcube.common.portal</groupId>
<artifactId>portal-manager</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.portal</groupId>
@ -81,6 +82,8 @@
<dependency>
<groupId>org.gcube.portal</groupId>
<artifactId>notifications-common-library</artifactId>
<version>[1.3.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.applicationsupportlayer</groupId>
@ -90,11 +93,13 @@
<dependency>
<groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>aslsocial</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.portlets.user</groupId>
<artifactId>gcube-widgets</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<scope>compile</scope>
</dependency>
<dependency>
@ -160,12 +165,6 @@
<groupId>org.gcube.common</groupId>
<artifactId>home-library</artifactId>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>asm-all</artifactId>
<groupId>asm</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.gcube.common</groupId>
@ -175,11 +174,13 @@
<dependency>
<groupId>org.gcube.portal</groupId>
<artifactId>custom-portal-handler</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.dvos</groupId>
<artifactId>usermanagement-core</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency>
<dependency>
@ -215,6 +216,25 @@
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>portal-service</artifactId>
<version>${liferay.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-bridges</artifactId>
<version>${liferay.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-taglib</artifactId>
<version>${liferay.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-java</artifactId>
<version>${liferay.version}</version>
<scope>provided</scope>
</dependency>
<dependency>

View File

@ -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<Boolean>() {
@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');
}-*/;
}

View File

@ -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) {

View File

@ -37,8 +37,7 @@
</td>
<td class="share-updates-cell">
<b:Form>
<b:Fieldset>
<b:ControlGroup>
<g:ListBox styleName="wizardListbox" ui:field="privacyLevel"
visible="false" />
<g:ListBox styleName="wizardListbox" ui:field="notifyListbox"
@ -46,10 +45,8 @@
<b:Button ui:field="attachButton" icon="UPLOAD_ALT"
visible="false" />
<b:Button ui:field="submitButton" type="INFO" width="52px"
<b:Button ui:field="submitButton" type="PRIMARY" width="70px"
text="Share" visible="false" />
</b:ControlGroup>
</b:Fieldset>
</b:Form>
</td>
</tr>

View File

@ -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<ItemBean> 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<ItemBean> 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<String, String> 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<String, String> getUserVreNames(String username) {
HashMap<String, String> toReturn = new HashMap<String, String>();
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<Organization> 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<GroupModel> getUserVREs(String username) {
ArrayList<GroupModel> toReturn = new ArrayList<GroupModel>();
com.liferay.portal.model.User currUser;
private ArrayList<GCubeGroup> getUserVREs(String username) {
ArrayList<GCubeGroup> toReturn = new ArrayList<GCubeGroup>();
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<UserModel> users = null;
List<GCubeUser> 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()));
}
}
}

View File

@ -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<ItemBean> taggedPeople) {
protected static String convertMentionPeopleAnchorHTML(String escapedFeedText, ArrayList<ItemBean> taggedPeople, HttpServletRequest request) {
String userProfilePageURL = "";
userProfilePageURL = PortalContext.getConfiguration().getSiteLandingPagePath(request)+GCubePortalConstants.USER_PROFILE_FRIENDLY_URL;
for (ItemBean tagged : taggedPeople) {
String taggedHTML = "<a class=\"link\" style=\"font-size:14px;\" href=\""+GCubeSocialNetworking.USER_PROFILE_LINK
String taggedHTML = "<a class=\"link\" href=\""+userProfilePageURL
+"?"+
new String(Base64.encodeBase64(GCubeSocialNetworking.USER_PROFILE_OID.getBytes()))+"="+
new String(Base64.encodeBase64(tagged.getName().getBytes()))+"\">"+tagged.getAlternativeName()+"</a> ";
@ -69,7 +76,6 @@ public class TextTransfromUtils {
}
return escapedFeedText;
}
/**
* utility method that extract the hashtags from a text
* @param postText

View File

@ -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 + "]";
}
}

View File

@ -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;

View File

@ -13,8 +13,6 @@
window.PageBus = window.parent.PageBus;
}
</script>
<script type="text/javascript" src="<%=request.getContextPath()%>/shareupdates/js/jquery-1.10.1.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/shareupdates/js/bootstrap.min.js"></script>
<script type="text/javascript"
src='<%=request.getContextPath()%>/shareupdates/shareupdates.nocache.js'></script>