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="/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="/target/generated-sources/gwt"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/resources"/> <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="java-output-path" value="/${module}/target/www/WEB-INF/classes"/>
<property name="context-root" value="share-updates"/> <property name="context-root" value="share-updates"/>
</wb-module> </wb-module>

36
pom.xml
View File

@ -27,7 +27,7 @@
<!-- Convenience property to set the GWT version --> <!-- Convenience property to set the GWT version -->
<gwtVersion>2.7.0</gwtVersion> <gwtVersion>2.7.0</gwtVersion>
<distroDirectory>distro</distroDirectory> <distroDirectory>distro</distroDirectory>
<liferay.version>6.2.5</liferay.version>
<maven.compiler.source>1.7</maven.compiler.source> <maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target> <maven.compiler.target>1.7</maven.compiler.target>
<webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory> <webappDirectory>${project.build.directory}/${project.build.finalName}</webappDirectory>
@ -59,7 +59,7 @@
<version>${gwtVersion}</version> <version>${gwtVersion}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.google.gwt</groupId> <groupId>com.google.gwt</groupId>
<artifactId>gwt-dev</artifactId> <artifactId>gwt-dev</artifactId>
<version>${gwtVersion}</version> <version>${gwtVersion}</version>
@ -72,6 +72,7 @@
<dependency> <dependency>
<groupId>org.gcube.common.portal</groupId> <groupId>org.gcube.common.portal</groupId>
<artifactId>portal-manager</artifactId> <artifactId>portal-manager</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.portal</groupId> <groupId>org.gcube.portal</groupId>
@ -81,6 +82,8 @@
<dependency> <dependency>
<groupId>org.gcube.portal</groupId> <groupId>org.gcube.portal</groupId>
<artifactId>notifications-common-library</artifactId> <artifactId>notifications-common-library</artifactId>
<version>[1.3.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.applicationsupportlayer</groupId> <groupId>org.gcube.applicationsupportlayer</groupId>
@ -90,11 +93,13 @@
<dependency> <dependency>
<groupId>org.gcube.applicationsupportlayer</groupId> <groupId>org.gcube.applicationsupportlayer</groupId>
<artifactId>aslsocial</artifactId> <artifactId>aslsocial</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.portlets.user</groupId> <groupId>org.gcube.portlets.user</groupId>
<artifactId>gcube-widgets</artifactId> <artifactId>gcube-widgets</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -160,12 +165,6 @@
<groupId>org.gcube.common</groupId> <groupId>org.gcube.common</groupId>
<artifactId>home-library</artifactId> <artifactId>home-library</artifactId>
<scope>provided</scope> <scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>asm-all</artifactId>
<groupId>asm</groupId>
</exclusion>
</exclusions>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.common</groupId> <groupId>org.gcube.common</groupId>
@ -175,11 +174,13 @@
<dependency> <dependency>
<groupId>org.gcube.portal</groupId> <groupId>org.gcube.portal</groupId>
<artifactId>custom-portal-handler</artifactId> <artifactId>custom-portal-handler</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.gcube.dvos</groupId> <groupId>org.gcube.dvos</groupId>
<artifactId>usermanagement-core</artifactId> <artifactId>usermanagement-core</artifactId>
<version>[2.0.0-SNAPSHOT, 3.0.0-SNAPSHOT)</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
@ -215,6 +216,25 @@
<dependency> <dependency>
<groupId>com.liferay.portal</groupId> <groupId>com.liferay.portal</groupId>
<artifactId>portal-service</artifactId> <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> <scope>provided</scope>
</dependency> </dependency>
<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 org.gcube.portlets.user.shareupdates.client.view.ShareUpdateForm;
import com.google.gwt.core.client.EntryPoint; 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.Window.Location;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.RootPanel; 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 class ShareUpdates implements EntryPoint {
public void onModuleLoad() { 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 // start UI and related stuff
ClientScopeHelper.getService().setScope(Location.getHref(), new AsyncCallback<Boolean>() { ClientScopeHelper.getService().setScope(Location.getHref(), new AsyncCallback<Boolean>() {
@Override @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 //change css if deployed in VRE scope
if (!userSettings.isInfrastructure()) { if (!userSettings.isInfrastructure()) {
mainPanel.addStyleName("framed");
notifyListbox.addItem("Share with: " + singleVREName); notifyListbox.addItem("Share with: " + singleVREName);
notifyListbox.addItem("Share with: " + singleVREName+" + Notification to members"); notifyListbox.addItem("Share with: " + singleVREName+" + Notification to members");
if (notificationEmail) { if (notificationEmail) {

View File

@ -37,8 +37,7 @@
</td> </td>
<td class="share-updates-cell"> <td class="share-updates-cell">
<b:Form> <b:Form>
<b:Fieldset>
<b:ControlGroup>
<g:ListBox styleName="wizardListbox" ui:field="privacyLevel" <g:ListBox styleName="wizardListbox" ui:field="privacyLevel"
visible="false" /> visible="false" />
<g:ListBox styleName="wizardListbox" ui:field="notifyListbox" <g:ListBox styleName="wizardListbox" ui:field="notifyListbox"
@ -46,10 +45,8 @@
<b:Button ui:field="attachButton" icon="UPLOAD_ALT" <b:Button ui:field="attachButton" icon="UPLOAD_ALT"
visible="false" /> visible="false" />
<b:Button ui:field="submitButton" type="INFO" width="52px" <b:Button ui:field="submitButton" type="PRIMARY" width="70px"
text="Share" visible="false" /> text="Share" visible="false" />
</b:ControlGroup>
</b:Fieldset>
</b:Form> </b:Form>
</td> </td>
</tr> </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.ApplicationNotificationsManager;
import org.gcube.applicationsupportlayer.social.NotificationsManager; import org.gcube.applicationsupportlayer.social.NotificationsManager;
import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser; import org.gcube.applicationsupportlayer.social.shared.SocialNetworkingUser;
import org.gcube.common.portal.GCubePortalConstants;
import org.gcube.common.portal.PortalContext; import org.gcube.common.portal.PortalContext;
import org.gcube.common.scope.api.ScopeProvider; import org.gcube.common.scope.api.ScopeProvider;
import org.gcube.common.scope.impl.ScopeBean; 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.AccessType;
import org.gcube.contentmanager.storageclient.wrapper.MemoryType; import org.gcube.contentmanager.storageclient.wrapper.MemoryType;
import org.gcube.contentmanager.storageclient.wrapper.StorageClient; 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.custom.scopemanager.scopehelper.ScopeHelper;
import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl; import org.gcube.portal.databook.server.DBCassandraAstyanaxImpl;
import org.gcube.portal.databook.server.DatabookStore; 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.portlets.widgets.pickitem.shared.ItemBean;
import org.gcube.vomanagement.usermanagement.GroupManager; import org.gcube.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.UserManager; import org.gcube.vomanagement.usermanagement.UserManager;
import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayGroupManager; import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayUserManager; import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
import org.gcube.vomanagement.usermanagement.model.GroupModel; import org.gcube.vomanagement.usermanagement.impl.LiferayGroupManager;
import org.gcube.vomanagement.usermanagement.model.UserModel; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.google.gwt.user.server.rpc.RemoteServiceServlet; import com.google.gwt.user.server.rpc.RemoteServiceServlet;
import com.liferay.portal.kernel.exception.PortalException; import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException; 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.service.UserLocalServiceUtil;
import com.liferay.portal.theme.ThemeDisplay;
/** /**
* The server side implementation of the RPC service. * The server side implementation of the RPC service.
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class ShareUpdateServiceImpl extends RemoteServiceServlet implements ShareUpdateService { public class ShareUpdateServiceImpl extends RemoteServiceServlet implements ShareUpdateService {
/**
*
*/
private static final String ADMIN_ROLE = "Administrator";
public static final String TEST_USER = "test.user"; public static final String TEST_USER = "test.user";
private static final String STORAGE_OWNER = "gCubeSocialFramework"; private static final String STORAGE_OWNER = "gCubeSocialFramework";
public static final String UPLOAD_DIR = "/social-framework-uploads"; 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 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() { public String getDevelopmentUser() {
String user = TEST_USER; String user = TEST_USER;
// user = "costantino.perciante"; // user = "costantino.perciante";
return user; return user;
} }
/** /**
@ -161,7 +153,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
ArrayList<ItemBean> mentionedUsers = null; ArrayList<ItemBean> mentionedUsers = null;
if (mentionedUserFullNames != null && ! mentionedUserFullNames.isEmpty()) { if (mentionedUserFullNames != null && ! mentionedUserFullNames.isEmpty()) {
mentionedUsers = getSelectedUserIds(mentionedUserFullNames); mentionedUsers = getSelectedUserIds(mentionedUserFullNames);
escapedFeedText = TextTransfromUtils.convertMentionPeopleAnchorHTML(escapedFeedText, mentionedUsers); escapedFeedText = TextTransfromUtils.convertMentionPeopleAnchorHTML(escapedFeedText, mentionedUsers, getThreadLocalRequest());
} }
// get session // get session
@ -197,7 +189,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
//get the VRE scope if single channel post //get the VRE scope if single channel post
String vreScope2Set = ""; String vreScope2Set = "";
if (pLevel == PrivacyLevel.SINGLE_VRE && vreOrgId != null) { 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) // 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 //need to put the feed into VRES Timeline too
if (pLevel == PrivacyLevel.VRES) { if (pLevel == PrivacyLevel.VRES) {
_log.trace("PrivacyLevel was set to VRES attempting to write onto User's VRES Timelines"); _log.trace("PrivacyLevel was set to VRES attempting to write onto User's VRES Timelines");
for (GroupModel vre : getUserVREs(username)) { for (GCubeGroup vre : getUserVREs(username)) {
Long orgId = Long.parseLong(vre.getGroupId()); String vreScope = "";
String vreScope = getScopeByOrganizationId(orgId);
_log.trace("Attempting to write onto " + vreScope);
try { try {
vreScope = new LiferayGroupManager().getInfrastructureScope(vre.getGroupId());
_log.trace("Attempting to write onto " + vreScope);
store.saveFeedToVRETimeline(toShare.getKey(), vreScope); store.saveFeedToVRETimeline(toShare.getKey(), vreScope);
} catch (FeedIDNotFoundException e) { } catch (FeedIDNotFoundException e) {
_log.error("Error writing onto VRES Time Line" + vreScope); _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); _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 //send the notification about this posts to everyone in the group if notifyGroup is true
if (pLevel == PrivacyLevel.SINGLE_VRE && vreOrgId != null && notifyGroup) { if (pLevel == PrivacyLevel.SINGLE_VRE && vreOrgId != null && notifyGroup) {
NotificationsManager nm = new ApplicationNotificationsManager( NotificationsManager nm = new ApplicationNotificationsManager(getThreadLocalRequest(),
vreScope2Set, vreScope2Set,
new SocialNetworkingUser(username, email, fullName, thumbnailAvatarURL), new SocialNetworkingUser(username, email, fullName, thumbnailAvatarURL),
NEWS_FEED_PORTLET_CLASSNAME); NEWS_FEED_PORTLET_CLASSNAME);
@ -257,7 +253,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
} }
//send the notification to the mentioned users //send the notification to the mentioned users
if (mentionedUsers != null && mentionedUsers.size() > 0) { if (mentionedUsers != null && mentionedUsers.size() > 0) {
NotificationsManager nm = new ApplicationNotificationsManager( NotificationsManager nm = new ApplicationNotificationsManager(getThreadLocalRequest(),
vreScope2Set, vreScope2Set,
new SocialNetworkingUser(username, email, fullName, thumbnailAvatarURL), new SocialNetworkingUser(username, email, fullName, thumbnailAvatarURL),
NEWS_FEED_PORTLET_CLASSNAME); NEWS_FEED_PORTLET_CLASSNAME);
@ -292,7 +288,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
ArrayList<ItemBean> mentionedUsers = null; ArrayList<ItemBean> mentionedUsers = null;
if (mentionedUserFullNames != null && ! mentionedUserFullNames.isEmpty()) { if (mentionedUserFullNames != null && ! mentionedUserFullNames.isEmpty()) {
mentionedUsers = getSelectedUserIds(mentionedUserFullNames); mentionedUsers = getSelectedUserIds(mentionedUserFullNames);
escapedFeedText = TextTransfromUtils.convertMentionPeopleAnchorHTML(escapedFeedText, mentionedUsers); escapedFeedText = TextTransfromUtils.convertMentionPeopleAnchorHTML(escapedFeedText, mentionedUsers, getThreadLocalRequest());
} }
ASLSession session = getASLSession(); ASLSession session = getASLSession();
@ -382,7 +378,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
//get the VRE scope if single channel post //get the VRE scope if single channel post
String vreScope2Set = ""; String vreScope2Set = "";
if (pLevel == PrivacyLevel.SINGLE_VRE && vreOrgId != null ) { if (pLevel == PrivacyLevel.SINGLE_VRE && vreOrgId != null ) {
vreScope2Set = (withinPortal) ? getScopeByOrganizationId(vreOrgId) : session.getScope(); vreScope2Set = (withinPortal) ? getScopeByGroupId(vreOrgId) : session.getScope();
} }
Feed toShare = null; Feed toShare = null;
@ -418,9 +414,8 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
//need to put the feed into VRES Timeline too //need to put the feed into VRES Timeline too
if (pLevel == PrivacyLevel.VRES) { if (pLevel == PrivacyLevel.VRES) {
_log.trace("PrivacyLevel was set to VRES attempting to write onto User's VRES Timelines"); _log.trace("PrivacyLevel was set to VRES attempting to write onto User's VRES Timelines");
for (GroupModel vre : getUserVREs(username)) { for (GCubeGroup vre : getUserVREs(username)) {
Long orgId = Long.parseLong(vre.getGroupId()); String vreScope = getScopeByGroupId(vre.getGroupId());
String vreScope = getScopeByOrganizationId(orgId);
_log.trace("Attempting to write onto " + vreScope); _log.trace("Attempting to write onto " + vreScope);
try { try {
store.saveFeedToVRETimeline(toShare.getKey(), vreScope); 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 //send the notification about this posts to everyone in the group if notifyGroup is true
if (pLevel == PrivacyLevel.SINGLE_VRE && vreOrgId != null && notifyGroup) { if (pLevel == PrivacyLevel.SINGLE_VRE && vreOrgId != null && notifyGroup) {
NotificationsManager nm = new ApplicationNotificationsManager( NotificationsManager nm = new ApplicationNotificationsManager(getThreadLocalRequest(),
vreScope2Set, vreScope2Set,
new SocialNetworkingUser(username, email, fullName, thumbnailAvatarURL), new SocialNetworkingUser(username, email, fullName, thumbnailAvatarURL),
NEWS_FEED_PORTLET_CLASSNAME); NEWS_FEED_PORTLET_CLASSNAME);
@ -463,7 +458,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
} }
//send the notification to the mentioned users //send the notification to the mentioned users
if (mentionedUsers != null && mentionedUsers.size() > 0) { if (mentionedUsers != null && mentionedUsers.size() > 0) {
NotificationsManager nm = new ApplicationNotificationsManager( NotificationsManager nm = new ApplicationNotificationsManager(getThreadLocalRequest(),
vreScope2Set, vreScope2Set,
new SocialNetworkingUser(username, email, fullName, thumbnailAvatarURL), new SocialNetworkingUser(username, email, fullName, thumbnailAvatarURL),
NEWS_FEED_PORTLET_CLASSNAME); NEWS_FEED_PORTLET_CLASSNAME);
@ -499,25 +494,33 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
try { try {
ASLSession session = getASLSession(); ASLSession session = getASLSession();
String username = session.getUsername(); String username = session.getUsername();
_log.debug("getUserSettings() for " + username);
String email = username+"@isti.cnr.it"; String email = username+"@isti.cnr.it";
String fullName = username+" FULL"; String fullName = username+" FULL";
String thumbnailURL = "images/Avatar_default.png"; String thumbnailURL = "images/Avatar_default.png";
if (isWithinPortal() && username.compareTo(TEST_USER) != 0) { if (isWithinPortal() && username.compareTo(TEST_USER) != 0) {
long companyId = OrganizationsUtil.getCompany().getCompanyId(); UserManager um = new LiferayUserManager();
com.liferay.portal.model.UserModel user = UserLocalServiceUtil.getUserByScreenName(companyId, username); GCubeUser user = um.getUserByUsername(username);
thumbnailURL = "/image/user_male_portrait?img_id="+user.getPortraitId(); thumbnailURL = user.getUserAvatarURL();
fullName = user.getFirstName() + " " + user.getLastName(); fullName = user.getFullname();
email = user.getEmailAddress(); email = user.getEmail();
ThemeDisplay themeDisplay = (ThemeDisplay) this.getThreadLocalRequest().getSession().getAttribute(WebKeys.THEME_DISPLAY); final String profilePageURL =
GCubePortalConstants.PREFIX_GROUP_URL +
String accountURL = themeDisplay.getURLMyAccount().toString(); 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); HashMap<String, String> vreNames = getUserVreNames(username);
UserInfo userInfo = new UserInfo(username, fullName, thumbnailURL, user.getEmail(), accountURL, true, isAdmin(), vreNames);
UserInfo userInfo = new UserInfo(username, fullName, thumbnailURL, user.getEmailAddress(), accountURL, true, isAdmin(), vreNames);
UserSettings toReturn = new UserSettings(userInfo, 0, session.getScopeName(), isInfrastructureScope(), isNotificationViaEmailEnabled(session)); UserSettings toReturn = new UserSettings(userInfo, 0, session.getScopeName(), isInfrastructureScope(), isNotificationViaEmailEnabled(session));
_log.debug("getUserSettings() return " + toReturn);
return toReturn; return toReturn;
} }
else { else {
@ -536,11 +539,30 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
return new UserSettings(); return new UserSettings();
} }
private boolean isNotificationViaEmailEnabled(ASLSession session) throws PortalException, SystemException { private boolean isNotificationViaEmailEnabled(ASLSession session) throws UserManagementSystemException, GroupRetrievalFault {
Organization currOrg = OrganizationLocalServiceUtil.getOrganization(session.getGroupId()); GroupManager gm = new LiferayGroupManager();
return OrganizationManagerImpl.readOrganizationCustomAttribute(session.getUsername(), currOrg, ATTR_TO_CHECK); 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 * 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 * Open Graph protocol
* Meta "title" and "description" tags * Meta "title" and "description" tags
* Best guess from page content (not recommended) * Best guess from page content (not recommended)
*
* Schema.org microdata <-- This is still a TODO
*/ */
@Override @Override
public LinkPreview checkLink(String linkToCheck) { public LinkPreview checkLink(String linkToCheck) {
@ -647,15 +667,17 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
URL pageURL; URL pageURL;
URLConnection siteConnection = null; URLConnection siteConnection = null;
try { try {
pageURL = new URL(linkToCheck); pageURL = new URL(null, linkToCheck, new sun.net.www.protocol.https.Handler());
if (pageURL.getProtocol().equalsIgnoreCase("https")) { if (pageURL.getProtocol().equalsIgnoreCase("https")) {
System.setProperty("java.protocol.handler.pkgs", "com.sun.net.ssl.internal.www.protocol"); 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()); java.security.Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
TextTransfromUtils.trustAllHTTPSConnections(); TextTransfromUtils.trustAllHTTPSConnections();
siteConnection = (HttpsURLConnection) pageURL.openConnection(); siteConnection = (HttpsURLConnection) pageURL.openConnection();
} }
else else {
pageURL = new URL(linkToCheck);
siteConnection = (HttpURLConnection) pageURL.openConnection(); siteConnection = (HttpURLConnection) pageURL.openConnection();
}
} catch (MalformedURLException e) { } catch (MalformedURLException e) {
_log.error("url is not valid"); _log.error("url is not valid");
return null; return null;
@ -716,70 +738,27 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
*/ */
private HashMap<String, String> getUserVreNames(String username) { private HashMap<String, String> getUserVreNames(String username) {
HashMap<String, String> toReturn = new HashMap<String, String>(); 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) if (vre.getGroupName().compareTo(getASLSession().getGroupName())==0)
toReturn.put(vre.getGroupId(), vre.getGroupName()); toReturn.put(vre.getGroupId()+"", vre.getGroupName());
} }
// }
return toReturn; 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 * @param username
* @return * @return
*/ */
private ArrayList<GroupModel> getUserVREs(String username) { private ArrayList<GCubeGroup> getUserVREs(String username) {
ArrayList<GroupModel> toReturn = new ArrayList<GroupModel>(); ArrayList<GCubeGroup> toReturn = new ArrayList<GCubeGroup>();
com.liferay.portal.model.User currUser; GCubeUser currUser;
try { try {
GroupManager gm = new LiferayGroupManager(); GroupManager gm = new LiferayGroupManager();
currUser = OrganizationsUtil.validateUser(username); currUser = new LiferayUserManager().getUserByUsername(username);
for (Organization org : currUser.getOrganizations())
if (gm.isVRE(org.getOrganizationId()+"")) { for (GCubeGroup group : gm.listGroupsByUser(currUser.getUserId()))
GroupModel toAdd = gm.getGroup(""+org.getOrganizationId()); if (gm.isVRE(group.getGroupId())) {
toReturn.add(toAdd); toReturn.add(group);
} }
} catch (Exception e) { } catch (Exception e) {
_log.error("Failed reading User VREs for : " + username); _log.error("Failed reading User VREs for : " + username);
@ -789,12 +768,11 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
return toReturn; return toReturn;
} }
private String getScopeByOrganizationId(Long vreOrgId) { private String getScopeByGroupId(Long vreGroupId) {
GroupManager gm = new LiferayGroupManager();
try { try {
return gm.getScope(vreOrgId+""); return new LiferayGroupManager().getInfrastructureScope(vreGroupId);
} catch (Exception e) { } 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; return null;
} }
} }
@ -872,7 +850,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
UserManager um = new LiferayUserManager(); UserManager um = new LiferayUserManager();
GroupManager gm = new LiferayGroupManager(); GroupManager gm = new LiferayGroupManager();
ScopeBean sb = new ScopeBean(scope); ScopeBean sb = new ScopeBean(scope);
List<UserModel> users = null; List<GCubeUser> users = null;
if (sb.is(Type.INFRASTRUCTURE)) if (sb.is(Type.INFRASTRUCTURE))
users = um.listUsersByGroup(gm.getRootVO().getGroupId()); 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"); _log.error("Error, you must be in SCOPE VRE OR INFRASTURCTURE, you are in VO SCOPE returning no users");
return portalUsers; return portalUsers;
} }
for (UserModel user : users) { for (GCubeUser user : users) {
if (user.getScreenName().compareTo("test.user") != 0 && user.getScreenName().compareTo(currUser) != 0) { //skip test.user & current user if (user.getUsername().compareTo(TEST_USER) != 0 && user.getUsername().compareTo(currUser) != 0) { //skip test.user & current user
String thumbnailURL = ""; portalUsers.add(new ItemBean(user.getUserId()+"", user.getUsername(), user.getFullname(), user.getUserAvatarURL()));
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));
} }
} }
} }

View File

@ -15,8 +15,11 @@ import java.util.regex.Pattern;
import javax.net.ssl.SSLContext; import javax.net.ssl.SSLContext;
import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager; import javax.net.ssl.X509TrustManager;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.codec.binary.Base64; 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.portal.databook.client.GCubeSocialNetworking;
import org.gcube.portlets.user.shareupdates.server.metaseeker.MetaSeeker; import org.gcube.portlets.user.shareupdates.server.metaseeker.MetaSeeker;
import org.gcube.portlets.user.shareupdates.server.opengraph.OpenGraph; 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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.liferay.portal.kernel.exception.PortalException;
import com.liferay.portal.kernel.exception.SystemException;
import com.sun.net.ssl.HttpsURLConnection; import com.sun.net.ssl.HttpsURLConnection;
/** /**
* this class contains utility method for parsing and trasforming users pasted text containing URLs and other utility methods * 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(); return sb.toString();
} }
/** /**
* convert the mentioned people in HTML anchor and also Encode the params Base64 * convert the mentioned people in HTML anchor and also Encode the params Base64
* @param escapedFeedText * @param escapedFeedText
* @param taggedPeople * @param taggedPeople
* @return * @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) { 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(GCubeSocialNetworking.USER_PROFILE_OID.getBytes()))+"="+
new String(Base64.encodeBase64(tagged.getName().getBytes()))+"\">"+tagged.getAlternativeName()+"</a> "; new String(Base64.encodeBase64(tagged.getName().getBytes()))+"\">"+tagged.getAlternativeName()+"</a> ";
@ -69,7 +76,6 @@ public class TextTransfromUtils {
} }
return escapedFeedText; return escapedFeedText;
} }
/** /**
* utility method that extract the hashtags from a text * utility method that extract the hashtags from a text
* @param postText * @param postText

View File

@ -58,12 +58,15 @@ public class UserSettings implements Serializable {
public void setInfrastructure(boolean isInfrastructure) { public void setInfrastructure(boolean isInfrastructure) {
this.isInfrastructure = isInfrastructure; this.isInfrastructure = isInfrastructure;
} }
@Override @Override
public String toString() { public String toString() {
return "UserSettings [userInfo=" + userInfo return "UserSettings [userInfo=" + userInfo
+ ", refreshingTimeInMillis=" + refreshingTimeInMillis + ", refreshingTimeInMillis=" + refreshingTimeInMillis
+ ", currentScope=" + currentScope + ", isInfrastructure=" + ", currentScope=" + currentScope + ", isInfrastructure="
+ isInfrastructure + "]"; + isInfrastructure + ", isNotificationViaEmailEnabled="
+ isNotificationViaEmailEnabled + "]";
} }
} }

View File

@ -3,19 +3,6 @@ td>form {
margin-bottom: 0px !important; 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 { .share-updates-table {
border-collapse: collapse; border-collapse: collapse;
width: 100%; width: 100%;
@ -79,7 +66,7 @@ fieldset select {
/* this is very important when usere paste long links*/ /* this is very important when usere paste long links*/
} }
.postTextArea { div#inputContainer textarea.postTextArea {
padding: 4px 2px; padding: 4px 2px;
color: #999; color: #999;
background-color: transparent; background-color: transparent;
@ -145,17 +132,6 @@ fieldset select {
background: #e3e8f3; 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 { .buttonDiv {
text-align: right; text-align: right;
padding-top: 2px; padding-top: 2px;
@ -286,7 +262,7 @@ a.link:hover {
background-image: none; background-image: none;
} }
.wizardListbox { select.wizardListbox {
height: 25px; height: 25px;
width: 372px; width: 372px;
background: #F2F2F2 url(images/white-grad.png) repeat-x scroll left top; background: #F2F2F2 url(images/white-grad.png) repeat-x scroll left top;

View File

@ -13,8 +13,6 @@
window.PageBus = window.parent.PageBus; window.PageBus = window.parent.PageBus;
} }
</script> </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" <script type="text/javascript"
src='<%=request.getContextPath()%>/shareupdates/shareupdates.nocache.js'></script> src='<%=request.getContextPath()%>/shareupdates/shareupdates.nocache.js'></script>