made notification to members option configurable as default, see Feature #121

git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/share-updates@117026 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2015-07-06 13:11:58 +00:00
parent 96dcf96949
commit 499703699a
6 changed files with 69 additions and 32 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/share-updates-1.7.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<classpathentry kind="src" output="target/share-updates-1.8.0-SNAPSHOT/WEB-INF/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
@ -31,5 +31,5 @@
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/share-updates-1.7.0-SNAPSHOT/WEB-INF/classes"/>
<classpathentry kind="output" path="target/share-updates-1.8.0-SNAPSHOT/WEB-INF/classes"/>
</classpath>

View File

@ -1,4 +1,8 @@
<ReleaseNotes>
<Changeset component="org.gcube.portlets-user.shareupdates.1-8-0"
date="2015-07-06">
<Change>made notification to members option configurable as default, see Feature #121</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.shareupdates.1-7-0"
date="2015-05-27">
<Change>Integrated gwt-bootstrap and revised css</Change>
@ -7,7 +11,8 @@
<Changeset component="org.gcube.portlets-user.shareupdates.1-6-1"
date="2014-12-13">
<Change>Added Client scope handler, to set the scope from the client
and help preventing the browser back button cache problem</Change>
and help preventing the browser back button cache problem
</Change>
</Changeset>
<Changeset component="org.gcube.portlets-user.shareupdates.1-6-0"
date="2014-11-03">

View File

@ -13,7 +13,7 @@
<groupId>org.gcube.portlets.user</groupId>
<artifactId>share-updates</artifactId>
<packaging>war</packaging>
<version>1.7.0-SNAPSHOT</version>
<version>1.8.0-SNAPSHOT</version>
<name>gCube Share Updates Portlet</name>
<description>

View File

@ -20,6 +20,7 @@ import org.gcube.portlets.widgets.fileupload.client.view.UploadProgressPanel;
import org.jsonmaker.gwt.client.Jsonizer;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.dom.client.Style.Display;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.dom.client.Style.Visibility;
@ -30,7 +31,6 @@ import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiFactory;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Element;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.Button;
@ -46,7 +46,6 @@ import com.google.gwt.user.client.ui.Widget;
/**
*
* @author Massimiliano Assante
* @version 1.2 Nov 2012
*
*/
public class ShareUpdateForm extends Composite {
@ -110,10 +109,10 @@ public class ShareUpdateForm extends Composite {
@UiField SuperPosedTextArea shareTextArea;
@UiField
ListBox privacyLevel = new ListBox(false);
ListBox privacyLevel = new ListBox();
@UiField
ListBox notifyListbox = new ListBox(false);
ListBox notifyListbox = new ListBox();
private UserInfo myUserInfo;
@ -155,6 +154,9 @@ public class ShareUpdateForm extends Composite {
avatarImage.setSize("60px", "60px");
avatarImage.setUrl(myUserInfo.getAvatarId());
String singleVREName = "";
boolean notificationEmail = userSettings.isNotificationViaEmailEnabled();
if (myUserInfo.getOwnVREs().size() > 1) {
privacyLevel.addItem(ALL_VRES, PrivacyLevel.VRES.toString());
for (String vreId : myUserInfo.getOwnVREs().keySet())
@ -172,8 +174,13 @@ public class ShareUpdateForm extends Composite {
//change css if deployed in VRE scope
if (!userSettings.isInfrastructure()) {
mainPanel.addStyleName("framed");
if (notificationEmail) {
notifyListbox.addItem("Share with: " + singleVREName+" + Notification to members");
notifyListbox.addItem("Share with: " + singleVREName);
} else {
notifyListbox.addItem("Share with: " + singleVREName);
notifyListbox.addItem("Share with: " + singleVREName+" + Notification to members");
}
notifyListbox.setVisible(true);
}
else

View File

@ -28,7 +28,9 @@ 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.OrganizationManager;
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;
@ -116,7 +118,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
}
public String getDevelopmentUser() {
String user = TEST_USER;
// user = "massimiliano.assante";
user = "massimiliano.assante";
return user;
}
/**
@ -272,16 +274,20 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
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);
long companyId = OrganizationsUtil.getCompany().getCompanyId();
com.liferay.portal.model.UserModel user = UserLocalServiceUtil.getUserByScreenName(companyId, username);
Organization currOrg = OrganizationLocalServiceUtil.getOrganization(session.getGroupId());
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();
HashMap<String, String> vreNames = getUserVreNames(username);
UserInfo userInfo = new UserInfo(username, fullName, thumbnailURL, user.getEmailAddress(), accountURL, true, isAdmin(), vreNames);
UserSettings toReturn = new UserSettings(userInfo, 0, session.getScopeName(), isInfrastructureScope());
UserSettings toReturn = new UserSettings(userInfo, 0, session.getScopeName(), isInfrastructureScope(), isNotificationViaEmailEnabled(username, currOrg));
return toReturn;
}
else {
@ -291,7 +297,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
//fakeVreNames.put("/gcube/devNext/NexNext","NexNext");
UserInfo user = new UserInfo(session.getUsername(), fullName, thumbnailURL, email, "fakeAccountUrl", true, false, fakeVreNames);
return new UserSettings(user, 0, session.getScopeName(), false);
return new UserSettings(user, 0, session.getScopeName(), false, true);
}
} catch (Exception e) {
@ -299,6 +305,12 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
}
return new UserSettings();
}
private boolean isNotificationViaEmailEnabled(String username, Organization currOrg) {
final String ATTR_TO_CHECK = "PostNotificationViaEmail";
return OrganizationManagerImpl.get().readOrganizationCustomAttribute(username, currOrg, ATTR_TO_CHECK);
}
/**
* generate a preview of the file, upload the file on the storage and shorts the link
*/

View File

@ -10,17 +10,30 @@ public class UserSettings implements Serializable {
private int refreshingTimeInMillis;
private String currentScope;
boolean isInfrastructure;
boolean isNotificationViaEmailEnabled;
public UserSettings() {
super();
}
public UserSettings(UserInfo userInfo, int refreshingTimeInMillis,
String currentScope, boolean isInfrastructure) {
String currentScope, boolean isInfrastructure,
boolean isNotificationViaEmailEnabled) {
super();
this.userInfo = userInfo;
this.refreshingTimeInMillis = refreshingTimeInMillis;
this.currentScope = currentScope;
this.isInfrastructure = isInfrastructure;
this.isNotificationViaEmailEnabled = isNotificationViaEmailEnabled;
}
public boolean isNotificationViaEmailEnabled() {
return isNotificationViaEmailEnabled;
}
public void setNotificationViaEmailEnabled(boolean isNotificationViaEmailEnabled) {
this.isNotificationViaEmailEnabled = isNotificationViaEmailEnabled;
}
public UserInfo getUserInfo() {
return userInfo;
}