Fixed posts when multiple tabs are open, now the status is kept on the client

git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/share-updates@95507 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2014-05-09 15:05:42 +00:00
parent fbecbb7c87
commit 324ff0db64
5 changed files with 55 additions and 33 deletions

View File

@ -7,6 +7,9 @@
<dependent-module archiveName="pickuser-widget-0.4.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/pickuser-widget/pickuser-widget"> <dependent-module archiveName="pickuser-widget-0.4.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/pickuser-widget/pickuser-widget">
<dependency-type>uses</dependency-type> <dependency-type>uses</dependency-type>
</dependent-module> </dependent-module>
<dependent-module archiveName="fileupload-progress-bar-1.1.0-SNAPSHOT.jar" deploy-path="/WEB-INF/lib" handle="module:/resource/fileupload-progress-bar/fileupload-progress-bar">
<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>

View File

@ -1,6 +1,6 @@
<ReleaseNotes> <ReleaseNotes>
<Changeset component="org.gcube.portlets.user.shareupdates.1-3-0" <Changeset component="org.gcube.portlets.user.shareupdates.1-3-0"
date="2014-04-03"> date="2014-05-09">
<Change>Added possibility to alert the users of a VRE when sharing an update</Change> <Change>Added possibility to alert the users of a VRE when sharing an update</Change>
<Change>Refined the way to guess content and images when parsing HTML</Change> <Change>Refined the way to guess content and images when parsing HTML</Change>
<Change>Improved images recognition when parsing html pages having no image indication from openGraph</Change> <Change>Improved images recognition when parsing html pages having no image indication from openGraph</Change>
@ -11,6 +11,7 @@
<Change>resolved problem with AdBlock plugin </Change> <Change>resolved problem with AdBlock plugin </Change>
<Change>Fixed mention user dialog y-position when textbox is higher than usual due to new lines</Change> <Change>Fixed mention user dialog y-position when textbox is higher than usual due to new lines</Change>
<Change>Mention users list now returns only the list of the available users in the current organization</Change> <Change>Mention users list now returns only the list of the available users in the current organization</Change>
<Change>Fixed posts when multiple tabs are open, now the status is kept on the client</Change>
</Changeset> </Changeset>
<Changeset component="org.gcube.portlets.user.shareupdates.1-1-3" <Changeset component="org.gcube.portlets.user.shareupdates.1-1-3"
date="2014-02-10"> date="2014-02-10">

View File

@ -65,6 +65,11 @@
<artifactId>gwt-servlet</artifactId> <artifactId>gwt-servlet</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.gcube.common.portal</groupId>
<artifactId>portal-manager</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
</dependency>
<dependency> <dependency>
<groupId>org.gcube.portal</groupId> <groupId>org.gcube.portal</groupId>
<artifactId>social-networking-library</artifactId> <artifactId>social-networking-library</artifactId>

View File

