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">
<dependency-type>uses</dependency-type>
</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="context-root" value="share-updates"/>
</wb-module>

View File

@ -1,6 +1,6 @@
<ReleaseNotes>
<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>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>
@ -11,6 +11,7 @@
<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>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 component="org.gcube.portlets.user.shareupdates.1-1-3"
date="2014-02-10">

View File

@ -65,6 +65,11 @@
<artifactId>gwt-servlet</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.gcube.common.portal</groupId>
<artifactId>portal-manager</artifactId>
<version>[1.0.0-SNAPSHOT, 2.0.0-SNAPSHOT)</version>
</dependency>
<dependency>
<groupId>org.gcube.portal</groupId>
<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";
/**
*
*/
public static final String TEST_USER = "test.user";
private static final String STORAGE_OWNER = "gCubeSocialFramework";
public static final String UPLOAD_DIR = "/social-framework-uploads";
@ -86,10 +85,6 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
* The Cassandra store interface
*/
private DatabookStore store;
/**
* used for debugging in eclipse
*/
private boolean withinPortal = false;
/**
* connect to cassandra at startup
*/
@ -112,19 +107,29 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
if (user == null) {
_log.warn("USER IS NULL setting test.user and Running OUTSIDE PORTAL");
user = getDevelopmentUser();
SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube/devsec/devVRE");
withinPortal = false;
}
else {
withinPortal = true;
}
SessionManager.getInstance().getASLSession(sessionID, user).setScope("/gcube/devsec/devVRE");
}
return SessionManager.getInstance().getASLSession(sessionID, user);
}
public String getDevelopmentUser() {
String user = "test.user";
//user = "massimiliano.assante";
String user = TEST_USER;
// user = "massimiliano.assante";
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 fullName = username+" FULL";
String thumbnailURL = "images/Avatar_default.png";
if (withinPortal) {
boolean withinPortal = isWithinPortal();
if (withinPortal && username.compareTo(TEST_USER) != 0) {
try {
UserInfo user = getUserSettings().getUserInfo();
email = user.getEmailaddress();
@ -174,14 +181,17 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
textToPost = escapedFeedText;
//System.out.println("textToPost=" + textToPost);
}
ScopeBean scope = new ScopeBean(session.getScope());
String vreId2Set = scope.is(Type.VRE) ? scope.toString() : "";
//get the VRE scope if single channel post
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,
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);
@ -202,14 +212,13 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
} //share on a single VRE Timeline
//receives a VreId(groupId) get the scope from the groupId
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 " + vreScope);
_log.trace("Attempting to write onto " + vreScope2Set);
try {
store.saveFeedToVRETimeline(toShare.getKey(), vreScope);
store.saveFeedToVRETimeline(toShare.getKey(), vreScope2Set);
} catch (FeedIDNotFoundException e) {
_log.error("Error writing onto VRES Time Line" + vreScope);
_log.error("Error writing onto VRES Time Line" + vreScope2Set);
} //save the feed
_log.trace("Success writing onto " + vreScope);
_log.trace("Success writing onto " + vreScope2Set);
}
if (!result) return null;
@ -251,10 +260,9 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
String username = session.getUsername();
String email = username+"@isti.cnr.it";
String fullName = username+" FULL";
String thumbnailURL = "images/Avatar_default.png";
if (withinPortal) {
getUserVREs(username);
String thumbnailURL = "images/Avatar_default.png";
if (isWithinPortal() && username.compareTo(TEST_USER) != 0) {
com.liferay.portal.model.UserModel user = UserLocalServiceUtil.getUserByScreenName(OrganizationsUtil.getCompany().getCompanyId(), username);
thumbnailURL = "/image/user_male_portrait?img_id="+user.getPortraitId();
fullName = user.getFirstName() + " " + user.getLastName();
@ -569,6 +577,10 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
@Override
public ArrayList<PickingUser> getPortalUsers() {
ASLSession session = getASLSession();
boolean withinPortal = false;
if (isWithinPortal() && session.getUsername().compareTo(TEST_USER) != 0) {
withinPortal = true;
}
return getOrganizationUsers(session.getScope(), session.getUsername(), withinPortal);
}
@ -626,4 +638,5 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
return portalUsers;
}
}

View File

@ -12,7 +12,7 @@ public class TestForDeploy {
ShareUpdateServiceImpl serviceImpl = new ShareUpdateServiceImpl();
String username = serviceImpl.getDevelopmentUser();
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!");
}