@ -71,9 +71,8 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
* *
*/ */
private static final String ADMIN_ROLE = "Administrator"; private static final String ADMIN_ROLE = "Administrator";
/**
* 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";
@ -86,10 +85,6 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
* The Cassandra store interface * The Cassandra store interface
*/ */
private DatabookStore store; private DatabookStore store;
/**
* used for debugging in eclipse
*/
private boolean withinPortal = false;
/** /**
* connect to cassandra at startup * connect to cassandra at startup
*/ */
@ -112,19 +107,29 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
if (user == null) { if (user == null) {
_log.warn("USER IS NULL setting test.user and Running OUTSIDE PORTAL"); _log.warn("USER IS NULL setting test.user and Running OUTSIDE PORTAL");
user = getDevelopmentUser(); user = getDevelopmentUser();
SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube/devsec/devVRE"); SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube/devsec/devVRE");
withinPortal = false; }
}
else {
withinPortal = true;
}
return SessionManager.getInstance().getASLSession(sessionID, user); return SessionManager.getInstance().getASLSession(sessionID, user);
} }
public String getDevelopmentUser() { public String getDevelopmentUser() {
String user = "test.user"; String user = TEST_USER;
//user = "massimiliano.assante"; // user = "massimiliano.assante";
return user; return user;
} }
/**
*
* @return true if you're running into the portal, false if in development
*/
private boolean isWithinPortal() {
try {
UserLocalServiceUtil.getService();
return true;
}
catch (com.liferay.portal.kernel.bean.BeanLocatorException ex) {
_log.trace("Development Mode ON");
return false;
}
}
/** /**
* *
@ -146,8 +151,10 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
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 (withinPortal) { boolean withinPortal = isWithinPortal();
if (withinPortal && username.compareTo(TEST_USER) != 0) {
try { try {
UserInfo user = getUserSettings().getUserInfo(); UserInfo user = getUserSettings().getUserInfo();
email = user.getEmailaddress(); email = user.getEmailaddress();
@ -174,14 +181,17 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
textToPost = escapedFeedText; textToPost = escapedFeedText;
//System.out.println("textToPost=" + textToPost); //System.out.println("textToPost=" + textToPost);
} }
ScopeBean scope = new ScopeBean(session.getScope()); //get the VRE scope if single channel post
String vreId2Set = scope.is(Type.VRE) ? scope.toString() : ""; String vreScope2Set = "";
if (pLevel == PrivacyLevel.SINGLE_VRE && vreId != null && vreId.compareTo("") != 0) {
vreScope2Set = (withinPortal) ? getScopeByOrganizationId(vreId) : session.getScope();
}
Feed toShare = new Feed(UUID.randomUUID().toString(), feedType, username, feedDate, Feed toShare = new Feed(UUID.randomUUID().toString(), feedType, username, feedDate,
vreId2Set, url, urlThumbnail, textToPost, pLevel, fullName, email, thumbnailURL, linkTitle, linkDesc, host); vreScope2Set, url, urlThumbnail, textToPost, pLevel, fullName, email, thumbnailURL, linkTitle, linkDesc, host);
_log.trace("Attempting to save Feed with text: " + textToPost + " Level: " + pLevel); _log.info("Attempting to save Feed with text: " + textToPost + " Level: " + pLevel + " Timeline="+vreScope2Set);
boolean result = store.saveUserFeed(toShare); boolean result = store.saveUserFeed(toShare);
@ -202,14 +212,13 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
} //share on a single VRE Timeline } //share on a single VRE Timeline
//receives a VreId(groupId) get the scope from the groupId //receives a VreId(groupId) get the scope from the groupId
else if (pLevel == PrivacyLevel.SINGLE_VRE && vreId != null && vreId.compareTo("") != 0) { else if (pLevel == PrivacyLevel.SINGLE_VRE && vreId != null && vreId.compareTo("") != 0) {
String vreScope = (withinPortal) ? getScopeByOrganizationId(vreId) : "/gcube/devsec/devVRE"; _log.trace("Attempting to write onto " + vreScope2Set);
_log.trace("Attempting to write onto " + vreScope);
try { try {
store.saveFeedToVRETimeline(toShare.getKey(), vreScope); store.saveFeedToVRETimeline(toShare.getKey(), vreScope2Set);
} catch (FeedIDNotFoundException e) { } catch (FeedIDNotFoundException e) {
_log.error("Error writing onto VRES Time Line" + vreScope); _log.error("Error writing onto VRES Time Line" + vreScope2Set);
} //save the feed } //save the feed
_log.trace("Success writing onto " + vreScope); _log.trace("Success writing onto " + vreScope2Set);
} }
if (!result) return null; if (!result) return null;
@ -251,10 +260,9 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
String username = session.getUsername(); String username = session.getUsername();
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 (withinPortal) { if (isWithinPortal() && username.compareTo(TEST_USER) != 0) {
getUserVREs(username);
com.liferay.portal.model.UserModel user = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), username); com.liferay.portal.model.UserModel user = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), username);
thumbnailURL = "/image/user_male_portrait?img_id="+user.getPortraitId(); thumbnailURL = "/image/user_male_portrait?img_id="+user.getPortraitId();
fullName = user.getFirstName() + " " + user.getLastName(); fullName = user.getFirstName() + " " + user.getLastName();
@ -569,6 +577,10 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
@Override @Override
public ArrayList<PickingUser> getPortalUsers() { public ArrayList<PickingUser> getPortalUsers() {
ASLSession session = getASLSession(); ASLSession session = getASLSession();
boolean withinPortal = false;
if (isWithinPortal() && session.getUsername().compareTo(TEST_USER) != 0) {
withinPortal = true;
}
return getOrganizationUsers(session.getScope(), session.getUsername(), withinPortal); return getOrganizationUsers(session.getScope(), session.getUsername(), withinPortal);
} }
@ -626,4 +638,5 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
return portalUsers; return portalUsers;
} }
} }

View File

@ -12,7 +12,7 @@ public class TestForDeploy {
ShareUpdateServiceImpl serviceImpl = new ShareUpdateServiceImpl(); ShareUpdateServiceImpl serviceImpl = new ShareUpdateServiceImpl();
String username = serviceImpl.getDevelopmentUser(); String username = serviceImpl.getDevelopmentUser();
System.out.println("username for deploy is: " + username); System.out.println("username for deploy is: " + username);
assertTrue(username.compareTo("test.user") == 0); assertTrue(username.compareTo(ShareUpdateServiceImpl.TEST_USER) == 0);
System.out.println("Test OK!"); System.out.println("Test OK!");
} }