kune-commits
Threads by month
- ----- 2026 -----
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
January 2012
- 1 participants
- 26 discussions
r1667 - in trunk/src/main/java/cc/kune: core/client core/client/rpcservices core/client/sitebar core/client/sitebar/auth core/client/state/impl core/server/manager core/server/manager/impl core/server/rpc gspace/client gspace/client/options gspace/client/options/general gspace/client/options/license
by Vicente J. Ruiz Jurado 18 Jan '12
by Vicente J. Ruiz Jurado 18 Jan '12
18 Jan '12
Author: vjrj_
Date: 2012-01-18 16:27:17 +0100 (Wed, 18 Jan 2012)
New Revision: 1667
Modified:
trunk/src/main/java/cc/kune/core/client/CoreParts.java
trunk/src/main/java/cc/kune/core/client/rpcservices/UserService.java
trunk/src/main/java/cc/kune/core/client/sitebar/SitebarSignInLink.java
trunk/src/main/java/cc/kune/core/client/sitebar/auth/PasswordResetPanel.java
trunk/src/main/java/cc/kune/core/client/sitebar/auth/VerifyEmailClientManager.java
trunk/src/main/java/cc/kune/core/client/state/impl/StateManagerDefault.java
trunk/src/main/java/cc/kune/core/server/manager/UserManager.java
trunk/src/main/java/cc/kune/core/server/manager/impl/UserManagerDefault.java
trunk/src/main/java/cc/kune/core/server/rpc/UserRPC.java
trunk/src/main/java/cc/kune/gspace/client/GSpaceParts.java
trunk/src/main/java/cc/kune/gspace/client/options/GroupOptionsCollection.java
trunk/src/main/java/cc/kune/gspace/client/options/UserOptionsCollection.java
trunk/src/main/java/cc/kune/gspace/client/options/general/EntityOptGeneralPanel.java
trunk/src/main/java/cc/kune/gspace/client/options/general/EntityOptGeneralView.java
trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneral.java
trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPresenter.java
trunk/src/main/java/cc/kune/gspace/client/options/license/EntityOptDefLicensePresenter.java
Log:
Password recovery small fixes
Modified: trunk/src/main/java/cc/kune/core/client/CoreParts.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/CoreParts.java 2012-01-17 12:35:15 UTC (rev 1666)
+++ trunk/src/main/java/cc/kune/core/client/CoreParts.java 2012-01-18 15:27:17 UTC (rev 1667)
@@ -46,6 +46,8 @@
import cc.kune.gspace.client.options.GroupOptions;
import cc.kune.gspace.client.options.UserOptions;
+import com.google.gwt.core.client.Scheduler;
+import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.event.shared.EventBus;
import com.google.inject.Inject;
import com.google.inject.Provider;
@@ -80,7 +82,12 @@
tokenListener.put(SiteTokens.SIGN_IN, new HistoryTokenAuthNotNeededCallback() {
@Override
public void onHistoryToken(final String token) {
- signIn.get().showSignInDialog();
+ Scheduler.get().scheduleFinally(new ScheduledCommand() {
+ @Override
+ public void execute() {
+ signIn.get().showSignInDialog();
+ }
+ });
}
});
tokenListener.put(SiteTokens.ABOUT_KUNE, new HistoryTokenAuthNotNeededCallback() {
@@ -99,7 +106,12 @@
tokenListener.put(SiteTokens.NEW_GROUP, new HistoryTokenMustBeAuthCallback() {
@Override
public void onHistoryToken(final String token) {
- newGroup.get().doNewGroup();
+ Scheduler.get().scheduleFinally(new ScheduledCommand() {
+ @Override
+ public void execute() {
+ newGroup.get().doNewGroup();
+ }
+ });
}
});
tokenListener.put(SiteTokens.SUBTITLES, new HistoryTokenAuthNotNeededCallback() {
@@ -123,30 +135,51 @@
tokenListener.put(SiteTokens.PREFS, new HistoryTokenMustBeAuthCallback() {
@Override
public void onHistoryToken(final String token) {
- SpaceSelectEvent.fire(eventBus, Space.groupSpace);
- userOptionsDialog.get().show();
+ Scheduler.get().scheduleFinally(new ScheduledCommand() {
+ @Override
+ public void execute() {
+ SpaceSelectEvent.fire(eventBus, Space.groupSpace);
+ userOptionsDialog.get().show();
+ }
+ });
}
});
tokenListener.put(SiteTokens.GROUP_PREFS, new HistoryTokenMustBeAuthCallback() {
@Override
public void onHistoryToken(final String token) {
- groupOptionsDialog.get().show(token);
+ Scheduler.get().scheduleFinally(new ScheduledCommand() {
+ @Override
+ public void execute() {
+ groupOptionsDialog.get().show(token);
+ }
+ });
}
});
tokenListener.put(SiteTokens.RESET_PASSWD, new HistoryTokenAuthNotNeededCallback() {
@Override
public void onHistoryToken(final String token) {
- if (!session.isLogged()) {
- askForPass.get().show();
- }
+ Scheduler.get().scheduleFinally(new ScheduledCommand() {
+ @Override
+ public void execute() {
+ if (!session.isLogged()) {
+ askForPass.get().show();
+ }
+ }
+ });
}
});
tokenListener.put(SiteTokens.ASK_RESET_PASSWD, new HistoryTokenAuthNotNeededCallback() {
@Override
public void onHistoryToken(final String token) {
- if (!session.isLogged()) {
- askForPass.get().show();
- }
+ Scheduler.get().scheduleFinally(new ScheduledCommand() {
+ @Override
+ public void execute() {
+ if (!session.isLogged()) {
+ askForPass.get().show();
+ }
+ }
+ });
+
}
});
tokenListener.put(SiteTokens.RESET_PASSWD, new HistoryTokenAuthNotNeededCallback() {
@@ -159,6 +192,5 @@
}
});
verifyManager.get();
-
}
}
Modified: trunk/src/main/java/cc/kune/core/client/rpcservices/UserService.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/rpcservices/UserService.java 2012-01-17 12:35:15 UTC (rev 1666)
+++ trunk/src/main/java/cc/kune/core/client/rpcservices/UserService.java 2012-01-18 15:27:17 UTC (rev 1667)
@@ -20,6 +20,7 @@
package cc.kune.core.client.rpcservices;
import cc.kune.core.client.errors.DefaultException;
+import cc.kune.core.client.errors.EmailHashExpiredException;
import cc.kune.core.client.errors.EmailHashInvalidException;
import cc.kune.core.client.errors.EmailNotFoundException;
import cc.kune.core.shared.domain.UserSNetVisibility;
@@ -36,7 +37,8 @@
@RemoteServiceRelativePath("UserService")
public interface UserService extends RemoteService {
- void askForEmailConfirmation(String userHash);
+ void askForEmailConfirmation(String userHash) throws EmailHashInvalidException,
+ EmailHashExpiredException;
void askForPasswordReset(String email) throws EmailNotFoundException;
@@ -62,6 +64,7 @@
StateAbstractDTO updateUser(String userHash, UserDTO user, I18nLanguageSimpleDTO lang);
- void verifyPasswordHash(String userHash, String emailReceivedHash);
+ void verifyPasswordHash(String userHash, String emailReceivedHash) throws EmailHashInvalidException,
+ EmailHashExpiredException;
}
Modified: trunk/src/main/java/cc/kune/core/client/sitebar/SitebarSignInLink.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sitebar/SitebarSignInLink.java 2012-01-17 12:35:15 UTC (rev 1666)
+++ trunk/src/main/java/cc/kune/core/client/sitebar/SitebarSignInLink.java 2012-01-18 15:27:17 UTC (rev 1667)
@@ -24,8 +24,8 @@
import cc.kune.common.client.actions.ActionEvent;
import cc.kune.common.client.actions.ui.descrip.ButtonDescriptor;
import cc.kune.core.client.events.UserSignInEvent;
+import cc.kune.core.client.events.UserSignInEvent.UserSignInHandler;
import cc.kune.core.client.events.UserSignOutEvent;
-import cc.kune.core.client.events.UserSignInEvent.UserSignInHandler;
import cc.kune.core.client.events.UserSignOutEvent.UserSignOutHandler;
import cc.kune.core.client.i18n.I18nUITranslationService;
import cc.kune.core.client.state.Session;
@@ -48,10 +48,10 @@
super();
this.stateManager = stateManager;
putValue(Action.NAME, i18n.t("Sign in to collaborate"));
- putValue(
- Action.TOOLTIP,
- i18n.t("Please sign in or register to get full access to [%s] tools and contents",
- i18n.getSiteCommonName()));
+ // putValue(
+ // Action.TOOLTIP,
+ // i18n.t("Please sign in or register to get full access to [%s] tools and contents",
+ // i18n.getSiteCommonName()));
}
@Override
Modified: trunk/src/main/java/cc/kune/core/client/sitebar/auth/PasswordResetPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sitebar/auth/PasswordResetPanel.java 2012-01-17 12:35:15 UTC (rev 1666)
+++ trunk/src/main/java/cc/kune/core/client/sitebar/auth/PasswordResetPanel.java 2012-01-18 15:27:17 UTC (rev 1667)
@@ -1,5 +1,6 @@
package cc.kune.core.client.sitebar.auth;
+import cc.kune.common.client.log.Log;
import cc.kune.common.client.notify.NotifyLevel;
import cc.kune.common.client.notify.NotifyLevelImages;
import cc.kune.common.client.notify.NotifyUser;
@@ -14,7 +15,6 @@
import cc.kune.core.client.state.Session;
import cc.kune.core.client.state.SiteTokens;
import cc.kune.core.client.state.StateManager;
-import cc.kune.core.client.state.TokenUtils;
import cc.kune.core.client.ui.DefaultForm;
import com.extjs.gxt.ui.client.widget.form.TextField;
@@ -91,8 +91,7 @@
public void onSuccess(final Void result) {
NotifyUser.info(i18n.t("Your password has been reset. Sign in"));
hide();
- stateManager.gotoHistoryToken(TokenUtils.addRedirect(SiteTokens.HOME,
- SiteTokens.SIGN_IN));
+ stateManager.gotoHistoryToken(SiteTokens.SIGN_IN);
}
});
}
@@ -111,6 +110,7 @@
}
public String getPasswordHash() {
+ Log.debug("Password hash:" + passwordHash);
return passwordHash;
}
Modified: trunk/src/main/java/cc/kune/core/client/sitebar/auth/VerifyEmailClientManager.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sitebar/auth/VerifyEmailClientManager.java 2012-01-17 12:35:15 UTC (rev 1666)
+++ trunk/src/main/java/cc/kune/core/client/sitebar/auth/VerifyEmailClientManager.java 2012-01-18 15:27:17 UTC (rev 1667)
@@ -2,7 +2,8 @@
import cc.kune.common.client.notify.NotifyUser;
import cc.kune.common.shared.i18n.I18nTranslationService;
-import cc.kune.core.client.rpcservices.AsyncCallbackSimple;
+import cc.kune.core.client.errors.EmailHashExpiredException;
+import cc.kune.core.client.errors.EmailHashInvalidException;
import cc.kune.core.client.rpcservices.UserServiceAsync;
import cc.kune.core.client.state.HistoryTokenMustBeAuthCallback;
import cc.kune.core.client.state.Session;
@@ -10,6 +11,7 @@
import cc.kune.core.client.state.SiteTokens;
import cc.kune.gspace.client.options.general.UserOptGeneral;
+import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
@@ -24,15 +26,28 @@
tokens.put(SiteTokens.VERIFY_EMAIL, new HistoryTokenMustBeAuthCallback() {
@Override
public void onHistoryToken(final String token) {
- userService.get().verifyPasswordHash(session.getUserHash(), token,
- new AsyncCallbackSimple<Void>() {
- @Override
- public void onSuccess(final Void result) {
- NotifyUser.info("Great. Your email is now verified");
- session.getCurrentUser().setEmailVerified(true);
- optGeneral.get().update();
- }
- });
+ userService.get().verifyPasswordHash(session.getUserHash(), token, new AsyncCallback<Void>() {
+ @Override
+ public void onFailure(final Throwable caught) {
+ if (caught instanceof EmailHashExpiredException) {
+ NotifyUser.error(i18n.t("Email confirmation code expired"), true);
+ } else if (caught instanceof EmailHashInvalidException) {
+ NotifyUser.error(i18n.t("Invalid confirmation code"), true);
+ } else {
+ NotifyUser.error(i18n.t("Other error trying to verify your password"), true);
+ }
+ }
+
+ @Override
+ public void onSuccess(final Void result) {
+ NotifyUser.info("Great. Your email is now verified");
+ session.getCurrentUser().setEmailVerified(true);
+ // This get NPE
+ // if (optGeneral.get().isVisible()) {
+ // optGeneral.get().update();
+ // }
+ }
+ });
}
});
Modified: trunk/src/main/java/cc/kune/core/client/state/impl/StateManagerDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/state/impl/StateManagerDefault.java 2012-01-17 12:35:15 UTC (rev 1666)
+++ trunk/src/main/java/cc/kune/core/client/state/impl/StateManagerDefault.java 2012-01-18 15:27:17 UTC (rev 1667)
@@ -151,20 +151,21 @@
}
private void doActionOrSignInIfNeeded(final HistoryTokenCallback tokenListener,
- final String newHistoryToken) {
+ final String currentToken, final String secondPart) {
if (tokenListener.authMandatory() && session.isNotLogged()) {
- Log.debug("login mandatory for " + newHistoryToken);
+ Log.debug("login mandatory for " + currentToken);
// Ok, we have to redirect because this token (for instance
// #translate) needs the user authenticated
- redirectButSignInBefore(newHistoryToken);
+ redirectButSignInBefore(currentToken);
} else {
// The auth is not mandatory, go ahead with the token action
- Log.debug("Executing action related with historytoken " + newHistoryToken);
- tokenListener.onHistoryToken(newHistoryToken);
+ Log.debug("Executing action related with historytoken " + secondPart);
+ tokenListener.onHistoryToken(secondPart);
}
}
private void getContent(final StateToken newState) {
+ Log.debug("Get Content: " + newState);
getContent(newState, false);
}
@@ -204,6 +205,7 @@
@Override
public void gotoDefaultHomepage() {
+ Log.debug("Goto def page called");
getContent(new StateToken(SiteTokens.GROUP_HOME), true);
}
@@ -297,12 +299,13 @@
if (startingUp()) {
// Starting with some token like "signin": load defContent
// also
+ Log.debug("Starting up with some token like #signin: load defContent also");
getContent(new StateToken(SiteTokens.GROUP_HOME), false);
// processHistoryToken(SiteTokens.GROUP_HOME);
// SpaceSelectEvent.fire(eventBus, Space.groupSpace);
}
// Fire the listener of this #hash token
- doActionOrSignInIfNeeded(tokenListener, newHistoryToken);
+ doActionOrSignInIfNeeded(tokenListener, newHistoryToken, newHistoryToken);
} else {
Log.debug("Is not a special hash like #newgroup, etc, or maybe has a #hash(redirection)");
// token is not one of #newgroup #signin #translate ...
@@ -320,7 +323,7 @@
final HistoryTokenCallback tokenWithRedirect = siteTokens.get(firstToken);
if (tokenWithRedirect != null) {
Log.info("Is some #subtitle(foo) or #verifyemail(hash) etc");
- doActionOrSignInIfNeeded(tokenWithRedirect,
+ doActionOrSignInIfNeeded(tokenWithRedirect, newHistoryToken,
tokenMatcher.getRedirect(newHistoryToken).getRight());
} else if (firstToken.equals(SiteTokens.NEW_GROUP)) {
siteTokens.get(SiteTokens.NEW_GROUP).onHistoryToken(newHistoryToken);
@@ -363,7 +366,9 @@
SpaceSelectEvent.fire(eventBus, Space.groupSpace);
getContent(new StateToken(newHistoryToken));
} else {
- gotoDefaultHomepage();
+ if (!startingUp()) {
+ // gotoDefaultHomepage();
+ }
}
}
} else {
Modified: trunk/src/main/java/cc/kune/core/server/manager/UserManager.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/manager/UserManager.java 2012-01-17 12:35:15 UTC (rev 1666)
+++ trunk/src/main/java/cc/kune/core/server/manager/UserManager.java 2012-01-18 15:27:17 UTC (rev 1667)
@@ -22,6 +22,8 @@
import org.waveprotocol.box.server.authentication.PasswordDigest;
import cc.kune.core.client.errors.DefaultException;
+import cc.kune.core.client.errors.EmailHashExpiredException;
+import cc.kune.core.client.errors.EmailHashInvalidException;
import cc.kune.core.client.errors.I18nNotFoundException;
import cc.kune.core.server.manager.impl.EmailConfirmationType;
import cc.kune.core.shared.domain.UserSNetVisibility;
@@ -30,7 +32,12 @@
import cc.kune.domain.User;
import cc.kune.domain.UserBuddiesData;
+// TODO: Auto-generated Javadoc
+/**
+ * The Interface UserManager.
+ */
public interface UserManager {
+
/**
* Ask for email confirmation.
*
@@ -38,6 +45,8 @@
* the user
* @param type
* the type
+ * @throws DefaultException
+ * the default exception
*/
void askForEmailConfirmation(User user, EmailConfirmationType type) throws DefaultException;
@@ -58,53 +67,133 @@
User changePasswd(Long userId, String oldPassword, String newPassword, boolean checkOldPasswd);
/**
- * CreateUser new method with language country and timezone params
+ * Clear password hash (after been used)
*
+ * @param user
+ * the user
+ */
+ void clearPasswordHash(User user);
+
+ /**
+ * CreateUser new method with language country and timezone params.
+ *
* @param shortName
+ * the short name
* @param longName
+ * the long name
* @param email
+ * the email
* @param passwd
- * @param timezone
+ * the passwd
+ * @param language
+ * the language
* @param country
- * @param language
+ * the country
* @param timezone
+ * the timezone
* @param wantPersonalHomepage
+ * the want personal homepage
* @return User
* @throws I18nNotFoundException
+ * the i18n not found exception
*/
User createUser(String shortName, String longName, String email, String passwd, String language,
String country, String timezone, boolean wantPersonalHomepage) throws I18nNotFoundException;
+ /**
+ * Creates the wave account.
+ *
+ * @param shortName
+ * the short name
+ * @param passwdDigest
+ * the passwd digest
+ */
void createWaveAccount(String shortName, PasswordDigest passwdDigest);
/**
* IMPORTANT: if userId == null, it returns User.UNKNOWN_USER
*
* @param userId
- * @return
+ * the user id
+ * @return the user
*/
User find(Long userId);
+ /**
+ * Find by shortname.
+ *
+ * @param shortName
+ * the short name
+ * @return the user
+ */
User findByShortname(String shortName);
+ /**
+ * Gets the user buddies.
+ *
+ * @param shortName
+ * the short name
+ * @return the user buddies
+ */
UserBuddiesData getUserBuddies(String shortName);
+ /**
+ * Login.
+ *
+ * @param nickOrEmail
+ * the nick or email
+ * @param passwd
+ * the passwd
+ * @return the user
+ */
User login(String nickOrEmail, String passwd);
+ /**
+ * Re index.
+ */
void reIndex();
+ /**
+ * Search.
+ *
+ * @param search
+ * the search
+ * @return the search result
+ */
SearchResult<User> search(String search);
+ /**
+ * Search.
+ *
+ * @param search
+ * the search
+ * @param firstResult
+ * the first result
+ * @param maxResults
+ * the max results
+ * @return the search result
+ */
SearchResult<User> search(String search, Integer firstResult, Integer maxResults);
+ /**
+ * Sets the s net visibility.
+ *
+ * @param user
+ * the user
+ * @param visibility
+ * the visibility
+ */
void setSNetVisibility(User user, UserSNetVisibility visibility);
/**
+ * Update.
+ *
* @param userId
* the userId to change
* @param user
* the userDTO with values to change
* @param lang
+ * the lang
* @return the User after updated
*/
User update(Long userId, UserDTO user, I18nLanguageSimpleDTO lang);
@@ -118,7 +207,12 @@
* the email received hash
* @param period
* the period (1h or more if is a new account);
+ * @throws EmailHashInvalidException
+ * the email hash invalid exception
+ * @throws EmailHashExpiredException
+ * the email hash expired exception
*/
- void verifyPasswordHash(Long userId, String emailReceivedHash, long period) throws DefaultException;
+ void verifyPasswordHash(Long userId, String emailReceivedHash, long period)
+ throws EmailHashInvalidException, EmailHashExpiredException;
}
Modified: trunk/src/main/java/cc/kune/core/server/manager/impl/UserManagerDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/manager/impl/UserManagerDefault.java 2012-01-17 12:35:15 UTC (rev 1666)
+++ trunk/src/main/java/cc/kune/core/server/manager/impl/UserManagerDefault.java 2012-01-18 15:27:17 UTC (rev 1667)
@@ -158,8 +158,8 @@
notifyService.sendEmailToWithLink(
user,
"Verify password reset",
- "You are receiving this email because a request has been made to change the password associated with this email address in %s.<br>"
- + "If this was a mistake, just ignore this email and nothing will happen.<br>"
+ "You are receiving this email because a request has been made to change the password associated with this email address in %s.<br><br>"
+ + "If this was a mistake, just ignore this email and nothing will happen.<br><br>"
+ "If you would like to reset the password for this account simply click on the link below or paste it into the url field on your favorite browser:",
TokenUtils.addRedirect(SiteTokens.RESET_PASSWD, hash));
default:
@@ -228,6 +228,13 @@
}
@Override
+ public void clearPasswordHash(final User user) {
+ user.setEmailVerified(true);
+ user.setEmailCheckDate(0l);
+ user.setEmailConfirmHash("");
+ }
+
+ @Override
public User createUser(final String shortName, final String longName, final String email,
final String passwd, final String langCode, final String countryCode, final String timezone,
final boolean wantPersonalHomepage) throws I18nNotFoundException {
@@ -457,7 +464,7 @@
@Override
public void verifyPasswordHash(final Long userId, final String emailReceivedHash, final long period)
- throws DefaultException {
+ throws EmailHashInvalidException, EmailHashExpiredException {
final User user = find(userId);
final Date on = new Date(user.getEmailCheckDate() + period);
@@ -468,8 +475,7 @@
final String emailConfirmHash = user.getEmailConfirmHash();
if (emailReceivedHash != null && emailConfirmHash != null
&& emailReceivedHash.equals(emailConfirmHash)) {
- user.setEmailVerified(true);
- user.setEmailConfirmHash("");
+ clearPasswordHash(user);
persist(user);
} else {
throw new EmailHashInvalidException();
Modified: trunk/src/main/java/cc/kune/core/server/rpc/UserRPC.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/rpc/UserRPC.java 2012-01-17 12:35:15 UTC (rev 1666)
+++ trunk/src/main/java/cc/kune/core/server/rpc/UserRPC.java 2012-01-18 15:27:17 UTC (rev 1667)
@@ -29,6 +29,7 @@
import cc.kune.core.client.errors.AccessViolationException;
import cc.kune.core.client.errors.DefaultException;
+import cc.kune.core.client.errors.EmailHashExpiredException;
import cc.kune.core.client.errors.EmailHashInvalidException;
import cc.kune.core.client.errors.EmailNotFoundException;
import cc.kune.core.client.errors.UserAuthException;
@@ -215,6 +216,7 @@
try {
final User user = userFinder.findByHash(passwdHash);
userManager.changePasswd(user.getId(), null, newpasswd, false);
+ userManager.clearPasswordHash(user);
} catch (final NoResultException e) {
throw new EmailHashInvalidException();
}
@@ -250,7 +252,8 @@
@Authenticated
@Override
@Transactional
- public void verifyPasswordHash(final String userHash, final String emailReceivedHash) {
+ public void verifyPasswordHash(final String userHash, final String emailReceivedHash)
+ throws EmailHashInvalidException, EmailHashExpiredException {
final User user = userSessionManager.getUser();
userManager.verifyPasswordHash(user.getId(), emailReceivedHash, SessionConstants._AN_HOUR);
}
Modified: trunk/src/main/java/cc/kune/gspace/client/GSpaceParts.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/GSpaceParts.java 2012-01-17 12:35:15 UTC (rev 1666)
+++ trunk/src/main/java/cc/kune/gspace/client/GSpaceParts.java 2012-01-18 15:27:17 UTC (rev 1667)
@@ -33,20 +33,7 @@
import cc.kune.gspace.client.i18n.I18nTranslatorTabsCollection;
import cc.kune.gspace.client.i18n.SiteOptionsI18nTranslatorAction;
import cc.kune.gspace.client.options.GroupOptions;
-import cc.kune.gspace.client.options.GroupOptionsCollection;
import cc.kune.gspace.client.options.UserOptions;
-import cc.kune.gspace.client.options.UserOptionsCollection;
-import cc.kune.gspace.client.options.general.GroupOptGeneral;
-import cc.kune.gspace.client.options.general.UserOptGeneral;
-import cc.kune.gspace.client.options.general.UserOptPass;
-import cc.kune.gspace.client.options.license.GroupOptDefLicense;
-import cc.kune.gspace.client.options.license.UserOptDefLicense;
-import cc.kune.gspace.client.options.logo.GroupOptLogo;
-import cc.kune.gspace.client.options.logo.UserOptLogo;
-import cc.kune.gspace.client.options.style.GroupOptStyle;
-import cc.kune.gspace.client.options.style.UserOptStyle;
-import cc.kune.gspace.client.options.tools.GroupOptTools;
-import cc.kune.gspace.client.options.tools.UserOptTools;
import cc.kune.gspace.client.tags.TagsSummaryPresenter;
import cc.kune.gspace.client.themes.GSpaceThemeManager;
import cc.kune.gspace.client.tool.selector.ToolSelector;
@@ -61,18 +48,20 @@
public class GSpaceParts {
@Inject
- public GSpaceParts(final Session session, final GSpaceThemeManager themeManager,
+ public GSpaceParts(
+ final Session session,
+ final GSpaceThemeManager themeManager,
final Provider<EntityLicensePresenter> licenseFooter,
- final Provider<TagsSummaryPresenter> tagsPresenter, final Provider<ToolSelector> toolSelector,
- final Provider<NoHomePageViewer> noHome, final Provider<ContentViewerPresenter> docsViewer,
- final Provider<FolderViewerPresenter> folderViewer, final Provider<GroupOptions> go,
- final Provider<UserOptions> uo, final Provider<GroupOptionsCollection> gocProv,
- final Provider<UserOptionsCollection> uocProv, final Provider<GroupOptGeneral> gg,
- final Provider<GroupOptDefLicense> gdl, final Provider<GroupOptStyle> gps,
- final Provider<GroupOptLogo> gl, final Provider<GroupOptTools> gtc,
- final Provider<UserOptGeneral> ug, final Provider<UserOptPass> up,
- final Provider<UserOptDefLicense> udl, final Provider<UserOptStyle> ups,
- final Provider<UserOptLogo> ul, final Provider<UserOptTools> utc,
+ final Provider<TagsSummaryPresenter> tagsPresenter,
+ final Provider<ToolSelector> toolSelector,
+ final Provider<NoHomePageViewer> noHome,
+ final Provider<ContentViewerPresenter> docsViewer,
+ final Provider<FolderViewerPresenter> folderViewer,
+ final Provider<GroupOptions> go,
+ final Provider<UserOptions> uo, // final Provider<GroupOptionsCollection>
+ // gocProv,
+ // final Provider<UserOptionsCollection> uocProv,
+
final Provider<SitebarSearchPresenter> siteSearch,
final Provider<SiteOptionsI18nTranslatorAction> transAction,
final Provider<GiveUsFeedbackBtn> giveUsFeedback,
@@ -91,20 +80,9 @@
siteSearch.get();
noHome.get();
- // Add User & Groups Options
- final GroupOptionsCollection goc = gocProv.get();
- final UserOptionsCollection uoc = uocProv.get();
- goc.add(gg);
- goc.add(gtc);
- goc.add(gl);
- goc.add(gps);
- goc.add(gdl);
- uoc.add(ug);
- uoc.add(up);
- uoc.add(utc);
- uoc.add(ul);
- uoc.add(ups);
- uoc.add(udl);
+ // // Add User & Groups Options
+ // final GroupOptionsCollection goc = gocProv.get();
+ // final UserOptionsCollection uoc = uocProv.get();
// Init
go.get();
Modified: trunk/src/main/java/cc/kune/gspace/client/options/GroupOptionsCollection.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/options/GroupOptionsCollection.java 2012-01-17 12:35:15 UTC (rev 1666)
+++ trunk/src/main/java/cc/kune/gspace/client/options/GroupOptionsCollection.java 2012-01-18 15:27:17 UTC (rev 1667)
@@ -20,7 +20,27 @@
package cc.kune.gspace.client.options;
import cc.kune.common.client.ProvidersCollection;
+import cc.kune.gspace.client.options.general.GroupOptGeneral;
+import cc.kune.gspace.client.options.license.GroupOptDefLicense;
+import cc.kune.gspace.client.options.logo.GroupOptLogo;
+import cc.kune.gspace.client.options.style.GroupOptStyle;
+import cc.kune.gspace.client.options.tools.GroupOptTools;
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.google.inject.Singleton;
+
@SuppressWarnings("serial")
+@Singleton
public class GroupOptionsCollection extends ProvidersCollection {
+ @Inject
+ public GroupOptionsCollection(final Provider<GroupOptGeneral> gg, final Provider<GroupOptTools> gtc,
+ final Provider<GroupOptLogo> gl, final Provider<GroupOptStyle> gps,
+ final Provider<GroupOptDefLicense> gdl) {
+ add(gg);
+ add(gtc);
+ add(gl);
+ add(gps);
+ add(gdl);
+ }
}
Modified: trunk/src/main/java/cc/kune/gspace/client/options/UserOptionsCollection.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/options/UserOptionsCollection.java 2012-01-17 12:35:15 UTC (rev 1666)
+++ trunk/src/main/java/cc/kune/gspace/client/options/UserOptionsCollection.java 2012-01-18 15:27:17 UTC (rev 1667)
@@ -20,7 +20,30 @@
package cc.kune.gspace.client.options;
import cc.kune.common.client.ProvidersCollection;
+import cc.kune.gspace.client.options.general.UserOptGeneral;
+import cc.kune.gspace.client.options.general.UserOptPass;
+import cc.kune.gspace.client.options.license.UserOptDefLicense;
+import cc.kune.gspace.client.options.logo.UserOptLogo;
+import cc.kune.gspace.client.options.style.UserOptStyle;
+import cc.kune.gspace.client.options.tools.UserOptTools;
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.google.inject.Singleton;
+
@SuppressWarnings("serial")
+@Singleton
public class UserOptionsCollection extends ProvidersCollection {
+
+ @Inject
+ public UserOptionsCollection(final Provider<UserOptGeneral> ug, final Provider<UserOptPass> up,
+ final Provider<UserOptTools> utc, final Provider<UserOptLogo> ul,
+ final Provider<UserOptStyle> ups, final Provider<UserOptDefLicense> udl) {
+ add(ug);
+ add(up);
+ add(utc);
+ add(ul);
+ add(ups);
+ add(udl);
+ }
}
Modified: trunk/src/main/java/cc/kune/gspace/client/options/general/EntityOptGeneralPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/options/general/EntityOptGeneralPanel.java 2012-01-17 12:35:15 UTC (rev 1666)
+++ trunk/src/main/java/cc/kune/gspace/client/options/general/EntityOptGeneralPanel.java 2012-01-18 15:27:17 UTC (rev 1667)
@@ -78,6 +78,11 @@
}
@Override
+ public boolean isRendered() {
+ return super.getFormPanel().isRendered();
+ }
+
+ @Override
public void mask() {
maskWidget.mask(this);
}
Modified: trunk/src/main/java/cc/kune/gspace/client/options/general/EntityOptGeneralView.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/options/general/EntityOptGeneralView.java 2012-01-17 12:35:15 UTC (rev 1666)
+++ trunk/src/main/java/cc/kune/gspace/client/options/general/EntityOptGeneralView.java 2012-01-18 15:27:17 UTC (rev 1667)
@@ -27,6 +27,8 @@
void clear();
+ boolean isRendered();
+
boolean isValid();
void mask();
Modified: trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneral.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneral.java 2012-01-17 12:35:15 UTC (rev 1666)
+++ trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneral.java 2012-01-18 15:27:17 UTC (rev 1667)
@@ -21,6 +21,8 @@
public interface UserOptGeneral extends EntityOptGeneral {
+ boolean isVisible();
+
void update();
}
Modified: trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPresenter.java 2012-01-17 12:35:15 UTC (rev 1666)
+++ trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPresenter.java 2012-01-18 15:27:17 UTC (rev 1667)
@@ -89,6 +89,11 @@
}
@Override
+ public boolean isVisible() {
+ return view.isRendered();
+ }
+
+ @Override
protected void setState() {
final UserSimpleDTO currentUser = session.getCurrentUser();
userView.setLongName(currentUser.getName());
Modified: trunk/src/main/java/cc/kune/gspace/client/options/license/EntityOptDefLicensePresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/options/license/EntityOptDefLicensePresenter.java 2012-01-17 12:35:15 UTC (rev 1666)
+++ trunk/src/main/java/cc/kune/gspace/client/options/license/EntityOptDefLicensePresenter.java 2012-01-18 15:27:17 UTC (rev 1667)
@@ -107,6 +107,7 @@
protected void setState() {
if (applicable()) {
+ // Is a user and app is not starting up
setLicense(getCurrentDefLicense());
}
}
1
0
Author: vjrj_
Date: 2012-01-17 13:35:15 +0100 (Tue, 17 Jan 2012)
New Revision: 1666
Modified:
trunk/TODO
Log:
TODO updated
Modified: trunk/TODO
===================================================================
--- trunk/TODO 2012-01-17 12:34:00 UTC (rev 1665)
+++ trunk/TODO 2012-01-17 12:35:15 UTC (rev 1666)
@@ -12,62 +12,10 @@
nick == assigned to
* SHORT-TERM (URGENT)
-** Passwd reset
-Please enter your username or email address. You will receive a link to create a new password via email.
-Username or E-mail:
-Get New Password
-Check your e-mail for the confirmation link.
-
-
-Enter your new password below.
-
-New password
-Confirm new password
-Reset password
-
-Your password has been reset. Log in
---------------------------------
-
-Please enter your username or email address. You will receive a link to create a new password via email.
-
-You are receiving this e-mail because a request has been made to change the FIXME password associated with this address (vruiz.jurado(a)gmail.com) If you would like to reset the password for this account simply click on the link below or paste it into the url field on your favorite browser:
-
-LINK
-
-If you didn't request this email then you can just ignore it -- your details have not been disclosed to anyone.
-If you have any questions about the system, feel free to contact us anytime at FIXME.
-
-Bla, bla, bla
------
-
-Someone requested that the password be reset for the following account:
-
-LINK
-Username: vjrj
-
-ReseIf this was a mistake, just ignore this email and nothing will happen.
-
-To reset your password, visit the following address:
-LINK
-
-
-
-
-
** Connection persistence
java.io.NotSerializableException: org.eclipse.jetty.websocket.WebSocketConnectionD13$WSFrameConnection
java.io.NotSerializableException: com.glines.socketio.server.transport.jetty.JettyContinuationTransportHandler
-
-** Email notifications for new waves
-*** Migration of DB!!!!!
-*** Text for UI
-Email Notifications
-How often do you want to receive notifications?
- almost immediately
- at most hourly
- at most daily
- I don't need email notifications
** group.inexistentTool nasty error
** calendar support
*** gwt-cal + http://ical4j.sourceforge.net/introduction.html
1
0
r1665 - in trunk/src/main/java/cc/kune/core: client client/auth client/rpcservices client/sitebar/auth client/state server/rpc
by Vicente J. Ruiz Jurado 17 Jan '12
by Vicente J. Ruiz Jurado 17 Jan '12
17 Jan '12
Author: vjrj_
Date: 2012-01-17 13:34:00 +0100 (Tue, 17 Jan 2012)
New Revision: 1665
Added:
trunk/src/main/java/cc/kune/core/client/sitebar/auth/PasswordResetPanel.java
Modified:
trunk/src/main/java/cc/kune/core/client/CoreParts.java
trunk/src/main/java/cc/kune/core/client/auth/SignInPanel.java
trunk/src/main/java/cc/kune/core/client/auth/SignInPresenter.java
trunk/src/main/java/cc/kune/core/client/rpcservices/UserService.java
trunk/src/main/java/cc/kune/core/client/sitebar/auth/AskForPasswordResetPanel.java
trunk/src/main/java/cc/kune/core/client/state/SiteTokens.java
trunk/src/main/java/cc/kune/core/server/rpc/UserRPC.java
Log:
CLOSED - # 99: Add a recovery password functionality
http://kune.ourproject.org/issues/ticket/99
Modified: trunk/src/main/java/cc/kune/core/client/CoreParts.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/CoreParts.java 2012-01-17 01:24:06 UTC (rev 1664)
+++ trunk/src/main/java/cc/kune/core/client/CoreParts.java 2012-01-17 12:34:00 UTC (rev 1665)
@@ -28,6 +28,7 @@
import cc.kune.core.client.sitebar.AboutKuneDialog;
import cc.kune.core.client.sitebar.SiteUserOptionsPresenter;
import cc.kune.core.client.sitebar.auth.AskForPasswordResetPanel;
+import cc.kune.core.client.sitebar.auth.PasswordResetPanel;
import cc.kune.core.client.sitebar.auth.VerifyEmailClientManager;
import cc.kune.core.client.sitebar.spaces.Space;
import cc.kune.core.client.sitebar.spaces.SpaceSelectEvent;
@@ -63,7 +64,7 @@
final Provider<SubtitlesManager> subProvider, final EventBus eventBus,
final Provider<VerifyEmailClientManager> verifyManager,
final Provider<UserOptions> userOptionsDialog, final Provider<GroupOptions> groupOptionsDialog,
- final Provider<AskForPasswordResetPanel> askForPass) {
+ final Provider<PasswordResetPanel> passReset, final Provider<AskForPasswordResetPanel> askForPass) {
session.onAppStart(true, new AppStartHandler() {
@Override
public void onAppStart(final AppStartEvent event) {
@@ -140,6 +141,24 @@
}
}
});
+ tokenListener.put(SiteTokens.ASK_RESET_PASSWD, new HistoryTokenAuthNotNeededCallback() {
+ @Override
+ public void onHistoryToken(final String token) {
+ if (!session.isLogged()) {
+ askForPass.get().show();
+ }
+ }
+ });
+ tokenListener.put(SiteTokens.RESET_PASSWD, new HistoryTokenAuthNotNeededCallback() {
+ @Override
+ public void onHistoryToken(final String token) {
+ if (!session.isLogged()) {
+ passReset.get().setPasswordHash(token);
+ passReset.get().show();
+ }
+ }
+ });
verifyManager.get();
+
}
}
Modified: trunk/src/main/java/cc/kune/core/client/auth/SignInPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/auth/SignInPanel.java 2012-01-17 01:24:06 UTC (rev 1664)
+++ trunk/src/main/java/cc/kune/core/client/auth/SignInPanel.java 2012-01-17 12:34:00 UTC (rev 1665)
@@ -40,8 +40,10 @@
public static final String CANCEL_BUTTON_ID = "k-signinp-cb";
public static final String CREATE_ONE = "k-signinp-create";
public static final String ERROR_MSG = "k-sigp-errmsg";
+ public static final String FORGOT_PASSWD = "k-signinp-forgot";
public static final String SIGN_IN_BUTTON_ID = "k-signinp-sib";
public static final String SIGNIN_DIALOG = "k-signinp-dialog";
+ private Label forgotPasswordLabel;
private Label registerLabel;
private final SignInForm signInForm;
@@ -54,24 +56,31 @@
signInForm = new SignInForm(i18n);
signInForm.setWidth(330);
- signInForm.add(createNoAccountRegister());
+ signInForm.add(createRegisterAndForgotPasswd());
messageErrorBar = new MessageToolbar(images, errorLabelId);
signInForm.add(messageErrorBar);
super.getInnerPanel().add(signInForm.getFormPanel());
}
- private VerticalPanel createNoAccountRegister() {
+ private void createLink(final Label label, final String id) {
+ label.ensureDebugId(id);
+ label.addStyleName("k-link");
+ label.addStyleName("k-cursor");
+ }
+
+ private VerticalPanel createRegisterAndForgotPasswd() {
final VerticalPanel noAccRegisterPanel = new VerticalPanel();
final HorizontalPanel hpanel = new HorizontalPanel();
final Label dontHaveAccount = new Label(i18n.t("Don't have an account?"));
registerLabel = new Label(i18n.t("Create one."));
- registerLabel.ensureDebugId(CREATE_ONE);
+ createLink(registerLabel, CREATE_ONE);
registerLabel.addStyleName("kune-Margin-Medium-l");
- registerLabel.addStyleName("k-link");
- registerLabel.addStyleName("k-cursor");
+ forgotPasswordLabel = new Label(i18n.t("Lost your password?"));
+ createLink(forgotPasswordLabel, FORGOT_PASSWD);
hpanel.add(dontHaveAccount);
hpanel.add(registerLabel);
noAccRegisterPanel.add(hpanel);
+ noAccRegisterPanel.add(forgotPasswordLabel);
return noAccRegisterPanel;
}
@@ -91,6 +100,11 @@
}
@Override
+ public HasClickHandlers getForgotPasswd() {
+ return forgotPasswordLabel;
+ }
+
+ @Override
public String getLoginPassword() {
return signInForm.getLoginPassword();
}
Modified: trunk/src/main/java/cc/kune/core/client/auth/SignInPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/auth/SignInPresenter.java 2012-01-17 01:24:06 UTC (rev 1664)
+++ trunk/src/main/java/cc/kune/core/client/auth/SignInPresenter.java 2012-01-17 12:34:00 UTC (rev 1665)
@@ -33,6 +33,7 @@
import cc.kune.core.client.i18n.I18nUITranslationService;
import cc.kune.core.client.resources.CoreMessages;
import cc.kune.core.client.rpcservices.UserServiceAsync;
+import cc.kune.core.client.sitebar.auth.AskForPasswordResetPanel;
import cc.kune.core.client.state.Session;
import cc.kune.core.client.state.SiteTokens;
import cc.kune.core.client.state.StateManager;
@@ -68,6 +69,8 @@
HasClickHandlers getAccountRegister();
+ HasClickHandlers getForgotPasswd();
+
String getLoginPassword();
String getNickOrEmail();
@@ -83,7 +86,7 @@
void validate();
}
-
+ private final Provider<AskForPasswordResetPanel> askPasswdReset;
private final EventBus eventBus;
private final Provider<Register> registerProvider;
private final TimerWrapper timer;
@@ -95,13 +98,15 @@
final Session session, final StateManager stateManager, final I18nUITranslationService i18n,
final UserServiceAsync userService, final Provider<Register> registerProvider,
final CookiesManager cookiesManager, final UserPassAutocompleteManager autocomplete,
- final TimerWrapper timeWrapper, final WaveClientSimpleAuthenticator waveClientAuthenticator) {
+ final TimerWrapper timeWrapper, final WaveClientSimpleAuthenticator waveClientAuthenticator,
+ final Provider<AskForPasswordResetPanel> askPasswdReset) {
super(eventBus, view, proxy, session, stateManager, i18n, cookiesManager, autocomplete);
this.eventBus = eventBus;
this.userService = userService;
this.registerProvider = registerProvider;
this.timer = timeWrapper;
this.waveClientAuthenticator = waveClientAuthenticator;
+ this.askPasswdReset = askPasswdReset;
}
@Override
@@ -185,6 +190,12 @@
onAccountRegister();
}
});
+ getView().getForgotPasswd().addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(final ClickEvent event) {
+ askPasswdReset.get().show();
+ }
+ });
}
public void onFormSignIn() {
Modified: trunk/src/main/java/cc/kune/core/client/rpcservices/UserService.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/rpcservices/UserService.java 2012-01-17 01:24:06 UTC (rev 1664)
+++ trunk/src/main/java/cc/kune/core/client/rpcservices/UserService.java 2012-01-17 12:34:00 UTC (rev 1665)
@@ -20,6 +20,7 @@
package cc.kune.core.client.rpcservices;
import cc.kune.core.client.errors.DefaultException;
+import cc.kune.core.client.errors.EmailHashInvalidException;
import cc.kune.core.client.errors.EmailNotFoundException;
import cc.kune.core.shared.domain.UserSNetVisibility;
import cc.kune.core.shared.domain.utils.StateToken;
@@ -55,7 +56,7 @@
UserInfoDTO reloadUserInfo(String userHash) throws DefaultException;
- void resetPassword(String passwdHash, String newpasswd);
+ void resetPassword(String passwdHash, String newpasswd) throws EmailHashInvalidException;
void setBuddiesVisibility(String userHash, StateToken groupToken, UserSNetVisibility visibility);
Modified: trunk/src/main/java/cc/kune/core/client/sitebar/auth/AskForPasswordResetPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sitebar/auth/AskForPasswordResetPanel.java 2012-01-17 01:24:06 UTC (rev 1664)
+++ trunk/src/main/java/cc/kune/core/client/sitebar/auth/AskForPasswordResetPanel.java 2012-01-17 12:34:00 UTC (rev 1665)
@@ -12,14 +12,16 @@
import cc.kune.core.client.events.StackErrorEvent;
import cc.kune.core.client.rpcservices.UserServiceAsync;
import cc.kune.core.client.state.Session;
+import cc.kune.core.client.state.SiteTokens;
+import cc.kune.core.client.state.StateManager;
import cc.kune.core.client.ui.DefaultForm;
-import com.extjs.gxt.ui.client.widget.form.LabelField;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.ui.Label;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
@@ -33,18 +35,21 @@
public static final String ERRMSG = "k-ask-for-pwd-error";
public static final String RESET_BUTTON_ID = "k-ask-for-pwd-reset";
private final TextField<String> resetEmail;
+ private final StateManager stateManager;
@Inject
public AskForPasswordResetPanel(final I18nTranslationService i18n, final Session session,
final MaskWidgetView mask, final NotifyLevelImages images, final EventBus eventbus,
- final UserFieldFactory userFieldFactory, final Provider<UserServiceAsync> userService) {
+ final UserFieldFactory userFieldFactory, final Provider<UserServiceAsync> userService,
+ final StateManager stateManager) {
super(ASK_PASSWD_RESET_DIALOG, mask, i18n, i18n.t("Reset your password"), true, true, true, "",
i18n.t("Reset your password"), RESET_BUTTON_ID, i18n.tWithNT("Cancel", "used in button"),
CANCEL_BUTTON_ID, images, ERRMSG, 1);
+ this.stateManager = stateManager;
final DefaultForm form = new DefaultForm();
- final LabelField desc = new LabelField(
+ final Label desc = new Label(
i18n.t("Please enter your email address. You will receive a link to create a new password via email."));
- form.add(desc);
+ desc.setWidth("300px");
resetEmail = userFieldFactory.createUserEmail(EMAIL_RESET_ID);
resetEmail.setFieldLabel(i18n.t("email"));
resetEmail.setTabIndex(1);
@@ -77,14 +82,15 @@
}
}
});
- super.getInnerPanel().add(form.getFormPanel());
super.getSecondBtn().addClickHandler(new ClickHandler() {
-
@Override
public void onClick(final ClickEvent event) {
hide();
}
});
+ super.getInnerPanel().add(desc);
+ super.getInnerPanel().add(form.getFormPanel());
+
}
@Override
@@ -92,6 +98,7 @@
super.hide();
super.messageErrorBar.hideErrorMessage();
resetEmail.clear();
+ stateManager.gotoHistoryToken(SiteTokens.HOME);
}
@Override
Copied: trunk/src/main/java/cc/kune/core/client/sitebar/auth/PasswordResetPanel.java (from rev 1664, trunk/src/main/java/cc/kune/core/client/sitebar/auth/AskForPasswordResetPanel.java)
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sitebar/auth/PasswordResetPanel.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/client/sitebar/auth/PasswordResetPanel.java 2012-01-17 12:34:00 UTC (rev 1665)
@@ -0,0 +1,134 @@
+package cc.kune.core.client.sitebar.auth;
+
+import cc.kune.common.client.notify.NotifyLevel;
+import cc.kune.common.client.notify.NotifyLevelImages;
+import cc.kune.common.client.notify.NotifyUser;
+import cc.kune.common.client.ui.MaskWidgetView;
+import cc.kune.common.client.ui.dialogs.MessageToolbar;
+import cc.kune.common.shared.i18n.I18nTranslationService;
+import cc.kune.core.client.auth.SignInAbstractPanel;
+import cc.kune.core.client.auth.UserFieldFactory;
+import cc.kune.core.client.errors.EmailHashInvalidException;
+import cc.kune.core.client.events.StackErrorEvent;
+import cc.kune.core.client.rpcservices.UserServiceAsync;
+import cc.kune.core.client.state.Session;
+import cc.kune.core.client.state.SiteTokens;
+import cc.kune.core.client.state.StateManager;
+import cc.kune.core.client.state.TokenUtils;
+import cc.kune.core.client.ui.DefaultForm;
+
+import com.extjs.gxt.ui.client.widget.form.TextField;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.event.shared.EventBus;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.gwt.user.client.ui.Label;
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.google.inject.Singleton;
+
+@Singleton
+public class PasswordResetPanel extends SignInAbstractPanel {
+
+ public static final String CANCEL_BUTTON_ID = "k-pwd-reset-cancel";
+ public static final String ERRMSG = "k-pwd-reset-error";
+ public static final String PASSWD_RESET_DIALOG = "k-pwd-reset-diag";
+ public static final String PASSWD_RESET_ID = "k-pwd-reset-email";
+ public static final String PASSWD2_RESET_DIALOG = "k-pwd-reset-diag";
+ public static final String RESET_BUTTON_ID = "k-pwd-reset-reset";
+ private final TextField<String> confirmPasswdField;
+ private final TextField<String> newPasswdField;
+ private String passwordHash;
+ private final StateManager stateManager;
+
+ @Inject
+ public PasswordResetPanel(final I18nTranslationService i18n, final Session session,
+ final MaskWidgetView mask, final NotifyLevelImages images, final EventBus eventbus,
+ final UserFieldFactory userFieldFactory, final Provider<UserServiceAsync> userService,
+ final StateManager stateManager) {
+ super(PASSWD_RESET_DIALOG, mask, i18n, i18n.t("Reset your password"), true, true, true, "",
+ i18n.t("Reset your password"), RESET_BUTTON_ID, i18n.tWithNT("Cancel", "used in button"),
+ CANCEL_BUTTON_ID, images, ERRMSG, 1);
+ this.stateManager = stateManager;
+ final DefaultForm form = new DefaultForm();
+ final Label desc = new Label(i18n.t("Enter your new password below."));
+ desc.setWidth("300px");
+ newPasswdField = userFieldFactory.createUserPasswd(PASSWD_RESET_ID, i18n.t("New password"));
+ newPasswdField.setTabIndex(1);
+ confirmPasswdField = userFieldFactory.createUserPasswd(PASSWD_RESET_ID, i18n.t("Confirm"));
+ confirmPasswdField.setTabIndex(1);
+
+ messageErrorBar = new MessageToolbar(images, errorLabelId);
+ form.add(newPasswdField);
+ form.add(confirmPasswdField);
+ form.add(messageErrorBar);
+ super.getFirstBtn().addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(final ClickEvent event) {
+ final String newPass = newPasswdField.getValue();
+ final String confirmPass = confirmPasswdField.getValue();
+ if (form.isValid()) {
+ if (!newPass.equals(confirmPass)) {
+ messageErrorBar.setErrorMessage(i18n.t("Passwords are different"), NotifyLevel.error);
+ messageErrorBar.setVisible(true);
+ } else {
+ userService.get().resetPassword(getPasswordHash(), newPasswdField.getValue(),
+ new AsyncCallback<Void>() {
+ @Override
+ public void onFailure(final Throwable caught) {
+ if (caught instanceof EmailHashInvalidException) {
+ PasswordResetPanel.this.setErrorMessage(i18n.t("Invalid confirmation code"),
+ NotifyLevel.error);
+ } else {
+ PasswordResetPanel.this.setErrorMessage(
+ i18n.t("Other error trying to reset your password"), NotifyLevel.error);
+ }
+ StackErrorEvent.fire(eventbus, caught);
+ PasswordResetPanel.this.messageErrorBar.setVisible(true);
+ }
+
+ @Override
+ public void onSuccess(final Void result) {
+ NotifyUser.info(i18n.t("Your password has been reset. Sign in"));
+ hide();
+ stateManager.gotoHistoryToken(TokenUtils.addRedirect(SiteTokens.HOME,
+ SiteTokens.SIGN_IN));
+ }
+ });
+ }
+ }
+ }
+ });
+ super.getSecondBtn().addClickHandler(new ClickHandler() {
+
+ @Override
+ public void onClick(final ClickEvent event) {
+ hide();
+ }
+ });
+ super.getInnerPanel().add(desc);
+ super.getInnerPanel().add(form.getFormPanel());
+ }
+
+ public String getPasswordHash() {
+ return passwordHash;
+ }
+
+ @Override
+ public void hide() {
+ super.hide();
+ super.messageErrorBar.hideErrorMessage();
+ newPasswdField.clear();
+ confirmPasswdField.clear();
+ stateManager.gotoHistoryToken(SiteTokens.HOME);
+ }
+
+ public void setPasswordHash(final String passwordHash) {
+ this.passwordHash = passwordHash;
+ }
+
+ @Override
+ public void show() {
+ super.show();
+ }
+}
Modified: trunk/src/main/java/cc/kune/core/client/state/SiteTokens.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/state/SiteTokens.java 2012-01-17 01:24:06 UTC (rev 1664)
+++ trunk/src/main/java/cc/kune/core/client/state/SiteTokens.java 2012-01-17 12:34:00 UTC (rev 1665)
@@ -29,6 +29,7 @@
*/
public final class SiteTokens {
public static final String ABOUT_KUNE = "about";
+ public final static String ASK_RESET_PASSWD = "askresetpasswd";
public final static String GROUP_HOME = "";
public final static String GROUP_PREFS = "gprefs";
public final static String HOME = "";
Modified: trunk/src/main/java/cc/kune/core/server/rpc/UserRPC.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/rpc/UserRPC.java 2012-01-17 01:24:06 UTC (rev 1664)
+++ trunk/src/main/java/cc/kune/core/server/rpc/UserRPC.java 2012-01-17 12:34:00 UTC (rev 1665)
@@ -210,7 +210,8 @@
@Override
@Transactional
- public void resetPassword(final String passwdHash, final String newpasswd) {
+ public void resetPassword(final String passwdHash, final String newpasswd)
+ throws EmailHashInvalidException {
try {
final User user = userFinder.findByHash(passwdHash);
userManager.changePasswd(user.getId(), null, newpasswd, false);
1
0
17 Jan '12
Author: vjrj_
Date: 2012-01-17 02:24:06 +0100 (Tue, 17 Jan 2012)
New Revision: 1664
Added:
trunk/src/main/java/cc/kune/core/client/sitebar/auth/AskForPasswordResetPanel.java
Modified:
trunk/TODO
trunk/src/main/java/cc/kune/core/client/CoreParts.java
trunk/src/main/java/cc/kune/core/client/auth/RegisterForm.java
trunk/src/main/java/cc/kune/core/client/auth/RegisterPanel.java
trunk/src/main/java/cc/kune/core/client/rpcservices/UserService.java
trunk/src/main/java/cc/kune/core/client/rpcservices/UserServiceAsync.java
trunk/src/main/java/cc/kune/core/client/sitebar/auth/VerifyEmailClientManager.java
trunk/src/main/java/cc/kune/core/client/state/SiteTokens.java
trunk/src/main/java/cc/kune/core/server/manager/UserManager.java
trunk/src/main/java/cc/kune/core/server/manager/impl/UserManagerDefault.java
trunk/src/main/java/cc/kune/core/server/rpc/UserRPC.java
trunk/src/main/java/cc/kune/domain/User.java
trunk/src/main/java/cc/kune/domain/finders/UserFinder.java
Log:
NEW - # 99: Add a recovery password functionality
http://kune.ourproject.org/issues/ticket/99
Modified: trunk/TODO
===================================================================
--- trunk/TODO 2012-01-16 20:53:44 UTC (rev 1663)
+++ trunk/TODO 2012-01-17 01:24:06 UTC (rev 1664)
@@ -12,7 +12,54 @@
nick == assigned to
* SHORT-TERM (URGENT)
-** Emil notifications for new waves
+** Passwd reset
+Please enter your username or email address. You will receive a link to create a new password via email.
+Username or E-mail:
+Get New Password
+Check your e-mail for the confirmation link.
+
+
+Enter your new password below.
+
+New password
+Confirm new password
+Reset password
+
+Your password has been reset. Log in
+--------------------------------
+
+Please enter your username or email address. You will receive a link to create a new password via email.
+
+You are receiving this e-mail because a request has been made to change the FIXME password associated with this address (vruiz.jurado(a)gmail.com) If you would like to reset the password for this account simply click on the link below or paste it into the url field on your favorite browser:
+
+LINK
+
+If you didn't request this email then you can just ignore it -- your details have not been disclosed to anyone.
+If you have any questions about the system, feel free to contact us anytime at FIXME.
+
+Bla, bla, bla
+-----
+
+Someone requested that the password be reset for the following account:
+
+LINK
+Username: vjrj
+
+ReseIf this was a mistake, just ignore this email and nothing will happen.
+
+To reset your password, visit the following address:
+LINK
+
+
+
+
+
+** Connection persistence
+java.io.NotSerializableException: org.eclipse.jetty.websocket.WebSocketConnectionD13$WSFrameConnection
+java.io.NotSerializableException: com.glines.socketio.server.transport.jetty.JettyContinuationTransportHandler
+
+
+** Email notifications for new waves
*** Migration of DB!!!!!
*** Text for UI
Email Notifications
@@ -21,7 +68,6 @@
at most hourly
at most daily
I don't need email notifications
-*** Cron and pseudocode
** group.inexistentTool nasty error
** calendar support
*** gwt-cal + http://ical4j.sourceforge.net/introduction.html
Modified: trunk/src/main/java/cc/kune/core/client/CoreParts.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/CoreParts.java 2012-01-16 20:53:44 UTC (rev 1663)
+++ trunk/src/main/java/cc/kune/core/client/CoreParts.java 2012-01-17 01:24:06 UTC (rev 1664)
@@ -27,6 +27,7 @@
import cc.kune.core.client.groups.newgroup.NewGroup;
import cc.kune.core.client.sitebar.AboutKuneDialog;
import cc.kune.core.client.sitebar.SiteUserOptionsPresenter;
+import cc.kune.core.client.sitebar.auth.AskForPasswordResetPanel;
import cc.kune.core.client.sitebar.auth.VerifyEmailClientManager;
import cc.kune.core.client.sitebar.spaces.Space;
import cc.kune.core.client.sitebar.spaces.SpaceSelectEvent;
@@ -61,7 +62,8 @@
final Provider<AboutKuneDialog> aboutKuneDialog, final Provider<NewGroup> newGroup,
final Provider<SubtitlesManager> subProvider, final EventBus eventBus,
final Provider<VerifyEmailClientManager> verifyManager,
- final Provider<UserOptions> userOptionsDialog, final Provider<GroupOptions> groupOptionsDialog) {
+ final Provider<UserOptions> userOptionsDialog, final Provider<GroupOptions> groupOptionsDialog,
+ final Provider<AskForPasswordResetPanel> askForPass) {
session.onAppStart(true, new AppStartHandler() {
@Override
public void onAppStart(final AppStartEvent event) {
@@ -130,7 +132,14 @@
groupOptionsDialog.get().show(token);
}
});
-
+ tokenListener.put(SiteTokens.RESET_PASSWD, new HistoryTokenAuthNotNeededCallback() {
+ @Override
+ public void onHistoryToken(final String token) {
+ if (!session.isLogged()) {
+ askForPass.get().show();
+ }
+ }
+ });
verifyManager.get();
}
}
Modified: trunk/src/main/java/cc/kune/core/client/auth/RegisterForm.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/auth/RegisterForm.java 2012-01-16 20:53:44 UTC (rev 1663)
+++ trunk/src/main/java/cc/kune/core/client/auth/RegisterForm.java 2012-01-17 01:24:06 UTC (rev 1664)
@@ -21,7 +21,6 @@
import cc.kune.common.shared.i18n.I18nTranslationService;
import cc.kune.core.client.ui.DefaultForm;
-import cc.kune.core.shared.SessionConstants;
import com.extjs.gxt.ui.client.widget.form.Field;
import com.extjs.gxt.ui.client.widget.form.TextField;
@@ -46,8 +45,7 @@
private final TextField<String> shortNameRegField;
- public RegisterForm(final I18nTranslationService i18n, final SessionConstants session,
- final UserFieldFactory userFieldFactory) {
+ public RegisterForm(final I18nTranslationService i18n, final UserFieldFactory userFieldFactory) {
super.addStyleName("kune-Margin-Large-l");
shortNameRegField = userFieldFactory.createUserShortName(NICK_FIELD);
@@ -63,7 +61,7 @@
add(passwdRegField);
emailRegField = userFieldFactory.createUserEmail(EMAIL_FIELD);
- emailRegField.setTabIndex(5);
+ emailRegField.setTabIndex(4);
add(emailRegField);
}
Modified: trunk/src/main/java/cc/kune/core/client/auth/RegisterPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/auth/RegisterPanel.java 2012-01-16 20:53:44 UTC (rev 1663)
+++ trunk/src/main/java/cc/kune/core/client/auth/RegisterPanel.java 2012-01-17 01:24:06 UTC (rev 1664)
@@ -26,7 +26,6 @@
import cc.kune.core.client.auth.RegisterPresenter.RegisterView;
import cc.kune.core.client.resources.CoreMessages;
import cc.kune.core.client.ui.KuneUiUtils;
-import cc.kune.core.shared.SessionConstants;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
@@ -35,9 +34,7 @@
public class RegisterPanel extends SignInAbstractPanel implements RegisterView {
public static final String CANCEL_BUTTON_ID = "k-regp-cb";
-
public static final String ERRMSG = "k-regp-errmsg";
-
public static final String REGISTER_BUTTON_ID = "k-regp-rb";
public static final String REGISTER_DIALOG = "k-regp-dialog";
public static final String REGISTER_FORM = "k-regp-p";
@@ -46,12 +43,12 @@
private final RegisterForm registerForm;
@Inject
- public RegisterPanel(final I18nTranslationService i18n, final SessionConstants session,
- final MaskWidgetView mask, final NotifyLevelImages images, final UserFieldFactory userFieldFactory) {
+ public RegisterPanel(final I18nTranslationService i18n, final MaskWidgetView mask,
+ final NotifyLevelImages images, final UserFieldFactory userFieldFactory) {
super(REGISTER_DIALOG, mask, i18n, i18n.t(CoreMessages.REGISTER_TITLE), true, true, true, "",
i18n.t(CoreMessages.REGISTER_TITLE), REGISTER_BUTTON_ID,
- i18n.tWithNT("Cancel", "used in button"), CANCEL_BUTTON_ID, images, ERRMSG, 5);
- registerForm = new RegisterForm(i18n, session, userFieldFactory);
+ i18n.tWithNT("Cancel", "used in button"), CANCEL_BUTTON_ID, images, ERRMSG, 4);
+ registerForm = new RegisterForm(i18n, userFieldFactory);
registerForm.setWidth(330);
registerForm.getFormPanel().setId(REGISTER_FORM);
messageErrorBar = new MessageToolbar(images, errorLabelId);
Modified: trunk/src/main/java/cc/kune/core/client/rpcservices/UserService.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/rpcservices/UserService.java 2012-01-16 20:53:44 UTC (rev 1663)
+++ trunk/src/main/java/cc/kune/core/client/rpcservices/UserService.java 2012-01-17 01:24:06 UTC (rev 1664)
@@ -20,6 +20,7 @@
package cc.kune.core.client.rpcservices;
import cc.kune.core.client.errors.DefaultException;
+import cc.kune.core.client.errors.EmailNotFoundException;
import cc.kune.core.shared.domain.UserSNetVisibility;
import cc.kune.core.shared.domain.utils.StateToken;
import cc.kune.core.shared.dto.I18nLanguageSimpleDTO;
@@ -34,9 +35,9 @@
@RemoteServiceRelativePath("UserService")
public interface UserService extends RemoteService {
- void askForEmailConfirmation(String userHash);;
+ void askForEmailConfirmation(String userHash);
- void askForEmailForgot(String email);
+ void askForPasswordReset(String email) throws EmailNotFoundException;
void changePasswd(String userHash, String oldPassword, String newPassword) throws DefaultException;
@@ -54,6 +55,8 @@
UserInfoDTO reloadUserInfo(String userHash) throws DefaultException;
+ void resetPassword(String passwdHash, String newpasswd);
+
void setBuddiesVisibility(String userHash, StateToken groupToken, UserSNetVisibility visibility);
StateAbstractDTO updateUser(String userHash, UserDTO user, I18nLanguageSimpleDTO lang);
Modified: trunk/src/main/java/cc/kune/core/client/rpcservices/UserServiceAsync.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/rpcservices/UserServiceAsync.java 2012-01-16 20:53:44 UTC (rev 1663)
+++ trunk/src/main/java/cc/kune/core/client/rpcservices/UserServiceAsync.java 2012-01-17 01:24:06 UTC (rev 1664)
@@ -33,7 +33,7 @@
void askForEmailConfirmation(String userHash, AsyncCallback<Void> callback);
- void askForEmailForgot(String email, AsyncCallback<Void> callback);
+ void askForPasswordReset(String email, AsyncCallback<Void> callback);
void changePasswd(String userHash, String oldPassword, String newPassword, AsyncCallback<Void> callback);
@@ -52,6 +52,8 @@
void reloadUserInfo(String userHash, AsyncCallback<UserInfoDTO> asyncCallback);
+ void resetPassword(String passwdHash, String newpasswd, AsyncCallback<Void> callback);
+
void setBuddiesVisibility(String userHash, StateToken groupToken, UserSNetVisibility visibility,
AsyncCallback<Void> asyncCallback);
Added: trunk/src/main/java/cc/kune/core/client/sitebar/auth/AskForPasswordResetPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sitebar/auth/AskForPasswordResetPanel.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/client/sitebar/auth/AskForPasswordResetPanel.java 2012-01-17 01:24:06 UTC (rev 1664)
@@ -0,0 +1,101 @@
+package cc.kune.core.client.sitebar.auth;
+
+import cc.kune.common.client.notify.NotifyLevel;
+import cc.kune.common.client.notify.NotifyLevelImages;
+import cc.kune.common.client.notify.NotifyUser;
+import cc.kune.common.client.ui.MaskWidgetView;
+import cc.kune.common.client.ui.dialogs.MessageToolbar;
+import cc.kune.common.shared.i18n.I18nTranslationService;
+import cc.kune.core.client.auth.SignInAbstractPanel;
+import cc.kune.core.client.auth.UserFieldFactory;
+import cc.kune.core.client.errors.EmailNotFoundException;
+import cc.kune.core.client.events.StackErrorEvent;
+import cc.kune.core.client.rpcservices.UserServiceAsync;
+import cc.kune.core.client.state.Session;
+import cc.kune.core.client.ui.DefaultForm;
+
+import com.extjs.gxt.ui.client.widget.form.LabelField;
+import com.extjs.gxt.ui.client.widget.form.TextField;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
+import com.google.gwt.event.shared.EventBus;
+import com.google.gwt.user.client.rpc.AsyncCallback;
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.google.inject.Singleton;
+
+@Singleton
+public class AskForPasswordResetPanel extends SignInAbstractPanel {
+
+ public static final String ASK_PASSWD_RESET_DIALOG = "k-ask-for-pwd-diag";
+ public static final String CANCEL_BUTTON_ID = "k-ask-for-pwd-cancel";
+ public static final String EMAIL_RESET_ID = "k-ask-for-pwd-email";
+ public static final String ERRMSG = "k-ask-for-pwd-error";
+ public static final String RESET_BUTTON_ID = "k-ask-for-pwd-reset";
+ private final TextField<String> resetEmail;
+
+ @Inject
+ public AskForPasswordResetPanel(final I18nTranslationService i18n, final Session session,
+ final MaskWidgetView mask, final NotifyLevelImages images, final EventBus eventbus,
+ final UserFieldFactory userFieldFactory, final Provider<UserServiceAsync> userService) {
+ super(ASK_PASSWD_RESET_DIALOG, mask, i18n, i18n.t("Reset your password"), true, true, true, "",
+ i18n.t("Reset your password"), RESET_BUTTON_ID, i18n.tWithNT("Cancel", "used in button"),
+ CANCEL_BUTTON_ID, images, ERRMSG, 1);
+ final DefaultForm form = new DefaultForm();
+ final LabelField desc = new LabelField(
+ i18n.t("Please enter your email address. You will receive a link to create a new password via email."));
+ form.add(desc);
+ resetEmail = userFieldFactory.createUserEmail(EMAIL_RESET_ID);
+ resetEmail.setFieldLabel(i18n.t("email"));
+ resetEmail.setTabIndex(1);
+ messageErrorBar = new MessageToolbar(images, errorLabelId);
+ form.add(resetEmail);
+ form.add(messageErrorBar);
+ super.getFirstBtn().addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(final ClickEvent event) {
+ if (form.isValid()) {
+ userService.get().askForPasswordReset(resetEmail.getValue(), new AsyncCallback<Void>() {
+ @Override
+ public void onFailure(final Throwable caught) {
+ if (caught instanceof EmailNotFoundException) {
+ AskForPasswordResetPanel.this.setErrorMessage(i18n.t("Invalid email"), NotifyLevel.error);
+ } else {
+ AskForPasswordResetPanel.this.setErrorMessage(
+ i18n.t("Other error trying to reset your password"), NotifyLevel.error);
+ }
+ StackErrorEvent.fire(eventbus, caught);
+ AskForPasswordResetPanel.this.messageErrorBar.setVisible(true);
+ }
+
+ @Override
+ public void onSuccess(final Void result) {
+ NotifyUser.info(i18n.t("Check your email for the confirmation link"));
+ hide();
+ }
+ });
+ }
+ }
+ });
+ super.getInnerPanel().add(form.getFormPanel());
+ super.getSecondBtn().addClickHandler(new ClickHandler() {
+
+ @Override
+ public void onClick(final ClickEvent event) {
+ hide();
+ }
+ });
+ }
+
+ @Override
+ public void hide() {
+ super.hide();
+ super.messageErrorBar.hideErrorMessage();
+ resetEmail.clear();
+ }
+
+ @Override
+ public void show() {
+ super.show();
+ }
+}
Modified: trunk/src/main/java/cc/kune/core/client/sitebar/auth/VerifyEmailClientManager.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sitebar/auth/VerifyEmailClientManager.java 2012-01-16 20:53:44 UTC (rev 1663)
+++ trunk/src/main/java/cc/kune/core/client/sitebar/auth/VerifyEmailClientManager.java 2012-01-17 01:24:06 UTC (rev 1664)
@@ -28,7 +28,7 @@
new AsyncCallbackSimple<Void>() {
@Override
public void onSuccess(final Void result) {
- NotifyUser.info("Great. Your email is now verified.");
+ NotifyUser.info("Great. Your email is now verified");
session.getCurrentUser().setEmailVerified(true);
optGeneral.get().update();
}
Modified: trunk/src/main/java/cc/kune/core/client/state/SiteTokens.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/state/SiteTokens.java 2012-01-16 20:53:44 UTC (rev 1663)
+++ trunk/src/main/java/cc/kune/core/client/state/SiteTokens.java 2012-01-17 01:24:06 UTC (rev 1664)
@@ -36,7 +36,7 @@
public final static String PREFS = "prefs";
public static final String PREVIEW = "preview";
public final static String REGISTER = "register";
- public final static String RESET_PWD = "resetpasswd";
+ public final static String RESET_PASSWD = "resetpasswd";
public final static String SIGN_IN = "signin";
public final static String SUBTITLES = "sub";
public final static String TRANSLATE = "translate";
@@ -58,6 +58,6 @@
reserverdWords.add(PREFS);
reserverdWords.add(GROUP_PREFS);
reserverdWords.add(VERIFY_EMAIL);
- reserverdWords.add(RESET_PWD);
+ reserverdWords.add(RESET_PASSWD);
}
}
Modified: trunk/src/main/java/cc/kune/core/server/manager/UserManager.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/manager/UserManager.java 2012-01-16 20:53:44 UTC (rev 1663)
+++ trunk/src/main/java/cc/kune/core/server/manager/UserManager.java 2012-01-17 01:24:06 UTC (rev 1664)
@@ -41,7 +41,21 @@
*/
void askForEmailConfirmation(User user, EmailConfirmationType type) throws DefaultException;
- User changePasswd(Long userId, String oldPassword, String newPassword);
+ /**
+ * Change passwd.
+ *
+ * @param userId
+ * the user id to change the passwd
+ * @param oldPassword
+ * the old password
+ * @param newPassword
+ * the new password
+ * @param checkOldPasswd
+ * if we have to check the old passwd (not necessary if we are
+ * reseting a unknown password)
+ * @return the user
+ */
+ User changePasswd(Long userId, String oldPassword, String newPassword, boolean checkOldPasswd);
/**
* CreateUser new method with language country and timezone params
Modified: trunk/src/main/java/cc/kune/core/server/manager/impl/UserManagerDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/manager/impl/UserManagerDefault.java 2012-01-16 20:53:44 UTC (rev 1663)
+++ trunk/src/main/java/cc/kune/core/server/manager/impl/UserManagerDefault.java 2012-01-17 01:24:06 UTC (rev 1664)
@@ -133,6 +133,11 @@
* @see
* cc.kune.core.server.manager.UserManager#askForEmailConfirmation(cc.kune
* .domain.User, cc.kune.core.server.manager.impl.EmailConfirmationType)
+ *
+ * More info: http://en.wikipedia.org/wiki/Self-service_password_reset
+ * http://en.wikipedia.org/wiki/Password_notification_e-mail
+ * http://stackoverflow
+ * .com/questions/1102781/best-way-for-a-forgot-password-implementation
*/
@Override
public void askForEmailConfirmation(final User user, final EmailConfirmationType type)
@@ -150,29 +155,43 @@
TokenUtils.addRedirect(SiteTokens.VERIFY_EMAIL, hash));
break;
case passwordReset:
- // FIXME
+ notifyService.sendEmailToWithLink(
+ user,
+ "Verify password reset",
+ "You are receiving this email because a request has been made to change the password associated with this email address in %s.<br>"
+ + "If this was a mistake, just ignore this email and nothing will happen.<br>"
+ + "If you would like to reset the password for this account simply click on the link below or paste it into the url field on your favorite browser:",
+ TokenUtils.addRedirect(SiteTokens.RESET_PASSWD, hash));
default:
break;
}
}
@Override
- public User changePasswd(final Long userId, final String oldPassword, final String newPassword) {
+ public User changePasswd(final Long userId, final String oldPassword, final String newPassword,
+ final boolean checkOldPasswd) {
final User user = find(userId);
final ParticipantId participantId = participantUtils.of(user.getShortName());
- // Check oldPasswd
+ if (checkOldPasswd) {
+ // Check oldPasswd
+ AccountData account;
+ try {
+ account = waveAccountStore.getAccount(participantId);
+ if (TextUtils.notEmpty(oldPassword) && account != null
+ && !account.asHuman().getPasswordDigest().verify(oldPassword.toCharArray())) {
+ throw new WrongCurrentPasswordException();
+ }
+ } catch (final PersistenceException e) {
+ thowExceptionChangingPasswd(e);
+ }
+ }
try {
- final AccountData account = waveAccountStore.getAccount(participantId);
- if (TextUtils.notEmpty(oldPassword) && account != null
- && !account.asHuman().getPasswordDigest().verify(oldPassword.toCharArray())) {
- throw new WrongCurrentPasswordException();
- }
// Wave change passwd
RobotAgentUtil.changeUserPassword(newPassword, participantId, waveAccountStore);
} catch (final IllegalArgumentException e) {
- throw new DefaultException("Error changing user passwd", e);
+ thowExceptionChangingPasswd(e);
} catch (final PersistenceException e) {
- throw new DefaultException("Error changing user passwd", e);
+ thowExceptionChangingPasswd(e);
}
// Kune db change passwd
final PasswordDigest newPasswordDigest = new PasswordDigest(newPassword.toCharArray());
@@ -402,6 +421,10 @@
persist(user);
}
+ private void thowExceptionChangingPasswd(final Exception e) {
+ throw new DefaultException("Error changing user passwd", e);
+ }
+
@Override
public User update(final Long userId, final UserDTO userDTO, final I18nLanguageSimpleDTO lang) {
final User user = find(userId);
Modified: trunk/src/main/java/cc/kune/core/server/rpc/UserRPC.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/rpc/UserRPC.java 2012-01-16 20:53:44 UTC (rev 1663)
+++ trunk/src/main/java/cc/kune/core/server/rpc/UserRPC.java 2012-01-17 01:24:06 UTC (rev 1664)
@@ -29,6 +29,7 @@
import cc.kune.core.client.errors.AccessViolationException;
import cc.kune.core.client.errors.DefaultException;
+import cc.kune.core.client.errors.EmailHashInvalidException;
import cc.kune.core.client.errors.EmailNotFoundException;
import cc.kune.core.client.errors.UserAuthException;
import cc.kune.core.client.rpcservices.UserService;
@@ -104,7 +105,7 @@
@Override
@Transactional
- public void askForEmailForgot(final String email) throws DefaultException {
+ public void askForPasswordReset(final String email) throws EmailNotFoundException {
try {
final User user = userFinder.findByEmail(email);
userManager.askForEmailConfirmation(user, EmailConfirmationType.passwordReset);
@@ -119,7 +120,7 @@
public void changePasswd(final String userHash, final String oldPassword, final String newPassword)
throws DefaultException {
final Long userId = userSessionManager.getUser().getId();
- userManager.changePasswd(userId, oldPassword, newPassword);
+ userManager.changePasswd(userId, oldPassword, newPassword, true);
}
@Override
@@ -208,6 +209,17 @@
}
@Override
+ @Transactional
+ public void resetPassword(final String passwdHash, final String newpasswd) {
+ try {
+ final User user = userFinder.findByHash(passwdHash);
+ userManager.changePasswd(user.getId(), null, newpasswd, false);
+ } catch (final NoResultException e) {
+ throw new EmailHashInvalidException();
+ }
+ }
+
+ @Override
@Authenticated(mandatory = true)
@Authorizated(accessRolRequired = AccessRol.Administrator, actionLevel = ActionLevel.group)
@Transactional
@@ -241,4 +253,5 @@
final User user = userSessionManager.getUser();
userManager.verifyPasswordHash(user.getId(), emailReceivedHash, SessionConstants._AN_HOUR);
}
+
}
Modified: trunk/src/main/java/cc/kune/domain/User.java
===================================================================
--- trunk/src/main/java/cc/kune/domain/User.java 2012-01-16 20:53:44 UTC (rev 1663)
+++ trunk/src/main/java/cc/kune/domain/User.java 2012-01-17 01:24:06 UTC (rev 1664)
@@ -83,11 +83,13 @@
@Length(min = 1)
private String email;
+ @Basic(optional = true)
private Long emailCheckDate;
// @OneToOne(cascade = CascadeType.REMOVE)
// private final CustomProperties customProperties;
+ @Column(unique = true, nullable = true)
private String emailConfirmHash;
@Enumerated(EnumType.STRING)
Modified: trunk/src/main/java/cc/kune/domain/finders/UserFinder.java
===================================================================
--- trunk/src/main/java/cc/kune/domain/finders/UserFinder.java 2012-01-16 20:53:44 UTC (rev 1663)
+++ trunk/src/main/java/cc/kune/domain/finders/UserFinder.java 2012-01-17 01:24:06 UTC (rev 1664)
@@ -44,6 +44,9 @@
@Finder(query = "from User where email = :email")
public User findByEmail(@Named("email") final String email);
+ @Finder(query = "from User where emailConfirmHash = :emailConfirmHash")
+ public User findByHash(@Named("emailConfirmHash") final String emailConfirmHash);
+
@Finder(query = "from User where id = :id")
public User findById(@Named("id") final Long id);
1
0
Author: vjrj_
Date: 2012-01-16 21:53:44 +0100 (Mon, 16 Jan 2012)
New Revision: 1663
Added:
trunk/src/main/java/cc/kune/core/client/errors/EmailHashExpiredException.java
trunk/src/main/java/cc/kune/core/client/errors/EmailHashInvalidException.java
trunk/src/main/java/cc/kune/core/client/errors/EmailNotFoundException.java
trunk/src/main/java/cc/kune/core/client/sitebar/auth/
trunk/src/main/java/cc/kune/core/client/sitebar/auth/VerifyEmailClientManager.java
trunk/src/main/java/cc/kune/core/client/state/HistoryTokenAuthNotNeededCallback.java
trunk/src/main/java/cc/kune/core/client/state/HistoryTokenMustBeAuthCallback.java
trunk/src/main/java/cc/kune/core/server/manager/impl/EmailConfirmationType.java
trunk/src/main/java/cc/kune/core/shared/SessionConstants.java
trunk/src/test/java/cc/kune/core/shared/
trunk/src/test/java/cc/kune/core/shared/utils/
trunk/src/test/java/cc/kune/core/shared/utils/SharedFileDownloadUtilsTest.java
Modified:
trunk/src/main/java/cc/kune/barters/client/BartersParts.java
trunk/src/main/java/cc/kune/blogs/client/BlogsParts.java
trunk/src/main/java/cc/kune/chat/client/actions/ChatSitebarActions.java
trunk/src/main/java/cc/kune/chat/client/actions/OpenChatAction.java
trunk/src/main/java/cc/kune/core/KuneCore.gwt.xml
trunk/src/main/java/cc/kune/core/client/CoreParts.java
trunk/src/main/java/cc/kune/core/client/auth/AnonUsersManager.java
trunk/src/main/java/cc/kune/core/client/auth/RegisterForm.java
trunk/src/main/java/cc/kune/core/client/auth/RegisterPanel.java
trunk/src/main/java/cc/kune/core/client/cookies/CookiesManagerImpl.java
trunk/src/main/java/cc/kune/core/client/errors/ErrorHandler.java
trunk/src/main/java/cc/kune/core/client/rpcservices/UserService.java
trunk/src/main/java/cc/kune/core/client/rpcservices/UserServiceAsync.java
trunk/src/main/java/cc/kune/core/client/sitebar/SitebarNewGroupLink.java
trunk/src/main/java/cc/kune/core/client/sitebar/SitebarSignInLink.java
trunk/src/main/java/cc/kune/core/client/sitebar/search/SitebarSearchPanel.java
trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorPanel.java
trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorPresenter.java
trunk/src/main/java/cc/kune/core/client/sn/actions/JoinGroupAction.java
trunk/src/main/java/cc/kune/core/client/sn/actions/SessionAction.java
trunk/src/main/java/cc/kune/core/client/sn/actions/registry/GroupSNAdminsMenuItemsRegistry.java
trunk/src/main/java/cc/kune/core/client/sn/actions/registry/GroupSNCollabsMenuItemsRegistry.java
trunk/src/main/java/cc/kune/core/client/sn/actions/registry/GroupSNConfActions.java
trunk/src/main/java/cc/kune/core/client/sn/actions/registry/GroupSNPendingsMenuItemsRegistry.java
trunk/src/main/java/cc/kune/core/client/sn/actions/registry/UserSNMenuItemsRegistry.java
trunk/src/main/java/cc/kune/core/client/state/HistoryTokenCallback.java
trunk/src/main/java/cc/kune/core/client/state/Session.java
trunk/src/main/java/cc/kune/core/client/state/SiteTokens.java
trunk/src/main/java/cc/kune/core/client/state/impl/StateManagerDefault.java
trunk/src/main/java/cc/kune/core/public/ws.css
trunk/src/main/java/cc/kune/core/server/mail/MailServiceDefault.java
trunk/src/main/java/cc/kune/core/server/manager/UserManager.java
trunk/src/main/java/cc/kune/core/server/manager/impl/UserManagerDefault.java
trunk/src/main/java/cc/kune/core/server/notifier/NotificationHtmlHelper.java
trunk/src/main/java/cc/kune/core/server/notifier/NotificationSenderDefault.java
trunk/src/main/java/cc/kune/core/server/notifier/NotificationService.java
trunk/src/main/java/cc/kune/core/server/rpc/UserRPC.java
trunk/src/main/java/cc/kune/core/server/utils/AbsoluteFileDownloadUtils.java
trunk/src/main/java/cc/kune/core/shared/dto/UserSimpleDTO.java
trunk/src/main/java/cc/kune/core/shared/utils/SharedFileDownloadUtils.java
trunk/src/main/java/cc/kune/docs/client/DocsParts.java
trunk/src/main/java/cc/kune/domain/User.java
trunk/src/main/java/cc/kune/events/client/EventsParts.java
trunk/src/main/java/cc/kune/gspace/client/GSpaceParts.java
trunk/src/main/java/cc/kune/gspace/client/actions/AbstractFoldableToolActions.java
trunk/src/main/java/cc/kune/gspace/client/actions/DelContainerMenuItem.java
trunk/src/main/java/cc/kune/gspace/client/actions/GiveUsFeedbackAction.java
trunk/src/main/java/cc/kune/gspace/client/options/GroupOptions.java
trunk/src/main/java/cc/kune/gspace/client/options/GroupOptionsPresenter.java
trunk/src/main/java/cc/kune/gspace/client/options/UserOptionsPresenter.java
trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneral.java
trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPanel.java
trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPresenter.java
trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralView.java
trunk/src/main/java/cc/kune/gspace/client/tags/TagsSummaryPresenter.java
trunk/src/main/java/cc/kune/hspace/client/HSpacePanel.java
trunk/src/main/java/cc/kune/lists/client/ListsParts.java
trunk/src/main/java/cc/kune/lists/client/actions/NewListPostAction.java
trunk/src/main/java/cc/kune/lists/client/actions/SubscriteToListAction.java
trunk/src/main/java/cc/kune/tasks/client/TasksParts.java
trunk/src/main/java/cc/kune/wave/client/WebClient.java
trunk/src/main/java/cc/kune/wave/server/kspecific/WaveEmailNotifier.java
trunk/src/main/java/cc/kune/wiki/client/WikiParts.java
trunk/src/main/resources/kune.properties
trunk/src/test/java/cc/kune/core/client/state/impl/StateManagerDefaultTest.java
trunk/src/test/java/cc/kune/core/server/mail/MailServiceDefaultTest.java
trunk/src/test/java/cc/kune/gspace/client/tags/TagsSummaryPresenterTest.java
trunk/src/test/java/cc/kune/selenium/login/ScreenCastsViaSeleniumTests.java
Log:
NEW - # 94: Registration: emails not timely going out
http://kune.ourproject.org/issues/ticket/94
Modified: trunk/src/main/java/cc/kune/barters/client/BartersParts.java
===================================================================
--- trunk/src/main/java/cc/kune/barters/client/BartersParts.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/barters/client/BartersParts.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -21,7 +21,7 @@
import cc.kune.barters.client.actions.BartersClientActions;
import cc.kune.barters.shared.BartersConstants;
-import cc.kune.core.client.state.Session;
+import cc.kune.core.shared.SessionConstants;
import cc.kune.gspace.client.tool.ContentViewerSelector;
import cc.kune.gspace.client.viewers.ContentViewerPresenter;
import cc.kune.gspace.client.viewers.FolderViewerPresenter;
@@ -32,7 +32,7 @@
public class BartersParts {
@Inject
- public BartersParts(final Session session, final Provider<BartersClientTool> clientTool,
+ public BartersParts(final SessionConstants session, final Provider<BartersClientTool> clientTool,
final ContentViewerSelector viewerSelector, final BartersClientActions bartersActions,
final ContentViewerPresenter contentViewer, final FolderViewerPresenter folderViewer) {
clientTool.get();
Modified: trunk/src/main/java/cc/kune/blogs/client/BlogsParts.java
===================================================================
--- trunk/src/main/java/cc/kune/blogs/client/BlogsParts.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/blogs/client/BlogsParts.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -21,7 +21,7 @@
import cc.kune.blogs.client.actions.BlogsClientActions;
import cc.kune.blogs.shared.BlogsConstants;
-import cc.kune.core.client.state.Session;
+import cc.kune.core.shared.SessionConstants;
import cc.kune.gspace.client.tool.ContentViewerSelector;
import cc.kune.gspace.client.viewers.ContentViewerPresenter;
import cc.kune.gspace.client.viewers.FolderViewerPresenter;
@@ -32,7 +32,7 @@
public class BlogsParts {
@Inject
- public BlogsParts(final Session session, final Provider<BlogsClientTool> clientTool,
+ public BlogsParts(final SessionConstants session, final Provider<BlogsClientTool> clientTool,
final ContentViewerSelector viewerSelector, final BlogsClientActions blogsActions,
final ContentViewerPresenter contentViewer, final FolderViewerPresenter folderViewer) {
clientTool.get();
Modified: trunk/src/main/java/cc/kune/chat/client/actions/ChatSitebarActions.java
===================================================================
--- trunk/src/main/java/cc/kune/chat/client/actions/ChatSitebarActions.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/chat/client/actions/ChatSitebarActions.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -37,7 +37,7 @@
import cc.kune.core.client.events.WindowFocusEvent;
import cc.kune.core.client.sitebar.SiteUserOptions;
import cc.kune.core.client.sitebar.SiteUserOptionsPresenter;
-import cc.kune.core.client.state.Session;
+import cc.kune.core.shared.SessionConstants;
import com.calclab.emite.core.client.events.StateChangedEvent;
import com.calclab.emite.core.client.events.StateChangedHandler;
@@ -124,7 +124,7 @@
private final XmppSession xmppSession;
@Inject
- public ChatSitebarActions(final Session session, final ChatClient chatClient,
+ public ChatSitebarActions(final SessionConstants session, final ChatClient chatClient,
final SiteUserOptions userOptions, final I18nTranslationService i18n, final ChatResources res,
final ChatInstances chatInstances, final EventBus eventBus) {
this.chatClient = chatClient;
Modified: trunk/src/main/java/cc/kune/chat/client/actions/OpenChatAction.java
===================================================================
--- trunk/src/main/java/cc/kune/chat/client/actions/OpenChatAction.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/chat/client/actions/OpenChatAction.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -67,7 +67,7 @@
} else {
signIn.get().setErrorMessage(i18n.t("Sign in or create an account to access to this room"),
NotifyLevel.info);
- stateManager.gotoHistoryToken(TokenUtils.addRedirect(SiteTokens.SIGNIN,
+ stateManager.gotoHistoryToken(TokenUtils.addRedirect(SiteTokens.SIGN_IN,
session.getCurrentStateToken().toString()));
}
}
Modified: trunk/src/main/java/cc/kune/core/KuneCore.gwt.xml
===================================================================
--- trunk/src/main/java/cc/kune/core/KuneCore.gwt.xml 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/KuneCore.gwt.xml 2012-01-16 20:53:44 UTC (rev 1663)
@@ -6,7 +6,7 @@
see http://code.google.com/p/google-web-toolkit/issues/detail?id=4454 -->
<source path='client'
excludes="**/*Test.java,**/*Tests.java,**/*MockProvider.java"/>
- <source path="shared"/>
+ <source path="shared" excludes="**/*Test.java,**/*Tests.java,**/*MockProvider.java"/>
<public path="public"/>
<!-- Dependencies ============================================= -->
<inherits name="com.google.gwt.user.User"/>
Modified: trunk/src/main/java/cc/kune/core/client/CoreParts.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/CoreParts.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/client/CoreParts.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -27,6 +27,7 @@
import cc.kune.core.client.groups.newgroup.NewGroup;
import cc.kune.core.client.sitebar.AboutKuneDialog;
import cc.kune.core.client.sitebar.SiteUserOptionsPresenter;
+import cc.kune.core.client.sitebar.auth.VerifyEmailClientManager;
import cc.kune.core.client.sitebar.spaces.Space;
import cc.kune.core.client.sitebar.spaces.SpaceSelectEvent;
import cc.kune.core.client.sitebar.spaces.SpaceSelectorPresenter;
@@ -34,11 +35,14 @@
import cc.kune.core.client.sn.UserSNPresenter;
import cc.kune.core.client.sn.actions.registry.GroupSNConfActions;
import cc.kune.core.client.sn.actions.registry.UserSNConfActions;
-import cc.kune.core.client.state.HistoryTokenCallback;
+import cc.kune.core.client.state.HistoryTokenAuthNotNeededCallback;
+import cc.kune.core.client.state.HistoryTokenMustBeAuthCallback;
import cc.kune.core.client.state.Session;
import cc.kune.core.client.state.SiteTokenListeners;
import cc.kune.core.client.state.SiteTokens;
import cc.kune.core.client.sub.SubtitlesManager;
+import cc.kune.gspace.client.options.GroupOptions;
+import cc.kune.gspace.client.options.UserOptions;
import com.google.gwt.event.shared.EventBus;
import com.google.inject.Inject;
@@ -55,7 +59,9 @@
final Provider<SpaceSelectorPresenter> spaceSelector, final SiteTokenListeners tokenListener,
final Provider<SignIn> signIn, final Provider<Register> register,
final Provider<AboutKuneDialog> aboutKuneDialog, final Provider<NewGroup> newGroup,
- final Provider<SubtitlesManager> subProvider, final EventBus eventBus) {
+ final Provider<SubtitlesManager> subProvider, final EventBus eventBus,
+ final Provider<VerifyEmailClientManager> verifyManager,
+ final Provider<UserOptions> userOptionsDialog, final Provider<GroupOptions> groupOptionsDialog) {
session.onAppStart(true, new AppStartHandler() {
@Override
public void onAppStart(final AppStartEvent event) {
@@ -68,48 +74,63 @@
spaceSelector.get();
}
});
- tokenListener.put(SiteTokens.SIGNIN, new HistoryTokenCallback() {
+ tokenListener.put(SiteTokens.SIGN_IN, new HistoryTokenAuthNotNeededCallback() {
@Override
public void onHistoryToken(final String token) {
signIn.get().showSignInDialog();
}
});
- tokenListener.put(SiteTokens.ABOUTKUNE, new HistoryTokenCallback() {
+ tokenListener.put(SiteTokens.ABOUT_KUNE, new HistoryTokenAuthNotNeededCallback() {
@Override
public void onHistoryToken(final String token) {
// FIXME, something to come back
aboutKuneDialog.get().showCentered();
}
});
- tokenListener.put(SiteTokens.REGISTER, new HistoryTokenCallback() {
+ tokenListener.put(SiteTokens.REGISTER, new HistoryTokenAuthNotNeededCallback() {
@Override
public void onHistoryToken(final String token) {
register.get().doRegister();
}
});
- tokenListener.put(SiteTokens.NEWGROUP, new HistoryTokenCallback() {
+ tokenListener.put(SiteTokens.NEW_GROUP, new HistoryTokenMustBeAuthCallback() {
@Override
public void onHistoryToken(final String token) {
newGroup.get().doNewGroup();
}
});
- tokenListener.put(SiteTokens.SUBTITLES, new HistoryTokenCallback() {
+ tokenListener.put(SiteTokens.SUBTITLES, new HistoryTokenAuthNotNeededCallback() {
@Override
public void onHistoryToken(final String token) {
subProvider.get().show(token);
}
});
- tokenListener.put(SiteTokens.HOME, new HistoryTokenCallback() {
+ tokenListener.put(SiteTokens.HOME, new HistoryTokenAuthNotNeededCallback() {
@Override
public void onHistoryToken(final String token) {
SpaceSelectEvent.fire(eventBus, Space.homeSpace);
}
});
- tokenListener.put(SiteTokens.WAVEINBOX, new HistoryTokenCallback() {
+ tokenListener.put(SiteTokens.WAVE_INBOX, new HistoryTokenMustBeAuthCallback() {
@Override
public void onHistoryToken(final String token) {
SpaceSelectEvent.fire(eventBus, Space.userSpace);
}
});
+ tokenListener.put(SiteTokens.PREFS, new HistoryTokenMustBeAuthCallback() {
+ @Override
+ public void onHistoryToken(final String token) {
+ SpaceSelectEvent.fire(eventBus, Space.groupSpace);
+ userOptionsDialog.get().show();
+ }
+ });
+ tokenListener.put(SiteTokens.GROUP_PREFS, new HistoryTokenMustBeAuthCallback() {
+ @Override
+ public void onHistoryToken(final String token) {
+ groupOptionsDialog.get().show(token);
+ }
+ });
+
+ verifyManager.get();
}
}
Modified: trunk/src/main/java/cc/kune/core/client/auth/AnonUsersManager.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/auth/AnonUsersManager.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/client/auth/AnonUsersManager.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -52,7 +52,7 @@
cookiesManager.setAnonCookie(false);
final String register = TextUtils.generateHtmlLink("#" + SiteTokens.REGISTER,
i18n.tWithNT("register", "register, in lowercase"), false);
- final String signin = TextUtils.generateHtmlLink("#" + SiteTokens.SIGNIN,
+ final String signin = TextUtils.generateHtmlLink("#" + SiteTokens.SIGN_IN,
i18n.tWithNT("sign in", "register, in lowercase"), false);
final String siteCommonName = i18n.getSiteCommonName();
notifyMsg = UserNotifyEvent.fire(
Modified: trunk/src/main/java/cc/kune/core/client/auth/RegisterForm.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/auth/RegisterForm.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/client/auth/RegisterForm.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -20,8 +20,8 @@
package cc.kune.core.client.auth;
import cc.kune.common.shared.i18n.I18nTranslationService;
-import cc.kune.core.client.state.Session;
import cc.kune.core.client.ui.DefaultForm;
+import cc.kune.core.shared.SessionConstants;
import com.extjs.gxt.ui.client.widget.form.Field;
import com.extjs.gxt.ui.client.widget.form.TextField;
@@ -46,7 +46,7 @@
private final TextField<String> shortNameRegField;
- public RegisterForm(final I18nTranslationService i18n, final Session session,
+ public RegisterForm(final I18nTranslationService i18n, final SessionConstants session,
final UserFieldFactory userFieldFactory) {
super.addStyleName("kune-Margin-Large-l");
Modified: trunk/src/main/java/cc/kune/core/client/auth/RegisterPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/auth/RegisterPanel.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/client/auth/RegisterPanel.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -25,8 +25,8 @@
import cc.kune.common.shared.i18n.I18nTranslationService;
import cc.kune.core.client.auth.RegisterPresenter.RegisterView;
import cc.kune.core.client.resources.CoreMessages;
-import cc.kune.core.client.state.Session;
import cc.kune.core.client.ui.KuneUiUtils;
+import cc.kune.core.shared.SessionConstants;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
@@ -46,7 +46,7 @@
private final RegisterForm registerForm;
@Inject
- public RegisterPanel(final I18nTranslationService i18n, final Session session,
+ public RegisterPanel(final I18nTranslationService i18n, final SessionConstants session,
final MaskWidgetView mask, final NotifyLevelImages images, final UserFieldFactory userFieldFactory) {
super(REGISTER_DIALOG, mask, i18n, i18n.t(CoreMessages.REGISTER_TITLE), true, true, true, "",
i18n.t(CoreMessages.REGISTER_TITLE), REGISTER_BUTTON_ID,
Modified: trunk/src/main/java/cc/kune/core/client/cookies/CookiesManagerImpl.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/cookies/CookiesManagerImpl.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/client/cookies/CookiesManagerImpl.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -22,7 +22,7 @@
import java.util.Date;
import cc.kune.common.client.log.Log;
-import cc.kune.core.client.state.Session;
+import cc.kune.core.shared.SessionConstants;
import com.google.gwt.user.client.Cookies;
@@ -40,7 +40,7 @@
@Override
public String getAuthCookie() {
- return Cookies.getCookie(Session.USERHASH);
+ return Cookies.getCookie(SessionConstants.USERHASH);
}
@Override
@@ -55,23 +55,23 @@
// issue:
// http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/ded8…
// http://code.google.com/p/google-web-toolkit/issues/detail?id=1735&q=removeC…
- Cookies.removeCookie(Session.USERHASH);
+ Cookies.removeCookie(SessionConstants.USERHASH);
// Workaround:
- Cookies.setCookie(Session.USERHASH, null, new Date(0), null, "/", false);
+ Cookies.setCookie(SessionConstants.USERHASH, null, new Date(0), null, "/", false);
}
@Override
public void setAnonCookie(final Boolean userRegister) {
final Date expires = new Date(System.currentTimeMillis()
- + (userRegister ? Session.ANON_SESSION_DURATION_AFTER_REG : Session.ANON_SESSION_DURATION));
+ + (userRegister ? SessionConstants.ANON_SESSION_DURATION_AFTER_REG : SessionConstants.ANON_SESSION_DURATION));
Cookies.setCookie(ANON, userRegister.toString(), expires, null, "/", false);
}
@Override
public void setAuthCookie(final String userHash) {
// http://code.google.com/p/google-web-toolkit-incubator/wiki/LoginSecurityFAQ
- final Date expires = new Date(System.currentTimeMillis() + Session.SESSION_DURATION);
- Cookies.setCookie(Session.USERHASH, userHash, expires, null, "/", false);
+ final Date expires = new Date(System.currentTimeMillis() + SessionConstants.SESSION_DURATION);
+ Cookies.setCookie(SessionConstants.USERHASH, userHash, expires, null, "/", false);
Log.info("Received hash: " + userHash, null);
}
}
Added: trunk/src/main/java/cc/kune/core/client/errors/EmailHashExpiredException.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/errors/EmailHashExpiredException.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/client/errors/EmailHashExpiredException.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -0,0 +1,24 @@
+/*
+ *
+ * Copyright (C) 2007-2011 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package cc.kune.core.client.errors;
+
+public class EmailHashExpiredException extends DefaultException {
+ private static final long serialVersionUID = 576604826176441925L;
+}
Added: trunk/src/main/java/cc/kune/core/client/errors/EmailHashInvalidException.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/errors/EmailHashInvalidException.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/client/errors/EmailHashInvalidException.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -0,0 +1,26 @@
+/*
+ *
+ * Copyright (C) 2007-2011 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package cc.kune.core.client.errors;
+
+public class EmailHashInvalidException extends DefaultException {
+
+ private static final long serialVersionUID = 7285974904505390494L;
+
+}
Added: trunk/src/main/java/cc/kune/core/client/errors/EmailNotFoundException.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/errors/EmailNotFoundException.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/client/errors/EmailNotFoundException.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -0,0 +1,24 @@
+/*
+ *
+ * Copyright (C) 2007-2011 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package cc.kune.core.client.errors;
+
+public class EmailNotFoundException extends DefaultException {
+ private static final long serialVersionUID = 576604826176441925L;
+}
Modified: trunk/src/main/java/cc/kune/core/client/errors/ErrorHandler.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/errors/ErrorHandler.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/client/errors/ErrorHandler.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -118,6 +118,15 @@
logException(caught);
eventBus.fireEvent(new UserNotifyEvent(NotifyLevel.error,
i18n.t("This user is already a group member")));
+ } else if (caught instanceof EmailHashInvalidException) {
+ logException(caught);
+ eventBus.fireEvent(new UserNotifyEvent(NotifyLevel.error,
+ i18n.t("This confirmation email is invalid")));
+ } else if (caught instanceof EmailHashExpiredException) {
+ logException(caught);
+ eventBus.fireEvent(new UserNotifyEvent(
+ NotifyLevel.error,
+ i18n.t("This email verification is expired. In your preferences, resend you the confirmation email")));
} else if (caught instanceof MoveOnSameContainerException) {
logException(caught);
eventBus.fireEvent(new UserNotifyEvent(NotifyLevel.info,
Modified: trunk/src/main/java/cc/kune/core/client/rpcservices/UserService.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/rpcservices/UserService.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/client/rpcservices/UserService.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -34,8 +34,12 @@
@RemoteServiceRelativePath("UserService")
public interface UserService extends RemoteService {
- void changePasswd(String userHash, String oldPassword, String newPassword) throws DefaultException;;
+ void askForEmailConfirmation(String userHash);;
+ void askForEmailForgot(String email);
+
+ void changePasswd(String userHash, String oldPassword, String newPassword) throws DefaultException;
+
void createUser(UserDTO user, boolean wantPersonalHomepage) throws DefaultException;
String getUserAvatarBaser64(String userHash, StateToken userToken) throws DefaultException;
@@ -54,4 +58,6 @@
StateAbstractDTO updateUser(String userHash, UserDTO user, I18nLanguageSimpleDTO lang);
+ void verifyPasswordHash(String userHash, String emailReceivedHash);
+
}
Modified: trunk/src/main/java/cc/kune/core/client/rpcservices/UserServiceAsync.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/rpcservices/UserServiceAsync.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/client/rpcservices/UserServiceAsync.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -31,6 +31,10 @@
public interface UserServiceAsync {
+ void askForEmailConfirmation(String userHash, AsyncCallback<Void> callback);
+
+ void askForEmailForgot(String email, AsyncCallback<Void> callback);
+
void changePasswd(String userHash, String oldPassword, String newPassword, AsyncCallback<Void> callback);
void createUser(UserDTO user, boolean wantPersonalHomepage, AsyncCallback<Void> asyncCallback);
@@ -53,4 +57,6 @@
void updateUser(String userHash, UserDTO user, I18nLanguageSimpleDTO lang,
AsyncCallback<StateAbstractDTO> callback);
+
+ void verifyPasswordHash(String userHash, String emailReceivedHash, AsyncCallback<Void> asyncCallback);
}
Modified: trunk/src/main/java/cc/kune/core/client/sitebar/SitebarNewGroupLink.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sitebar/SitebarNewGroupLink.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/client/sitebar/SitebarNewGroupLink.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -46,7 +46,7 @@
@Override
public void actionPerformed(final ActionEvent event) {
- stateManager.gotoHistoryToken(SiteTokens.NEWGROUP);
+ stateManager.gotoHistoryToken(SiteTokens.NEW_GROUP);
}
}
Modified: trunk/src/main/java/cc/kune/core/client/sitebar/SitebarSignInLink.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sitebar/SitebarSignInLink.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/client/sitebar/SitebarSignInLink.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -31,6 +31,7 @@
import cc.kune.core.client.state.Session;
import cc.kune.core.client.state.SiteTokens;
import cc.kune.core.client.state.StateManager;
+import cc.kune.core.shared.SessionConstants;
import com.google.gwt.event.shared.EventBus;
import com.google.inject.Inject;
@@ -43,7 +44,7 @@
@Inject
public SitebarSignInAction(final StateManager stateManager, final I18nUITranslationService i18n,
- final Session session) {
+ final SessionConstants session) {
super();
this.stateManager = stateManager;
putValue(Action.NAME, i18n.t("Sign in to collaborate"));
@@ -55,7 +56,7 @@
@Override
public void actionPerformed(final ActionEvent event) {
- stateManager.gotoHistoryTokenButRedirectToCurrent(SiteTokens.SIGNIN);
+ stateManager.gotoHistoryTokenButRedirectToCurrent(SiteTokens.SIGN_IN);
}
}
Added: trunk/src/main/java/cc/kune/core/client/sitebar/auth/VerifyEmailClientManager.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sitebar/auth/VerifyEmailClientManager.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/client/sitebar/auth/VerifyEmailClientManager.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -0,0 +1,40 @@
+package cc.kune.core.client.sitebar.auth;
+
+import cc.kune.common.client.notify.NotifyUser;
+import cc.kune.common.shared.i18n.I18nTranslationService;
+import cc.kune.core.client.rpcservices.AsyncCallbackSimple;
+import cc.kune.core.client.rpcservices.UserServiceAsync;
+import cc.kune.core.client.state.HistoryTokenMustBeAuthCallback;
+import cc.kune.core.client.state.Session;
+import cc.kune.core.client.state.SiteTokenListeners;
+import cc.kune.core.client.state.SiteTokens;
+import cc.kune.gspace.client.options.general.UserOptGeneral;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.google.inject.Singleton;
+
+@Singleton
+public class VerifyEmailClientManager {
+
+ @Inject
+ VerifyEmailClientManager(final Session session, final SiteTokenListeners tokens,
+ final Provider<UserOptGeneral> optGeneral, final I18nTranslationService i18n,
+ final Provider<UserServiceAsync> userService) {
+ tokens.put(SiteTokens.VERIFY_EMAIL, new HistoryTokenMustBeAuthCallback() {
+ @Override
+ public void onHistoryToken(final String token) {
+ userService.get().verifyPasswordHash(session.getUserHash(), token,
+ new AsyncCallbackSimple<Void>() {
+ @Override
+ public void onSuccess(final Void result) {
+ NotifyUser.info("Great. Your email is now verified.");
+ session.getCurrentUser().setEmailVerified(true);
+ optGeneral.get().update();
+ }
+ });
+ }
+ });
+
+ }
+}
Modified: trunk/src/main/java/cc/kune/core/client/sitebar/search/SitebarSearchPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sitebar/search/SitebarSearchPanel.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/client/sitebar/search/SitebarSearchPanel.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -22,8 +22,8 @@
import cc.kune.core.client.i18n.I18nUITranslationService;
import cc.kune.core.client.resources.CoreResources;
import cc.kune.core.client.sitebar.search.SitebarSearchPresenter.SitebarSearchView;
-import cc.kune.core.client.state.Session;
import cc.kune.core.client.state.StateManager;
+import cc.kune.core.shared.SessionConstants;
import cc.kune.gspace.client.armor.GSpaceArmor;
import com.google.gwt.event.dom.client.HasAllFocusHandlers;
@@ -49,7 +49,7 @@
private final SuggestBox suggestBox;
@Inject
- public SitebarSearchPanel(final GSpaceArmor gs, final CoreResources img, final Session session,
+ public SitebarSearchPanel(final GSpaceArmor gs, final CoreResources img, final SessionConstants session,
final StateManager stateManager, final I18nUITranslationService i18n) {
searchButton = new PushButton(new Image(img.kuneSearchIco()), new Image(img.kuneSearchIcoPush()));
searchButton.ensureDebugId(SITE_SEARCH_BUTTON);
Modified: trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorPanel.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorPanel.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -23,7 +23,7 @@
import cc.kune.common.client.ui.BlinkAnimation;
import cc.kune.core.client.i18n.I18nUITranslationService;
import cc.kune.core.client.sitebar.spaces.SpaceSelectorPresenter.SpaceSelectorView;
-import cc.kune.core.client.state.Session;
+import cc.kune.core.shared.SessionConstants;
import cc.kune.gspace.client.armor.GSpaceArmor;
import cc.kune.gspace.client.armor.resources.GSpaceArmorResources;
@@ -60,7 +60,7 @@
@Inject
public SpaceSelectorPanel(final GSpaceArmor armor, final I18nUITranslationService i18n,
- final GSpaceArmorResources res, final Session session) {
+ final GSpaceArmorResources res, final SessionConstants session) {
armor.getSitebar().insert(uiBinder.createAndBindUi(this), 0);
// homeButton.setVisible(false);
final String siteCommonName = i18n.getSiteCommonName();
Modified: trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorPresenter.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/client/sitebar/spaces/SpaceSelectorPresenter.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -124,7 +124,7 @@
this.i18n = i18n;
currentSpace = null;
homeToken = SiteTokens.HOME;
- inboxToken = SiteTokens.WAVEINBOX;
+ inboxToken = SiteTokens.WAVE_INBOX;
groupToken = SiteTokens.GROUP_HOME;
publicToken = TokenUtils.preview(SiteTokens.GROUP_HOME);
view.getHomeBtn().addClickHandler(new ClickHandler() {
@@ -254,7 +254,7 @@
if (currentSpace == Space.userSpace) {
restoreToken(homeToken);
}
- inboxToken = SiteTokens.WAVEINBOX;
+ inboxToken = SiteTokens.WAVE_INBOX;
}
private void onUserSpaceSelect(final boolean shouldRestoreToken) {
@@ -268,7 +268,7 @@
} else {
signIn.get().setErrorMessage(i18n.t("Sign in or create an account to access to your inbox"),
NotifyLevel.info);
- stateManager.gotoHistoryToken(TokenUtils.addRedirect(SiteTokens.SIGNIN, inboxToken));
+ stateManager.gotoHistoryToken(TokenUtils.addRedirect(SiteTokens.SIGN_IN, inboxToken));
getView().setUserBtnDown(false);
}
}
Modified: trunk/src/main/java/cc/kune/core/client/sn/actions/JoinGroupAction.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sn/actions/JoinGroupAction.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/client/sn/actions/JoinGroupAction.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -98,7 +98,7 @@
} else {
signIn.get().setErrorMessage(i18n.t("Sign in or create an account to participate in this group"),
NotifyLevel.info);
- stateManager.gotoHistoryToken(TokenUtils.addRedirect(SiteTokens.SIGNIN,
+ stateManager.gotoHistoryToken(TokenUtils.addRedirect(SiteTokens.SIGN_IN,
session.getCurrentStateToken().toString()));
}
Modified: trunk/src/main/java/cc/kune/core/client/sn/actions/SessionAction.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sn/actions/SessionAction.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/client/sn/actions/SessionAction.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -28,33 +28,33 @@
import com.google.inject.Inject;
public abstract class SessionAction extends AbstractExtendedAction {
- protected final Session session;
+ protected final Session session;
- @Inject
- public SessionAction(final Session session, final boolean authNeed) {
- this.session = session;
- session.onUserSignInOrSignOut(true, new UserSignInOrSignOutHandler() {
- @Override
- public void onUserSignInOrSignOut(final UserSignInOrSignOutEvent event) {
- refreshStatus(authNeed, event.isLogged());
- }
- });
- }
+ @Inject
+ public SessionAction(final Session session, final boolean authNeed) {
+ this.session = session;
+ session.onUserSignInOrSignOut(true, new UserSignInOrSignOutHandler() {
+ @Override
+ public void onUserSignInOrSignOut(final UserSignInOrSignOutEvent event) {
+ refreshStatus(authNeed, event.isLogged());
+ }
+ });
+ }
- public void refreshStatus(final boolean authNeed, final boolean isLogged) {
- boolean visible = false;
- final boolean noLogged = !isLogged;
- if (authNeed && noLogged) {
- visible = false;
- } else {
- // Auth ok
- visible = true;
- }
- setVisible(visible);
+ public void refreshStatus(final boolean authNeed, final boolean isLogged) {
+ boolean visible = false;
+ final boolean noLogged = !isLogged;
+ if (authNeed && noLogged) {
+ visible = false;
+ } else {
+ // Auth ok
+ visible = true;
}
+ setVisible(visible);
+ }
- public void setVisible(final boolean visible) {
- setEnabled(visible);
- putValue(GuiActionDescrip.VISIBLE, visible);
- }
+ public void setVisible(final boolean visible) {
+ setEnabled(visible);
+ putValue(GuiActionDescrip.VISIBLE, visible);
+ }
}
Modified: trunk/src/main/java/cc/kune/core/client/sn/actions/registry/GroupSNAdminsMenuItemsRegistry.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sn/actions/registry/GroupSNAdminsMenuItemsRegistry.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/client/sn/actions/registry/GroupSNAdminsMenuItemsRegistry.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -37,7 +37,7 @@
import cc.kune.core.client.sn.actions.conditions.IsMeCondition;
import cc.kune.core.client.sn.actions.conditions.IsNotMeCondition;
import cc.kune.core.client.sn.actions.conditions.IsPersonCondition;
-import cc.kune.core.client.state.Session;
+import cc.kune.core.shared.SessionConstants;
import com.google.inject.Inject;
import com.google.inject.Provider;
@@ -45,7 +45,7 @@
public class GroupSNAdminsMenuItemsRegistry extends AbstractSNMembersActionsRegistry {
@Inject
- public GroupSNAdminsMenuItemsRegistry(final Session session, final I18nTranslationService i18n,
+ public GroupSNAdminsMenuItemsRegistry(final SessionConstants session, final I18nTranslationService i18n,
final IsLoggedCondition isLogged, final IsCurrentStateAdministrableCondition isAdministrable,
final IsPersonCondition isPerson, final IsGroupCondition isGroup,
final IsBuddieCondition isBuddie, final IsMeCondition isMe, final IsNotMeCondition isNotMe,
Modified: trunk/src/main/java/cc/kune/core/client/sn/actions/registry/GroupSNCollabsMenuItemsRegistry.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sn/actions/registry/GroupSNCollabsMenuItemsRegistry.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/client/sn/actions/registry/GroupSNCollabsMenuItemsRegistry.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -37,7 +37,7 @@
import cc.kune.core.client.sn.actions.conditions.IsMeCondition;
import cc.kune.core.client.sn.actions.conditions.IsNotMeCondition;
import cc.kune.core.client.sn.actions.conditions.IsPersonCondition;
-import cc.kune.core.client.state.Session;
+import cc.kune.core.shared.SessionConstants;
import com.google.inject.Inject;
import com.google.inject.Provider;
@@ -45,7 +45,7 @@
public class GroupSNCollabsMenuItemsRegistry extends AbstractSNMembersActionsRegistry {
@Inject
- public GroupSNCollabsMenuItemsRegistry(final Session session, final I18nTranslationService i18n,
+ public GroupSNCollabsMenuItemsRegistry(final SessionConstants session, final I18nTranslationService i18n,
final IsLoggedCondition isLogged,
final IsCurrentStateAdministrableCondition isAdministrableCondition,
final IsPersonCondition isPersonCondition, final IsGroupCondition isGroupCondition,
Modified: trunk/src/main/java/cc/kune/core/client/sn/actions/registry/GroupSNConfActions.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sn/actions/registry/GroupSNConfActions.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/client/sn/actions/registry/GroupSNConfActions.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -41,8 +41,8 @@
import cc.kune.core.client.sn.actions.WriteToMembers;
import cc.kune.core.client.sn.actions.conditions.IsGroupCondition;
import cc.kune.core.client.sn.actions.conditions.IsLoggedCondition;
-import cc.kune.core.client.state.Session;
import cc.kune.core.client.state.StateManager;
+import cc.kune.core.shared.SessionConstants;
import cc.kune.core.shared.domain.AdmissionType;
import cc.kune.core.shared.domain.SocialNetworkVisibility;
import cc.kune.core.shared.dto.GroupDTO;
@@ -64,7 +64,7 @@
public static final String OPTIONS_STYLES = "k-sn-options-menu, k-noborder, k-nobackcolor, k-no-backimage, k-btn-min";
@Inject
- public GroupSNConfActions(final Session session, final StateManager stateManager,
+ public GroupSNConfActions(final SessionConstants session, final StateManager stateManager,
final I18nTranslationService i18n, final Provider<MembersVisibilityMenuItem> membersVisibility,
final Provider<MembersModerationMenuItem> membersModeration, final CoreResources res,
final IsLoggedCondition isLoggedCondition, final JoinGroupAction joinGroupAction,
Modified: trunk/src/main/java/cc/kune/core/client/sn/actions/registry/GroupSNPendingsMenuItemsRegistry.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sn/actions/registry/GroupSNPendingsMenuItemsRegistry.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/client/sn/actions/registry/GroupSNPendingsMenuItemsRegistry.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -30,7 +30,7 @@
import cc.kune.core.client.sn.actions.conditions.IsCurrentStateAdministrableCondition;
import cc.kune.core.client.sn.actions.conditions.IsGroupCondition;
import cc.kune.core.client.sn.actions.conditions.IsPersonCondition;
-import cc.kune.core.client.state.Session;
+import cc.kune.core.shared.SessionConstants;
import com.google.inject.Inject;
import com.google.inject.Provider;
@@ -38,7 +38,7 @@
public class GroupSNPendingsMenuItemsRegistry extends AbstractSNMembersActionsRegistry {
@Inject
- public GroupSNPendingsMenuItemsRegistry(final Session session, final IsCurrentStateAdministrableCondition isAdministrableCondition,
+ public GroupSNPendingsMenuItemsRegistry(final SessionConstants session, final IsCurrentStateAdministrableCondition isAdministrableCondition,
final IsPersonCondition isPersonCondition, final IsGroupCondition isGroupCondition,
final ChangeToCollabAction changeToCollabAction, final ChangeToAdminAction changeToAdminAction,
final RemoveMemberAction removeMemberAction, final AcceptJoinGroupAction acceptJoinGroupAction,
Modified: trunk/src/main/java/cc/kune/core/client/sn/actions/registry/UserSNMenuItemsRegistry.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/sn/actions/registry/UserSNMenuItemsRegistry.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/client/sn/actions/registry/UserSNMenuItemsRegistry.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -39,7 +39,7 @@
import cc.kune.core.client.sn.actions.conditions.IsMeCondition;
import cc.kune.core.client.sn.actions.conditions.IsNotMeCondition;
import cc.kune.core.client.sn.actions.conditions.IsPersonCondition;
-import cc.kune.core.client.state.Session;
+import cc.kune.core.shared.SessionConstants;
import com.google.inject.Inject;
import com.google.inject.Provider;
@@ -48,7 +48,7 @@
public class UserSNMenuItemsRegistry extends AbstractSNMembersActionsRegistry {
@Inject
- public UserSNMenuItemsRegistry(final Session session, final I18nTranslationService i18n,
+ public UserSNMenuItemsRegistry(final SessionConstants session, final I18nTranslationService i18n,
final IsCurrentStateAdministrableCondition isAdministrableCondition,
final IsPersonCondition isPerson, final IsGroupCondition isGroup,
final ImPartOfGroupCondition imPartOfGroup, final IsLoggedCondition isLogged,
Added: trunk/src/main/java/cc/kune/core/client/state/HistoryTokenAuthNotNeededCallback.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/state/HistoryTokenAuthNotNeededCallback.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/client/state/HistoryTokenAuthNotNeededCallback.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -0,0 +1,18 @@
+package cc.kune.core.client.state;
+
+/**
+ * The Class HistoryTokenNotLoggedCallback is used to indicate the action
+ * related to this token (like #about, etc) should not be authenticated.
+ */
+public abstract class HistoryTokenAuthNotNeededCallback implements HistoryTokenCallback {
+
+ /* (non-Javadoc)
+ * @see cc.kune.core.client.state.HistoryTokenCallback#authMandatory()
+ */
+ @Override
+ public boolean authMandatory() {
+ return false;
+
+ }
+
+}
Modified: trunk/src/main/java/cc/kune/core/client/state/HistoryTokenCallback.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/state/HistoryTokenCallback.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/client/state/HistoryTokenCallback.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -19,8 +19,25 @@
*/
package cc.kune.core.client.state;
+/**
+ * The Interface HistoryTokenCallback is used make relations between browser
+ * hashs like #inbox #signin etc, with its actions
+ */
public interface HistoryTokenCallback {
+ /**
+ * Auth The user should be logged (mandatory).
+ *
+ * @return true, if yes
+ */
+ boolean authMandatory();
+
+ /**
+ * On history token do some action (Example #inbox, #newgroup)
+ *
+ * @param token
+ * the token
+ */
void onHistoryToken(String token);
}
Added: trunk/src/main/java/cc/kune/core/client/state/HistoryTokenMustBeAuthCallback.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/state/HistoryTokenMustBeAuthCallback.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/client/state/HistoryTokenMustBeAuthCallback.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -0,0 +1,19 @@
+package cc.kune.core.client.state;
+
+/**
+ * The Class HistoryTokenMustBeAuthCallback is used to indicate the action
+ * related to this token (like #inbox, etc) should be authenticated.
+ */
+public abstract class HistoryTokenMustBeAuthCallback implements HistoryTokenCallback {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see cc.kune.core.client.state.HistoryTokenCallback#authMandatory()
+ */
+ @Override
+ public boolean authMandatory() {
+ return true;
+ }
+
+}
Modified: trunk/src/main/java/cc/kune/core/client/state/Session.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/state/Session.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/client/state/Session.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -61,14 +61,6 @@
public interface Session {
- long A_DAY = 1000 * 60 * 60 * 24;
- long ANON_SESSION_DURATION = A_DAY;
- long ANON_SESSION_DURATION_AFTER_REG = A_DAY * 365;
- long SESSION_DURATION = A_DAY * 14; // two weeks login session duration
- // long SESSION_DURATION = 100; // For test
-
- String USERHASH = "k007userHash";
-
void check(AsyncCallbackSimple<Void> callback);
StateContainerDTO getContainerState();
Modified: trunk/src/main/java/cc/kune/core/client/state/SiteTokens.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/state/SiteTokens.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/client/state/SiteTokens.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -24,32 +24,40 @@
import com.google.inject.Inject;
/**
- * Some common history tokens like {@link #SIGNIN} and {@link #NEWGROUP}
+ * Some common history tokens like {@link #SIGN_IN} and {@link #NEW_GROUP}
*
*/
public final class SiteTokens {
- public static final String ABOUTKUNE = "about";
+ public static final String ABOUT_KUNE = "about";
public final static String GROUP_HOME = "";
+ public final static String GROUP_PREFS = "gprefs";
public final static String HOME = "";
- public final static String NEWGROUP = "newgroup";
+ public final static String NEW_GROUP = "newgroup";
+ public final static String PREFS = "prefs";
public static final String PREVIEW = "preview";
public final static String REGISTER = "register";
- public final static String SIGNIN = "signin";
+ public final static String RESET_PWD = "resetpasswd";
+ public final static String SIGN_IN = "signin";
public final static String SUBTITLES = "sub";
public final static String TRANSLATE = "translate";
- public final static String WAVEINBOX = "inbox";
+ public final static String VERIFY_EMAIL = "verifyemail";
+ public final static String WAVE_INBOX = "inbox";
@Inject
public SiteTokens(final ReservedWordsRegistryDTO reserverdWords) {
- reserverdWords.add(ABOUTKUNE);
+ reserverdWords.add(ABOUT_KUNE);
reserverdWords.add(GROUP_HOME);
reserverdWords.add(HOME);
- reserverdWords.add(NEWGROUP);
+ reserverdWords.add(NEW_GROUP);
reserverdWords.add(PREVIEW);
reserverdWords.add(REGISTER);
- reserverdWords.add(SIGNIN);
+ reserverdWords.add(SIGN_IN);
reserverdWords.add(TRANSLATE);
- reserverdWords.add(WAVEINBOX);
+ reserverdWords.add(WAVE_INBOX);
reserverdWords.add(SUBTITLES);
+ reserverdWords.add(PREFS);
+ reserverdWords.add(GROUP_PREFS);
+ reserverdWords.add(VERIFY_EMAIL);
+ reserverdWords.add(RESET_PWD);
}
}
Modified: trunk/src/main/java/cc/kune/core/client/state/impl/StateManagerDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/state/impl/StateManagerDefault.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/client/state/impl/StateManagerDefault.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -31,18 +31,18 @@
import cc.kune.common.client.notify.ProgressHideEvent;
import cc.kune.common.client.utils.Pair;
import cc.kune.core.client.events.AppStartEvent;
+import cc.kune.core.client.events.AppStartEvent.AppStartHandler;
import cc.kune.core.client.events.GoHomeEvent;
import cc.kune.core.client.events.GroupChangedEvent;
+import cc.kune.core.client.events.GroupChangedEvent.GroupChangedHandler;
import cc.kune.core.client.events.SocialNetworkChangedEvent;
+import cc.kune.core.client.events.SocialNetworkChangedEvent.SocialNetworkChangedHandler;
import cc.kune.core.client.events.StateChangedEvent;
+import cc.kune.core.client.events.StateChangedEvent.StateChangedHandler;
import cc.kune.core.client.events.ToolChangedEvent;
+import cc.kune.core.client.events.ToolChangedEvent.ToolChangedHandler;
import cc.kune.core.client.events.UserSignInEvent;
import cc.kune.core.client.events.UserSignOutEvent;
-import cc.kune.core.client.events.AppStartEvent.AppStartHandler;
-import cc.kune.core.client.events.GroupChangedEvent.GroupChangedHandler;
-import cc.kune.core.client.events.SocialNetworkChangedEvent.SocialNetworkChangedHandler;
-import cc.kune.core.client.events.StateChangedEvent.StateChangedHandler;
-import cc.kune.core.client.events.ToolChangedEvent.ToolChangedHandler;
import cc.kune.core.client.rpcservices.AsyncCallbackSimple;
import cc.kune.core.client.sitebar.spaces.Space;
import cc.kune.core.client.sitebar.spaces.SpaceConfEvent;
@@ -150,6 +150,20 @@
}
}
+ private void doActionOrSignInIfNeeded(final HistoryTokenCallback tokenListener,
+ final String newHistoryToken) {
+ if (tokenListener.authMandatory() && session.isNotLogged()) {
+ Log.debug("login mandatory for " + newHistoryToken);
+ // Ok, we have to redirect because this token (for instance
+ // #translate) needs the user authenticated
+ redirectButSignInBefore(newHistoryToken);
+ } else {
+ // The auth is not mandatory, go ahead with the token action
+ Log.debug("Executing action related with historytoken " + newHistoryToken);
+ tokenListener.onHistoryToken(newHistoryToken);
+ }
+ }
+
private void getContent(final StateToken newState) {
getContent(newState, false);
}
@@ -278,8 +292,19 @@
tokenListener = siteTokens.get(nToken);
}
Log.debug("StateManager: on history changed (" + newHistoryToken + ")");
- if (tokenListener == null) {
- // Log.debug("Is not a special hash");
+ if (tokenListener != null) {
+ Log.debug("token is one of #newgroup #signin #translate without #hash(redirection) ...");
+ if (startingUp()) {
+ // Starting with some token like "signin": load defContent
+ // also
+ getContent(new StateToken(SiteTokens.GROUP_HOME), false);
+ // processHistoryToken(SiteTokens.GROUP_HOME);
+ // SpaceSelectEvent.fire(eventBus, Space.groupSpace);
+ }
+ // Fire the listener of this #hash token
+ doActionOrSignInIfNeeded(tokenListener, newHistoryToken);
+ } else {
+ Log.debug("Is not a special hash like #newgroup, etc, or maybe has a #hash(redirection)");
// token is not one of #newgroup #signin #translate ...
final String nToken = newHistoryToken != null ? newHistoryToken.toLowerCase() : null;
if (nToken != null && tokenMatcher.hasRedirect(nToken)) {
@@ -291,23 +316,29 @@
SpaceConfEvent.fire(eventBus, Space.groupSpace, sndToken);
SpaceConfEvent.fire(eventBus, Space.publicSpace, TokenUtils.preview(sndToken));
getContent(new StateToken(sndToken));
- } else if (firstToken.equals(SiteTokens.SUBTITLES)) {
- siteTokens.get(SiteTokens.SUBTITLES).onHistoryToken(
- tokenMatcher.getRedirect(newHistoryToken).getRight());
- } else if (firstToken.equals(SiteTokens.NEWGROUP)) {
- siteTokens.get(SiteTokens.NEWGROUP).onHistoryToken(newHistoryToken);
- } else if (firstToken.equals(SiteTokens.SIGNIN)) {
- if (session.isLogged()) {
- // We are logged, then redirect:
- history.newItem(sndToken, false);
- processHistoryToken(sndToken);
- } else {
- // We have to loggin
- siteTokens.get(SiteTokens.SIGNIN).onHistoryToken(newHistoryToken);
+ } else {
+ final HistoryTokenCallback tokenWithRedirect = siteTokens.get(firstToken);
+ if (tokenWithRedirect != null) {
+ Log.info("Is some #subtitle(foo) or #verifyemail(hash) etc");
+ doActionOrSignInIfNeeded(tokenWithRedirect,
+ tokenMatcher.getRedirect(newHistoryToken).getRight());
+ } else if (firstToken.equals(SiteTokens.NEW_GROUP)) {
+ siteTokens.get(SiteTokens.NEW_GROUP).onHistoryToken(newHistoryToken);
+ } else if (firstToken.equals(SiteTokens.SIGN_IN)) {
+ if (session.isLogged()) {
+ // We are logged, then redirect:
+ history.newItem(sndToken, false);
+ processHistoryToken(sndToken);
+ } else {
+ // We have to login
+ siteTokens.get(SiteTokens.SIGN_IN).onHistoryToken(newHistoryToken);
+ }
}
}
- } else
- // No redirection
+ } else {
+ // Is not a Redirect token
+ Log.debug("Is not a redirect token");
+ }
if (tokenMatcher.isWaveToken(newHistoryToken)) {
if (session.isLogged()) {
SpaceConfEvent.fire(eventBus, Space.userSpace, newHistoryToken);
@@ -320,7 +351,7 @@
}
} else {
// Wave, but don't logged
- history.newItem(TokenUtils.addRedirect(SiteTokens.SIGNIN, newHistoryToken));
+ redirectButSignInBefore(newHistoryToken);
if (startingUp()) {
// Starting application (with Wave)
getContent(new StateToken(SiteTokens.GROUP_HOME), false);
@@ -334,30 +365,23 @@
} else {
gotoDefaultHomepage();
}
- } else {
- // token is one of #newgroup #signin #translate ...
- if (startingUp()) {
- // Starting with some token like "signin": load defContent
- // also
- getContent(new StateToken(SiteTokens.GROUP_HOME), false);
- // processHistoryToken(SiteTokens.GROUP_HOME);
- // SpaceSelectEvent.fire(eventBus, Space.groupSpace);
- }
- // Fire the listener of this #hash token
- tokenListener.onHistoryToken(newHistoryToken);
}
} else {
resumedHistoryToken = newHistoryToken;
}
}
+ private void redirectButSignInBefore(final String newHistoryToken) {
+ history.newItem(TokenUtils.addRedirect(SiteTokens.SIGN_IN, newHistoryToken));
+ }
+
@Override
public void redirectOrRestorePreviousToken() {
final String token = history.getToken();
if (tokenMatcher.hasRedirect(token)) {
// URL of the form signin(group.tool)
final String previousToken = tokenMatcher.getRedirect(token).getRight();
- if (previousToken.equals(SiteTokens.WAVEINBOX) && session.isNotLogged()) {
+ if (previousToken.equals(SiteTokens.WAVE_INBOX) && session.isNotLogged()) {
// signin(inbox) && cancel
restorePreviousToken();
} else {
Modified: trunk/src/main/java/cc/kune/core/public/ws.css
===================================================================
--- trunk/src/main/java/cc/kune/core/public/ws.css 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/public/ws.css 2012-01-16 20:53:44 UTC (rev 1663)
@@ -1,4 +1,4 @@
-GCHARSET "UTF-8 "; body {
+GCHARSET "UTF-8 "; body {
background-color: transparent;
color: black;
font-family: 'Ubuntu', Arial;
@@ -324,12 +324,9 @@
float: left;
}
-.k-space-sel-btn-blink {
-/* kfilter: alpha(opacity = */
-/* 30); */
-/* -moz-opacity: 0.30; */
-/* -khtml-opacity: 0.30; */
-/* opacity: 0.30; */
+.k-space-sel-btn-blink { /* kfilter: alpha(opacity = */
+ /* 30); */ /* -moz-opacity: 0.30; */
+ /* -khtml-opacity: 0.30; */ /* opacity: 0.30; */
visibility: hidden;
}
@@ -953,7 +950,7 @@
border-color: #CCCCCC !important;
background: inherits !important;
kfilter: alpha(opacity =
- 60) !important;
+ 60) !important;
-moz-opacity: 0.60 !important;
-khtml-opacity: 0.60 !important;
opacity: 0.60 !important;
@@ -1239,7 +1236,7 @@
-moz-border-radius-bottomleft: 5px;
border-bottom-left-radius: 5px;
kfilter: alpha(opacity =
- 90);
+ 90);
-moz-opacity: 0.90;
-khtml-opacity: 0.90;
opacity: 0.90;
@@ -1561,14 +1558,13 @@
}
/* Calendar */
-
.gwt-cal-MonthView {
- bottom: 0 !important;
- height: auto !important;
- left: 0 !important;
- overflow: auto !important;
- position: absolute !important;
- right: 0 !important;
- top: 0 !important;
- width: auto !important;
+ bottom: 0 !important;
+ height: auto !important;
+ left: 0 !important;
+ overflow: auto !important;
+ position: absolute !important;
+ right: 0 !important;
+ top: 0 !important;
+ width: auto !important;
}
\ No newline at end of file
Modified: trunk/src/main/java/cc/kune/core/server/mail/MailServiceDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/mail/MailServiceDefault.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/server/mail/MailServiceDefault.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -77,14 +77,19 @@
for (final String to : tos) {
try {
message.setFrom(new InternetAddress(from));
+ // In case we should use utf8 also in address:
+ // http://stackoverflow.com/questions/2656478/send-javax-mail-internet-mimemes…
message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
+ // If additional header should be added
+ // message.addHeader(name, MimeUtility.encodeText(value, "utf-8", "B"));
final String formatedSubject = subject.getString();
- message.setSubject(formatedSubject);
+ message.setSubject(formatedSubject, "utf-8");
final String formatedBody = body.getString();
if (isHtml) {
- message.setContent(formatedBody, "text/html");
+ // message.setContent(formatedBody, "text/html");
+ message.setText(formatedBody, "UTF-8", "html");
} else {
- message.setText(formatedBody);
+ message.setText(formatedBody, "UTF-8");
}
// Send message
Transport.send(message);
Modified: trunk/src/main/java/cc/kune/core/server/manager/UserManager.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/manager/UserManager.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/server/manager/UserManager.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -21,7 +21,9 @@
import org.waveprotocol.box.server.authentication.PasswordDigest;
+import cc.kune.core.client.errors.DefaultException;
import cc.kune.core.client.errors.I18nNotFoundException;
+import cc.kune.core.server.manager.impl.EmailConfirmationType;
import cc.kune.core.shared.domain.UserSNetVisibility;
import cc.kune.core.shared.dto.I18nLanguageSimpleDTO;
import cc.kune.core.shared.dto.UserDTO;
@@ -29,6 +31,16 @@
import cc.kune.domain.UserBuddiesData;
public interface UserManager {
+ /**
+ * Ask for email confirmation.
+ *
+ * @param user
+ * the user
+ * @param type
+ * the type
+ */
+ void askForEmailConfirmation(User user, EmailConfirmationType type) throws DefaultException;
+
User changePasswd(Long userId, String oldPassword, String newPassword);
/**
@@ -83,4 +95,16 @@
*/
User update(Long userId, UserDTO user, I18nLanguageSimpleDTO lang);
+ /**
+ * Verify password hash of a user.
+ *
+ * @param userId
+ * the user id
+ * @param emailReceivedHash
+ * the email received hash
+ * @param period
+ * the period (1h or more if is a new account);
+ */
+ void verifyPasswordHash(Long userId, String emailReceivedHash, long period) throws DefaultException;
+
}
Added: trunk/src/main/java/cc/kune/core/server/manager/impl/EmailConfirmationType.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/manager/impl/EmailConfirmationType.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/server/manager/impl/EmailConfirmationType.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -0,0 +1,10 @@
+package cc.kune.core.server.manager.impl;
+
+/**
+ * The Enum EmailConfirmationType is used internally to differentiate several
+ * types of email confirmation/verification
+ */
+public enum EmailConfirmationType {
+ emailVerification, fstTimeEmailVerification, passwordReset
+
+}
Modified: trunk/src/main/java/cc/kune/core/server/manager/impl/UserManagerDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/manager/impl/UserManagerDefault.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/server/manager/impl/UserManagerDefault.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -20,11 +20,13 @@
package cc.kune.core.server.manager.impl;
import java.util.Collection;
+import java.util.Date;
import java.util.HashSet;
import java.util.List;
import java.util.TimeZone;
import java.util.Timer;
import java.util.TimerTask;
+import java.util.UUID;
import javax.persistence.EntityManager;
import javax.persistence.NoResultException;
@@ -46,11 +48,15 @@
import cc.kune.common.shared.utils.TextUtils;
import cc.kune.core.client.errors.DefaultException;
import cc.kune.core.client.errors.EmailAddressInUseException;
+import cc.kune.core.client.errors.EmailHashExpiredException;
+import cc.kune.core.client.errors.EmailHashInvalidException;
import cc.kune.core.client.errors.GroupLongNameInUseException;
import cc.kune.core.client.errors.GroupShortNameInUseException;
import cc.kune.core.client.errors.I18nNotFoundException;
import cc.kune.core.client.errors.UserRegistrationException;
import cc.kune.core.client.errors.WrongCurrentPasswordException;
+import cc.kune.core.client.state.SiteTokens;
+import cc.kune.core.client.state.TokenUtils;
import cc.kune.core.server.i18n.I18nTranslationServiceMultiLang;
import cc.kune.core.server.manager.GroupManager;
import cc.kune.core.server.manager.I18nCountryManager;
@@ -121,7 +127,36 @@
this.notifyService = notifyService;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * cc.kune.core.server.manager.UserManager#askForEmailConfirmation(cc.kune
+ * .domain.User, cc.kune.core.server.manager.impl.EmailConfirmationType)
+ */
@Override
+ public void askForEmailConfirmation(final User user, final EmailConfirmationType type)
+ throws DefaultException {
+ user.setEmailCheckDate(System.currentTimeMillis());
+ final String hash = UUID.randomUUID().toString();
+ user.setEmailConfirmHash(hash);
+ persist(user);
+
+ switch (type) {
+ case emailVerification:
+ case fstTimeEmailVerification:
+ notifyService.sendEmailToWithLink(user, "Please verify your email",
+ "Please click in the following link to verify your email at %s:",
+ TokenUtils.addRedirect(SiteTokens.VERIFY_EMAIL, hash));
+ break;
+ case passwordReset:
+ // FIXME
+ default:
+ break;
+ }
+ }
+
+ @Override
public User changePasswd(final Long userId, final String oldPassword, final String newPassword) {
final User user = find(userId);
final ParticipantId participantId = participantUtils.of(user.getShortName());
@@ -211,10 +246,7 @@
// Is this necessary? try to remove (used when we were setting the def
// content
// contentManager.save(userGroup.getDefaultContent());
-
- // FIXME: notifyService.
- // mailService.sendPlain(new FormatedString("Welcome", ""), new
- // FormatedString("welcome"), email);
+ askForEmailConfirmation(user, EmailConfirmationType.emailVerification);
return user;
} catch (final RuntimeException e) {
try {
@@ -400,4 +432,24 @@
return user;
}
+ @Override
+ public void verifyPasswordHash(final Long userId, final String emailReceivedHash, final long period)
+ throws DefaultException {
+ final User user = find(userId);
+ final Date on = new Date(user.getEmailCheckDate() + period);
+
+ final Date now = new Date();
+ if (on.before(now)) {
+ throw new EmailHashExpiredException();
+ }
+ final String emailConfirmHash = user.getEmailConfirmHash();
+ if (emailReceivedHash != null && emailConfirmHash != null
+ && emailReceivedHash.equals(emailConfirmHash)) {
+ user.setEmailVerified(true);
+ user.setEmailConfirmHash("");
+ persist(user);
+ } else {
+ throw new EmailHashInvalidException();
+ }
+ }
}
Modified: trunk/src/main/java/cc/kune/core/server/notifier/NotificationHtmlHelper.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/notifier/NotificationHtmlHelper.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/server/notifier/NotificationHtmlHelper.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -2,7 +2,6 @@
import cc.kune.core.server.mail.FormatedString;
import cc.kune.core.server.utils.AbsoluteFileDownloadUtils;
-import cc.kune.core.shared.utils.SharedFileDownloadUtils;
import com.google.inject.Inject;
import com.google.inject.Singleton;
@@ -23,7 +22,7 @@
+ "%s"
+ "</td></tr></tbody></table>";
- private final SharedFileDownloadUtils fileDownloadUtils;
+ private final AbsoluteFileDownloadUtils fileDownloadUtils;
/**
* Instantiates a new notify html helper.
@@ -51,9 +50,25 @@
*/
public FormatedString groupNotification(final String groupName, final boolean hasLogo,
final String message) {
- final String groupUrl = fileDownloadUtils.getPrefix() + "#" + groupName;
+ final String groupUrl = fileDownloadUtils.getUrl(groupName);
return FormatedString.build(false, GROUP_TEMPLATE, groupUrl,
- fileDownloadUtils.getLogoAvatarHtml(groupName, hasLogo, false, 50, 50), groupUrl, groupName,
+ fileDownloadUtils.getLogoAvatarHtml(groupName, hasLogo, false, 50, 5), groupUrl, groupName,
message);
}
+
+ /**
+ * Format a user notification with an additional link. The first an unique %s
+ * in body is changed by the site name.
+ *
+ * @param body
+ * the body
+ * @param hash
+ * the hash
+ * @return the formated string
+ */
+ public FormatedString userNotification(final String body, final String hash) {
+ final String hashUrl = fileDownloadUtils.getUrl(hash);
+ return FormatedString.build(false, body + "<br><a href='%s'>%s</a>",
+ fileDownloadUtils.getSiteCommonName(), hashUrl, hashUrl);
+ }
}
Modified: trunk/src/main/java/cc/kune/core/server/notifier/NotificationSenderDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/notifier/NotificationSenderDefault.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/server/notifier/NotificationSenderDefault.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -92,7 +92,8 @@
String.format("<b>%s</b>%s", subject.getString(), body.getString()));
break;
case email:
- if (forceSend || (noOnline(username) && withFrequency == user.getEmailNotifFreq())) {
+ if (forceSend
+ || (user.isEmailVerified() && noOnline(username) && withFrequency == user.getEmailNotifFreq())) {
// we'll send this notification if is mandatory or this user is not
// only and has this freq configured
mailService.send(subject, FormatedString.build(emailTemplate.replace("%s", body.getString())),
Modified: trunk/src/main/java/cc/kune/core/server/notifier/NotificationService.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/notifier/NotificationService.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/server/notifier/NotificationService.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -34,6 +34,10 @@
this.userFinder = userFinder;
}
+ private FormatedString createPlainSubject(final String subject) {
+ return FormatedString.build(subject);
+ }
+
@SuppressWarnings("unchecked")
private void getAllUserMembers(final Set<User> users, final Group groupToNotify,
final boolean onlyAdmins) {
@@ -79,14 +83,34 @@
private void notifyToAll(final Group groupSender, final String subject, final String message,
final Collection<User> users) {
for (final User to : users) {
- sender.add(NotificationType.email, FormatedString.build(subject),
+ sender.add(NotificationType.email, createPlainSubject(subject),
helper.groupNotification(groupSender.getShortName(), groupSender.hasLogo(), message), true,
true, to);
}
}
public void notifyUser(final User to, final Group group, final String subject, final String message) {
- sender.add(NotificationType.email, FormatedString.build(subject),
+ sender.add(NotificationType.email, createPlainSubject(subject),
helper.groupNotification(group.getShortName(), group.hasLogo(), message), true, true, to);
}
+
+ /**
+ * Send email to an User with a link.The first an unique %s in body is changed
+ * by the site name.
+ *
+ * @param to
+ * the User to send the notification
+ * @param subject
+ * the subject of the email
+ * @param body
+ * the body of the email with a %s that will be replaced by the site
+ * name
+ * @param hash
+ * the hash an additional link that will be added at the end
+ */
+ public void sendEmailToWithLink(final User to, final String subject, final String body,
+ final String hash) {
+ sender.add(NotificationType.email, createPlainSubject(subject), helper.userNotification(body, hash),
+ true, true, to);
+ }
}
Modified: trunk/src/main/java/cc/kune/core/server/rpc/UserRPC.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/rpc/UserRPC.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/server/rpc/UserRPC.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -19,6 +19,7 @@
*/
package cc.kune.core.server.rpc;
+import javax.persistence.NoResultException;
import javax.servlet.http.HttpSession;
import org.jivesoftware.smack.util.Base64;
@@ -28,6 +29,7 @@
import cc.kune.core.client.errors.AccessViolationException;
import cc.kune.core.client.errors.DefaultException;
+import cc.kune.core.client.errors.EmailNotFoundException;
import cc.kune.core.client.errors.UserAuthException;
import cc.kune.core.client.rpcservices.UserService;
import cc.kune.core.server.UserSession;
@@ -36,10 +38,12 @@
import cc.kune.core.server.auth.Authenticated;
import cc.kune.core.server.auth.Authorizated;
import cc.kune.core.server.manager.UserManager;
+import cc.kune.core.server.manager.impl.EmailConfirmationType;
import cc.kune.core.server.mapper.Mapper;
import cc.kune.core.server.properties.ReservedWordsRegistry;
import cc.kune.core.server.users.UserInfo;
import cc.kune.core.server.users.UserInfoService;
+import cc.kune.core.shared.SessionConstants;
import cc.kune.core.shared.domain.AccessRol;
import cc.kune.core.shared.domain.UserSNetVisibility;
import cc.kune.core.shared.domain.utils.StateToken;
@@ -50,6 +54,7 @@
import cc.kune.core.shared.dto.WaveClientParams;
import cc.kune.domain.Group;
import cc.kune.domain.User;
+import cc.kune.domain.finders.UserFinder;
import cc.kune.wave.server.CustomWaveClientServlet;
import com.google.inject.Inject;
@@ -62,6 +67,7 @@
private final ContentRPC contentRPC;
private final Mapper mapper;
private final ReservedWordsRegistry reserverdWords;
+ private final UserFinder userFinder;
private final UserInfoService userInfoService;
private final UserManager userManager;
private final UserSessionManager userSessionManager;
@@ -75,7 +81,7 @@
final UserInfoService userInfoService, final Mapper mapper,
final SessionManager waveSessionManager, final CustomWaveClientServlet waveClientServlet,
final ReservedWordsRegistry reserverdWords, final ContentRPC contentRPC,
- final UserSessionManager userSessionManager) {
+ final UserSessionManager userSessionManager, final UserFinder userFinder) {
this.userManager = userManager;
this.useSocketIO = useSocketIO;
this.userInfoService = userInfoService;
@@ -85,9 +91,29 @@
this.reserverdWords = reserverdWords;
this.contentRPC = contentRPC;
this.userSessionManager = userSessionManager;
+ this.userFinder = userFinder;
}
+ @Authenticated
@Override
+ @Transactional
+ public void askForEmailConfirmation(final String userHash) throws DefaultException {
+ final User user = userSessionManager.getUser();
+ userManager.askForEmailConfirmation(user, EmailConfirmationType.emailVerification);
+ }
+
+ @Override
+ @Transactional
+ public void askForEmailForgot(final String email) throws DefaultException {
+ try {
+ final User user = userFinder.findByEmail(email);
+ userManager.askForEmailConfirmation(user, EmailConfirmationType.passwordReset);
+ } catch (final NoResultException e) {
+ throw new EmailNotFoundException();
+ }
+ }
+
+ @Override
@Authenticated
@Transactional
public void changePasswd(final String userHash, final String oldPassword, final String newPassword)
@@ -131,7 +157,7 @@
final JSONObject sessionJson = waveClientServlet.getSessionJson(sessionFromToken);
final JSONObject clientFlags = new JSONObject(); // waveClientServlet.getClientFlags();
return new WaveClientParams(sessionJson.toString(), clientFlags.toString(), useSocketIO);
- }
+ };
private UserInfoDTO loadUserInfo(final User user) throws DefaultException {
final UserInfo userInfo = userInfoService.buildInfo(user, userSessionManager.getHash());
@@ -146,7 +172,7 @@
// sessionService.getNewSession();
final User user = userManager.login(nickOrEmail, passwd);
return loginUser(user, waveToken);
- };
+ }
private UserInfoDTO loginUser(final User user, final String waveToken) throws DefaultException {
if (user != null) {
@@ -207,4 +233,12 @@
userSessionManager.updateLoggedUser();
return contentRPC.getContent(userHash, userUpdated.getUserGroup().getStateToken());
}
+
+ @Authenticated
+ @Override
+ @Transactional
+ public void verifyPasswordHash(final String userHash, final String emailReceivedHash) {
+ final User user = userSessionManager.getUser();
+ userManager.verifyPasswordHash(user.getId(), emailReceivedHash, SessionConstants._AN_HOUR);
+ }
}
Modified: trunk/src/main/java/cc/kune/core/server/utils/AbsoluteFileDownloadUtils.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/utils/AbsoluteFileDownloadUtils.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/server/utils/AbsoluteFileDownloadUtils.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -13,8 +13,15 @@
@Singleton
public class AbsoluteFileDownloadUtils extends SharedFileDownloadUtils {
+ private final KuneBasicProperties properties;
+
@Inject
public AbsoluteFileDownloadUtils(final KuneBasicProperties properties) {
super(properties.getSiteUrl());
+ this.properties = properties;
}
+
+ public String getSiteCommonName() {
+ return properties.getSiteCommonName();
+ }
}
Added: trunk/src/main/java/cc/kune/core/shared/SessionConstants.java
===================================================================
--- trunk/src/main/java/cc/kune/core/shared/SessionConstants.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/shared/SessionConstants.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -0,0 +1,17 @@
+package cc.kune.core.shared;
+
+public final class SessionConstants {
+
+ public final static int _AN_HOUR = 1000 * 60 * 60;
+ public final static long A_DAY = _AN_HOUR * 24;
+ public final static long ANON_SESSION_DURATION = A_DAY;
+ public final static long ANON_SESSION_DURATION_AFTER_REG = A_DAY * 365;
+ public final static long SESSION_DURATION = A_DAY * 14; // two weeks login
+ // session duration
+ // public final static long SESSION_DURATION = 100; // For test
+ public final static String USERHASH = "k007userHash";
+
+ public SessionConstants() {
+
+ }
+}
\ No newline at end of file
Modified: trunk/src/main/java/cc/kune/core/shared/dto/UserSimpleDTO.java
===================================================================
--- trunk/src/main/java/cc/kune/core/shared/dto/UserSimpleDTO.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/shared/dto/UserSimpleDTO.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -25,146 +25,159 @@
import com.google.gwt.user.client.rpc.IsSerializable;
public class UserSimpleDTO implements IsSerializable {
- private I18nCountryDTO country;
- private boolean hasLogo;
- private Long id;
- private I18nLanguageDTO language;
- private String name;
- private String shortName;
- private StateToken stateToken;
- private TimeZoneDTO timezone;
- private EmailNotificationFrequency emailNotifFreq;
+ private I18nCountryDTO country;
+ private EmailNotificationFrequency emailNotifFreq;
+ private boolean emailVerified;
+ private boolean hasLogo;
+ private Long id;
+ private I18nLanguageDTO language;
+ private String name;
+ private String shortName;
+ private StateToken stateToken;
+ private TimeZoneDTO timezone;
- public UserSimpleDTO() {
- this(null, null, null, null, null);
- }
+ public UserSimpleDTO() {
+ this(null, null, null, null, null);
+ }
- public UserSimpleDTO(final String name, final String shortName, final I18nLanguageDTO language,
- final I18nCountryDTO country, final TimeZoneDTO timezone) {
- this.name = name;
- this.shortName = shortName;
- this.language = language;
- this.country = country;
- this.timezone = timezone;
- }
+ public UserSimpleDTO(final String name, final String shortName, final I18nLanguageDTO language,
+ final I18nCountryDTO country, final TimeZoneDTO timezone) {
+ this.name = name;
+ this.shortName = shortName;
+ this.language = language;
+ this.country = country;
+ this.timezone = timezone;
+ }
- @Override
- public boolean equals(final Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final UserSimpleDTO other = (UserSimpleDTO) obj;
- if (id == null) {
- if (other.id != null) {
- return false;
- }
- } else if (!id.equals(other.id)) {
- return false;
- }
- if (shortName == null) {
- if (other.shortName != null) {
- return false;
- }
- } else if (!shortName.equals(other.shortName)) {
- return false;
- }
- return true;
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
}
-
- public I18nCountryDTO getCountry() {
- return country;
+ if (obj == null) {
+ return false;
}
-
- public boolean getHasLogo() {
- return hasLogo;
+ if (getClass() != obj.getClass()) {
+ return false;
}
-
- public Long getId() {
- return id;
+ final UserSimpleDTO other = (UserSimpleDTO) obj;
+ if (id == null) {
+ if (other.id != null) {
+ return false;
+ }
+ } else if (!id.equals(other.id)) {
+ return false;
}
-
- public I18nLanguageDTO getLanguage() {
- return language;
+ if (shortName == null) {
+ if (other.shortName != null) {
+ return false;
+ }
+ } else if (!shortName.equals(other.shortName)) {
+ return false;
}
+ return true;
+ }
- public String getName() {
- return name;
- }
+ public I18nCountryDTO getCountry() {
+ return country;
+ }
- public String getShortName() {
- return shortName;
- }
+ public EmailNotificationFrequency getEmailNotifFreq() {
+ return emailNotifFreq;
+ }
- public StateToken getStateToken() {
- return stateToken;
- }
+ public boolean getEmailVerified() {
+ return isEmailVerified();
+ }
- public TimeZoneDTO getTimezone() {
- return timezone;
- }
+ public boolean getHasLogo() {
+ return hasLogo;
+ }
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((id == null) ? 0 : id.hashCode());
- result = prime * result + ((shortName == null) ? 0 : shortName.hashCode());
- return result;
- }
+ public Long getId() {
+ return id;
+ }
- public boolean hasLogo() {
- return hasLogo;
- }
+ public I18nLanguageDTO getLanguage() {
+ return language;
+ }
- public void setCountry(final I18nCountryDTO country) {
- this.country = country;
- }
+ public String getName() {
+ return name;
+ }
- public void setHasLogo(final boolean hasLogo) {
- this.hasLogo = hasLogo;
- }
+ public String getShortName() {
+ return shortName;
+ }
- public void setId(final Long id) {
- this.id = id;
- }
+ public StateToken getStateToken() {
+ return stateToken;
+ }
- public void setLanguage(final I18nLanguageDTO language) {
- this.language = language;
- }
+ public TimeZoneDTO getTimezone() {
+ return timezone;
+ }
- public void setName(final String name) {
- this.name = name;
- }
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((id == null) ? 0 : id.hashCode());
+ result = prime * result + ((shortName == null) ? 0 : shortName.hashCode());
+ return result;
+ }
- public void setShortName(final String shortName) {
- this.shortName = shortName;
- }
+ public boolean hasLogo() {
+ return hasLogo;
+ }
- public void setStateToken(final StateToken stateToken) {
- this.stateToken = stateToken;
- }
+ public boolean isEmailVerified() {
+ return emailVerified;
+ }
- public void setTimezone(final TimeZoneDTO timezone) {
- this.timezone = timezone;
- }
+ public void setCountry(final I18nCountryDTO country) {
+ this.country = country;
+ }
- @Override
- public String toString() {
- return "UserSimpleDTO(" + shortName + ")";
- }
+ public void setEmailNotifFreq(final EmailNotificationFrequency emailNotifFreq) {
+ this.emailNotifFreq = emailNotifFreq;
+ }
- public EmailNotificationFrequency getEmailNotifFreq() {
- return emailNotifFreq;
- }
+ public void setEmailVerified(final boolean emailVerified) {
+ this.emailVerified = emailVerified;
+ }
- public void setEmailNotifFreq(EmailNotificationFrequency emailNotifFreq) {
- this.emailNotifFreq = emailNotifFreq;
- }
+ public void setHasLogo(final boolean hasLogo) {
+ this.hasLogo = hasLogo;
+ }
+ public void setId(final Long id) {
+ this.id = id;
+ }
+
+ public void setLanguage(final I18nLanguageDTO language) {
+ this.language = language;
+ }
+
+ public void setName(final String name) {
+ this.name = name;
+ }
+
+ public void setShortName(final String shortName) {
+ this.shortName = shortName;
+ }
+
+ public void setStateToken(final StateToken stateToken) {
+ this.stateToken = stateToken;
+ }
+
+ public void setTimezone(final TimeZoneDTO timezone) {
+ this.timezone = timezone;
+ }
+
+ @Override
+ public String toString() {
+ return "UserSimpleDTO(" + shortName + ")";
+ }
+
}
Modified: trunk/src/main/java/cc/kune/core/shared/utils/SharedFileDownloadUtils.java
===================================================================
--- trunk/src/main/java/cc/kune/core/shared/utils/SharedFileDownloadUtils.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/core/shared/utils/SharedFileDownloadUtils.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -27,10 +27,10 @@
public String getLogoAvatarHtml(final String groupName, final boolean groupHasLogo,
final boolean isPersonal, final int size, final int hvspace) {
- final String imgUrl = groupHasLogo ? getLogoImageUrl(groupName)
- : isPersonal ? FileConstants.PERSON_NO_AVATAR_IMAGE : FileConstants.GROUP_NO_AVATAR_IMAGE;
+ final String imgUrl = groupHasLogo ? getLogoImageUrl(groupName) : isPersonal ? prefix + "/"
+ + FileConstants.PERSON_NO_AVATAR_IMAGE : prefix + "/" + FileConstants.GROUP_NO_AVATAR_IMAGE;
return "<img hspace='" + hvspace + "' vspace='" + hvspace + "' align='left' style='width: " + size
- + "px; height: " + size + "px;' src='" + prefix + imgUrl + "'>";
+ + "px; height: " + size + "px;' src='" + imgUrl + "'>";
}
public String getLogoImageUrl(final String groupName) {
@@ -42,6 +42,10 @@
return prefix;
}
+ public String getUrl(final String hash) {
+ return getPrefix() + "#" + hash;
+ }
+
public String getUserAvatar(final String username) {
return prefix
+ new Url(FileConstants.AVATARDOWNLOADSERVLET, new UrlParam(FileConstants.USERNAME, username)).toString();
Modified: trunk/src/main/java/cc/kune/docs/client/DocsParts.java
===================================================================
--- trunk/src/main/java/cc/kune/docs/client/DocsParts.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/docs/client/DocsParts.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -19,7 +19,7 @@
*/
package cc.kune.docs.client;
-import cc.kune.core.client.state.Session;
+import cc.kune.core.shared.SessionConstants;
import cc.kune.docs.client.actions.DocsClientActions;
import cc.kune.docs.shared.DocsConstants;
import cc.kune.gspace.client.tool.ContentViewerSelector;
@@ -32,7 +32,7 @@
public class DocsParts {
@Inject
- public DocsParts(final Session session, final Provider<DocsClientTool> clientTool,
+ public DocsParts(final SessionConstants session, final Provider<DocsClientTool> clientTool,
final ContentViewerSelector viewerSelector, final DocsClientActions docsActions,
final ContentViewerPresenter contentViewer, final FolderViewerPresenter folderViewer) {
clientTool.get();
Modified: trunk/src/main/java/cc/kune/domain/User.java
===================================================================
--- trunk/src/main/java/cc/kune/domain/User.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/domain/User.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -83,12 +83,18 @@
@Length(min = 1)
private String email;
- @Enumerated(EnumType.STRING)
- private EmailNotificationFrequency emailNotifFreq;
+ private Long emailCheckDate;
// @OneToOne(cascade = CascadeType.REMOVE)
// private final CustomProperties customProperties;
+ private String emailConfirmHash;
+
+ @Enumerated(EnumType.STRING)
+ private EmailNotificationFrequency emailNotifFreq;
+
+ private Boolean emailVerified;
+
@Id
@DocumentId
@GeneratedValue
@@ -154,12 +160,22 @@
this.lastLogin = null;
emailNotifFreq = DEF_EMAIL_FREQ;
// this.properties = properties;
+ emailVerified = false;
}
// @OneToOne
// @OnDelete(action = OnDeleteAction.CASCADE)
// private Properties properties;
+ //
+ // public User(final String shortName, final String longName, final String
+ // email, final String passwd,
+ // final I18nLanguage language, final I18nCountry country, final TimeZone
+ // timezone) {
+ // this(shortName, longName, email, passwd, language, country, timezone,
+ // null);
+ // }
+
@Override
public boolean equals(final Object obj) {
if (this == obj) {
@@ -182,15 +198,6 @@
return true;
}
- //
- // public User(final String shortName, final String longName, final String
- // email, final String passwd,
- // final I18nLanguage language, final I18nCountry country, final TimeZone
- // timezone) {
- // this(shortName, longName, email, passwd, language, country, timezone,
- // null);
- // }
-
public I18nCountry getCountry() {
return country;
}
@@ -203,18 +210,30 @@
return diggest;
}
+ // public CustomProperties getCustomProperties() {
+ // return customProperties;
+ // }
+
public String getEmail() {
return email;
}
- // public CustomProperties getCustomProperties() {
- // return customProperties;
- // }
+ public Long getEmailCheckDate() {
+ return emailCheckDate;
+ }
+ public String getEmailConfirmHash() {
+ return emailConfirmHash;
+ }
+
public EmailNotificationFrequency getEmailNotifFreq() {
return emailNotifFreq == null ? DEF_EMAIL_FREQ : emailNotifFreq;
}
+ public boolean getEmailVerified() {
+ return isEmailVerified();
+ }
+
public boolean getHasLogo() {
return hasLogo();
}
@@ -224,6 +243,10 @@
return id;
}
+ // public Properties getProperties() {
+ // return properties;
+ // }
+
public I18nLanguage getLanguage() {
return language;
}
@@ -240,10 +263,6 @@
return password;
}
- // public Properties getProperties() {
- // return properties;
- // }
-
public byte[] getSalt() {
return salt;
}
@@ -282,6 +301,10 @@
return getUserGroup().hasLogo();
}
+ public boolean isEmailVerified() {
+ return emailVerified == null ? false : emailVerified;
+ }
+
public void setCountry(final I18nCountry country) {
this.country = country;
}
@@ -294,10 +317,22 @@
this.email = email;
}
+ public void setEmailCheckDate(final Long emailCheckDate) {
+ this.emailCheckDate = emailCheckDate;
+ }
+
+ public void setEmailConfirmHash(final String emailConfirmHash) {
+ this.emailConfirmHash = emailConfirmHash;
+ }
+
public void setEmailNotifFreq(final EmailNotificationFrequency emailNotifFreq) {
this.emailNotifFreq = emailNotifFreq;
}
+ public void setEmailVerified(final boolean emailVerified) {
+ this.emailVerified = emailVerified;
+ }
+
@Override
public void setId(final Long id) {
this.id = id;
Modified: trunk/src/main/java/cc/kune/events/client/EventsParts.java
===================================================================
--- trunk/src/main/java/cc/kune/events/client/EventsParts.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/events/client/EventsParts.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -19,7 +19,7 @@
*/
package cc.kune.events.client;
-import cc.kune.core.client.state.Session;
+import cc.kune.core.shared.SessionConstants;
import cc.kune.events.client.actions.EventsClientActions;
import cc.kune.events.client.viewer.CalendarViewer;
import cc.kune.events.shared.EventsConstants;
@@ -32,7 +32,7 @@
public class EventsParts {
@Inject
- public EventsParts(final Session session, final Provider<EventsClientTool> clientTool,
+ public EventsParts(final SessionConstants session, final Provider<EventsClientTool> clientTool,
final ContentViewerSelector viewerSelector, final EventsClientActions meetsActions,
final ContentViewerPresenter contentViewer, final CalendarViewer calendarViewer) {
clientTool.get();
Modified: trunk/src/main/java/cc/kune/gspace/client/GSpaceParts.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/GSpaceParts.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/gspace/client/GSpaceParts.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -23,7 +23,7 @@
import cc.kune.core.client.events.AppStartEvent.AppStartHandler;
import cc.kune.core.client.sitebar.search.SitebarSearchPresenter;
import cc.kune.core.client.sn.actions.WriteToBuddyHeaderButton;
-import cc.kune.core.client.state.HistoryTokenCallback;
+import cc.kune.core.client.state.HistoryTokenMustBeAuthCallback;
import cc.kune.core.client.state.Session;
import cc.kune.core.client.state.SiteTokenListeners;
import cc.kune.core.client.state.SiteTokens;
@@ -125,7 +125,7 @@
writeToBuddie.get();
}
});
- tokenListener.put(SiteTokens.TRANSLATE, new HistoryTokenCallback() {
+ tokenListener.put(SiteTokens.TRANSLATE, new HistoryTokenMustBeAuthCallback() {
@Override
public void onHistoryToken(final String token) {
if (session.isLogged() && session.getInitData().isTranslatorEnabled()) {
Modified: trunk/src/main/java/cc/kune/gspace/client/actions/AbstractFoldableToolActions.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/actions/AbstractFoldableToolActions.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/gspace/client/actions/AbstractFoldableToolActions.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -28,25 +28,25 @@
public abstract class AbstractFoldableToolActions {
- protected final ActionRegistryByType actionsRegistry;
- protected final I18nUITranslationService i18n;
- protected final Session session;
- protected final StateManager stateManager;
+ protected final ActionRegistryByType actionsRegistry;
+ protected final I18nUITranslationService i18n;
+ protected final Session session;
+ protected final StateManager stateManager;
- public AbstractFoldableToolActions(final Session session, final StateManager stateManager,
- final I18nUITranslationService i18n, final ActionRegistryByType actionsRegistry) {
- this.session = session;
- this.stateManager = stateManager;
- this.i18n = i18n;
- this.actionsRegistry = actionsRegistry;
- session.onAppStart(true, new AppStartHandler() {
- @Override
- public void onAppStart(final AppStartEvent event) {
- createPostSessionInitActions();
- }
- });
- }
+ public AbstractFoldableToolActions(final Session session, final StateManager stateManager,
+ final I18nUITranslationService i18n, final ActionRegistryByType actionsRegistry) {
+ this.session = session;
+ this.stateManager = stateManager;
+ this.i18n = i18n;
+ this.actionsRegistry = actionsRegistry;
+ session.onAppStart(true, new AppStartHandler() {
+ @Override
+ public void onAppStart(final AppStartEvent event) {
+ createPostSessionInitActions();
+ }
+ });
+ }
- protected abstract void createPostSessionInitActions();
+ protected abstract void createPostSessionInitActions();
}
Modified: trunk/src/main/java/cc/kune/gspace/client/actions/DelContainerMenuItem.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/actions/DelContainerMenuItem.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/gspace/client/actions/DelContainerMenuItem.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -28,8 +28,8 @@
import cc.kune.core.client.actions.RolAction;
import cc.kune.core.client.resources.CoreResources;
import cc.kune.core.client.rpcservices.ContentServiceAsync;
-import cc.kune.core.client.state.Session;
import cc.kune.core.client.state.StateManager;
+import cc.kune.core.shared.SessionConstants;
import cc.kune.core.shared.domain.utils.StateToken;
import cc.kune.core.shared.dto.AbstractContentSimpleDTO;
import cc.kune.core.shared.dto.AccessRolDTO;
@@ -47,12 +47,12 @@
private final EventBus eventBus;
private final I18nTranslationService i18n;
private final Provider<FolderViewerPresenter> presenter;
- private final Session session;
+ private final SessionConstants session;
private final StateManager stateManager;
@Inject
public DelContainerAction(final EventBus eventBus, final StateManager stateManager,
- final Session session, final Provider<ContentServiceAsync> contentService,
+ final SessionConstants session, final Provider<ContentServiceAsync> contentService,
final I18nTranslationService i18n, final Provider<FolderViewerPresenter> presenter) {
super(AccessRolDTO.Administrator, true);
this.eventBus = eventBus;
Modified: trunk/src/main/java/cc/kune/gspace/client/actions/GiveUsFeedbackAction.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/actions/GiveUsFeedbackAction.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/gspace/client/actions/GiveUsFeedbackAction.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -82,7 +82,7 @@
} else {
signIn.get().setErrorMessage(i18n.t("Sign in or create an account to give us feedback"),
NotifyLevel.info);
- stateManager.gotoHistoryToken(TokenUtils.addRedirect(SiteTokens.SIGNIN,
+ stateManager.gotoHistoryToken(TokenUtils.addRedirect(SiteTokens.SIGN_IN,
session.getCurrentStateToken().toString()));
}
}
Modified: trunk/src/main/java/cc/kune/gspace/client/options/GroupOptions.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/options/GroupOptions.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/gspace/client/options/GroupOptions.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -21,5 +21,14 @@
public interface GroupOptions extends EntityOptions {
+ /**
+ * Show the group options dialog but also goes to this token (the group name
+ * usually).
+ *
+ * @param token
+ * the token
+ */
+ void show(String token);
+
void showTooltip();
}
Modified: trunk/src/main/java/cc/kune/gspace/client/options/GroupOptionsPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/options/GroupOptionsPresenter.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/gspace/client/options/GroupOptionsPresenter.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -26,11 +26,12 @@
import cc.kune.common.client.actions.ui.descrip.GuiActionDescrip;
import cc.kune.common.shared.i18n.I18nTranslationService;
import cc.kune.core.client.events.StateChangedEvent;
+import cc.kune.core.client.events.StateChangedEvent.StateChangedHandler;
import cc.kune.core.client.events.UserSignOutEvent;
-import cc.kune.core.client.events.StateChangedEvent.StateChangedHandler;
import cc.kune.core.client.events.UserSignOutEvent.UserSignOutHandler;
import cc.kune.core.client.resources.CoreResources;
import cc.kune.core.client.state.Session;
+import cc.kune.core.client.state.SiteTokenListeners;
import cc.kune.core.client.state.StateManager;
import cc.kune.core.client.ui.dialogs.tabbed.AbstractTabbedDialogPresenter;
import cc.kune.core.shared.dto.StateAbstractDTO;
@@ -63,7 +64,7 @@
@Inject
public GroupOptionsPresenter(final EventBus eventBus, final GroupOptionsProxy proxy,
final StateManager stateManager, final Session session, final I18nTranslationService i18n,
- final CoreResources img, final GroupOptionsView view) {
+ final CoreResources img, final GroupOptionsView view, final SiteTokenListeners tokenListener) {
super(eventBus, view, proxy);
this.stateManager = stateManager;
this.session = session;
@@ -118,9 +119,16 @@
getView().hide();
}
});
+
}
@Override
+ public void show(final String token) {
+ stateManager.gotoHistoryToken(token);
+ super.show();
+ }
+
+ @Override
public void showTooltip() {
prefsItem.toggleTooltipVisible();
}
Modified: trunk/src/main/java/cc/kune/gspace/client/options/UserOptionsPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/options/UserOptionsPresenter.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/gspace/client/options/UserOptionsPresenter.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -25,8 +25,8 @@
import cc.kune.common.client.actions.ui.descrip.MenuItemDescriptor;
import cc.kune.common.shared.i18n.I18nTranslationService;
import cc.kune.core.client.events.UserSignInEvent;
+import cc.kune.core.client.events.UserSignInEvent.UserSignInHandler;
import cc.kune.core.client.events.UserSignOutEvent;
-import cc.kune.core.client.events.UserSignInEvent.UserSignInHandler;
import cc.kune.core.client.events.UserSignOutEvent.UserSignOutHandler;
import cc.kune.core.client.resources.CoreResources;
import cc.kune.core.client.sitebar.SiteUserOptions;
@@ -86,9 +86,6 @@
@Override
public void actionPerformed(final ActionEvent event) {
- if (!session.isInCurrentUserSpace()) {
- stateManager.gotoStateToken(session.getCurrentUser().getStateToken());
- }
show();
}
};
@@ -104,4 +101,12 @@
prefsItem.setPosition(1);
userOptions.addAction(prefsItem);
}
+
+ @Override
+ public void show() {
+ if (!session.isInCurrentUserSpace()) {
+ stateManager.gotoStateToken(session.getCurrentUser().getStateToken());
+ }
+ super.show();
+ }
}
Modified: trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneral.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneral.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneral.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -21,4 +21,6 @@
public interface UserOptGeneral extends EntityOptGeneral {
+ void update();
+
}
Modified: trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPanel.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPanel.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -28,14 +28,20 @@
import cc.kune.core.shared.dto.I18nLanguageSimpleDTO;
import cc.kune.gspace.client.i18n.LanguageSelectorPanel;
+import com.extjs.gxt.ui.client.widget.form.AdapterField;
import com.extjs.gxt.ui.client.widget.form.FieldSet;
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
import com.extjs.gxt.ui.client.widget.form.Radio;
import com.extjs.gxt.ui.client.widget.form.TextField;
+import com.google.gwt.event.dom.client.HasClickHandlers;
+import com.google.gwt.user.client.ui.Button;
+import com.google.gwt.user.client.ui.Label;
import com.google.inject.Inject;
public class UserOptGeneralPanel extends EntityOptGeneralPanel implements UserOptGeneralView {
+ private static final String BIG_FIELD_SIZE = "310px";
+
public static final String DAILY_TYPE_ID = "k-ngp-type_daily";
public static final String HOURLY_TYPE_ID = "k-ngp-type_hourly";
public static final String IMMEDIATE_TYPE_ID = "k-ngp-type_immedi";
@@ -43,12 +49,17 @@
public static final String NO_TYPE_ID = "k-ngp-type_no";
public static final String TYPEOFEMAILNOTIF_FIELD = "k-ngp-type_of_email_notif";
private final Radio dailyRadio;
+ private final FieldSet emailNotifTypeFieldSet;
private final Radio hourlyRadio;
private final Radio immediateRadio;
private final LanguageSelectorPanel langSelector;
private final TextField<String> longName;
private final Radio noRadio;
+ private final AdapterField notVerifLabelAdapter;
+ private final AdapterField resendEmailVerifAdapter;
+ private final Button resendEmailVerifBtn;
+
@Inject
public UserOptGeneralPanel(final I18nUITranslationService i18n, final CoreResources res,
final MaskWidget maskWidget, final LanguageSelectorPanel langSelector,
@@ -62,11 +73,11 @@
langSelector.setLangSeparator(":");
add(langSelector);
- final FieldSet emailNotifTypeFieldSet = new FieldSet();
+ emailNotifTypeFieldSet = new FieldSet();
emailNotifTypeFieldSet.setHeading(i18n.t("How often do you want to receive email notifications?"));
emailNotifTypeFieldSet.addStyleName("k-form-fieldset");
emailNotifTypeFieldSet.setCollapsible(false);
- emailNotifTypeFieldSet.setWidth("310px");
+ emailNotifTypeFieldSet.setWidth(BIG_FIELD_SIZE);
emailNotifTypeFieldSet.setAutoHeight(true);
immediateRadio = DefaultFormUtils.createRadio(emailNotifTypeFieldSet, i18n.t("almost immediately"),
@@ -98,8 +109,25 @@
i18n.getSiteCommonName()), NO_TYPE_ID);
noRadio.setTabIndex(6);
noRadio.setValue(false);
+ add(emailNotifTypeFieldSet);
- add(emailNotifTypeFieldSet);
+ final Label notVerified = new Label(
+ i18n.t("Your email is not verified, so you will not receive email notifications"));
+ notVerified.setStyleName("oc-user-msg");
+ notVerified.addStyleName("k-3corners");
+ notVerifLabelAdapter = new AdapterField(notVerified);
+ notVerifLabelAdapter.setLabelSeparator("");
+ notVerifLabelAdapter.setWidth(BIG_FIELD_SIZE);
+ super.add(notVerifLabelAdapter);
+
+ resendEmailVerifBtn = new Button(i18n.t("Resend verification email"));
+ resendEmailVerifBtn.addStyleName("k-button");
+ resendEmailVerifAdapter = new AdapterField(resendEmailVerifBtn);
+ resendEmailVerifAdapter.setValidateOnBlur(false);
+ resendEmailVerifAdapter.setLabelSeparator("");
+ resendEmailVerifAdapter.setWidth(BIG_FIELD_SIZE);
+ // resendEmailVerifAdapter.setFieldLabel(i18n.t("Maybe you want receive again our verification email"));
+ add(resendEmailVerifAdapter);
}
@Override
@@ -128,6 +156,11 @@
}
@Override
+ public HasClickHandlers getResendEmailVerif() {
+ return resendEmailVerifBtn;
+ }
+
+ @Override
public void setEmailNotifChecked(final EmailNotificationFrequency freq) {
switch (freq) {
case no:
@@ -146,6 +179,13 @@
}
@Override
+ public void setEmailVerified(final boolean verified) {
+ resendEmailVerifAdapter.setVisible(!verified);
+ notVerifLabelAdapter.setVisible(!verified);
+ emailNotifTypeFieldSet.setVisible(verified);
+ }
+
+ @Override
public void setLanguage(final I18nLanguageSimpleDTO language) {
langSelector.setLanguage(language);
}
@@ -155,4 +195,9 @@
this.longName.setValue(longName);
}
+ @Override
+ public void setResendEmailVerifEnabled(final boolean enabled) {
+ resendEmailVerifBtn.setEnabled(enabled);
+ }
+
}
Modified: trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPresenter.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPresenter.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -34,7 +34,10 @@
import cc.kune.core.shared.dto.UserSimpleDTO;
import cc.kune.gspace.client.options.UserOptions;
+import com.google.gwt.event.dom.client.ClickEvent;
+import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.shared.EventBus;
+import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.inject.Inject;
import com.google.inject.Provider;
@@ -67,6 +70,22 @@
@Override
public void init(final EntityOptGeneralView view) {
super.init(view);
+ userView.getResendEmailVerif().addClickHandler(new ClickHandler() {
+ @Override
+ public void onClick(final ClickEvent event) {
+ userView.setResendEmailVerifEnabled(false);
+ userService.get().askForEmailConfirmation(session.getUserHash(), new AsyncCallback<Void>() {
+ @Override
+ public void onFailure(final Throwable caught) {
+ }
+
+ @Override
+ public void onSuccess(final Void result) {
+ NotifyUser.info("Sended. Check your email for the verification link.");
+ }
+ });
+ }
+ });
}
@Override
@@ -75,9 +94,16 @@
userView.setLongName(currentUser.getName());
userView.setLanguage(I18nLanguageSimpleDTO.create(currentUser.getLanguage()));
userView.setEmailNotifChecked(currentUser.getEmailNotifFreq());
+ userView.setEmailVerified(currentUser.isEmailVerified());
+ userView.setResendEmailVerifEnabled(!currentUser.isEmailVerified());
}
@Override
+ public void update() {
+ setState();
+ }
+
+ @Override
protected void updateInServer() {
if (view.isValid()) {
NotifyUser.showProgress();
Modified: trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralView.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralView.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralView.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -22,6 +22,8 @@
import cc.kune.core.shared.domain.dto.EmailNotificationFrequency;
import cc.kune.core.shared.dto.I18nLanguageSimpleDTO;
+import com.google.gwt.event.dom.client.HasClickHandlers;
+
public interface UserOptGeneralView extends EntityOptGeneralView {
EmailNotificationFrequency getEmailNotif();
@@ -30,10 +32,16 @@
String getLongName();
+ HasClickHandlers getResendEmailVerif();
+
+ void setEmailVerified(boolean verified);
+
void setEmailNotifChecked(EmailNotificationFrequency freq);
void setLanguage(I18nLanguageSimpleDTO language);
void setLongName(String longName);
+ void setResendEmailVerifEnabled(boolean enabled);
+
}
Modified: trunk/src/main/java/cc/kune/gspace/client/tags/TagsSummaryPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/tags/TagsSummaryPresenter.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/gspace/client/tags/TagsSummaryPresenter.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -41,85 +41,87 @@
import com.gwtplatform.mvp.client.proxy.RevealRootContentEvent;
public class TagsSummaryPresenter extends
- Presenter<TagsSummaryPresenter.TagsSummaryView, TagsSummaryPresenter.TagsSummaryProxy> implements TagsSummary {
+ Presenter<TagsSummaryPresenter.TagsSummaryView, TagsSummaryPresenter.TagsSummaryProxy> implements
+ TagsSummary {
- public interface TagsSummaryView extends View {
- void addTag(String name, Long count, String style, ClickHandler clickHandler);
+ @ProxyCodeSplit
+ public interface TagsSummaryProxy extends Proxy<TagsSummaryPresenter> {
+ }
- void clear();
+ public interface TagsSummaryView extends View {
+ void addTag(String name, Long count, String style, ClickHandler clickHandler);
- void setVisible(boolean visible);
- }
+ void clear();
- @ProxyCodeSplit
- public interface TagsSummaryProxy extends Proxy<TagsSummaryPresenter> {
- }
+ void setVisible(boolean visible);
+ }
- private static final int MINSIZE = 11;
- private static final int MAXSIZE = 26;
+ private static final int MAXSIZE = 26;
+ private static final int MINSIZE = 11;
- @Override
- protected void revealInParent() {
- RevealRootContentEvent.fire(this, this);
- }
+ @Inject
+ public TagsSummaryPresenter(final EventBus eventBus, final TagsSummaryView view,
+ final TagsSummaryProxy proxy, final Session session, final StateManager stateManager) {
+ super(eventBus, view, proxy);
+ stateManager.onStateChanged(true, new StateChangedHandler() {
+ @Override
+ public void onStateChanged(final StateChangedEvent event) {
+ final StateAbstractDTO state = event.getState();
+ if (state instanceof StateContainerDTO) {
+ setState((StateContainerDTO) state);
+ } else {
+ getView().setVisible(false);
+ }
+ }
+ });
+ }
- @Inject
- public TagsSummaryPresenter(EventBus eventBus, TagsSummaryView view, TagsSummaryProxy proxy, final Session session,
- final StateManager stateManager) {
- super(eventBus, view, proxy);
- stateManager.onStateChanged(true, new StateChangedHandler() {
- @Override
- public void onStateChanged(StateChangedEvent event) {
- StateAbstractDTO state = event.getState();
- if (state instanceof StateContainerDTO) {
- setState((StateContainerDTO) state);
- } else {
- getView().setVisible(false);
- }
- }
- });
- }
+ public void doSearchTag(final String name) {
+ // searcherProvider.get().doSearchOfType(
+ // "group:" + session.getCurrentState().getGroup().getShortName() +
+ // " tag:" + name,
+ // SiteSearcherType.content);
+ NotifyUser.info("Searcher in development");
+ }
- public void doSearchTag(final String name) {
- // searcherProvider.get().doSearchOfType(
- // "group:" + session.getCurrentState().getGroup().getShortName() +
- // " tag:" + name,
- // SiteSearcherType.content);
- NotifyUser.info("Searcher in development");
- }
+ @Override
+ protected void revealInParent() {
+ RevealRootContentEvent.fire(this, this);
+ }
- public void setGroupTags(final TagCloudResult tagCloud) {
- setCloud(tagCloud);
- getView().setVisible(true);
- }
-
- // @PMD:REVIEWED:DefaultPackage: by vjrj on 27/05/09 3:13
- void setState(final StateContainerDTO state) {
- if (state.getTagCloudResult() != null && state.getTagCloudResult().getTagCountList().size() > 0) {
- Log.debug(state.getTagCloudResult().toString());
- setCloud(state.getTagCloudResult());
- getView().setVisible(true);
- } else {
- getView().setVisible(false);
+ private void setCloud(final TagCloudResult tagCloudResult) {
+ // Inspired in snippet http://www.bytemycode.com/snippets/snippet/415/
+ getView().clear();
+ final int max = tagCloudResult.getMaxValue();
+ final int min = tagCloudResult.getMinValue();
+ final int diff = max - min;
+ final int step = (MAXSIZE - MINSIZE) / (diff == 0 ? 1 : diff);
+ for (final TagCount tagCount : tagCloudResult.getTagCountList()) {
+ final String name = tagCount.getName();
+ final int size = Math.round((MINSIZE + (tagCount.getCount().floatValue() - min) * step));
+ getView().addTag(name, tagCount.getCount(), "kune-ft" + size + "px", new ClickHandler() {
+ @Override
+ public void onClick(final ClickEvent event) {
+ doSearchTag(name);
}
+ });
}
+ }
- private void setCloud(final TagCloudResult tagCloudResult) {
- // Inspired in snippet http://www.bytemycode.com/snippets/snippet/415/
- getView().clear();
- final int max = tagCloudResult.getMaxValue();
- final int min = tagCloudResult.getMinValue();
- final int diff = max - min;
- final int step = (MAXSIZE - MINSIZE) / (diff == 0 ? 1 : diff);
- for (final TagCount tagCount : tagCloudResult.getTagCountList()) {
- final String name = tagCount.getName();
- final int size = Math.round((MINSIZE + (tagCount.getCount().floatValue() - min) * step));
- getView().addTag(name, tagCount.getCount(), "kune-ft" + size + "px", new ClickHandler() {
- @Override
- public void onClick(ClickEvent event) {
- doSearchTag(name);
- }
- });
- }
+ @Override
+ public void setGroupTags(final TagCloudResult tagCloud) {
+ setCloud(tagCloud);
+ getView().setVisible(true);
+ }
+
+ // @PMD:REVIEWED:DefaultPackage: by vjrj on 27/05/09 3:13
+ void setState(final StateContainerDTO state) {
+ if (state.getTagCloudResult() != null && state.getTagCloudResult().getTagCountList().size() > 0) {
+ Log.debug(state.getTagCloudResult().toString());
+ setCloud(state.getTagCloudResult());
+ getView().setVisible(true);
+ } else {
+ getView().setVisible(false);
}
+ }
}
Modified: trunk/src/main/java/cc/kune/hspace/client/HSpacePanel.java
===================================================================
--- trunk/src/main/java/cc/kune/hspace/client/HSpacePanel.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/hspace/client/HSpacePanel.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -117,7 +117,7 @@
tabPanel.addTab(lastGroupsPanel);
tabPanel.addTab(lastPublishedPanel);
globalStats.removeFromParent();
- unreadInYourInbox.setTargetHistoryToken(SiteTokens.WAVEINBOX);
+ unreadInYourInbox.setTargetHistoryToken(SiteTokens.WAVE_INBOX);
globalStatsParent = RootPanel.get(K_HOME_GLOBAL_STATS);
groupStatsParent = RootPanel.get(K_HOME_GROUP_STATS);
if (globalStatsParent != null) {
Modified: trunk/src/main/java/cc/kune/lists/client/ListsParts.java
===================================================================
--- trunk/src/main/java/cc/kune/lists/client/ListsParts.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/lists/client/ListsParts.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -19,7 +19,7 @@
*/
package cc.kune.lists.client;
-import cc.kune.core.client.state.Session;
+import cc.kune.core.shared.SessionConstants;
import cc.kune.gspace.client.tool.ContentViewerSelector;
import cc.kune.gspace.client.viewers.ContentViewerPresenter;
import cc.kune.gspace.client.viewers.FolderViewerPresenter;
@@ -32,7 +32,7 @@
public class ListsParts {
@Inject
- public ListsParts(final Session session, final Provider<ListsClientTool> clientTool,
+ public ListsParts(final SessionConstants session, final Provider<ListsClientTool> clientTool,
final ContentViewerSelector viewerSelector, final ListsClientActions listsActions,
final ContentViewerPresenter contentViewer, final FolderViewerPresenter folderViewer) {
clientTool.get();
Modified: trunk/src/main/java/cc/kune/lists/client/actions/NewListPostAction.java
===================================================================
--- trunk/src/main/java/cc/kune/lists/client/actions/NewListPostAction.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/lists/client/actions/NewListPostAction.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -114,7 +114,7 @@
} else {
signIn.get().setErrorMessage(i18n.t("Sign in or create an account to susbscribe to this list"),
NotifyLevel.info);
- stateManager.gotoHistoryToken(TokenUtils.addRedirect(SiteTokens.SIGNIN,
+ stateManager.gotoHistoryToken(TokenUtils.addRedirect(SiteTokens.SIGN_IN,
session.getCurrentStateToken().toString()));
}
}
Modified: trunk/src/main/java/cc/kune/lists/client/actions/SubscriteToListAction.java
===================================================================
--- trunk/src/main/java/cc/kune/lists/client/actions/SubscriteToListAction.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/lists/client/actions/SubscriteToListAction.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -81,7 +81,7 @@
} else {
signIn.get().setErrorMessage(i18n.t("Sign in or create an account to susbscribe to this list"),
NotifyLevel.info);
- stateManager.gotoHistoryToken(TokenUtils.addRedirect(SiteTokens.SIGNIN,
+ stateManager.gotoHistoryToken(TokenUtils.addRedirect(SiteTokens.SIGN_IN,
session.getCurrentStateToken().toString()));
}
}
Modified: trunk/src/main/java/cc/kune/tasks/client/TasksParts.java
===================================================================
--- trunk/src/main/java/cc/kune/tasks/client/TasksParts.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/tasks/client/TasksParts.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -19,7 +19,7 @@
*/
package cc.kune.tasks.client;
-import cc.kune.core.client.state.Session;
+import cc.kune.core.shared.SessionConstants;
import cc.kune.gspace.client.tool.ContentViewerSelector;
import cc.kune.gspace.client.viewers.ContentViewerPresenter;
import cc.kune.gspace.client.viewers.FolderViewerPresenter;
@@ -32,7 +32,7 @@
public class TasksParts {
@Inject
- public TasksParts(final Session session, final Provider<TasksClientTool> clientTool,
+ public TasksParts(final SessionConstants session, final Provider<TasksClientTool> clientTool,
final ContentViewerSelector viewerSelector, final TasksClientActions tasksActions,
final ContentViewerPresenter contentViewer, final FolderViewerPresenter folderViewer) {
clientTool.get();
Modified: trunk/src/main/java/cc/kune/wave/client/WebClient.java
===================================================================
--- trunk/src/main/java/cc/kune/wave/client/WebClient.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/wave/client/WebClient.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -443,7 +443,7 @@
});
final String encodedToken = History.getToken();
// Kune patch
- if (encodedToken != null && !encodedToken.isEmpty() && !encodedToken.equals(SiteTokens.WAVEINBOX)) {
+ if (encodedToken != null && !encodedToken.isEmpty() && !encodedToken.equals(SiteTokens.WAVE_INBOX)) {
WaveRef fromWaveRef;
try {
fromWaveRef = GwtWaverefEncoder.decodeWaveRefFromPath(encodedToken);
Modified: trunk/src/main/java/cc/kune/wave/server/kspecific/WaveEmailNotifier.java
===================================================================
--- trunk/src/main/java/cc/kune/wave/server/kspecific/WaveEmailNotifier.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/wave/server/kspecific/WaveEmailNotifier.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -111,7 +111,7 @@
private FormatedString removeWaveTemplate(final String by, final String title) {
return FormatedString.build(
"Hi there,<br><br>You have been removed by '%s' from message '%s' at %s. <a href=\"%s#%s\">Read more</a>.<br>",
- by, title, siteCommonName, siteUrl, SiteTokens.WAVEINBOX);
+ by, title, siteCommonName, siteUrl, SiteTokens.WAVE_INBOX);
}
private FormatedString updatedWaveTemplate(final String by, final String title, final String url) {
Modified: trunk/src/main/java/cc/kune/wiki/client/WikiParts.java
===================================================================
--- trunk/src/main/java/cc/kune/wiki/client/WikiParts.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/java/cc/kune/wiki/client/WikiParts.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -19,7 +19,7 @@
*/
package cc.kune.wiki.client;
-import cc.kune.core.client.state.Session;
+import cc.kune.core.shared.SessionConstants;
import cc.kune.gspace.client.tool.ContentViewerSelector;
import cc.kune.gspace.client.viewers.ContentViewerPresenter;
import cc.kune.gspace.client.viewers.FolderViewerPresenter;
@@ -32,7 +32,7 @@
public class WikiParts {
@Inject
- public WikiParts(final Session session, final Provider<WikiClientTool> clientTool,
+ public WikiParts(final SessionConstants session, final Provider<WikiClientTool> clientTool,
final ContentViewerSelector viewerSelector, final WikiClientActions wikiActions,
final ContentViewerPresenter contentViewer, final FolderViewerPresenter folderViewer) {
clientTool.get();
Modified: trunk/src/main/resources/kune.properties
===================================================================
--- trunk/src/main/resources/kune.properties 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/main/resources/kune.properties 2012-01-16 20:53:44 UTC (rev 1663)
@@ -78,7 +78,7 @@
### Other params
# Reserved words to avoid it's use in the client side for user and group names (see client tokens used in SiteTokens)
-kune.server.names.reservedwords = root,adm,kune,fuck,about,home,newgroup,preview,register,signin,translate,inbox,sub,www,ftp,pop,pop3,smtp,mail,wave
+kune.server.names.reservedwords = root,adm,kune,fuck,about,home,newgroup,preview,register,signin,translate,inbox,sub,www,ftp,pop,pop3,smtp,mail,wave,resetpasswd,verifyemail,prefs,gprefs
# If defined create a copy of this wave as welcome to new users
# kune.site.welcomewave = w+rtackLTkDCA
Modified: trunk/src/test/java/cc/kune/core/client/state/impl/StateManagerDefaultTest.java
===================================================================
--- trunk/src/test/java/cc/kune/core/client/state/impl/StateManagerDefaultTest.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/test/java/cc/kune/core/client/state/impl/StateManagerDefaultTest.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -29,16 +29,16 @@
import cc.kune.common.client.actions.BeforeActionListener;
import cc.kune.core.client.events.AppStartEvent;
-import cc.kune.core.client.events.GroupChangedEvent;
-import cc.kune.core.client.events.StateChangedEvent;
-import cc.kune.core.client.events.ToolChangedEvent;
-import cc.kune.core.client.events.UserSignInEvent;
-import cc.kune.core.client.events.UserSignOutEvent;
import cc.kune.core.client.events.AppStartEvent.AppStartHandler;
+import cc.kune.core.client.events.GroupChangedEvent;
import cc.kune.core.client.events.GroupChangedEvent.GroupChangedHandler;
+import cc.kune.core.client.events.StateChangedEvent;
import cc.kune.core.client.events.StateChangedEvent.StateChangedHandler;
+import cc.kune.core.client.events.ToolChangedEvent;
import cc.kune.core.client.events.ToolChangedEvent.ToolChangedHandler;
+import cc.kune.core.client.events.UserSignInEvent;
import cc.kune.core.client.events.UserSignInEvent.UserSignInHandler;
+import cc.kune.core.client.events.UserSignOutEvent;
import cc.kune.core.client.events.UserSignOutEvent.UserSignOutHandler;
import cc.kune.core.client.state.ContentCache;
import cc.kune.core.client.state.HistoryTokenCallback;
@@ -47,7 +47,6 @@
import cc.kune.core.client.state.SiteTokenListeners;
import cc.kune.core.client.state.SiteTokens;
import cc.kune.core.client.state.TokenMatcher;
-import cc.kune.core.client.state.impl.StateManagerDefault;
import cc.kune.core.shared.domain.utils.StateToken;
import cc.kune.core.shared.dto.InitDataDTO;
import cc.kune.core.shared.dto.StateAbstractDTO;
@@ -237,7 +236,6 @@
return newToken;
}
- @SuppressWarnings("unchecked")
@Test
public void getDefGroup() {
stateManager.processHistoryToken("site.docs");
@@ -248,7 +246,6 @@
stateManager.processHistoryToken("example.com/w+abcd/~/conv+root/b+45kg");
}
- @SuppressWarnings("unchecked")
@Test
public void normalStartLoggedUser() {
// When a user enter reload state, also if the application is starting
@@ -258,7 +255,6 @@
verifyGetServerContent();
}
- @SuppressWarnings("unchecked")
@Test
public void oneBeforeStateChangeListenerAddAndRemove() {
final String newToken = confBeforeStateChangeListeners(false, false);
@@ -294,7 +290,6 @@
(StateToken) Mockito.anyObject(), (AsyncCallback<StateAbstractDTO>) Mockito.anyObject());
}
- @SuppressWarnings("unchecked")
@Test
public void oneBeforeStateChangeListenerReturnTrue() {
stateManager.processHistoryToken(confBeforeStateChangeListeners(true, true));
@@ -306,13 +301,12 @@
stateManager.removeBeforeStateChangeListener(beforeChangeListener2);
}
- @SuppressWarnings("unchecked")
@Test
public void siteTokenFirstLoadDefContentAndFireListener() {
final HistoryTokenCallback listener = Mockito.mock(HistoryTokenCallback.class);
- final String token = SiteTokens.SIGNIN;
+ final String token = SiteTokens.SIGN_IN;
stateManager.addSiteToken(token, listener);
- Mockito.when(siteTokens.get(SiteTokens.SIGNIN)).thenReturn(listener);
+ Mockito.when(siteTokens.get(SiteTokens.SIGN_IN)).thenReturn(listener);
stateManager.processHistoryToken(token);
Mockito.verify(listener, Mockito.times(1)).onHistoryToken(Mockito.anyString());
verifyGetServerContent();
@@ -321,8 +315,8 @@
@Test
public void siteTokenTest() {
final HistoryTokenCallback listener = Mockito.mock(HistoryTokenCallback.class);
- stateManager.addSiteToken(SiteTokens.SIGNIN, listener);
- Mockito.when(siteTokens.get(SiteTokens.SIGNIN)).thenReturn(listener);
+ stateManager.addSiteToken(SiteTokens.SIGN_IN, listener);
+ Mockito.when(siteTokens.get(SiteTokens.SIGN_IN)).thenReturn(listener);
stateManager.processHistoryToken("signIn");
Mockito.verify(listener, Mockito.times(1)).onHistoryToken(Mockito.anyString());
}
@@ -335,6 +329,7 @@
verifyGetServerContent();
}
+ @SuppressWarnings("unchecked")
private void verifyGetServerContent() {
Mockito.verify(contentProvider, Mockito.times(1)).getContent(Mockito.anyString(),
(StateToken) Mockito.anyObject(), (AsyncCallback<StateAbstractDTO>) Mockito.anyObject());
Modified: trunk/src/test/java/cc/kune/core/server/mail/MailServiceDefaultTest.java
===================================================================
--- trunk/src/test/java/cc/kune/core/server/mail/MailServiceDefaultTest.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/test/java/cc/kune/core/server/mail/MailServiceDefaultTest.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -39,4 +39,12 @@
service.sendPlain(FormatedString.build("Some test subject"), FormatedString.build("Some body"),
"vjrj@localhost");
}
+
+ @Test
+ public void utf8Test() {
+ service.sendPlain(FormatedString.build("áéíóú"), FormatedString.build("Some body áéíóú"),
+ "vjrj@localhost");
+ service.sendHtml(FormatedString.build("áéíóú"), FormatedString.build("Some body áéíóú"),
+ "vjrj@localhost");
+ }
}
Added: trunk/src/test/java/cc/kune/core/shared/utils/SharedFileDownloadUtilsTest.java
===================================================================
--- trunk/src/test/java/cc/kune/core/shared/utils/SharedFileDownloadUtilsTest.java (rev 0)
+++ trunk/src/test/java/cc/kune/core/shared/utils/SharedFileDownloadUtilsTest.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -0,0 +1,46 @@
+package cc.kune.core.shared.utils;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public class SharedFileDownloadUtilsTest {
+
+ private static final String GROUP = "groupname";
+ private SharedFileDownloadUtils noPrefixUtils;
+ private SharedFileDownloadUtils prefixUtils;
+
+ @Before
+ public void before() {
+ prefixUtils = new SharedFileDownloadUtils("http://example.org");
+ noPrefixUtils = new SharedFileDownloadUtils("");
+ }
+
+ @Test
+ public void testGetLogoHtml() {
+ assertTrue(prefixUtils.getLogoAvatarHtml(GROUP, false, false, 50, 5).contains(
+ "'http://example.org/others/defgroup.gif"));
+ assertTrue(noPrefixUtils.getLogoAvatarHtml(GROUP, false, true, 50, 5),
+ prefixUtils.getLogoAvatarHtml(GROUP, false, true, 50, 5).contains("/others/unknown.jpg"));
+ assertTrue(
+ prefixUtils.getLogoAvatarHtml(GROUP, true, false, 50, 5),
+ prefixUtils.getLogoAvatarHtml(GROUP, true, false, 50, 5).contains(
+ "'http://example.org/ws/servlets/EntityLogoDownloadManager?token=groupname"));
+ assertTrue(
+ noPrefixUtils.getLogoAvatarHtml(GROUP, true, true, 50, 5),
+ noPrefixUtils.getLogoAvatarHtml(GROUP, true, true, 50, 5).contains(
+ "/ws/servlets/EntityLogoDownloadManager?token=groupname"));
+ assertTrue(!noPrefixUtils.getLogoAvatarHtml(GROUP, true, true, 50, 5).contains("http"));
+ }
+
+ @Test
+ public void testUserAvatar() {
+ assertEquals("http://example.org/ws/servlets/UserLogoDownloadManager?username=groupname",
+ prefixUtils.getUserAvatar(GROUP));
+ assertEquals("/ws/servlets/UserLogoDownloadManager?username=groupname",
+ noPrefixUtils.getUserAvatar(GROUP));
+ }
+
+}
Modified: trunk/src/test/java/cc/kune/gspace/client/tags/TagsSummaryPresenterTest.java
===================================================================
--- trunk/src/test/java/cc/kune/gspace/client/tags/TagsSummaryPresenterTest.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/test/java/cc/kune/gspace/client/tags/TagsSummaryPresenterTest.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -31,51 +31,50 @@
import cc.kune.core.shared.domain.TagCloudResult;
import cc.kune.core.shared.domain.TagCount;
import cc.kune.core.shared.dto.StateContainerDTO;
-import cc.kune.gspace.client.tags.TagsSummaryPresenter;
import cc.kune.gspace.client.tags.TagsSummaryPresenter.TagsSummaryProxy;
import cc.kune.gspace.client.tags.TagsSummaryPresenter.TagsSummaryView;
public class TagsSummaryPresenterTest {
- private TagsSummaryPresenter tagsSummaryPresenter;
- private TagsSummaryView view;
+ private TagsSummaryPresenter tagsSummaryPresenter;
+ private TagsSummaryView view;
- @SuppressWarnings("unchecked")
- @Before
- public void before() {
- final Session session = Mockito.mock(Session.class);
- final StateManager stateManager = Mockito.mock(StateManager.class);
- // final SiteSearcher searcher = Mockito.mock(SiteSearcher.class);
- TagsSummaryProxy proxy = Mockito.mock(TagsSummaryProxy.class);
- // Mockito.when(searcherProvider.get()).thenReturn(searcher);
- view = Mockito.mock(TagsSummaryView.class);
- EventBusTester eventBus = new EventBusTester();
- tagsSummaryPresenter = new TagsSummaryPresenter(eventBus, view, proxy, session, stateManager);
- }
+ @SuppressWarnings("unchecked")
+ @Before
+ public void before() {
+ final Session session = Mockito.mock(Session.class);
+ final StateManager stateManager = Mockito.mock(StateManager.class);
+ // final SiteSearcher searcher = Mockito.mock(SiteSearcher.class);
+ final TagsSummaryProxy proxy = Mockito.mock(TagsSummaryProxy.class);
+ // Mockito.when(searcherProvider.get()).thenReturn(searcher);
+ view = Mockito.mock(TagsSummaryView.class);
+ final EventBusTester eventBus = new EventBusTester();
+ tagsSummaryPresenter = new TagsSummaryPresenter(eventBus, view, proxy, session, stateManager);
+ }
- @Test
- public void noTagsViewNotVisible() {
- final StateContainerDTO state = new StateContainerDTO();
- tagsSummaryPresenter.setState(state);
- Mockito.verify(view).setVisible(false);
- }
+ @Test
+ public void noTagsViewNotVisible() {
+ final StateContainerDTO state = new StateContainerDTO();
+ tagsSummaryPresenter.setState(state);
+ Mockito.verify(view).setVisible(false);
+ }
- @Test
- public void withTagsViewFalse() {
- final StateContainerDTO state = new StateContainerDTO();
- final ArrayList<TagCount> list = new ArrayList<TagCount>();
- state.setTagCloudResult(new TagCloudResult(list, 0, 0));
- tagsSummaryPresenter.setState(state);
- Mockito.verify(view).setVisible(false);
- }
+ @Test
+ public void withTagsViewFalse() {
+ final StateContainerDTO state = new StateContainerDTO();
+ final ArrayList<TagCount> list = new ArrayList<TagCount>();
+ state.setTagCloudResult(new TagCloudResult(list, 0, 0));
+ tagsSummaryPresenter.setState(state);
+ Mockito.verify(view).setVisible(false);
+ }
- @Test
- public void withTagsViewVisible() {
- final StateContainerDTO state = new StateContainerDTO();
- final ArrayList<TagCount> list = new ArrayList<TagCount>();
- list.add(new TagCount("abc", 1L));
- state.setTagCloudResult(new TagCloudResult(list, 0, 0));
- tagsSummaryPresenter.setState(state);
- Mockito.verify(view).setVisible(true);
- }
+ @Test
+ public void withTagsViewVisible() {
+ final StateContainerDTO state = new StateContainerDTO();
+ final ArrayList<TagCount> list = new ArrayList<TagCount>();
+ list.add(new TagCount("abc", 1L));
+ state.setTagCloudResult(new TagCloudResult(list, 0, 0));
+ tagsSummaryPresenter.setState(state);
+ Mockito.verify(view).setVisible(true);
+ }
}
Modified: trunk/src/test/java/cc/kune/selenium/login/ScreenCastsViaSeleniumTests.java
===================================================================
--- trunk/src/test/java/cc/kune/selenium/login/ScreenCastsViaSeleniumTests.java 2012-01-16 10:30:38 UTC (rev 1662)
+++ trunk/src/test/java/cc/kune/selenium/login/ScreenCastsViaSeleniumTests.java 2012-01-16 20:53:44 UTC (rev 1663)
@@ -133,7 +133,7 @@
sleep(2000);
showTitleSlide(t("Chat with your buddies"), t("compatible with gmail and similars"),
- SiteTokens.WAVEINBOX);
+ SiteTokens.WAVE_INBOX);
// showTooltip(chat.icon());
chat.show();
sleep(2000);
1
0
r1662 - in trunk: img/screenshots src/test/java/cc/kune/selenium src/test/java/cc/kune/selenium/login src/test/java/cc/kune/selenium/spaces
by Vicente J. Ruiz Jurado 16 Jan '12
by Vicente J. Ruiz Jurado 16 Jan '12
16 Jan '12
Author: vjrj_
Date: 2012-01-16 11:30:38 +0100 (Mon, 16 Jan 2012)
New Revision: 1662
Added:
trunk/img/screenshots/kune-newgroup.png
trunk/src/test/java/cc/kune/selenium/login/ScreenCastsViaSeleniumTests.java
Removed:
trunk/src/test/java/cc/kune/selenium/login/RegisterSeleniumTests.java
Modified:
trunk/img/screenshots/kune-register.png
trunk/src/test/java/cc/kune/selenium/SeleniumConf.java
trunk/src/test/java/cc/kune/selenium/login/RegisterPageObject.java
trunk/src/test/java/cc/kune/selenium/spaces/GroupSpacePageObject.java
Log:
Screencast improved (work in progress)
Added: trunk/img/screenshots/kune-newgroup.png
===================================================================
(Binary files differ)
Property changes on: trunk/img/screenshots/kune-newgroup.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/img/screenshots/kune-register.png
===================================================================
(Binary files differ)
Modified: trunk/src/test/java/cc/kune/selenium/SeleniumConf.java
===================================================================
--- trunk/src/test/java/cc/kune/selenium/SeleniumConf.java 2012-01-12 14:45:36 UTC (rev 1661)
+++ trunk/src/test/java/cc/kune/selenium/SeleniumConf.java 2012-01-16 10:30:38 UTC (rev 1662)
@@ -56,8 +56,8 @@
public static final Driver DRIVER = Driver.firefox;
/* Configure this for use other lang, site, or driver */
- public static final Lang LANG = Lang.es;
- public static final Site SITE = Site.localhost;
+ public static final Lang LANG = Lang.en;
+ public static final Site SITE = Site.demo;
public static final int TIMEOUT = 25;
SeleniumConf() {
Modified: trunk/src/test/java/cc/kune/selenium/login/RegisterPageObject.java
===================================================================
--- trunk/src/test/java/cc/kune/selenium/login/RegisterPageObject.java 2012-01-12 14:45:36 UTC (rev 1661)
+++ trunk/src/test/java/cc/kune/selenium/login/RegisterPageObject.java 2012-01-16 10:30:38 UTC (rev 1662)
@@ -65,7 +65,7 @@
hightlight(registerButton);
if (doScreenshot) {
SeleniumUtils.doScreenshot(getWebDriver(), "register");
- sleep(4000);
+ sleep(2000);
}
if (withReturn) {
email.sendKeys(Keys.RETURN);
Deleted: trunk/src/test/java/cc/kune/selenium/login/RegisterSeleniumTests.java
===================================================================
--- trunk/src/test/java/cc/kune/selenium/login/RegisterSeleniumTests.java 2012-01-12 14:45:36 UTC (rev 1661)
+++ trunk/src/test/java/cc/kune/selenium/login/RegisterSeleniumTests.java 2012-01-16 10:30:38 UTC (rev 1662)
@@ -1,153 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2011 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package cc.kune.selenium.login;
-
-import org.openqa.selenium.Keys;
-import org.testng.annotations.Test;
-
-import cc.kune.core.client.state.SiteTokens;
-import cc.kune.selenium.KuneSeleniumTest;
-import cc.kune.selenium.SeleniumConf;
-import cc.kune.selenium.SeleniumConstants;
-import cc.kune.selenium.SeleniumUtils;
-
-import com.calclab.emite.core.client.xmpp.stanzas.XmppURI;
-
-public class RegisterSeleniumTests extends KuneSeleniumTest {
-
- @Test(dataProvider = "correctregister")
- public void basicRegister(final String shortNameUntrans, final String longNameUntrans,
- final String passwd, final String emailUntrans) {
- final String shortName = t(shortNameUntrans);
- final String longName = t(longNameUntrans);
- final String email = t(emailUntrans);
- SeleniumUtils.fastSpeed(false);
- // 15 chars, the limit, so we don't use shortName
- final String prefix = getTempString();
- showTitleSlide(t("User registration"), t("to get full access to this site tools/contents"));
- login.createOne();
- register.fillRegisterForm(shortName + prefix, longName + prefix, passwd, prefix + email, false, true);
- doScreenshot("register");
- sleep(1000);
- login.assertIsConnectedAs(prefix);
- entityHeader.waitForEntityTitle(longName + prefix);
- register.getWelcomeMsg().click();
-
- // home space
- showTitleSlide(t("Home space (your welcome page)"),
- t("Here you can see a summary of your activity in this site"));
- site.homeSpaceBtn.click();
- sleep(2000);
- homeSpace.getSndStats().click();
- sleep(2000);
- homeSpace.getTrdStats().click();
- sleep(2000);
-
- // user space
- showTitleSlide(t("User space (your Inbox)"), t("contents in which you participate"));
- showTooltip(site.userSpaceBtn);
- site.userSpaceBtn.click();
- showMsg(t("You can see this like an advanced email system..."));
- userSpace.getFirstWave().click();
- sleep(2000);
- userSpace.getNewWave().click();
- showMsg(t("where you can compose personal messages..."));
- showMsg(t("but also create contents to publish later"));
- userSpace.rootBlipText().sendKeys(t("Congratulations for your report\n\n"));
- sleep(1000);
- userSpace.getCursive().click();
- userSpace.rootBlipText().sendKeys(
- t("Hi there, Just to say that I like") + t("a lot your last report\n\n"));
- sleep(1000);
- userSpace.getCursive().click();
- userSpace.rootBlipText().sendKeys(t("Best\n\nJane"));
- sleep(3000);
- userSpace.getRootEdit().click();
- userSpace.getAddParcipant().click();
- sleep(1000);
- answerOnNextPrompt("admin");
- sleep(5000);
-
- // group space
- showTitleSlide(t("Your personal public space"), t("here you can have your blog, etc"));
- sleep(500);
- site.groupSpaceBtn.click();
- site.groupSpaceBtn.click();
- showMsg(t("Let's start adding some buddie to our social network"));
- sleep(1000);
- groupSpace.addBuddieBtn().click();
- groupSpace.addNewBuddieTextBox.click();
- groupSpace.addNewBuddieTextBox.sendKeys("admin");
- groupSpace.addNewBuddieTextBox.sendKeys(Keys.ARROW_DOWN);
- sleep(500);
- groupSpace.firstFromSuggestionBox.click();
- site.confirmationOk.click();
- sleep(500);
- groupSpace.searchEntitiesOk().click();
- // groupSpace.firstAvatarOfGroup().click();
- sleep(2000);
-
- showTitleSlide(t("Chat with your buddies"), t("compatible with gmail and similars"),
- SiteTokens.WAVEINBOX);
- // showTooltip(chat.icon());
- chat.show();
- sleep(2000);
-
- final XmppURI jid = XmppURI.jid(SeleniumConstants.USER_SHORNAME + "@"
- + SeleniumConf.SITE.getDomain());
- final String jids = jid.toString();
- chat.getRosterItem("", jids).click();
-
- // chat.openChat(jid);
-
- // chat.getPage(jids).click();
- chat.getTalkBox(jids).sendKeys(t("Helloo... ;)"));
- chat.getSend(jids).click();
- chat.getTalkBox(jids).sendKeys(t("I'm just testing"));
- chat.getSend(jids).click();
-
- showMsg(t("And you can chat event while going back/forward with your browser"));
- site.homeSpaceBtn.click();
- sleep(2000);
- chat.getTalkBox(jids).sendKeys(t("la la la"));
- chat.getSend(jids).click();
- showMsg(t("Browser history back"));
- browserBack();
- sleep(2000);
- chat.getTalkBox(jids).sendKeys(t("I can continue chat smoothly ;)"));
- chat.getSend(jids).click();
- sleep(2000);
- showMsg(t("Browser history forward"));
- browserForward();
- sleep(1000);
- showMsg(t("And more options for your contacts"));
- chat.getItemMenu("", jids).click();
- chat.getTalkBox(jids).sendKeys(t("goodbye!"));
- chat.getSend(jids).click();
- sleep(1000);
- chat.getTalkBox(jids).sendKeys(Keys.chord(Keys.ALT, "C"));
- // chat.close();
-
- login.logout();
-
- showTitleSlide(t("Thank you"), t("and yes, feedback welcome"));
-
- }
-}
Copied: trunk/src/test/java/cc/kune/selenium/login/ScreenCastsViaSeleniumTests.java (from rev 1661, trunk/src/test/java/cc/kune/selenium/login/RegisterSeleniumTests.java)
===================================================================
--- trunk/src/test/java/cc/kune/selenium/login/ScreenCastsViaSeleniumTests.java (rev 0)
+++ trunk/src/test/java/cc/kune/selenium/login/ScreenCastsViaSeleniumTests.java 2012-01-16 10:30:38 UTC (rev 1662)
@@ -0,0 +1,181 @@
+/*
+ *
+ * Copyright (C) 2007-2011 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package cc.kune.selenium.login;
+
+import org.openqa.selenium.Keys;
+import org.testng.annotations.Test;
+
+import cc.kune.core.client.state.SiteTokens;
+import cc.kune.selenium.KuneSeleniumTest;
+import cc.kune.selenium.SeleniumConf;
+import cc.kune.selenium.SeleniumConstants;
+import cc.kune.selenium.SeleniumUtils;
+
+import com.calclab.emite.core.client.xmpp.stanzas.XmppURI;
+
+public class ScreenCastsViaSeleniumTests extends KuneSeleniumTest {
+
+ @Test(dataProvider = "correctregister")
+ public void globalScreencast(final String shortNameUntrans, final String longNameUntrans,
+ final String passwd, final String emailUntrans) {
+ final String shortName = t(shortNameUntrans);
+ final String longName = t(longNameUntrans);
+ final String email = t(emailUntrans);
+ SeleniumUtils.fastSpeed(false);
+ // 15 chars, the limit, so we don't use shortName
+ final String prefix = getTempString();
+ showTitleSlide(t("User registration"), t("to get full access to this site tools/contents"));
+ login.createOne();
+ register.fillRegisterForm(shortName + prefix, longName + prefix, passwd, prefix + email, false, true);
+ sleep(1000);
+ login.assertIsConnectedAs(prefix);
+ entityHeader.waitForEntityTitle(longName + prefix);
+ register.getWelcomeMsg().click();
+
+ // group space
+ showTitleSlide(t("Group space (collaboration space)"),
+ t("Here you can create groups and collaborate within them"));
+ site.groupSpaceBtn.click();
+ site.groupSpaceBtn.click();
+ showMsg(t("Let's create a new group"));
+ site.newGroupBtn.click();
+ newGroup.shortName.sendKeys("yseg" + prefix);
+ newGroup.longName.sendKeys(t("Yellow Summarine Environmental Group ") + prefix);
+ newGroup.publicDescription.sendKeys(t("The Yellow Summarine Environmental Group is an Argentine-Based environmental"
+ + " direct action group. Currently we are focusing or activities in the environmental impact of mining."));
+ newGroup.tags.sendKeys(t("environmental, Argentina, action"));
+ newGroup.projectType.click();
+ showTooltip(newGroup.projectType);
+ doScreenshot("newgroup");
+ newGroup.registerBtn.click();
+ showTitleSlide(t("Group space (collaboration space) III "),
+ t("Let's see the diferent tools you have available"));
+ groupSpace.blogTool.click();
+ sleep(2000);
+ groupSpace.wikiTool.click();
+ sleep(2000);
+ groupSpace.listTool.click();
+ sleep(2000);
+ groupSpace.eventTool.click();
+
+ showTitleSlide(t("Group space (collaboration space) II"),
+ t("but also you can have your personal space (with blogs, etc)"));
+
+ // home space
+ showTitleSlide(t("Home space (your welcome page)"),
+ t("Here you can see a summary of your activity in this site"));
+ site.homeSpaceBtn.click();
+ sleep(2000);
+ homeSpace.getSndStats().click();
+ sleep(2000);
+ homeSpace.getTrdStats().click();
+ sleep(2000);
+
+ // user space
+ showTitleSlide(t("User space (your Inbox)"), t("contents in which you participate"));
+ showTooltip(site.userSpaceBtn);
+ site.userSpaceBtn.click();
+ showMsg(t("You can see this like an advanced email system..."));
+ userSpace.getFirstWave().click();
+ sleep(2000);
+ userSpace.getNewWave().click();
+ showMsg(t("where you can compose personal messages..."));
+ showMsg(t("but also create contents to publish later"));
+ userSpace.rootBlipText().sendKeys(t("Congratulations for your report\n\n"));
+ sleep(1000);
+ userSpace.getCursive().click();
+ userSpace.rootBlipText().sendKeys(
+ t("Hi there, Just to say that I like") + t("a lot your last report\n\n"));
+ sleep(1000);
+ userSpace.getCursive().click();
+ userSpace.rootBlipText().sendKeys(t("Best\n\nJane"));
+ sleep(3000);
+ userSpace.getRootEdit().click();
+ userSpace.getAddParcipant().click();
+ sleep(1000);
+ answerOnNextPrompt("admin");
+ sleep(5000);
+
+ // group space
+ showTitleSlide(t("Your personal public space"), t("here you can have your blog, etc"));
+ sleep(500);
+ site.groupSpaceBtn.click();
+ site.groupSpaceBtn.click();
+ showMsg(t("Let's start adding some buddie to our social network"));
+ sleep(1000);
+ groupSpace.addBuddieBtn.click();
+ groupSpace.addNewBuddieTextBox.click();
+ groupSpace.addNewBuddieTextBox.sendKeys("admin");
+ groupSpace.addNewBuddieTextBox.sendKeys(Keys.ARROW_DOWN);
+ sleep(500);
+ groupSpace.firstFromSuggestionBox.click();
+ site.confirmationOk.click();
+ sleep(500);
+ groupSpace.searchEntitiesOk.click();
+ // groupSpace.firstAvatarOfGroup().click();
+ sleep(2000);
+
+ showTitleSlide(t("Chat with your buddies"), t("compatible with gmail and similars"),
+ SiteTokens.WAVEINBOX);
+ // showTooltip(chat.icon());
+ chat.show();
+ sleep(2000);
+
+ final XmppURI jid = XmppURI.jid(SeleniumConstants.USER_SHORNAME + "@"
+ + SeleniumConf.SITE.getDomain());
+ final String jids = jid.toString();
+ chat.getRosterItem("", jids).click();
+
+ // chat.openChat(jid);
+
+ // chat.getPage(jids).click();
+ chat.getTalkBox(jids).sendKeys(t("Helloo... ;)"));
+ chat.getSend(jids).click();
+ chat.getTalkBox(jids).sendKeys(t("I'm just testing"));
+ chat.getSend(jids).click();
+
+ showMsg(t("And you can chat event while going back/forward with your browser"));
+ site.homeSpaceBtn.click();
+ sleep(2000);
+ chat.getTalkBox(jids).sendKeys(t("la la la"));
+ chat.getSend(jids).click();
+ showMsg(t("Browser history back"));
+ browserBack();
+ sleep(2000);
+ chat.getTalkBox(jids).sendKeys(t("I can continue chat smoothly ;)"));
+ chat.getSend(jids).click();
+ sleep(2000);
+ showMsg(t("Browser history forward"));
+ browserForward();
+ sleep(1000);
+ showMsg(t("And more options for your contacts"));
+ chat.getItemMenu("", jids).click();
+ chat.getTalkBox(jids).sendKeys(t("goodbye!"));
+ chat.getSend(jids).click();
+ sleep(1000);
+ chat.getTalkBox(jids).sendKeys(Keys.chord(Keys.ALT, "C"));
+ // chat.close();
+
+ login.logout();
+
+ showTitleSlide(t("Thank you"), t("and yes, feedback welcome"));
+
+ }
+}
Modified: trunk/src/test/java/cc/kune/selenium/spaces/GroupSpacePageObject.java
===================================================================
--- trunk/src/test/java/cc/kune/selenium/spaces/GroupSpacePageObject.java 2012-01-12 14:45:36 UTC (rev 1661)
+++ trunk/src/test/java/cc/kune/selenium/spaces/GroupSpacePageObject.java 2012-01-16 10:30:38 UTC (rev 1662)
@@ -32,76 +32,32 @@
public class GroupSpacePageObject extends PageObject {
@FindBy(id = SeleniumConstants.GWTDEV + UserSNConfActions.ADD_BUDDIE_BTN)
- private WebElement addBuddieBtn;
+ public WebElement addBuddieBtn;
@FindBy(id = SeleniumConstants.GWTDEV + AddNewBuddiesAction.ADD_NEW_BUDDIES_TEXTBOX)
public WebElement addNewBuddieTextBox;
@FindBy(id = SeleniumConstants.GWTDEV + AddEntityToThisGroupAction.ADD_NEW_MEMBER_TEXTBOX)
public WebElement addNewMemberTextBox;
@FindBy(xpath = "//div[2]/div/div[3]/div/span")
- private WebElement blogTool;
+ public WebElement blogTool;
@FindBy(xpath = "//div[2]/div/div[4]/div/span")
- private WebElement chatTool;
+ public WebElement chatTool;
@FindBy(xpath = "//div[3]/div/div[2]/div/div/div/span")
- private WebElement docTool;
+ public WebElement docTool;
@FindBy(xpath = "//div[2]/div/div[6]/div/span")
- private WebElement eventTool;
+ public WebElement eventTool;
@FindBy(xpath = "//td/img")
- private WebElement firstAvatarOfGroup;
+ public WebElement firstAvatarOfGroup;
@FindBy(xpath = "//td[2]/div/div/table/tbody/tr/td")
public WebElement firstFromSuggestionBox;
@FindBy(xpath = "//div[2]/div/div[5]/div/span")
- private WebElement listTool;
+ public WebElement listTool;
@FindBy(id = SeleniumConstants.GWTDEV + EntitySearchPanel.OK_ID)
- private WebElement searchEntitiesOk;
+ public WebElement searchEntitiesOk;
@FindBy(xpath = "//div[3]/div/button")
- private WebElement socialNetOptions;
+ public WebElement socialNetOptions;
@FindBy(xpath = "//div[2]/div/div[7]/div/span")
- private WebElement taskTool;
+ public WebElement taskTool;
@FindBy(xpath = "//div[2]/div/div[7]/div/span")
- private WebElement wikiTool;
+ public WebElement wikiTool;
- public WebElement addBuddieBtn() {
- return addBuddieBtn;
- }
-
- public WebElement blogTool() {
- return blogTool;
- }
-
- public WebElement chatTool() {
- return chatTool;
- }
-
- public WebElement docTool() {
- return docTool;
- }
-
- public WebElement eventTool() {
- return eventTool;
- }
-
- public WebElement firstAvatarOfGroup() {
- return firstAvatarOfGroup;
- }
-
- public WebElement listTool() {
- return listTool;
- }
-
- public WebElement searchEntitiesOk() {
- return searchEntitiesOk;
- }
-
- public WebElement socialNetOptions() {
- return socialNetOptions;
- }
-
- public WebElement taskTool() {
- return taskTool;
- }
-
- public WebElement wikiTool() {
- return wikiTool;
- }
-
}
1
0
r1661 - in trunk/src/main/java/cc/kune: core/client/state/impl gspace/client/options/general
by Vicente J. Ruiz Jurado 12 Jan '12
by Vicente J. Ruiz Jurado 12 Jan '12
12 Jan '12
Author: vjrj_
Date: 2012-01-12 15:45:36 +0100 (Thu, 12 Jan 2012)
New Revision: 1661
Modified:
trunk/src/main/java/cc/kune/core/client/state/impl/SessionDefault.java
trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPanel.java
trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPresenter.java
trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralView.java
Log:
CLOSED - # 185: Implement email notification levels (hourly and daily) similar to Google Wave
http://kune.ourproject.org/issues/ticket/185
Modified: trunk/src/main/java/cc/kune/core/client/state/impl/SessionDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/client/state/impl/SessionDefault.java 2012-01-12 14:05:46 UTC (rev 1660)
+++ trunk/src/main/java/cc/kune/core/client/state/impl/SessionDefault.java 2012-01-12 14:45:36 UTC (rev 1661)
@@ -258,7 +258,9 @@
if (!isLogged()) {
return false;
}
- if (getCurrentStateToken().getGroup().equals(getCurrentUser().getShortName())) {
+ final StateToken currentStateToken = getCurrentStateToken();
+ if (currentStateToken != null
+ && currentStateToken.getGroup().equals(getCurrentUser().getShortName())) {
return true;
}
return false;
Modified: trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPanel.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPanel.java 2012-01-12 14:05:46 UTC (rev 1660)
+++ trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPanel.java 2012-01-12 14:45:36 UTC (rev 1661)
@@ -20,26 +20,37 @@
package cc.kune.gspace.client.options.general;
import cc.kune.common.client.ui.MaskWidget;
-import cc.kune.common.shared.i18n.I18nTranslationService;
import cc.kune.core.client.auth.UserFieldFactory;
+import cc.kune.core.client.i18n.I18nUITranslationService;
import cc.kune.core.client.resources.CoreResources;
+import cc.kune.core.client.ui.DefaultFormUtils;
+import cc.kune.core.shared.domain.dto.EmailNotificationFrequency;
import cc.kune.core.shared.dto.I18nLanguageSimpleDTO;
import cc.kune.gspace.client.i18n.LanguageSelectorPanel;
-import com.extjs.gxt.ui.client.widget.form.CheckBox;
+import com.extjs.gxt.ui.client.widget.form.FieldSet;
import com.extjs.gxt.ui.client.widget.form.FormPanel.LabelAlign;
+import com.extjs.gxt.ui.client.widget.form.Radio;
import com.extjs.gxt.ui.client.widget.form.TextField;
import com.google.inject.Inject;
public class UserOptGeneralPanel extends EntityOptGeneralPanel implements UserOptGeneralView {
+ public static final String DAILY_TYPE_ID = "k-ngp-type_daily";
+ public static final String HOURLY_TYPE_ID = "k-ngp-type_hourly";
+ public static final String IMMEDIATE_TYPE_ID = "k-ngp-type_immedi";
private static final String LONG_NAME_FIELD = "k-uogp-lname";
- private final CheckBox emailNotifField;
+ public static final String NO_TYPE_ID = "k-ngp-type_no";
+ public static final String TYPEOFEMAILNOTIF_FIELD = "k-ngp-type_of_email_notif";
+ private final Radio dailyRadio;
+ private final Radio hourlyRadio;
+ private final Radio immediateRadio;
private final LanguageSelectorPanel langSelector;
private final TextField<String> longName;
+ private final Radio noRadio;
@Inject
- public UserOptGeneralPanel(final I18nTranslationService i18n, final CoreResources res,
+ public UserOptGeneralPanel(final I18nUITranslationService i18n, final CoreResources res,
final MaskWidget maskWidget, final LanguageSelectorPanel langSelector,
final UserFieldFactory userFieldFactory) {
super(maskWidget, res.emblemSystem(), i18n.t("General"), i18n.t("Change this values:"));
@@ -50,12 +61,63 @@
langSelector.setLabelAlign(LabelAlign.LEFT);
langSelector.setLangSeparator(":");
add(langSelector);
- emailNotifField = new CheckBox();
- emailNotifField.setFieldLabel(i18n.t("Email notifications"));
- add(emailNotifField);
+
+ final FieldSet emailNotifTypeFieldSet = new FieldSet();
+ emailNotifTypeFieldSet.setHeading(i18n.t("How often do you want to receive email notifications?"));
+ emailNotifTypeFieldSet.addStyleName("k-form-fieldset");
+ emailNotifTypeFieldSet.setCollapsible(false);
+ emailNotifTypeFieldSet.setWidth("310px");
+ emailNotifTypeFieldSet.setAutoHeight(true);
+
+ immediateRadio = DefaultFormUtils.createRadio(emailNotifTypeFieldSet, i18n.t("almost immediately"),
+ TYPEOFEMAILNOTIF_FIELD, i18n.t(
+ "you will receive an email with any new messages in your inbox at [%s] almost immediately",
+ i18n.getSiteCommonName()), IMMEDIATE_TYPE_ID);
+ immediateRadio.setTabIndex(3);
+ immediateRadio.setValue(true);
+
+ hourlyRadio = DefaultFormUtils.createRadio(emailNotifTypeFieldSet, i18n.t("at most hourly"),
+ TYPEOFEMAILNOTIF_FIELD, i18n.t(
+ "you will receive an email with any new messages in your inbox at [%s] at most hourly",
+ i18n.getSiteCommonName()), HOURLY_TYPE_ID);
+ hourlyRadio.setTabIndex(4);
+ hourlyRadio.setValue(false);
+
+ dailyRadio = DefaultFormUtils.createRadio(emailNotifTypeFieldSet, i18n.t("at most daily"),
+ TYPEOFEMAILNOTIF_FIELD, i18n.t(
+ "you will receive an email with any new messages in your inbox at [%s] at most daily",
+ i18n.getSiteCommonName()), DAILY_TYPE_ID);
+ dailyRadio.setTabIndex(5);
+ dailyRadio.setValue(false);
+
+ noRadio = DefaultFormUtils.createRadio(
+ emailNotifTypeFieldSet,
+ i18n.t("I don't need email notifications"),
+ TYPEOFEMAILNOTIF_FIELD,
+ i18n.t("you will no receive an email with any new messages in your inbox at [%s]",
+ i18n.getSiteCommonName()), NO_TYPE_ID);
+ noRadio.setTabIndex(6);
+ noRadio.setValue(false);
+
+ add(emailNotifTypeFieldSet);
}
@Override
+ public EmailNotificationFrequency getEmailNotif() {
+ if (immediateRadio.getValue()) {
+ return EmailNotificationFrequency.immediately;
+ }
+ if (hourlyRadio.getValue()) {
+ return EmailNotificationFrequency.hourly;
+ }
+ if (dailyRadio.getValue()) {
+ return EmailNotificationFrequency.daily;
+ }
+ // if (noRadio.getValue())
+ return EmailNotificationFrequency.no;
+ }
+
+ @Override
public I18nLanguageSimpleDTO getLanguage() {
return langSelector.getLanguage();
}
@@ -65,14 +127,24 @@
return longName.getValue();
}
- public boolean isEmailNofifField() {
- return emailNotifField.getValue();
+ @Override
+ public void setEmailNotifChecked(final EmailNotificationFrequency freq) {
+ switch (freq) {
+ case no:
+ noRadio.setValue(true);
+ break;
+ case hourly:
+ hourlyRadio.setValue(true);
+ break;
+ case daily:
+ dailyRadio.setValue(true);
+ break;
+ case immediately:
+ immediateRadio.setValue(true);
+ break;
+ }
}
- public void setEmailNofifField(final boolean value) {
- emailNotifField.setValue(value);
- }
-
@Override
public void setLanguage(final I18nLanguageSimpleDTO language) {
langSelector.setLanguage(language);
Modified: trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPresenter.java 2012-01-12 14:05:46 UTC (rev 1660)
+++ trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPresenter.java 2012-01-12 14:45:36 UTC (rev 1661)
@@ -28,7 +28,6 @@
import cc.kune.core.client.rpcservices.UserServiceAsync;
import cc.kune.core.client.state.Session;
import cc.kune.core.client.state.StateManager;
-import cc.kune.core.shared.domain.dto.EmailNotificationFrequency;
import cc.kune.core.shared.dto.I18nLanguageSimpleDTO;
import cc.kune.core.shared.dto.StateAbstractDTO;
import cc.kune.core.shared.dto.UserDTO;
@@ -75,8 +74,7 @@
final UserSimpleDTO currentUser = session.getCurrentUser();
userView.setLongName(currentUser.getName());
userView.setLanguage(I18nLanguageSimpleDTO.create(currentUser.getLanguage()));
- userView.setEmailNofifField(currentUser.getEmailNotifFreq().equals(
- EmailNotificationFrequency.immediately));
+ userView.setEmailNotifChecked(currentUser.getEmailNotifFreq());
}
@Override
@@ -89,8 +87,7 @@
final String longName = userView.getLongName();
user.setName(longName);
final I18nLanguageSimpleDTO lang = userView.getLanguage();
- user.setEmailNotifFreq(userView.isEmailNofifField() ? EmailNotificationFrequency.immediately
- : EmailNotificationFrequency.no);
+ user.setEmailNotifFreq(userView.getEmailNotif());
userService.get().updateUser(session.getUserHash(), user, userView.getLanguage(),
new AsyncCallbackSimple<StateAbstractDTO>() {
@Override
@@ -110,8 +107,7 @@
}
});
};
- }
- );
+ });
}
}
}
Modified: trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralView.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralView.java 2012-01-12 14:05:46 UTC (rev 1660)
+++ trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralView.java 2012-01-12 14:45:36 UTC (rev 1661)
@@ -19,19 +19,21 @@
*/
package cc.kune.gspace.client.options.general;
+import cc.kune.core.shared.domain.dto.EmailNotificationFrequency;
import cc.kune.core.shared.dto.I18nLanguageSimpleDTO;
public interface UserOptGeneralView extends EntityOptGeneralView {
+ EmailNotificationFrequency getEmailNotif();
+
I18nLanguageSimpleDTO getLanguage();
String getLongName();
- boolean isEmailNofifField();
+ void setEmailNotifChecked(EmailNotificationFrequency freq);
- void setEmailNofifField(boolean value);
-
void setLanguage(I18nLanguageSimpleDTO language);
void setLongName(String longName);
+
}
1
0
r1660 - in trunk/src: main/java/cc/kune/core/server/notifier main/java/cc/kune/core/server/scheduler main/java/cc/kune/wave/server/kspecific test/java/cc/kune/core/server/notifier
by Vicente J. Ruiz Jurado 12 Jan '12
by Vicente J. Ruiz Jurado 12 Jan '12
12 Jan '12
Author: vjrj_
Date: 2012-01-12 15:05:46 +0100 (Thu, 12 Jan 2012)
New Revision: 1660
Added:
trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationProvider.java
Modified:
trunk/src/main/java/cc/kune/core/server/notifier/NotificationSenderDefault.java
trunk/src/main/java/cc/kune/core/server/notifier/PendingNotification.java
trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationSender.java
trunk/src/main/java/cc/kune/core/server/scheduler/CronServerTasksManager.java
trunk/src/main/java/cc/kune/wave/server/kspecific/WaveEmailNotifier.java
trunk/src/test/java/cc/kune/core/server/notifier/PendingNotificationSenderTest.java
Log:
NEW - # 185: Implement notification levels (hourly and daily) similar to Google Wave
http://kune.ourproject.org/issues/ticket/185
Modified: trunk/src/main/java/cc/kune/core/server/notifier/NotificationSenderDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/notifier/NotificationSenderDefault.java 2012-01-12 04:14:28 UTC (rev 1659)
+++ trunk/src/main/java/cc/kune/core/server/notifier/NotificationSenderDefault.java 2012-01-12 14:05:46 UTC (rev 1660)
@@ -51,7 +51,7 @@
private boolean noOnline(final String username) {
final boolean logged = usersOnline.isLogged(username);
- LOG.debug(String.format("User '' is online for notifications? %s", username, logged));
+ LOG.debug(String.format("User '%s' is online for notifications? %s", username, logged));
return !logged;
}
Modified: trunk/src/main/java/cc/kune/core/server/notifier/PendingNotification.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/notifier/PendingNotification.java 2012-01-12 04:14:28 UTC (rev 1659)
+++ trunk/src/main/java/cc/kune/core/server/notifier/PendingNotification.java 2012-01-12 14:05:46 UTC (rev 1660)
@@ -8,6 +8,13 @@
*/
public class PendingNotification {
+ /**
+ * The Constant NONE is used when for instance, all the destinations are not
+ * local, so, we should not notify them by email
+ */
+ public static final PendingNotification NONE = new PendingNotification(null, null, null, false, false,
+ null);
+
/** The body. */
private final FormatedString body;
Added: trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationProvider.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationProvider.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationProvider.java 2012-01-12 14:05:46 UTC (rev 1660)
@@ -0,0 +1,11 @@
+package cc.kune.core.server.notifier;
+
+import com.google.inject.Provider;
+
+/**
+ * The Class PendingNotificationProvider is used to generate notifications in a
+ * deferred way of waves updates (for instance)
+ */
+public abstract class PendingNotificationProvider implements Provider<PendingNotification> {
+
+}
Modified: trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationSender.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationSender.java 2012-01-12 04:14:28 UTC (rev 1659)
+++ trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationSender.java 2012-01-12 14:05:46 UTC (rev 1660)
@@ -19,16 +19,18 @@
public class PendingNotificationSender {
/** The Constant NO_NEXT. */
- private static final Collection<PendingNotification> NO_NEXT = null;
+ private static final Collection<PendingNotificationProvider> NO_NEXT = null;
+ // FIXME this should be in DB so we'll don't lose them in server restarts
/** The daily pend notif. list */
- private final Set<PendingNotification> dailyPendNotif;
+ private final Set<PendingNotificationProvider> dailyPendNotif;
+ // FIXME this should be in DB so we'll don't lose them in server restarts
/** The houry pend notif. list */
- private final Set<PendingNotification> hourlyPendNotif;
+ private final Set<PendingNotificationProvider> hourlyPendNotif;
/** The immediate pend notif. list */
- private final Set<PendingNotification> immediatePendNotif;
+ private final Set<PendingNotificationProvider> immediatePendNotif;
/** The sender. */
private final NotificationSender sender;
@@ -42,15 +44,20 @@
@Inject
public PendingNotificationSender(final NotificationSender sender) {
this.sender = sender;
- immediatePendNotif = new HashSet<PendingNotification>();
- hourlyPendNotif = new HashSet<PendingNotification>();
- dailyPendNotif = new HashSet<PendingNotification>();
+ immediatePendNotif = new HashSet<PendingNotificationProvider>();
+ hourlyPendNotif = new HashSet<PendingNotificationProvider>();
+ dailyPendNotif = new HashSet<PendingNotificationProvider>();
}
public void add(final NotificationType type, final FormatedString subject, final FormatedString body,
final boolean isHtml, final boolean forceSend, final User to) {
- add(new PendingNotification(type, subject, body, isHtml, forceSend,
- new SimpleDestinationProvider(to)));
+ add(new PendingNotificationProvider() {
+ @Override
+ public PendingNotification get() {
+ return new PendingNotification(type, subject, body, isHtml, forceSend,
+ new SimpleDestinationProvider(to));
+ }
+ });
}
/**
@@ -59,10 +66,10 @@
* @param notification
* the notification
*/
- public void add(final PendingNotification notification) {
- if (!hourlyPendNotif.contains(notification)) {
+ public void add(final PendingNotificationProvider notificationProv) {
+ if (!hourlyPendNotif.contains(notificationProv)) {
// If we have send a similar notification this hour just ignore
- immediatePendNotif.add(notification);
+ immediatePendNotif.add(notificationProv);
}
}
@@ -106,14 +113,18 @@
* The current frequency of notifications, that is, we'll send
* notifications only to users with this frequency configured
*/
- private void send(final Collection<PendingNotification> list,
- final Collection<PendingNotification> nextList, final EmailNotificationFrequency currentFreq) {
- for (final PendingNotification notification : list) {
- sender.send(notification, currentFreq);
- if (!notification.isForceSend() && nextList != NO_NEXT) {
- // Forced Send, are send immediately (independent of how User has its
- // notification configured)!
- nextList.add(notification);
+ private void send(final Collection<PendingNotificationProvider> list,
+ final Collection<PendingNotificationProvider> nextList,
+ final EmailNotificationFrequency currentFreq) {
+ for (final PendingNotificationProvider notificationProv : list) {
+ final PendingNotification notification = notificationProv.get();
+ if (!notification.equals(PendingNotification.NONE)) {
+ sender.send(notification, currentFreq);
+ if (!notification.isForceSend() && nextList != NO_NEXT) {
+ // Forced Send, are send immediately (independent of how User has its
+ // notification configured)!
+ nextList.add(notificationProv);
+ }
}
}
list.clear();
Modified: trunk/src/main/java/cc/kune/core/server/scheduler/CronServerTasksManager.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/scheduler/CronServerTasksManager.java 2012-01-12 04:14:28 UTC (rev 1659)
+++ trunk/src/main/java/cc/kune/core/server/scheduler/CronServerTasksManager.java 2012-01-12 14:05:46 UTC (rev 1660)
@@ -55,7 +55,7 @@
LOG.info("Starting cron manager");
try {
sched.start();
- scheduleJob(PendingNotificationImmediateJob.class, "0 */2 * * * ?", "pendinnotifimmediate");
+ scheduleJob(PendingNotificationImmediateJob.class, "0 */1 * * * ?", "pendinnotifimmediate");
scheduleJob(PendingNotificationHourlyJob.class, "0 0 * * * ?", "pendingnotifhourly");
scheduleJob(ClearUpdatedWavesHourlyJob.class, "0 0 * * * ?", "clearupdatedwaveshourly");
scheduleJob(PendingNotificationDailyJob.class, "0 5 0 * * ?", "pendingnotifdaily");
Modified: trunk/src/main/java/cc/kune/wave/server/kspecific/WaveEmailNotifier.java
===================================================================
--- trunk/src/main/java/cc/kune/wave/server/kspecific/WaveEmailNotifier.java 2012-01-12 04:14:28 UTC (rev 1659)
+++ trunk/src/main/java/cc/kune/wave/server/kspecific/WaveEmailNotifier.java 2012-01-12 14:05:46 UTC (rev 1660)
@@ -27,6 +27,7 @@
import cc.kune.core.server.mail.FormatedString;
import cc.kune.core.server.notifier.NotificationType;
import cc.kune.core.server.notifier.PendingNotification;
+import cc.kune.core.server.notifier.PendingNotificationProvider;
import cc.kune.core.server.notifier.PendingNotificationSender;
import cc.kune.core.server.notifier.SimpleDestinationProvider;
import cc.kune.core.server.notifier.WaveDestinationProvider;
@@ -76,29 +77,35 @@
final String siteUrl = basicProperties.getSiteUrl();
waveBus.subscribe(new Subscriber() {
- private void addPendingNotif(final ParticipantId participant, final FormatedString subject,
- final FormatedString body) {
+ private PendingNotification createPendingNotif(final ParticipantId participant,
+ final FormatedString subject, final FormatedString body) {
final String address = participant.getAddress();
if (partUtils.isLocal(address)) {
final String userName = partUtils.getAddressName(address);
try {
final User user = userFinder.findByShortName(userName);
- notificator.add(new PendingNotification(NotificationType.email, subject, body, true, false,
- new SimpleDestinationProvider(user)));
+ return new PendingNotification(NotificationType.email, subject, body, true, false,
+ new SimpleDestinationProvider(user));
} catch (final NoResultException e) {
// Seems is not a local user
}
}
+ return PendingNotification.NONE;
}
+ private String getTitle(final ReadableWaveletData wavelet, final ParticipantId by) {
+ return waveService.getTitle(WaveRef.of(wavelet.getWaveId(), wavelet.getWaveletId()),
+ by.toString());
+ }
+
private String getUrl(final ReadableWaveletData wavelet, final WaveletId waveletId) {
return KuneWaveServerUtils.getUrl(WaveRef.of(wavelet.getWaveId(), waveletId));
}
- private FormatedString newWaveTemplate(final String url) {
+ private FormatedString newWaveTemplate(final String by, final String url) {
return FormatedString.build(
- "Hi there,<br><br>You have a new message in your inbox at %s. <a href=\"%s#%s\">Read more</a>.<br>",
- siteCommonName, siteUrl, url);
+ "Hi there,<br><br>You have a new message by '%s' in your inbox at %s. <a href=\"%s#%s\">Read more</a>.<br>",
+ by, siteCommonName, siteUrl, url);
}
private FormatedString removeWaveTemplate(final String by, final String title) {
@@ -107,10 +114,10 @@
by, title, siteCommonName, siteUrl, SiteTokens.WAVEINBOX);
}
- private FormatedString updatedWaveTemplate(final String by, final String url) {
+ private FormatedString updatedWaveTemplate(final String by, final String title, final String url) {
return FormatedString.build(
- "Hi there,<br><br>You have an updated message by '%s' in your inbox at %s. <a href=\"%s#%s\">Read more</a>.<br>",
- by, siteCommonName, siteUrl, url);
+ "Hi there,<br><br>The message '%s' was updated by '%s' in your inbox at %s. <a href=\"%s#%s\">Read more</a>.<br>",
+ title, by, siteCommonName, siteUrl, url);
}
@Override
@@ -126,29 +133,57 @@
for (final TransformedWaveletDelta delta : deltas) {
for (final WaveletOperation op : delta) {
if (op instanceof AddParticipant) {
- final ParticipantId participant = ((AddParticipant) op).getParticipantId();
- addPendingNotif(participant, FormatedString.build("You have a new message"),
- newWaveTemplate(getUrl(wavelet, waveletId)));
+ notificator.add(new PendingNotificationProvider() {
+ @Override
+ public PendingNotification get() {
+ final AddParticipant addParticipantOp = (AddParticipant) op;
+ final ParticipantId by = addParticipantOp.getContext().getCreator();
+ final ParticipantId to = addParticipantOp.getParticipantId();
+ LOG.info(String.format("New wave from '%s' to '%s'", by, to));
+ return createPendingNotif(to, FormatedString.build("You have a new message"),
+ newWaveTemplate(by.toString(), getUrl(wavelet, waveletId)));
+ }
+ });
} else if (op instanceof RemoveParticipant) {
- final ParticipantId participant = ((RemoveParticipant) op).getParticipantId();
- final ParticipantId by = ((RemoveParticipant) op).getContext().getCreator();
- final String title = waveService.getTitle(WaveRef.of(wavelet.getWaveId(), waveletId),
- by.toString());
- addPendingNotif(participant, FormatedString.build("You have been removed from message"),
- removeWaveTemplate(by.toString(), title));
+ notificator.add(new PendingNotificationProvider() {
+ @Override
+ public PendingNotification get() {
+ final RemoveParticipant removeParticipantOp = (RemoveParticipant) op;
+ final ParticipantId by = removeParticipantOp.getContext().getCreator();
+ final ParticipantId to = removeParticipantOp.getParticipantId();
+ final String title = getTitle(wavelet, by);
+ LOG.info(String.format("'%s' removed from wave '%s' to '%s'", by, title, to));
+ return createPendingNotif(to,
+ FormatedString.build("You have been removed from message"),
+ removeWaveTemplate(by.toString(), title));
+ }
+ });
} else if (op instanceof WaveletBlipOperation) {
+ // Replies, etc
final WaveId waveId = wavelet.getWaveId();
if (!updatedWavesInLastHour.contains(waveId)) {
updatedWavesInLastHour.add(waveId);
- // Replies, etc
- final ParticipantId by = ((WaveletBlipOperation) op).getContext().getCreator();
- // Duplicate code above
- final WaveRef waveref = WaveRef.of(waveId, waveletId);
- final String url = KuneWaveServerUtils.getUrl(waveref);
- notificator.add(new PendingNotification(NotificationType.email,
- FormatedString.build("You have an updated message"), updatedWaveTemplate(
- by.toString(), url), true, false, new WaveDestinationProvider(waveref,
- by.toString())));
+ notificator.add(new PendingNotificationProvider() {
+ @Override
+ public PendingNotification get() {
+ final WaveRef waveref = WaveRef.of(waveId, waveletId);
+ final ParticipantId by = ((WaveletBlipOperation) op).getContext().getCreator();
+ final String title = getTitle(wavelet, by);
+ final String url = KuneWaveServerUtils.getUrl(waveref);
+ LOG.info(String.format("'%s' updated wave '%s'", by, title));
+ return new PendingNotification(NotificationType.email,
+ FormatedString.build("You have an updated message"), updatedWaveTemplate(
+ by.toString(), title, url), true, false, new WaveDestinationProvider(
+ waveref, by.toString()));
+ }
+ });
+ // notificator.add(new
+ // PendingNotification(NotificationType.email,
+ // FormatedString.build("You have an updated message"),
+ // updatedWaveTemplate(
+ // by.toString(), title, url), true, false, new
+ // WaveDestinationProvider(waveref,
+ // by.toString())));
}
}
}
Modified: trunk/src/test/java/cc/kune/core/server/notifier/PendingNotificationSenderTest.java
===================================================================
--- trunk/src/test/java/cc/kune/core/server/notifier/PendingNotificationSenderTest.java 2012-01-12 04:14:28 UTC (rev 1659)
+++ trunk/src/test/java/cc/kune/core/server/notifier/PendingNotificationSenderTest.java 2012-01-12 14:05:46 UTC (rev 1660)
@@ -15,10 +15,10 @@
private static final FormatedString OTHER_SUBJECT = FormatedString.build("Some other subject");
private static final FormatedString SUBJECT = FormatedString.build("Some subject");
private PendingNotificationSender manager;
- private PendingNotification otherNotif;
+ private PendingNotificationProvider otherNotif;
private NotificationSender sender;
- private PendingNotification someForcedNotif;
- private PendingNotification someNotif;
+ private PendingNotificationProvider someForcedNotif;
+ private PendingNotificationProvider someNotif;
private void assertQueues(final int i, final int j, final int k) {
// TODO Auto-generated method stub
@@ -32,12 +32,28 @@
public void before() {
sender = Mockito.mock(NotificationSender.class);
manager = new PendingNotificationSender(sender);
- someNotif = new PendingNotification(NotificationType.email, SUBJECT, BODY, false, false,
- someUserProvider);
- otherNotif = new PendingNotification(NotificationType.email, OTHER_SUBJECT, OTHER_BODY, false,
- false, someUserProvider);
- someForcedNotif = new PendingNotification(NotificationType.email, SUBJECT, BODY, false, true,
- someUserProvider);
+ otherNotif = new PendingNotificationProvider() {
+ @Override
+ public PendingNotification get() {
+ return new PendingNotification(NotificationType.email, OTHER_SUBJECT, OTHER_BODY, false, false,
+ someUserProvider);
+ }
+ };
+ someForcedNotif = new PendingNotificationProvider() {
+ @Override
+ public PendingNotification get() {
+ return new PendingNotification(NotificationType.email, SUBJECT, BODY, false, true,
+ someUserProvider);
+ }
+ };
+
+ someNotif = new PendingNotificationProvider() {
+ @Override
+ public PendingNotification get() {
+ return new PendingNotification(NotificationType.email, SUBJECT, BODY, false, false,
+ someUserProvider);
+ }
+ };
}
@Test
1
0
r1659 - in trunk/src/main/java/cc/kune: core/server core/server/notifier core/server/scheduler wave/server/kspecific
by Vicente J. Ruiz Jurado 12 Jan '12
by Vicente J. Ruiz Jurado 12 Jan '12
12 Jan '12
Author: vjrj_
Date: 2012-01-12 05:14:28 +0100 (Thu, 12 Jan 2012)
New Revision: 1659
Added:
trunk/src/main/java/cc/kune/core/server/notifier/ClearUpdatedWavesHourlyJob.java
Modified:
trunk/src/main/java/cc/kune/core/server/KuneRackModule.java
trunk/src/main/java/cc/kune/core/server/PlatformServerModule.java
trunk/src/main/java/cc/kune/core/server/notifier/NotificationSenderDefault.java
trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationHourlyJob.java
trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationSender.java
trunk/src/main/java/cc/kune/core/server/scheduler/CronServerTasksManager.java
trunk/src/main/java/cc/kune/wave/server/kspecific/WaveEmailNotifier.java
Log:
NEW - # 185: Implement notification levels (hourly and daily) similar to Google Wave
http://kune.ourproject.org/issues/ticket/185
Modified: trunk/src/main/java/cc/kune/core/server/KuneRackModule.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/KuneRackModule.java 2012-01-12 01:40:41 UTC (rev 1658)
+++ trunk/src/main/java/cc/kune/core/server/KuneRackModule.java 2012-01-12 04:14:28 UTC (rev 1659)
@@ -133,8 +133,6 @@
builder.add(KuneContainerListener.class);
builder.add(WaveEmailNotifier.class);
-
- // Cron tasks
builder.add(CronServerTasksManager.class);
builder.exclude("/http-bind.*");
Modified: trunk/src/main/java/cc/kune/core/server/PlatformServerModule.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/PlatformServerModule.java 2012-01-12 01:40:41 UTC (rev 1658)
+++ trunk/src/main/java/cc/kune/core/server/PlatformServerModule.java 2012-01-12 04:14:28 UTC (rev 1659)
@@ -89,6 +89,7 @@
import cc.kune.core.server.mapper.Mapper;
import cc.kune.core.server.notifier.NotificationSender;
import cc.kune.core.server.notifier.NotificationSenderDefault;
+import cc.kune.core.server.notifier.PendingNotificationSender;
import cc.kune.core.server.notifier.UsersOnline;
import cc.kune.core.server.rpc.ContentRPC;
import cc.kune.core.server.rpc.GroupRPC;
@@ -114,6 +115,7 @@
import cc.kune.wave.server.ParticipantUtils;
import cc.kune.wave.server.kspecific.KuneWaveService;
import cc.kune.wave.server.kspecific.KuneWaveServiceDefault;
+import cc.kune.wave.server.kspecific.WaveEmailNotifier;
import com.google.inject.Singleton;
import com.google.inject.matcher.Matchers;
@@ -195,8 +197,10 @@
bind(ParticipantUtils.class);
bind(UsersOnline.class).to(UserSessionManager.class).in(Singleton.class);
requestStaticInjection(AccessRightsUtils.class);
+ bind(WaveEmailNotifier.class).in(Singleton.class);
+ bind(PendingNotificationSender.class).in(Singleton.class);
+ bind(NotificationSender.class).to(NotificationSenderDefault.class).in(Singleton.class);
bind(CronServerTasksManager.class).in(Singleton.class);
- bind(NotificationSender.class).to(NotificationSenderDefault.class).in(Singleton.class);
bindInterceptor(Matchers.any(), Matchers.annotatedWith(Authenticated.class),
outermostCall(new AuthenticatedMethodInterceptor()));
bindInterceptor(Matchers.any(), Matchers.annotatedWith(Authorizated.class),
Added: trunk/src/main/java/cc/kune/core/server/notifier/ClearUpdatedWavesHourlyJob.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/notifier/ClearUpdatedWavesHourlyJob.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/server/notifier/ClearUpdatedWavesHourlyJob.java 2012-01-12 04:14:28 UTC (rev 1659)
@@ -0,0 +1,33 @@
+package cc.kune.core.server.notifier;
+
+import java.text.ParseException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.quartz.SchedulerException;
+
+import cc.kune.wave.server.kspecific.WaveEmailNotifier;
+
+import com.google.inject.Inject;
+
+public class ClearUpdatedWavesHourlyJob implements Job {
+
+ public static final Log LOG = LogFactory.getLog(ClearUpdatedWavesHourlyJob.class);
+
+ private final WaveEmailNotifier waveNotifier;
+
+ @Inject
+ public ClearUpdatedWavesHourlyJob(final WaveEmailNotifier waveNotifier) throws ParseException,
+ SchedulerException {
+ this.waveNotifier = waveNotifier;
+ }
+
+ @Override
+ public void execute(final JobExecutionContext context) throws JobExecutionException {
+ waveNotifier.clearUpdatedWaves();
+ }
+
+}
Modified: trunk/src/main/java/cc/kune/core/server/notifier/NotificationSenderDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/notifier/NotificationSenderDefault.java 2012-01-12 01:40:41 UTC (rev 1658)
+++ trunk/src/main/java/cc/kune/core/server/notifier/NotificationSenderDefault.java 2012-01-12 04:14:28 UTC (rev 1659)
@@ -49,34 +49,42 @@
"] ").toString();
}
+ private boolean noOnline(final String username) {
+ final boolean logged = usersOnline.isLogged(username);
+ LOG.debug(String.format("User '' is online for notifications? %s", username, logged));
+ return !logged;
+ }
+
@Override
public void send(final PendingNotification notification, final EmailNotificationFrequency withFrequency) {
+ final FormatedString subject = notification.getSubject();
+ final FormatedString body = notification.getBody();
+ final NotificationType notifyType = notification.getNotifyType();
+ final boolean forceSend = notification.isForceSend();
+ final boolean isHtml = notification.isHtml();
+
+ subject.setTemplate(subjectPrefix + subject.getTemplate());
+ if (subject.shouldBeTranslated()) {
+ // Translate per recipient language
+ // final String subjectTranslation = i18n.tWithNT(user.getLanguage(),
+ // subject.getTemplate(), "");
+ // if (subjectTranslation != null) {
+ // Right now commented because we are only testing
+ // subject.setTemplate(subjectTranslation);
+ // }
+ }
+ if (body.shouldBeTranslated()) {
+ // final String bodyTranslation = i18n.tWithNT(user.getLanguage(),
+ // body.getTemplate(), "");
+ // if (bodyTranslation != null) {
+ // Right now commented because we are only testing
+ // body.setTemplate(bodyTranslation);
+ // }
+ }
+
for (final User user : notification.getDestProvider().getDest()) {
final String username = user.getShortName();
- final FormatedString subject = notification.getSubject();
- final FormatedString body = notification.getBody();
- final NotificationType notifyType = notification.getNotifyType();
- final boolean forceSend = notification.isForceSend();
- final boolean isHtml = notification.isHtml();
- subject.setTemplate(subjectPrefix + subject.getTemplate());
- if (subject.shouldBeTranslated()) {
- // Translate per recipient language
- // final String subjectTranslation = i18n.tWithNT(user.getLanguage(),
- // subject.getTemplate(), "");
- // if (subjectTranslation != null) {
- // Right now commented because we are only testing
- // subject.setTemplate(subjectTranslation);
- // }
- }
- if (body.shouldBeTranslated()) {
- // final String bodyTranslation = i18n.tWithNT(user.getLanguage(),
- // body.getTemplate(), "");
- // if (bodyTranslation != null) {
- // Right now commented because we are only testing
- // body.setTemplate(bodyTranslation);
- // }
- }
switch (notifyType) {
case chat:
// FIXME seems that html is not sending correctly... check server specs
@@ -84,7 +92,7 @@
String.format("<b>%s</b>%s", subject.getString(), body.getString()));
break;
case email:
- if (forceSend || (!usersOnline.isLogged(username) && withFrequency == user.getEmailNotifFreq())) {
+ if (forceSend || (noOnline(username) && withFrequency == user.getEmailNotifFreq())) {
// we'll send this notification if is mandatory or this user is not
// only and has this freq configured
mailService.send(subject, FormatedString.build(emailTemplate.replace("%s", body.getString())),
Modified: trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationHourlyJob.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationHourlyJob.java 2012-01-12 01:40:41 UTC (rev 1658)
+++ trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationHourlyJob.java 2012-01-12 04:14:28 UTC (rev 1659)
@@ -18,20 +18,16 @@
public static final Log LOG = LogFactory.getLog(PendingNotificationHourlyJob.class);
private final PendingNotificationSender pendingManager;
- private final WaveEmailNotifier waveNotifier;
-
@Inject
public PendingNotificationHourlyJob(final PendingNotificationSender pendingManager,
final WaveEmailNotifier waveNotifier) throws ParseException, SchedulerException {
this.pendingManager = pendingManager;
- this.waveNotifier = waveNotifier;
}
@Override
public void execute(final JobExecutionContext context) throws JobExecutionException {
LOG.info(String.format("Hourly notifications cron job start, %s", pendingManager));
pendingManager.sendHourlyNotifications();
- waveNotifier.clearUpdatedWaves();
LOG.info(String.format("Hourly notifications cron job end, %s", pendingManager));
}
Modified: trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationSender.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationSender.java 2012-01-12 01:40:41 UTC (rev 1658)
+++ trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationSender.java 2012-01-12 04:14:28 UTC (rev 1659)
@@ -123,7 +123,7 @@
* Send daily notifications.
*/
public void sendDailyNotifications() {
- send(dailyPendNotif, NO_NEXT, EmailNotificationFrequency.immediately);
+ send(dailyPendNotif, NO_NEXT, EmailNotificationFrequency.daily);
}
/**
@@ -137,7 +137,7 @@
* Send immediate notifications.
*/
public void sendImmediateNotifications() {
- send(immediatePendNotif, hourlyPendNotif, EmailNotificationFrequency.daily);
+ send(immediatePendNotif, hourlyPendNotif, EmailNotificationFrequency.immediately);
}
@Override
Modified: trunk/src/main/java/cc/kune/core/server/scheduler/CronServerTasksManager.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/scheduler/CronServerTasksManager.java 2012-01-12 01:40:41 UTC (rev 1658)
+++ trunk/src/main/java/cc/kune/core/server/scheduler/CronServerTasksManager.java 2012-01-12 04:14:28 UTC (rev 1659)
@@ -16,6 +16,7 @@
import org.quartz.SchedulerException;
import org.quartz.impl.StdSchedulerFactory;
+import cc.kune.core.server.notifier.ClearUpdatedWavesHourlyJob;
import cc.kune.core.server.notifier.PendingNotificationDailyJob;
import cc.kune.core.server.notifier.PendingNotificationHourlyJob;
import cc.kune.core.server.notifier.PendingNotificationImmediateJob;
@@ -53,16 +54,17 @@
public void start() {
LOG.info("Starting cron manager");
try {
-
sched.start();
scheduleJob(PendingNotificationImmediateJob.class, "0 */2 * * * ?", "pendinnotifimmediate");
scheduleJob(PendingNotificationHourlyJob.class, "0 0 * * * ?", "pendingnotifhourly");
+ scheduleJob(ClearUpdatedWavesHourlyJob.class, "0 0 * * * ?", "clearupdatedwaveshourly");
scheduleJob(PendingNotificationDailyJob.class, "0 5 0 * * ?", "pendingnotifdaily");
} catch (final SchedulerException e) {
logError(e);
} catch (final ParseException e) {
logError(e);
}
+ LOG.info("Cron manager started");
}
@Override
Modified: trunk/src/main/java/cc/kune/wave/server/kspecific/WaveEmailNotifier.java
===================================================================
--- trunk/src/main/java/cc/kune/wave/server/kspecific/WaveEmailNotifier.java 2012-01-12 01:40:41 UTC (rev 1658)
+++ trunk/src/main/java/cc/kune/wave/server/kspecific/WaveEmailNotifier.java 2012-01-12 04:14:28 UTC (rev 1659)
@@ -24,7 +24,6 @@
import org.waveprotocol.wave.model.waveref.WaveRef;
import cc.kune.core.client.state.SiteTokens;
-import cc.kune.core.server.LogThis;
import cc.kune.core.server.mail.FormatedString;
import cc.kune.core.server.notifier.NotificationType;
import cc.kune.core.server.notifier.PendingNotification;
@@ -41,20 +40,40 @@
import com.google.inject.Inject;
import com.google.inject.Singleton;
-@LogThis
@Singleton
public class WaveEmailNotifier implements ContainerListener {
public static final Log LOG = LogFactory.getLog(WaveEmailNotifier.class);
- private HashSet<WaveId> updatedWavesInLastHour;
+ private final KuneBasicProperties basicProperties;
+ private final PendingNotificationSender notificator;
+ private final ParticipantUtils partUtils;
+ private final HashSet<WaveId> updatedWavesInLastHour;
+ private final UserFinder userFinder;
+ private final WaveBus waveBus;
+ private final KuneWaveService waveService;
+
@Inject
public WaveEmailNotifier(final WaveBus waveBus, final PendingNotificationSender notificator,
final KuneBasicProperties basicProperties, final ParticipantUtils partUtils,
final KuneWaveService waveService, final UserFinder userFinder) {
+ this.waveBus = waveBus;
+ this.notificator = notificator;
+ this.basicProperties = basicProperties;
+ this.partUtils = partUtils;
+ this.waveService = waveService;
+ this.userFinder = userFinder;
+ updatedWavesInLastHour = new HashSet<WaveId>();
+ LOG.info("WaveEmailNotifier created");
+ }
+ public void clearUpdatedWaves() {
+ updatedWavesInLastHour.clear();
+ }
+
+ @Override
+ public void start() {
final String siteCommonName = basicProperties.getSiteCommonName();
final String siteUrl = basicProperties.getSiteUrl();
- updatedWavesInLastHour = new HashSet<WaveId>();
waveBus.subscribe(new Subscriber() {
private void addPendingNotif(final ParticipantId participant, final FormatedString subject,
@@ -136,17 +155,10 @@
}
}
});
+ LOG.info("WaveEmailNotifier started");
}
- public void clearUpdatedWaves() {
- updatedWavesInLastHour.clear();
- }
-
@Override
- public void start() {
- }
-
- @Override
public void stop() {
}
1
0
Author: vjrj_
Date: 2012-01-12 02:40:41 +0100 (Thu, 12 Jan 2012)
New Revision: 1658
Added:
trunk/src/main/java/cc/kune/core/server/notifier/DestinationProvider.java
trunk/src/main/java/cc/kune/core/server/notifier/NotificationHtmlHelper.java
trunk/src/main/java/cc/kune/core/server/notifier/NotificationSender.java
trunk/src/main/java/cc/kune/core/server/notifier/NotificationSenderDefault.java
trunk/src/main/java/cc/kune/core/server/notifier/NotificationService.java
trunk/src/main/java/cc/kune/core/server/notifier/NotificationType.java
trunk/src/main/java/cc/kune/core/server/notifier/PendingNotification.java
trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationDailyJob.java
trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationHourlyJob.java
trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationImmediateJob.java
trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationSender.java
trunk/src/main/java/cc/kune/core/server/notifier/SimpleDestinationProvider.java
trunk/src/main/java/cc/kune/core/server/notifier/WaveDestinationProvider.java
trunk/src/main/java/cc/kune/core/server/scheduler/CustomJobFactory.java
trunk/src/main/java/cc/kune/wave/server/KuneWaveServerUtils.java
trunk/src/main/java/cc/kune/wave/server/kspecific/WaveEmailNotifier.java
trunk/src/main/java/cc/kune/wave/server/kspecific/pendnotif/
trunk/src/test/java/cc/kune/core/server/notifier/AbstractPendingNotificationTest.java
trunk/src/test/java/cc/kune/core/server/notifier/NotificationHtmlHelperTest.java
trunk/src/test/java/cc/kune/core/server/notifier/PendingNotificationSenderTest.java
trunk/src/test/java/cc/kune/core/server/notifier/SimpleDestinationProviderTest.java
Removed:
trunk/src/main/java/cc/kune/core/server/notifier/NotifyHtmlHelper.java
trunk/src/main/java/cc/kune/core/server/notifier/NotifySender.java
trunk/src/main/java/cc/kune/core/server/notifier/NotifySenderDefault.java
trunk/src/main/java/cc/kune/core/server/notifier/NotifyService.java
trunk/src/main/java/cc/kune/core/server/notifier/NotifyType.java
trunk/src/main/java/cc/kune/core/server/scheduler/AbstractJob.java
trunk/src/main/java/cc/kune/core/server/scheduler/DailyJob.java
trunk/src/main/java/cc/kune/core/server/scheduler/HourlyJob.java
trunk/src/main/java/cc/kune/wave/server/KuneWaveUtils.java
trunk/src/main/java/cc/kune/wave/server/kspecific/WaveEmailNotifier.java
trunk/src/test/java/cc/kune/core/server/notifier/NotifyHtmlHelperTest.java
Modified:
trunk/DEV-GUIDE
trunk/TODO
trunk/src/main/java/cc/kune/core/server/KuneRackModule.java
trunk/src/main/java/cc/kune/core/server/PlatformServerModule.java
trunk/src/main/java/cc/kune/core/server/content/ContentManagerDefault.java
trunk/src/main/java/cc/kune/core/server/mail/FormatedString.java
trunk/src/main/java/cc/kune/core/server/manager/impl/KuneWaveManagerDefault.java
trunk/src/main/java/cc/kune/core/server/manager/impl/UserManagerDefault.java
trunk/src/main/java/cc/kune/core/server/rack/RackServletFilter.java
trunk/src/main/java/cc/kune/core/server/rpc/SocialNetworkRPC.java
trunk/src/main/java/cc/kune/core/server/scheduler/CronServerTasksManager.java
trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPresenter.java
trunk/src/main/java/cc/kune/lists/server/ListsServerTool.java
trunk/src/main/java/cc/kune/wave/server/kspecific/KuneAgent.java
trunk/src/main/java/cc/kune/wave/server/kspecific/KuneWaveService.java
trunk/src/main/java/cc/kune/wave/server/kspecific/KuneWaveServiceDefault.java
Log:
NEW - # 185: Implement notification levels (hourly and daily) similar to Google Wave
http://kune.ourproject.org/issues/ticket/185
Modified: trunk/DEV-GUIDE
===================================================================
--- trunk/DEV-GUIDE 2012-01-09 15:37:06 UTC (rev 1657)
+++ trunk/DEV-GUIDE 2012-01-12 01:40:41 UTC (rev 1658)
@@ -222,6 +222,8 @@
====JRuby-Rack====
+(This part in now not used, probably we should go back when we return to develop the public part)
+
We use Rails via [http://kenai.com/projects/jruby-rack/pages/Home JRuby-Rack]. Ruby on Rails + Plugins + Gems are installed in trunk/src/main/webapp/WEB-INF/. Jetty uses these gems when running, but if you run ruby directly with script/server, take into account that you are using your installed local gems.
To install gems inside this directory:
@@ -303,6 +305,14 @@
"Being written in Java, we strongly recommend following the principles outlined in Effective Java. On top of that, patterns that aid testability (dependency injection, etc) are quite important. But beyond that, I don't know if there are any other patterns or practices that would be universal across the whole thing. The web client and the server run in very different environments, so the appropriate patterns change (e.g., the client-only code doesn't have to worry about thread safety, but should worry about excessive short-lived object creation)."
+=== Docs about OT, Wave Model, etc ===
+
+http://www.codecommit.com/blog/java/understanding-and-applying-operational-transformation
+Wave Model Deep Dive: http://www.youtube.com/watch?v=6ZqpeFydq4A
+
+Or for a list:
+http://www.youtube.com/user/GoogleDevelopers/search?query=Wave
+
=== Running Hosted Mode without Wave webclient ===
See class WaveClientProvider in Kune (in a short term, we should define this in a .gwt.xml not there, but this is a start point).
Modified: trunk/TODO
===================================================================
--- trunk/TODO 2012-01-09 15:37:06 UTC (rev 1657)
+++ trunk/TODO 2012-01-12 01:40:41 UTC (rev 1658)
@@ -13,12 +13,15 @@
* SHORT-TERM (URGENT)
** Emil notifications for new waves
+*** Migration of DB!!!!!
+*** Text for UI
Email Notifications
How often do you want to receive notifications?
almost immediately
at most hourly
at most daily
I don't need email notifications
+*** Cron and pseudocode
** group.inexistentTool nasty error
** calendar support
*** gwt-cal + http://ical4j.sourceforge.net/introduction.html
Modified: trunk/src/main/java/cc/kune/core/server/KuneRackModule.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/KuneRackModule.java 2012-01-09 15:37:06 UTC (rev 1657)
+++ trunk/src/main/java/cc/kune/core/server/KuneRackModule.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -57,12 +57,15 @@
import cc.kune.core.server.rest.I18nTranslationJSONService;
import cc.kune.core.server.rest.TestJSONService;
import cc.kune.core.server.rest.UserJSONService;
+import cc.kune.core.server.scheduler.CronServerTasksManager;
import cc.kune.docs.server.DocumentServerModule;
import cc.kune.events.server.EventsServerModule;
import cc.kune.hspace.client.ClientStatsService;
import cc.kune.lists.client.rpc.ListsService;
import cc.kune.lists.server.ListsServerModule;
import cc.kune.tasks.server.TaskServerModule;
+import cc.kune.wave.server.KuneWaveServerUtils;
+import cc.kune.wave.server.kspecific.WaveEmailNotifier;
import cc.kune.wiki.server.WikiServerModule;
import com.google.inject.AbstractModule;
@@ -118,6 +121,7 @@
if (sessionScope != null) {
bindScope(SessionScoped.class, sessionScope);
}
+ requestStaticInjection(KuneWaveServerUtils.class);
}
};
}
@@ -128,7 +132,11 @@
installGuiceModules(builder);
builder.add(KuneContainerListener.class);
+ builder.add(WaveEmailNotifier.class);
+ // Cron tasks
+ builder.add(CronServerTasksManager.class);
+
builder.exclude("/http-bind.*");
builder.exclude("/public/.*");
builder.exclude("/images/.*");
Modified: trunk/src/main/java/cc/kune/core/server/PlatformServerModule.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/PlatformServerModule.java 2012-01-09 15:37:06 UTC (rev 1657)
+++ trunk/src/main/java/cc/kune/core/server/PlatformServerModule.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -87,8 +87,8 @@
import cc.kune.core.server.manager.impl.UserManagerDefault;
import cc.kune.core.server.mapper.DozerMapper;
import cc.kune.core.server.mapper.Mapper;
-import cc.kune.core.server.notifier.NotifySender;
-import cc.kune.core.server.notifier.NotifySenderDefault;
+import cc.kune.core.server.notifier.NotificationSender;
+import cc.kune.core.server.notifier.NotificationSenderDefault;
import cc.kune.core.server.notifier.UsersOnline;
import cc.kune.core.server.rpc.ContentRPC;
import cc.kune.core.server.rpc.GroupRPC;
@@ -114,7 +114,6 @@
import cc.kune.wave.server.ParticipantUtils;
import cc.kune.wave.server.kspecific.KuneWaveService;
import cc.kune.wave.server.kspecific.KuneWaveServiceDefault;
-import cc.kune.wave.server.kspecific.WaveEmailNotifier;
import com.google.inject.Singleton;
import com.google.inject.matcher.Matchers;
@@ -197,8 +196,7 @@
bind(UsersOnline.class).to(UserSessionManager.class).in(Singleton.class);
requestStaticInjection(AccessRightsUtils.class);
bind(CronServerTasksManager.class).in(Singleton.class);
- bind(NotifySender.class).to(NotifySenderDefault.class).in(Singleton.class);
- bind(WaveEmailNotifier.class).in(Singleton.class);
+ bind(NotificationSender.class).to(NotificationSenderDefault.class).in(Singleton.class);
bindInterceptor(Matchers.any(), Matchers.annotatedWith(Authenticated.class),
outermostCall(new AuthenticatedMethodInterceptor()));
bindInterceptor(Matchers.any(), Matchers.annotatedWith(Authorizated.class),
Modified: trunk/src/main/java/cc/kune/core/server/content/ContentManagerDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/content/ContentManagerDefault.java 2012-01-09 15:37:06 UTC (rev 1657)
+++ trunk/src/main/java/cc/kune/core/server/content/ContentManagerDefault.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -56,7 +56,7 @@
import cc.kune.domain.finders.ContentFinder;
import cc.kune.domain.finders.I18nLanguageFinder;
import cc.kune.domain.finders.UserFinder;
-import cc.kune.wave.server.KuneWaveUtils;
+import cc.kune.wave.server.KuneWaveServerUtils;
import cc.kune.wave.server.ParticipantUtils;
import cc.kune.wave.server.kspecific.KuneWaveService;
@@ -104,7 +104,7 @@
}
public void addGadgetToContent(final User user, final Content content, final URL gadgetUrl) {
- kuneWaveManager.addGadget(KuneWaveUtils.getWaveRef(content),
+ kuneWaveManager.addGadget(KuneWaveServerUtils.getWaveRef(content),
participantUtils.of(user.getShortName()).toString(), gadgetUrl);
}
@@ -112,7 +112,7 @@
public void addParticipant(final User user, final Long contentId, final String participant) {
final Content content = finder.getContent(contentId);
if (content.isWave()) {
- kuneWaveManager.addParticipants(KuneWaveUtils.getWaveRef(content),
+ kuneWaveManager.addParticipants(KuneWaveServerUtils.getWaveRef(content),
content.getAuthors().get(0).getShortName(), user.getShortName(), participant);
}
}
@@ -243,7 +243,7 @@
content.getLastRevision().setTitle(newTitleWithoutNL);
if (content.isWave()) {
final String author = content.getAuthors().get(0).getShortName();
- kuneWaveManager.setTitle(KuneWaveUtils.getWaveRef(content), newTitle, author);
+ kuneWaveManager.setTitle(KuneWaveServerUtils.getWaveRef(content), newTitle, author);
}
setModifiedTime(content);
return content;
Modified: trunk/src/main/java/cc/kune/core/server/mail/FormatedString.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/mail/FormatedString.java 2012-01-09 15:37:06 UTC (rev 1657)
+++ trunk/src/main/java/cc/kune/core/server/mail/FormatedString.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -1,5 +1,8 @@
package cc.kune.core.server.mail;
+import java.util.Arrays;
+
+import com.calclab.emite.core.client.packet.TextUtils;
import com.google.common.base.Preconditions;
/**
@@ -139,4 +142,11 @@
public boolean shouldBeTranslated() {
return shouldBeTranslated;
}
+
+ @Override
+ public String toString() {
+ return "FormatedString ['" + TextUtils.ellipsis(template, 40) + "', args=" + Arrays.toString(args)
+ + ", shouldBeTranslated=" + shouldBeTranslated + "]";
+ }
+
}
Modified: trunk/src/main/java/cc/kune/core/server/manager/impl/KuneWaveManagerDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/manager/impl/KuneWaveManagerDefault.java 2012-01-09 15:37:06 UTC (rev 1657)
+++ trunk/src/main/java/cc/kune/core/server/manager/impl/KuneWaveManagerDefault.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -36,7 +36,7 @@
import cc.kune.domain.User;
import cc.kune.domain.UserBuddiesData;
import cc.kune.domain.finders.GroupFinder;
-import cc.kune.wave.server.KuneWaveUtils;
+import cc.kune.wave.server.KuneWaveServerUtils;
import cc.kune.wave.server.ParticipantUtils;
import cc.kune.wave.server.kspecific.KuneWaveService;
@@ -71,7 +71,7 @@
for (final String part : participants) {
partIds.add(participantUtils.of(part));
}
- return KuneWaveUtils.getUrl(waveService.createWave(title, body,
+ return KuneWaveServerUtils.getUrl(waveService.createWave(title, body,
partIds.toArray(new ParticipantId[0])));
}
@@ -104,6 +104,6 @@
toList.addAll(group.getSocialNetwork().getAccessLists().getEditors().getList());
}
}
- return KuneWaveUtils.getUrl(waveService.createWave(title, message, participantUtils.listFrom(toList)));
+ return KuneWaveServerUtils.getUrl(waveService.createWave(title, message, participantUtils.listFrom(toList)));
}
}
Modified: trunk/src/main/java/cc/kune/core/server/manager/impl/UserManagerDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/manager/impl/UserManagerDefault.java 2012-01-09 15:37:06 UTC (rev 1657)
+++ trunk/src/main/java/cc/kune/core/server/manager/impl/UserManagerDefault.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -57,7 +57,7 @@
import cc.kune.core.server.manager.I18nLanguageManager;
import cc.kune.core.server.manager.SearchResult;
import cc.kune.core.server.manager.UserManager;
-import cc.kune.core.server.notifier.NotifyService;
+import cc.kune.core.server.notifier.NotificationService;
import cc.kune.core.server.properties.ChatProperties;
import cc.kune.core.server.properties.KuneBasicProperties;
import cc.kune.core.server.xmpp.ChatConnection;
@@ -89,7 +89,7 @@
private final I18nTranslationServiceMultiLang i18n;
private final KuneWaveService kuneWaveManager;
private final I18nLanguageManager languageManager;
- private final NotifyService notifyService;
+ private final NotificationService notifyService;
private final ParticipantUtils participantUtils;
private final KuneBasicProperties properties;
private final UserFinder userFinder;
@@ -104,7 +104,7 @@
final I18nTranslationServiceMultiLang i18n, final CustomUserRegistrationServlet waveUserRegister,
final AccountStore waveAccountStore, final KuneWaveService kuneWaveManager,
final ParticipantUtils participantUtils, final KuneBasicProperties properties,
- final GroupManager groupManager, final NotifyService notifyService) {
+ final GroupManager groupManager, final NotificationService notifyService) {
super(provider, User.class);
this.userFinder = finder;
this.languageManager = languageManager;
Added: trunk/src/main/java/cc/kune/core/server/notifier/DestinationProvider.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/notifier/DestinationProvider.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/server/notifier/DestinationProvider.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -0,0 +1,19 @@
+package cc.kune.core.server.notifier;
+
+import java.util.Collection;
+
+import cc.kune.domain.User;
+
+/**
+ * The Interface DestinationProvider is used to provide a way to get a list of
+ * Users (for instance to send notifications to them)
+ */
+public interface DestinationProvider {
+
+ /**
+ * Gets the destination list
+ *
+ * @return the destination
+ */
+ Collection<User> getDest();
+}
Copied: trunk/src/main/java/cc/kune/core/server/notifier/NotificationHtmlHelper.java (from rev 1655, trunk/src/main/java/cc/kune/core/server/notifier/NotifyHtmlHelper.java)
===================================================================
--- trunk/src/main/java/cc/kune/core/server/notifier/NotificationHtmlHelper.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/server/notifier/NotificationHtmlHelper.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -0,0 +1,59 @@
+package cc.kune.core.server.notifier;
+
+import cc.kune.core.server.mail.FormatedString;
+import cc.kune.core.server.utils.AbsoluteFileDownloadUtils;
+import cc.kune.core.shared.utils.SharedFileDownloadUtils;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+
+/**
+ * The Class NotifyHtmlHelper is used to get html snippets for email
+ * notifications.
+ */
+@Singleton
+public class NotificationHtmlHelper {
+
+ /** The template used from messages snippets from a group */
+ private static String GROUP_TEMPLATE = "<table style=\"FIXME\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\" width=\"100%%\">"
+ + "<tbody><tr>"
+ + "<td style=\"\" valign=\"top\"><a href=\"%s\">%s</a></td>"
+ + "<td style=\"\" valign=\"top\" width=\"100%%\">"
+ + "<a href=\"%s\">%s</a><br>"
+ + "%s"
+ + "</td></tr></tbody></table>";
+
+ private final SharedFileDownloadUtils fileDownloadUtils;
+
+ /**
+ * Instantiates a new notify html helper.
+ *
+ * @param fileDownloadUtils
+ * the file download utils
+ */
+ @Inject
+ public NotificationHtmlHelper(final AbsoluteFileDownloadUtils fileDownloadUtils) {
+ this.fileDownloadUtils = fileDownloadUtils;
+ }
+
+ /**
+ * Generates a group notification in html like [logo|message]
+ *
+ * @param groupName
+ * the group name you want to get the notification
+ * @param hasLogo
+ * the has logo?
+ * @param message
+ * the message to show close to the logo
+ * @param readMoreMsg
+ * the read more msg
+ * @return the html string
+ */
+ public FormatedString groupNotification(final String groupName, final boolean hasLogo,
+ final String message) {
+ final String groupUrl = fileDownloadUtils.getPrefix() + "#" + groupName;
+ return FormatedString.build(false, GROUP_TEMPLATE, groupUrl,
+ fileDownloadUtils.getLogoAvatarHtml(groupName, hasLogo, false, 50, 50), groupUrl, groupName,
+ message);
+ }
+}
Added: trunk/src/main/java/cc/kune/core/server/notifier/NotificationSender.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/notifier/NotificationSender.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/server/notifier/NotificationSender.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -0,0 +1,20 @@
+package cc.kune.core.server.notifier;
+
+import cc.kune.core.shared.domain.dto.EmailNotificationFrequency;
+
+/**
+ * The Interface PendingNotificationSender. Used to send pending notifications
+ */
+public interface NotificationSender {
+
+ /**
+ * Send the notification to users with some frequency configured
+ *
+ * @param notification
+ * the notification to send
+ * @param currentFrequency
+ * the current frequency (only users with this frequency should be
+ * processed
+ */
+ void send(PendingNotification notification, EmailNotificationFrequency currentFrequency);
+}
Copied: trunk/src/main/java/cc/kune/core/server/notifier/NotificationSenderDefault.java (from rev 1657, trunk/src/main/java/cc/kune/core/server/notifier/NotifySenderDefault.java)
===================================================================
--- trunk/src/main/java/cc/kune/core/server/notifier/NotificationSenderDefault.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/server/notifier/NotificationSenderDefault.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -0,0 +1,105 @@
+package cc.kune.core.server.notifier;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.commons.io.FileUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import cc.kune.common.shared.utils.TextUtils;
+import cc.kune.core.server.i18n.I18nTranslationServiceMultiLang;
+import cc.kune.core.server.mail.FormatedString;
+import cc.kune.core.server.mail.MailService;
+import cc.kune.core.server.properties.KuneProperties;
+import cc.kune.core.server.xmpp.XmppManager;
+import cc.kune.core.shared.domain.dto.EmailNotificationFrequency;
+import cc.kune.domain.User;
+import cc.kune.wave.server.kspecific.KuneWaveService;
+
+import com.google.common.base.Preconditions;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+
+@Singleton
+public class NotificationSenderDefault implements NotificationSender {
+ public static final Log LOG = LogFactory.getLog(NotificationSenderDefault.class);
+ private final String emailTemplate;
+ private final I18nTranslationServiceMultiLang i18n;
+ private final MailService mailService;
+ private final String subjectPrefix;
+ private final UsersOnline usersOnline;
+ private final KuneWaveService waveService;
+ private final XmppManager xmppManager;
+
+ @Inject
+ public NotificationSenderDefault(final MailService mailService, final KuneWaveService waveService,
+ final XmppManager xmppManager, final I18nTranslationServiceMultiLang i18n,
+ final UsersOnline usersOnline, final KuneProperties kuneProperties) throws IOException {
+ this.mailService = mailService;
+ this.waveService = waveService;
+ this.xmppManager = xmppManager;
+ this.i18n = i18n;
+ this.usersOnline = usersOnline;
+ emailTemplate = FileUtils.readFileToString(new File(
+ kuneProperties.get(KuneProperties.SITE_EMAIL_TEMPLATE)));
+ Preconditions.checkNotNull(emailTemplate);
+ Preconditions.checkArgument(TextUtils.notEmpty(emailTemplate));
+ subjectPrefix = new StringBuffer("[").append(kuneProperties.get(KuneProperties.SITE_NAME)).append(
+ "] ").toString();
+ }
+
+ @Override
+ public void send(final PendingNotification notification, final EmailNotificationFrequency withFrequency) {
+ for (final User user : notification.getDestProvider().getDest()) {
+ final String username = user.getShortName();
+ final FormatedString subject = notification.getSubject();
+ final FormatedString body = notification.getBody();
+ final NotificationType notifyType = notification.getNotifyType();
+ final boolean forceSend = notification.isForceSend();
+ final boolean isHtml = notification.isHtml();
+
+ subject.setTemplate(subjectPrefix + subject.getTemplate());
+ if (subject.shouldBeTranslated()) {
+ // Translate per recipient language
+ // final String subjectTranslation = i18n.tWithNT(user.getLanguage(),
+ // subject.getTemplate(), "");
+ // if (subjectTranslation != null) {
+ // Right now commented because we are only testing
+ // subject.setTemplate(subjectTranslation);
+ // }
+ }
+ if (body.shouldBeTranslated()) {
+ // final String bodyTranslation = i18n.tWithNT(user.getLanguage(),
+ // body.getTemplate(), "");
+ // if (bodyTranslation != null) {
+ // Right now commented because we are only testing
+ // body.setTemplate(bodyTranslation);
+ // }
+ }
+ switch (notifyType) {
+ case chat:
+ // FIXME seems that html is not sending correctly... check server specs
+ xmppManager.sendMessage(username,
+ String.format("<b>%s</b>%s", subject.getString(), body.getString()));
+ break;
+ case email:
+ if (forceSend || (!usersOnline.isLogged(username) && withFrequency == user.getEmailNotifFreq())) {
+ // we'll send this notification if is mandatory or this user is not
+ // only and has this freq configured
+ mailService.send(subject, FormatedString.build(emailTemplate.replace("%s", body.getString())),
+ isHtml, user.getEmail());
+ }
+ break;
+ case wave:
+ if (isHtml) {
+ LOG.error("Wave html messages not supported yet");
+ }
+ waveService.createWave(subject.getString(), body.getString(), username);
+ break;
+ }
+ }
+
+ }
+
+}
Copied: trunk/src/main/java/cc/kune/core/server/notifier/NotificationService.java (from rev 1657, trunk/src/main/java/cc/kune/core/server/notifier/NotifyService.java)
===================================================================
--- trunk/src/main/java/cc/kune/core/server/notifier/NotificationService.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/server/notifier/NotificationService.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -0,0 +1,92 @@
+package cc.kune.core.server.notifier;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.NoResultException;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import cc.kune.core.server.mail.FormatedString;
+import cc.kune.domain.Group;
+import cc.kune.domain.User;
+import cc.kune.domain.finders.UserFinder;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+
+@Singleton
+public class NotificationService {
+
+ public static final Log LOG = LogFactory.getLog(NotificationService.class);
+ private final NotificationHtmlHelper helper;
+ private final PendingNotificationSender sender;
+ private final UserFinder userFinder;
+
+ @Inject
+ NotificationService(final PendingNotificationSender sender, final NotificationHtmlHelper helper,
+ final UserFinder userFinder) {
+ this.sender = sender;
+ this.helper = helper;
+ this.userFinder = userFinder;
+ }
+
+ @SuppressWarnings("unchecked")
+ private void getAllUserMembers(final Set<User> users, final Group groupToNotify,
+ final boolean onlyAdmins) {
+ final Collection<Group> members;
+ final Set<Group> admins = groupToNotify.getSocialNetwork().getAccessLists().getAdmins().getList();
+ if (onlyAdmins) {
+ members = admins;
+ } else {
+ final Set<Group> collabs = groupToNotify.getSocialNetwork().getAccessLists().getEditors().getList();
+ members = CollectionUtils.union(admins, collabs);
+ }
+ for (final Group member : members) {
+ if (member.isPersonal()) {
+ final String shortName = member.getShortName();
+ try {
+ final User user = userFinder.findByShortName(shortName);
+ users.add(user);
+ } catch (final NoResultException e) {
+ LOG.error(String.format("This personal group %s is not a local user", shortName));
+ }
+ } else {
+ // Is a group, so go recursively
+ getAllUserMembers(users, member, onlyAdmins);
+ }
+ }
+
+ }
+
+ public void notifyGroup(final Group groupToNotify, final Group groupSender, final String subject,
+ final String message) {
+ final Set<User> members = new HashSet<User>();
+ getAllUserMembers(members, groupToNotify, false);
+ notifyToAll(groupSender, subject, message, members);
+ }
+
+ public void notifyGroupAdmins(final Group groupToNotify, final Group groupSender,
+ final String subject, final String message) {
+ final Set<User> adminMembers = new HashSet<User>();
+ getAllUserMembers(adminMembers, groupToNotify, true);
+ notifyToAll(groupSender, subject, message, adminMembers);
+ }
+
+ private void notifyToAll(final Group groupSender, final String subject, final String message,
+ final Collection<User> users) {
+ for (final User to : users) {
+ sender.add(NotificationType.email, FormatedString.build(subject),
+ helper.groupNotification(groupSender.getShortName(), groupSender.hasLogo(), message), true,
+ true, to);
+ }
+ }
+
+ public void notifyUser(final User to, final Group group, final String subject, final String message) {
+ sender.add(NotificationType.email, FormatedString.build(subject),
+ helper.groupNotification(group.getShortName(), group.hasLogo(), message), true, true, to);
+ }
+}
Copied: trunk/src/main/java/cc/kune/core/server/notifier/NotificationType.java (from rev 1655, trunk/src/main/java/cc/kune/core/server/notifier/NotifyType.java)
===================================================================
--- trunk/src/main/java/cc/kune/core/server/notifier/NotificationType.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/server/notifier/NotificationType.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -0,0 +1,9 @@
+package cc.kune.core.server.notifier;
+
+/**
+ * Type of notifications for users
+ *
+ */
+public enum NotificationType {
+ chat, email, wave
+}
Deleted: trunk/src/main/java/cc/kune/core/server/notifier/NotifyHtmlHelper.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/notifier/NotifyHtmlHelper.java 2012-01-09 15:37:06 UTC (rev 1657)
+++ trunk/src/main/java/cc/kune/core/server/notifier/NotifyHtmlHelper.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -1,59 +0,0 @@
-package cc.kune.core.server.notifier;
-
-import cc.kune.core.server.mail.FormatedString;
-import cc.kune.core.server.utils.AbsoluteFileDownloadUtils;
-import cc.kune.core.shared.utils.SharedFileDownloadUtils;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-
-/**
- * The Class NotifyHtmlHelper is used to get html snippets for email
- * notifications.
- */
-@Singleton
-public class NotifyHtmlHelper {
-
- /** The template used from messages snippets from a group */
- private static String GROUP_TEMPLATE = "<table style=\"FIXME\" border=\"0\" cellpadding=\"2\" cellspacing=\"2\" width=\"100%%\">"
- + "<tbody><tr>"
- + "<td style=\"\" valign=\"top\"><a href=\"%s\">%s</a></td>"
- + "<td style=\"\" valign=\"top\" width=\"100%%\">"
- + "<a href=\"%s\">%s</a><br>"
- + "%s"
- + "</td></tr></tbody></table>";
-
- private final SharedFileDownloadUtils fileDownloadUtils;
-
- /**
- * Instantiates a new notify html helper.
- *
- * @param fileDownloadUtils
- * the file download utils
- */
- @Inject
- public NotifyHtmlHelper(final AbsoluteFileDownloadUtils fileDownloadUtils) {
- this.fileDownloadUtils = fileDownloadUtils;
- }
-
- /**
- * Generates a group notification in html like [logo|message]
- *
- * @param groupName
- * the group name you want to get the notification
- * @param hasLogo
- * the has logo?
- * @param message
- * the message to show close to the logo
- * @param readMoreMsg
- * the read more msg
- * @return the html string
- */
- public FormatedString groupNotification(final String groupName, final boolean hasLogo,
- final String message) {
- final String groupUrl = fileDownloadUtils.getPrefix() + "#" + groupName;
- return FormatedString.build(false, GROUP_TEMPLATE, groupUrl,
- fileDownloadUtils.getLogoAvatarHtml(groupName, hasLogo, false, 50, 50), groupUrl, groupName,
- message);
- }
-}
Deleted: trunk/src/main/java/cc/kune/core/server/notifier/NotifySender.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/notifier/NotifySender.java 2012-01-09 15:37:06 UTC (rev 1657)
+++ trunk/src/main/java/cc/kune/core/server/notifier/NotifySender.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -1,49 +0,0 @@
-package cc.kune.core.server.notifier;
-
-import cc.kune.core.server.mail.FormatedString;
-import cc.kune.domain.User;
-
-/**
- * The Interface NotifySender.
- */
-public interface NotifySender {
-
- /**
- * Send a html message to the recipients (also translate the subject/body
- * using the user language)
- *
- * @param notifyType
- * the notify type (email, etc)
- * @param subject
- * the subject of the message (not translated)
- * @param body
- * the body of the message (not translated) but with %s
- * {@link String.format} args
- * @param isHtml
- * if the body is html
- * @param forceSend
- * send even this user has "no notifications" selected
- * @param recipients
- * the recipients
- */
- void send(NotifyType notifyType, FormatedString subject, FormatedString body, boolean isHtml,
- final boolean forceSend, User... recipients);
-
- /**
- * Send a text message to the recipients (also translate the subject/body
- * using the user language)
- *
- * @param notifyType
- * the notify type (email, etc)
- * @param subject
- * the subject of the message
- * @param body
- * the body of the message (no translated) but with some %s
- * {@link String.format} args
- * @param recipients
- * the recipients
- */
- @Deprecated
- void send(NotifyType notifyType, FormatedString subject, FormatedString body, User... recipients);
-
-}
Deleted: trunk/src/main/java/cc/kune/core/server/notifier/NotifySenderDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/notifier/NotifySenderDefault.java 2012-01-09 15:37:06 UTC (rev 1657)
+++ trunk/src/main/java/cc/kune/core/server/notifier/NotifySenderDefault.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -1,109 +0,0 @@
-package cc.kune.core.server.notifier;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import cc.kune.common.shared.utils.TextUtils;
-import cc.kune.core.server.i18n.I18nTranslationServiceMultiLang;
-import cc.kune.core.server.mail.FormatedString;
-import cc.kune.core.server.mail.MailService;
-import cc.kune.core.server.properties.KuneProperties;
-import cc.kune.core.server.xmpp.XmppManager;
-import cc.kune.core.shared.domain.dto.EmailNotificationFrequency;
-import cc.kune.domain.User;
-import cc.kune.wave.server.kspecific.KuneWaveService;
-
-import com.google.common.base.Preconditions;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-
-@Singleton
-public class NotifySenderDefault implements NotifySender {
- public static final Log LOG = LogFactory.getLog(NotifySenderDefault.class);
- private final String emailTemplate;
- private final I18nTranslationServiceMultiLang i18n;
- private final MailService mailService;
- private final String subjectPrefix;
- private final UsersOnline usersOnline;
- private final KuneWaveService waveService;
- private final XmppManager xmppManager;
-
- @Inject
- public NotifySenderDefault(final MailService mailService, final KuneWaveService waveService,
- final XmppManager xmppManager, final I18nTranslationServiceMultiLang i18n,
- final UsersOnline usersOnline, final KuneProperties kuneProperties) throws IOException {
- this.mailService = mailService;
- this.waveService = waveService;
- this.xmppManager = xmppManager;
- this.i18n = i18n;
- this.usersOnline = usersOnline;
- emailTemplate = FileUtils.readFileToString(new File(
- kuneProperties.get(KuneProperties.SITE_EMAIL_TEMPLATE)));
- Preconditions.checkNotNull(emailTemplate);
- Preconditions.checkArgument(TextUtils.notEmpty(emailTemplate));
- subjectPrefix = new StringBuffer("[").append(kuneProperties.get(KuneProperties.SITE_NAME)).append(
- "] ").toString();
- }
-
- @Override
- public void send(final NotifyType notifyType, final FormatedString subject, final FormatedString body,
- final boolean isHtml, final boolean forceSend, final User... recipients) {
- for (final User user : recipients) {
- final String username = user.getShortName();
- subject.setTemplate(subjectPrefix + subject.getTemplate());
- if (subject.shouldBeTranslated()) {
- // Translate per recipient language
- // final String subjectTranslation = i18n.tWithNT(user.getLanguage(),
- // subject.getTemplate(), "");
- // if (subjectTranslation != null) {
- // Right now commented because we are only testing
- // subject.setTemplate(subjectTranslation);
- // }
- }
- if (body.shouldBeTranslated()) {
- // final String bodyTranslation = i18n.tWithNT(user.getLanguage(),
- // body.getTemplate(), "");
- // if (bodyTranslation != null) {
- // Right now commented because we are only testing
- // body.setTemplate(bodyTranslation);
- // }
- }
- switch (notifyType) {
- case chat:
- // FIXME seems that html is not sending correctly... check server specs
- xmppManager.sendMessage(username,
- String.format("<b>%s</b>%s", subject.getString(), body.getString()));
- break;
- case email:
- if (forceSend || !usersOnline.isLogged(username)) {
- if (user.getEmailNotifFreq().equals(EmailNotificationFrequency.immediately)) {
- mailService.send(subject,
- FormatedString.build(emailTemplate.replace("%s", body.getString())), isHtml,
- user.getEmail());
- } else {
- // TODO: handle other types of notifications frequencies
- }
- }
- break;
- case wave:
- if (isHtml) {
- LOG.error("Wave html messages not supported yet");
- }
- waveService.createWave(subject.getString(), body.getString(), username);
- break;
- }
- }
- }
-
- @Override
- @Deprecated
- public void send(final NotifyType notifyType, final FormatedString subject, final FormatedString body,
- final User... dests) {
- send(notifyType, subject, body, false, false, dests);
- }
-
-}
Deleted: trunk/src/main/java/cc/kune/core/server/notifier/NotifyService.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/notifier/NotifyService.java 2012-01-09 15:37:06 UTC (rev 1657)
+++ trunk/src/main/java/cc/kune/core/server/notifier/NotifyService.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -1,91 +0,0 @@
-package cc.kune.core.server.notifier;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.persistence.NoResultException;
-
-import org.apache.commons.collections.CollectionUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import cc.kune.core.server.mail.FormatedString;
-import cc.kune.domain.Group;
-import cc.kune.domain.User;
-import cc.kune.domain.finders.UserFinder;
-
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-
-@Singleton
-public class NotifyService {
-
- public static final Log LOG = LogFactory.getLog(NotifyService.class);
- private final NotifyHtmlHelper helper;
- private final NotifySender sender;
- private final UserFinder userFinder;
-
- @Inject
- NotifyService(final NotifySender sender, final NotifyHtmlHelper helper, final UserFinder userFinder) {
- this.sender = sender;
- this.helper = helper;
- this.userFinder = userFinder;
- }
-
- @SuppressWarnings("unchecked")
- private void getAllUserMembers(final Set<User> users, final Group groupToNotify,
- final boolean onlyAdmins) {
- final Collection<Group> members;
- final Set<Group> admins = groupToNotify.getSocialNetwork().getAccessLists().getAdmins().getList();
- if (onlyAdmins) {
- members = admins;
- } else {
- final Set<Group> collabs = groupToNotify.getSocialNetwork().getAccessLists().getEditors().getList();
- members = CollectionUtils.union(admins, collabs);
- }
- for (final Group member : members) {
- if (member.isPersonal()) {
- final String shortName = member.getShortName();
- try {
- final User user = userFinder.findByShortName(shortName);
- users.add(user);
- } catch (final NoResultException e) {
- LOG.error(String.format("This personal group %s is not a local user", shortName));
- }
- } else {
- // Is a group, so go recursively
- getAllUserMembers(users, member, onlyAdmins);
- }
- }
-
- }
-
- public void notifyGroup(final Group groupToNotify, final Group groupSender, final String subject,
- final String message) {
- final Set<User> members = new HashSet<User>();
- getAllUserMembers(members, groupToNotify, false);
- notifyToAll(groupSender, subject, message, members);
- }
-
- public void notifyGroupAdmins(final Group groupToNotify, final Group groupSender,
- final String subject, final String message) {
- final Set<User> adminMembers = new HashSet<User>();
- getAllUserMembers(adminMembers, groupToNotify, true);
- notifyToAll(groupSender, subject, message, adminMembers);
- }
-
- private void notifyToAll(final Group groupSender, final String subject, final String message,
- final Collection<User> users) {
- for (final User to : users) {
- sender.send(NotifyType.email, FormatedString.build(subject),
- helper.groupNotification(groupSender.getShortName(), groupSender.hasLogo(), message), true,
- true, to);
- }
- }
-
- public void notifyUser(final User to, final Group group, final String subject, final String message) {
- sender.send(NotifyType.email, FormatedString.build(subject),
- helper.groupNotification(group.getShortName(), group.hasLogo(), message), true, true, to);
- }
-}
Deleted: trunk/src/main/java/cc/kune/core/server/notifier/NotifyType.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/notifier/NotifyType.java 2012-01-09 15:37:06 UTC (rev 1657)
+++ trunk/src/main/java/cc/kune/core/server/notifier/NotifyType.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -1,9 +0,0 @@
-package cc.kune.core.server.notifier;
-
-/**
- * Type of notifications for users
- *
- */
-public enum NotifyType {
- chat, email, wave
-}
Added: trunk/src/main/java/cc/kune/core/server/notifier/PendingNotification.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/notifier/PendingNotification.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/server/notifier/PendingNotification.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -0,0 +1,110 @@
+package cc.kune.core.server.notifier;
+
+import cc.kune.core.server.mail.FormatedString;
+
+/**
+ * The Class PendingNotification is used to store and send notifications (for
+ * instance email) via cron
+ */
+public class PendingNotification {
+
+ /** The body. */
+ private final FormatedString body;
+
+ /** The dest provider. */
+ private final DestinationProvider destProvider;
+
+ /** The force send. */
+ private final boolean forceSend;
+
+ /** The is html. */
+ private final boolean isHtml;
+
+ /** The notify type. */
+ private final NotificationType notifyType;
+
+ /** The subject. */
+ private final FormatedString subject;
+
+ /**
+ * Instantiates a new pending notification
+ *
+ * @param notifyType
+ * the notify type
+ * @param subject
+ * the subject
+ * @param body
+ * the body
+ * @param isHtml
+ * the is html
+ * @param forceSend
+ * the force send
+ * @param destProvider
+ * the dest provider
+ */
+ public PendingNotification(final NotificationType notifyType, final FormatedString subject,
+ final FormatedString body, final boolean isHtml, final boolean forceSend,
+ final DestinationProvider destProvider) {
+ this.notifyType = notifyType;
+ this.subject = subject;
+ this.body = body;
+ this.isHtml = isHtml;
+ this.forceSend = forceSend;
+ this.destProvider = destProvider;
+ }
+
+ /**
+ * Gets the body.
+ *
+ * @return the body
+ */
+ public FormatedString getBody() {
+ return body;
+ }
+
+ /**
+ * Gets the dest provider.
+ *
+ * @return the dest provider
+ */
+ public DestinationProvider getDestProvider() {
+ return destProvider;
+ }
+
+ /**
+ * Gets the notify type.
+ *
+ * @return the notify type
+ */
+ public NotificationType getNotifyType() {
+ return notifyType;
+ }
+
+ /**
+ * Gets the subject.
+ *
+ * @return the subject
+ */
+ public FormatedString getSubject() {
+ return subject;
+ }
+
+ /**
+ * Checks if is force send.
+ *
+ * @return true, if is force send
+ */
+ public boolean isForceSend() {
+ return forceSend;
+ }
+
+ /**
+ * Checks if is html.
+ *
+ * @return true, if is html
+ */
+ public boolean isHtml() {
+ return isHtml;
+ }
+
+}
Added: trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationDailyJob.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationDailyJob.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationDailyJob.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -0,0 +1,33 @@
+package cc.kune.core.server.notifier;
+
+import java.text.ParseException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.quartz.SchedulerException;
+
+import com.google.inject.Inject;
+
+public class PendingNotificationDailyJob implements Job {
+
+ public static final Log LOG = LogFactory.getLog(PendingNotificationDailyJob.class);
+
+ private final PendingNotificationSender pendingManager;
+
+ @Inject
+ public PendingNotificationDailyJob(final PendingNotificationSender pendingManager)
+ throws ParseException, SchedulerException {
+ this.pendingManager = pendingManager;
+ }
+
+ @Override
+ public void execute(final JobExecutionContext context) throws JobExecutionException {
+ LOG.info(String.format("Daily notifications cron job start, %s", pendingManager));
+ pendingManager.sendDailyNotifications();
+ LOG.info(String.format("Daily notifications cron job end, %s", pendingManager));
+ }
+
+}
Added: trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationHourlyJob.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationHourlyJob.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationHourlyJob.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -0,0 +1,38 @@
+package cc.kune.core.server.notifier;
+
+import java.text.ParseException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.quartz.SchedulerException;
+
+import cc.kune.wave.server.kspecific.WaveEmailNotifier;
+
+import com.google.inject.Inject;
+
+public class PendingNotificationHourlyJob implements Job {
+
+ public static final Log LOG = LogFactory.getLog(PendingNotificationHourlyJob.class);
+ private final PendingNotificationSender pendingManager;
+
+ private final WaveEmailNotifier waveNotifier;
+
+ @Inject
+ public PendingNotificationHourlyJob(final PendingNotificationSender pendingManager,
+ final WaveEmailNotifier waveNotifier) throws ParseException, SchedulerException {
+ this.pendingManager = pendingManager;
+ this.waveNotifier = waveNotifier;
+ }
+
+ @Override
+ public void execute(final JobExecutionContext context) throws JobExecutionException {
+ LOG.info(String.format("Hourly notifications cron job start, %s", pendingManager));
+ pendingManager.sendHourlyNotifications();
+ waveNotifier.clearUpdatedWaves();
+ LOG.info(String.format("Hourly notifications cron job end, %s", pendingManager));
+ }
+
+}
Added: trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationImmediateJob.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationImmediateJob.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationImmediateJob.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -0,0 +1,33 @@
+package cc.kune.core.server.notifier;
+
+import java.text.ParseException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.quartz.SchedulerException;
+
+import com.google.inject.Inject;
+
+public class PendingNotificationImmediateJob implements Job {
+
+ public static final Log LOG = LogFactory.getLog(PendingNotificationImmediateJob.class);
+
+ private final PendingNotificationSender pendingManager;
+
+ @Inject
+ public PendingNotificationImmediateJob(final PendingNotificationSender pendingManager)
+ throws ParseException, SchedulerException {
+ this.pendingManager = pendingManager;
+ }
+
+ @Override
+ public void execute(final JobExecutionContext context) throws JobExecutionException {
+ LOG.info(String.format("Immediate notifications cron job start, %s", pendingManager));
+ pendingManager.sendImmediateNotifications();
+ LOG.info(String.format("Immediate notifications cron job end, %s", pendingManager));
+ }
+
+}
Added: trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationSender.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationSender.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/server/notifier/PendingNotificationSender.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -0,0 +1,148 @@
+package cc.kune.core.server.notifier;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import cc.kune.core.server.mail.FormatedString;
+import cc.kune.core.shared.domain.dto.EmailNotificationFrequency;
+import cc.kune.domain.User;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+
+/**
+ * The Class PendingNotificationSender is used to store and send pending
+ * notifications via cron tasks.
+ */
+@Singleton
+public class PendingNotificationSender {
+
+ /** The Constant NO_NEXT. */
+ private static final Collection<PendingNotification> NO_NEXT = null;
+
+ /** The daily pend notif. list */
+ private final Set<PendingNotification> dailyPendNotif;
+
+ /** The houry pend notif. list */
+ private final Set<PendingNotification> hourlyPendNotif;
+
+ /** The immediate pend notif. list */
+ private final Set<PendingNotification> immediatePendNotif;
+
+ /** The sender. */
+ private final NotificationSender sender;
+
+ /**
+ * Instantiates a new pending notifications manager.
+ *
+ * @param sender
+ * the sender
+ */
+ @Inject
+ public PendingNotificationSender(final NotificationSender sender) {
+ this.sender = sender;
+ immediatePendNotif = new HashSet<PendingNotification>();
+ hourlyPendNotif = new HashSet<PendingNotification>();
+ dailyPendNotif = new HashSet<PendingNotification>();
+ }
+
+ public void add(final NotificationType type, final FormatedString subject, final FormatedString body,
+ final boolean isHtml, final boolean forceSend, final User to) {
+ add(new PendingNotification(type, subject, body, isHtml, forceSend,
+ new SimpleDestinationProvider(to)));
+ }
+
+ /**
+ * Adds a pending notification.
+ *
+ * @param notification
+ * the notification
+ */
+ public void add(final PendingNotification notification) {
+ if (!hourlyPendNotif.contains(notification)) {
+ // If we have send a similar notification this hour just ignore
+ immediatePendNotif.add(notification);
+ }
+ }
+
+ /**
+ * Gets the daily pending notifications count.
+ *
+ * @return the daily count
+ */
+ public int getDailyCount() {
+ return dailyPendNotif.size();
+ }
+
+ /**
+ * Gets the hourly pending notifications count.
+ *
+ * @return the hourly count
+ */
+ public int getHourlyCount() {
+ return hourlyPendNotif.size();
+ }
+
+ /**
+ * Gets the immediate pending notifications count.
+ *
+ * @return the immediate count
+ */
+ public int getImmediateCount() {
+ return immediatePendNotif.size();
+ }
+
+ /**
+ * Send some list of notifications (called vía cron).
+ *
+ * @param list
+ * the list to process
+ * @param nextList
+ * the next list to store (we have a list of Users some that wants an
+ * immediate notification and other that want periodical
+ * notifications instead.
+ * @param currentFreq
+ * The current frequency of notifications, that is, we'll send
+ * notifications only to users with this frequency configured
+ */
+ private void send(final Collection<PendingNotification> list,
+ final Collection<PendingNotification> nextList, final EmailNotificationFrequency currentFreq) {
+ for (final PendingNotification notification : list) {
+ sender.send(notification, currentFreq);
+ if (!notification.isForceSend() && nextList != NO_NEXT) {
+ // Forced Send, are send immediately (independent of how User has its
+ // notification configured)!
+ nextList.add(notification);
+ }
+ }
+ list.clear();
+ }
+
+ /**
+ * Send daily notifications.
+ */
+ public void sendDailyNotifications() {
+ send(dailyPendNotif, NO_NEXT, EmailNotificationFrequency.immediately);
+ }
+
+ /**
+ * Send hourly notifications.
+ */
+ public void sendHourlyNotifications() {
+ send(hourlyPendNotif, dailyPendNotif, EmailNotificationFrequency.hourly);
+ }
+
+ /**
+ * Send immediate notifications.
+ */
+ public void sendImmediateNotifications() {
+ send(immediatePendNotif, hourlyPendNotif, EmailNotificationFrequency.daily);
+ }
+
+ @Override
+ public String toString() {
+ return "pendingNotifications: [" + getImmediateCount() + ", " + getHourlyCount() + ", "
+ + getDailyCount() + "]";
+ }
+}
Added: trunk/src/main/java/cc/kune/core/server/notifier/SimpleDestinationProvider.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/notifier/SimpleDestinationProvider.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/server/notifier/SimpleDestinationProvider.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -0,0 +1,58 @@
+package cc.kune.core.server.notifier;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import cc.kune.domain.User;
+
+public class SimpleDestinationProvider implements DestinationProvider {
+ private final List<User> list;
+
+ /**
+ * Instantiates a new simple destination provider (used for single
+ * notifications like add/remove participant emails).
+ *
+ * @param user
+ * the user to send the email or other type of notification
+ */
+ public SimpleDestinationProvider(final User user) {
+ list = Arrays.asList(user);
+ }
+
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final SimpleDestinationProvider other = (SimpleDestinationProvider) obj;
+ if (list == null) {
+ if (other.list != null) {
+ return false;
+ }
+ } else if (!list.equals(other.list)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public Collection<User> getDest() {
+ return list;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((list == null) ? 0 : list.hashCode());
+ return result;
+ }
+
+}
Added: trunk/src/main/java/cc/kune/core/server/notifier/WaveDestinationProvider.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/notifier/WaveDestinationProvider.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/server/notifier/WaveDestinationProvider.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -0,0 +1,88 @@
+package cc.kune.core.server.notifier;
+
+import java.util.Collection;
+
+import org.waveprotocol.wave.model.waveref.WaveRef;
+
+import cc.kune.domain.User;
+import cc.kune.wave.server.KuneWaveServerUtils;
+
+/**
+ * The Class WaveDestinationProvider. A WaveRef is used to get the participants
+ * and to send notifications to them
+ */
+public class WaveDestinationProvider implements DestinationProvider {
+
+ private final String author;
+
+ /** The list. */
+ private Collection<User> list;
+
+ /** The ref. */
+ private final WaveRef ref;
+
+ /**
+ * Instantiates a new wave destination provider.
+ *
+ * @param ref
+ * the ref
+ */
+ public WaveDestinationProvider(final WaveRef ref, final String author) {
+ this.ref = ref;
+ this.author = author;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(final Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final WaveDestinationProvider other = (WaveDestinationProvider) obj;
+ if (ref == null) {
+ if (other.ref != null) {
+ return false;
+ }
+ } else if (!ref.equals(other.ref)) {
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see cc.kune.wave.server.kspecific.pendnotif.DestinationProvider#getDest()
+ */
+ @Override
+ public Collection<User> getDest() {
+ if (list == null) {
+ list = KuneWaveServerUtils.getLocalParticipants(ref, author);
+ }
+ return list;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((ref == null) ? 0 : ref.hashCode());
+ return result;
+ }
+
+}
Modified: trunk/src/main/java/cc/kune/core/server/rack/RackServletFilter.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/rack/RackServletFilter.java 2012-01-09 15:37:06 UTC (rev 1657)
+++ trunk/src/main/java/cc/kune/core/server/rack/RackServletFilter.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -32,15 +32,13 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.quartz.SchedulerException;
import org.waveprotocol.box.server.rpc.ServerRpcProvider;
import cc.kune.core.server.error.ServerException;
import cc.kune.core.server.rack.dock.Dock;
import cc.kune.core.server.rack.dock.RequestMatcher;
import cc.kune.core.server.rack.utils.RackHelper;
-import cc.kune.core.server.scheduler.CronServerTasksManager;
-import cc.kune.wave.server.kspecific.WaveEmailNotifier;
+import cc.kune.core.server.scheduler.CustomJobFactory;
import com.google.inject.Injector;
@@ -143,16 +141,12 @@
rack = builder.getRack();
injector = (Injector) filterConfig.getServletContext().getAttribute(INJECTOR_PARENT_ATTRIBUTE);
final Injector kuneChildInjector = installInjector(filterConfig, rack, injector);
+ final CustomJobFactory jobFactory = kuneChildInjector.getInstance(CustomJobFactory.class);
+ jobFactory.setInjector(kuneChildInjector);
startContainerListeners(rack.getListeners(), kuneChildInjector);
docks = rack.getDocks();
excludes = rack.getExcludes();
initFilters(filterConfig);
- kuneChildInjector.getInstance(WaveEmailNotifier.class);
- try {
- kuneChildInjector.getInstance(CronServerTasksManager.class).start();
- } catch (final SchedulerException e) {
- LOG.error("Error starting cron scheduler", e);
- }
LOG.debug("INITIALIZATION DONE!");
}
@@ -181,7 +175,7 @@
private void stopContainerListeners(final List<Class<? extends ContainerListener>> listenerClasses,
final Injector injector) {
- LOG.debug("STOPING CONTAINER LISTENERS...");
+ LOG.debug("STOPPING CONTAINER LISTENERS...");
for (final Class<? extends ContainerListener> listenerClass : listenerClasses) {
final ContainerListener listener = injector.getInstance(listenerClass);
listener.stop();
Modified: trunk/src/main/java/cc/kune/core/server/rpc/SocialNetworkRPC.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/rpc/SocialNetworkRPC.java 2012-01-09 15:37:06 UTC (rev 1657)
+++ trunk/src/main/java/cc/kune/core/server/rpc/SocialNetworkRPC.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -28,7 +28,7 @@
import cc.kune.core.server.manager.GroupManager;
import cc.kune.core.server.manager.SocialNetworkManager;
import cc.kune.core.server.mapper.Mapper;
-import cc.kune.core.server.notifier.NotifyService;
+import cc.kune.core.server.notifier.NotificationService;
import cc.kune.core.shared.domain.AccessRol;
import cc.kune.core.shared.domain.utils.StateToken;
import cc.kune.core.shared.dto.SocialNetworkDataDTO;
@@ -43,14 +43,14 @@
private final GroupManager groupManager;
private final Mapper mapper;
- private final NotifyService notifyService;
+ private final NotificationService notifyService;
private final SocialNetworkManager socialNetworkManager;
private final UserSessionManager userSessionManager;
@Inject
public SocialNetworkRPC(final UserSessionManager userSessionManager, final GroupManager groupManager,
final SocialNetworkManager socialNetworkManager, final Mapper mapper,
- final NotifyService notifyService) {
+ final NotificationService notifyService) {
this.userSessionManager = userSessionManager;
this.groupManager = groupManager;
this.socialNetworkManager = socialNetworkManager;
Deleted: trunk/src/main/java/cc/kune/core/server/scheduler/AbstractJob.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/scheduler/AbstractJob.java 2012-01-09 15:37:06 UTC (rev 1657)
+++ trunk/src/main/java/cc/kune/core/server/scheduler/AbstractJob.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -1,26 +0,0 @@
-package cc.kune.core.server.scheduler;
-
-import static org.quartz.CronScheduleBuilder.cronSchedule;
-import static org.quartz.JobBuilder.newJob;
-import static org.quartz.TriggerBuilder.newTrigger;
-
-import java.text.ParseException;
-
-import org.quartz.CronTrigger;
-import org.quartz.Job;
-import org.quartz.JobDetail;
-import org.quartz.SchedulerException;
-
-public abstract class AbstractJob implements Job {
- private static final String DEF_GROUP = "groupdef";
-
- public AbstractJob(final CronServerTasksManager manager, final String cronExpression)
- throws ParseException, SchedulerException {
- final JobDetail job = newJob(HourlyJob.class).withIdentity("hourlyjob1", DEF_GROUP).build();
-
- final CronTrigger trigger = newTrigger().withIdentity("hourlytrigger1", DEF_GROUP).withSchedule(
- cronSchedule(cronExpression)).build();
-
- manager.scheduleJob(job, trigger);
- }
-}
Modified: trunk/src/main/java/cc/kune/core/server/scheduler/CronServerTasksManager.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/scheduler/CronServerTasksManager.java 2012-01-09 15:37:06 UTC (rev 1657)
+++ trunk/src/main/java/cc/kune/core/server/scheduler/CronServerTasksManager.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -1,34 +1,77 @@
package cc.kune.core.server.scheduler;
+import static org.quartz.CronScheduleBuilder.cronSchedule;
+import static org.quartz.JobBuilder.newJob;
+import static org.quartz.TriggerBuilder.newTrigger;
+
+import java.text.ParseException;
import java.util.Date;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.quartz.CronTrigger;
+import org.quartz.Job;
import org.quartz.JobDetail;
import org.quartz.Scheduler;
import org.quartz.SchedulerException;
import org.quartz.impl.StdSchedulerFactory;
+import cc.kune.core.server.notifier.PendingNotificationDailyJob;
+import cc.kune.core.server.notifier.PendingNotificationHourlyJob;
+import cc.kune.core.server.notifier.PendingNotificationImmediateJob;
+import cc.kune.core.server.rack.ContainerListener;
+
import com.google.inject.Inject;
import com.google.inject.Singleton;
@Singleton
-public class CronServerTasksManager {
+public class CronServerTasksManager implements ContainerListener {
+ private static final String DEF_GROUP = "groupdef";
+ public static final Log LOG = LogFactory.getLog(CronServerTasksManager.class);
private final Scheduler sched;
@Inject
- public CronServerTasksManager(final StdSchedulerFactory sf) throws SchedulerException {
+ public CronServerTasksManager(final StdSchedulerFactory sf, final CustomJobFactory jobFactory)
+ throws SchedulerException {
sched = sf.getScheduler();
+ sched.setJobFactory(jobFactory);
}
- public Date scheduleJob(final JobDetail job, final CronTrigger trigger) throws SchedulerException {
+ private void logError(final Exception e) {
+ LOG.error("Error starting cron scheduler", e);
+ }
+
+ public Date scheduleJob(final Class<? extends Job> jobClass, final String cronExpression,
+ final String identify) throws SchedulerException, ParseException {
+ final JobDetail job = newJob(jobClass).withIdentity(identify + "job", DEF_GROUP).build();
+ final CronTrigger trigger = newTrigger().withIdentity(identify + "trigger", DEF_GROUP).withSchedule(
+ cronSchedule(cronExpression)).startNow().build();
return sched.scheduleJob(job, trigger);
}
- public void start() throws SchedulerException {
- sched.start();
+ @Override
+ public void start() {
+ LOG.info("Starting cron manager");
+ try {
+
+ sched.start();
+ scheduleJob(PendingNotificationImmediateJob.class, "0 */2 * * * ?", "pendinnotifimmediate");
+ scheduleJob(PendingNotificationHourlyJob.class, "0 0 * * * ?", "pendingnotifhourly");
+ scheduleJob(PendingNotificationDailyJob.class, "0 5 0 * * ?", "pendingnotifdaily");
+ } catch (final SchedulerException e) {
+ logError(e);
+ } catch (final ParseException e) {
+ logError(e);
+ }
}
- public void stop() throws SchedulerException {
- sched.shutdown(true);
+ @Override
+ public void stop() {
+ LOG.info("Stopping cron manager");
+ try {
+ sched.shutdown(true);
+ } catch (final SchedulerException e) {
+ logError(e);
+ }
}
}
Added: trunk/src/main/java/cc/kune/core/server/scheduler/CustomJobFactory.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/scheduler/CustomJobFactory.java (rev 0)
+++ trunk/src/main/java/cc/kune/core/server/scheduler/CustomJobFactory.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -0,0 +1,31 @@
+package cc.kune.core.server.scheduler;
+
+import org.quartz.Job;
+import org.quartz.Scheduler;
+import org.quartz.SchedulerException;
+import org.quartz.spi.JobFactory;
+import org.quartz.spi.TriggerFiredBundle;
+
+import com.google.inject.Injector;
+import com.google.inject.Singleton;
+
+/**
+ * A factory for creating CustomJob objects. See:
+ * http://javaeenotes.blogspot.com
+ * /2011/09/inject-instances-in-quartz-jobs-with.html
+ */
+@Singleton
+public class CustomJobFactory implements JobFactory {
+
+ private Injector injector;
+
+ @Override
+ public Job newJob(final TriggerFiredBundle bundle, final Scheduler scheduler)
+ throws SchedulerException {
+ return injector.getInstance(bundle.getJobDetail().getJobClass());
+ }
+
+ public void setInjector(final Injector injector) {
+ this.injector = injector;
+ }
+}
\ No newline at end of file
Deleted: trunk/src/main/java/cc/kune/core/server/scheduler/DailyJob.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/scheduler/DailyJob.java 2012-01-09 15:37:06 UTC (rev 1657)
+++ trunk/src/main/java/cc/kune/core/server/scheduler/DailyJob.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -1,13 +0,0 @@
-package cc.kune.core.server.scheduler;
-
-import java.text.ParseException;
-
-import org.quartz.SchedulerException;
-
-public abstract class DailyJob extends AbstractJob {
-
- public DailyJob(final CronServerTasksManager manager) throws ParseException, SchedulerException {
- super(manager, "0 0 * * * ?");
- }
-
-}
Deleted: trunk/src/main/java/cc/kune/core/server/scheduler/HourlyJob.java
===================================================================
--- trunk/src/main/java/cc/kune/core/server/scheduler/HourlyJob.java 2012-01-09 15:37:06 UTC (rev 1657)
+++ trunk/src/main/java/cc/kune/core/server/scheduler/HourlyJob.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -1,13 +0,0 @@
-package cc.kune.core.server.scheduler;
-
-import java.text.ParseException;
-
-import org.quartz.SchedulerException;
-
-public abstract class HourlyJob extends AbstractJob {
-
- public HourlyJob(final CronServerTasksManager manager) throws ParseException, SchedulerException {
- super(manager, "0 * * * * ?");
- }
-
-}
Modified: trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPresenter.java
===================================================================
--- trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPresenter.java 2012-01-09 15:37:06 UTC (rev 1657)
+++ trunk/src/main/java/cc/kune/gspace/client/options/general/UserOptGeneralPresenter.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -111,7 +111,6 @@
});
};
}
-
);
}
}
Modified: trunk/src/main/java/cc/kune/lists/server/ListsServerTool.java
===================================================================
--- trunk/src/main/java/cc/kune/lists/server/ListsServerTool.java 2012-01-09 15:37:06 UTC (rev 1657)
+++ trunk/src/main/java/cc/kune/lists/server/ListsServerTool.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -44,7 +44,7 @@
import cc.kune.domain.Content;
import cc.kune.domain.Group;
import cc.kune.domain.User;
-import cc.kune.wave.server.KuneWaveUtils;
+import cc.kune.wave.server.KuneWaveServerUtils;
import cc.kune.wave.server.kspecific.KuneWaveService;
import com.google.inject.Inject;
@@ -91,7 +91,7 @@
}
members.add(getUserGroup().getShortName());
Collections.sort(members);
- waveManager.addParticipants(KuneWaveUtils.getWaveRef(content),
+ waveManager.addParticipants(KuneWaveServerUtils.getWaveRef(content),
content.getAuthors().get(0).getShortName(), getUserGroup().getShortName(),
members.toArray(new String[members.size()]));
}
Copied: trunk/src/main/java/cc/kune/wave/server/KuneWaveServerUtils.java (from rev 1655, trunk/src/main/java/cc/kune/wave/server/KuneWaveUtils.java)
===================================================================
--- trunk/src/main/java/cc/kune/wave/server/KuneWaveServerUtils.java (rev 0)
+++ trunk/src/main/java/cc/kune/wave/server/KuneWaveServerUtils.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -0,0 +1,76 @@
+/*
+ *
+ * Copyright (C) 2007-2011 The kune development team (see CREDITS for details)
+ * This file is part of kune.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package cc.kune.wave.server;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import javax.persistence.NoResultException;
+
+import org.waveprotocol.wave.model.waveref.InvalidWaveRefException;
+import org.waveprotocol.wave.model.waveref.WaveRef;
+import org.waveprotocol.wave.util.escapers.jvm.JavaWaverefEncoder;
+
+import cc.kune.core.client.errors.DefaultException;
+import cc.kune.domain.Content;
+import cc.kune.domain.User;
+import cc.kune.domain.finders.UserFinder;
+import cc.kune.wave.server.kspecific.KuneWaveService;
+
+import com.google.inject.Inject;
+import com.google.inject.Provider;
+import com.google.wave.api.Participants;
+
+public class KuneWaveServerUtils {
+
+ @Inject
+ static Provider<ParticipantUtils> participantUtils;
+ @Inject
+ static Provider<UserFinder> userFinder;
+ @Inject
+ static Provider<KuneWaveService> waveService;
+
+ public static Collection<User> getLocalParticipants(final WaveRef waveref, final String author) {
+ final Participants participants = waveService.get().getParticipants(waveref, author);
+ final Set<User> list = new HashSet<User>();
+ for (final String participant : participants) {
+ participantUtils.get().isLocal(participant);
+ try {
+ list.add(userFinder.get().findByShortName(participantUtils.get().getAddressName(participant)));
+ } catch (final NoResultException e) {
+ // Seems is not a local user
+ }
+ }
+ return list;
+ }
+
+ public static String getUrl(final WaveRef waveref) {
+ return JavaWaverefEncoder.encodeToUriPathSegment(waveref);
+ }
+
+ public static WaveRef getWaveRef(final Content content) {
+ try {
+ return JavaWaverefEncoder.decodeWaveRefFromPath(String.valueOf(content.getWaveId()));
+ } catch (final InvalidWaveRefException e) {
+ throw new DefaultException("Error getting the wave");
+ }
+ }
+}
Deleted: trunk/src/main/java/cc/kune/wave/server/KuneWaveUtils.java
===================================================================
--- trunk/src/main/java/cc/kune/wave/server/KuneWaveUtils.java 2012-01-09 15:37:06 UTC (rev 1657)
+++ trunk/src/main/java/cc/kune/wave/server/KuneWaveUtils.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -1,41 +0,0 @@
-/*
- *
- * Copyright (C) 2007-2011 The kune development team (see CREDITS for details)
- * This file is part of kune.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
- */
-package cc.kune.wave.server;
-
-import org.waveprotocol.wave.model.waveref.InvalidWaveRefException;
-import org.waveprotocol.wave.model.waveref.WaveRef;
-import org.waveprotocol.wave.util.escapers.jvm.JavaWaverefEncoder;
-
-import cc.kune.core.client.errors.DefaultException;
-import cc.kune.domain.Content;
-
-public class KuneWaveUtils {
- public static String getUrl(final WaveRef waveref) {
- return JavaWaverefEncoder.encodeToUriPathSegment(waveref);
- }
-
- public static WaveRef getWaveRef(final Content content) {
- try {
- return JavaWaverefEncoder.decodeWaveRefFromPath(String.valueOf(content.getWaveId()));
- } catch (final InvalidWaveRefException e) {
- throw new DefaultException("Error getting the wave");
- }
- }
-}
Modified: trunk/src/main/java/cc/kune/wave/server/kspecific/KuneAgent.java
===================================================================
--- trunk/src/main/java/cc/kune/wave/server/kspecific/KuneAgent.java 2012-01-09 15:37:06 UTC (rev 1657)
+++ trunk/src/main/java/cc/kune/wave/server/kspecific/KuneAgent.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -34,6 +34,7 @@
import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.Singleton;
+import com.google.wave.api.Participants;
import com.google.wave.api.Wavelet;
@SuppressWarnings("serial")
@@ -145,6 +146,12 @@
}
@Override
+ public Participants getParticipants(final WaveRef waveref, final String author) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
public String getRobotId() {
return "kune-agent";
}
@@ -160,6 +167,12 @@
}
@Override
+ public String getTitle(final WaveRef waveName, final String author) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
public boolean isParticipant(final Wavelet wavelet, final String user) {
// TODO Auto-generated method stub
return false;
Modified: trunk/src/main/java/cc/kune/wave/server/kspecific/KuneWaveService.java
===================================================================
--- trunk/src/main/java/cc/kune/wave/server/kspecific/KuneWaveService.java 2012-01-09 15:37:06 UTC (rev 1657)
+++ trunk/src/main/java/cc/kune/wave/server/kspecific/KuneWaveService.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -26,6 +26,7 @@
import org.waveprotocol.wave.model.wave.ParticipantId;
import org.waveprotocol.wave.model.waveref.WaveRef;
+import com.google.wave.api.Participants;
import com.google.wave.api.Wavelet;
public interface KuneWaveService {
@@ -54,6 +55,10 @@
Wavelet fetchWave(WaveRef waveRef, String author);
+ Participants getParticipants(WaveRef waveref, String author);
+
+ String getTitle(WaveRef waveName, String author);
+
boolean isParticipant(Wavelet wavelet, String user);
String render(Wavelet wavelet);
@@ -64,5 +69,4 @@
String someValue);
void setTitle(WaveRef waveName, String title, String author);
-
}
Modified: trunk/src/main/java/cc/kune/wave/server/kspecific/KuneWaveServiceDefault.java
===================================================================
--- trunk/src/main/java/cc/kune/wave/server/kspecific/KuneWaveServiceDefault.java 2012-01-09 15:37:06 UTC (rev 1657)
+++ trunk/src/main/java/cc/kune/wave/server/kspecific/KuneWaveServiceDefault.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -419,6 +419,17 @@
}
@Override
+ public Participants getParticipants(final WaveRef waveref, final String author) {
+ return fetchWave(waveref, author).getParticipants();
+ }
+
+ @Override
+ public String getTitle(final WaveRef waveName, final String author) {
+ final Wavelet wavelet = fetchWave(waveName, author);
+ return wavelet.getTitle();
+ }
+
+ @Override
public boolean isParticipant(final Wavelet wavelet, final String user) {
return wavelet.getParticipants().contains(participantUtils.of(user).toString());
}
Deleted: trunk/src/main/java/cc/kune/wave/server/kspecific/WaveEmailNotifier.java
===================================================================
--- trunk/src/main/java/cc/kune/wave/server/kspecific/WaveEmailNotifier.java 2012-01-09 15:37:06 UTC (rev 1657)
+++ trunk/src/main/java/cc/kune/wave/server/kspecific/WaveEmailNotifier.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -1,83 +0,0 @@
-package cc.kune.wave.server.kspecific;
-
-import javax.persistence.NoResultException;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.waveprotocol.box.common.DeltaSequence;
-import org.waveprotocol.box.server.waveserver.WaveBus;
-import org.waveprotocol.box.server.waveserver.WaveBus.Subscriber;
-import org.waveprotocol.wave.model.id.IdUtil;
-import org.waveprotocol.wave.model.id.WaveletId;
-import org.waveprotocol.wave.model.id.WaveletName;
-import org.waveprotocol.wave.model.operation.wave.AddParticipant;
-import org.waveprotocol.wave.model.operation.wave.TransformedWaveletDelta;
-import org.waveprotocol.wave.model.operation.wave.WaveletBlipOperation;
-import org.waveprotocol.wave.model.operation.wave.WaveletOperation;
-import org.waveprotocol.wave.model.version.HashedVersion;
-import org.waveprotocol.wave.model.wave.ParticipantId;
-import org.waveprotocol.wave.model.wave.data.ReadableWaveletData;
-import org.waveprotocol.wave.model.waveref.WaveRef;
-
-import cc.kune.core.server.LogThis;
-import cc.kune.core.server.mail.FormatedString;
-import cc.kune.core.server.notifier.NotifySender;
-import cc.kune.core.server.notifier.NotifyType;
-import cc.kune.core.server.properties.KuneBasicProperties;
-import cc.kune.domain.User;
-import cc.kune.domain.finders.UserFinder;
-import cc.kune.wave.server.KuneWaveUtils;
-import cc.kune.wave.server.ParticipantUtils;
-
-import com.google.inject.Inject;
-
-@LogThis
-public class WaveEmailNotifier {
- public static final Log LOG = LogFactory.getLog(WaveEmailNotifier.class);
-
- @Inject
- public WaveEmailNotifier(final WaveBus waveBus, final NotifySender notifyService,
- final KuneBasicProperties basicProperties, final ParticipantUtils partUtils,
- final UserFinder userFinder) {
- waveBus.subscribe(new Subscriber() {
- @Override
- public void waveletCommitted(final WaveletName waveletName, final HashedVersion version) {
- }
-
- @Override
- public void waveletUpdate(final ReadableWaveletData wavelet, final DeltaSequence deltas) {
- final WaveletId waveletId = wavelet.getWaveletId();
- if (IdUtil.isUserDataWavelet(waveletId)) {
- return;
- }
- for (final TransformedWaveletDelta delta : deltas) {
- for (final WaveletOperation op : delta) {
- if (op instanceof AddParticipant) {
- final ParticipantId participant = ((AddParticipant) op).getParticipantId();
- final String url = KuneWaveUtils.getUrl(WaveRef.of(wavelet.getWaveId(), waveletId));
- final FormatedString body = FormatedString.build(
- "Hi there,<br><br>You have a new message in %s. <a href=\"%s#%s\">Read more</a>.<br>",
- basicProperties.getSiteCommonName(), basicProperties.getSiteUrl(), url);
- final String address = participant.getAddress();
- if (partUtils.isLocal(address)) {
- final String userName = partUtils.getAddressName(address);
- try {
- final User user = userFinder.findByShortName(userName);
- notifyService.send(NotifyType.email, FormatedString.build("You have a new message"),
- body, true, false, user);
- // notifyService.send(NotifyType.chat,
- // FormatedString.build("New message"), body, true,
- // user);
- } catch (final NoResultException e) {
- // Seems is not a local user
- }
- }
- } else if (op instanceof WaveletBlipOperation) {
-
- }
- }
- }
- }
- });
- }
-}
Added: trunk/src/main/java/cc/kune/wave/server/kspecific/WaveEmailNotifier.java
===================================================================
--- trunk/src/main/java/cc/kune/wave/server/kspecific/WaveEmailNotifier.java (rev 0)
+++ trunk/src/main/java/cc/kune/wave/server/kspecific/WaveEmailNotifier.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -0,0 +1,153 @@
+package cc.kune.wave.server.kspecific;
+
+import java.util.HashSet;
+
+import javax.persistence.NoResultException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.waveprotocol.box.common.DeltaSequence;
+import org.waveprotocol.box.server.waveserver.WaveBus;
+import org.waveprotocol.box.server.waveserver.WaveBus.Subscriber;
+import org.waveprotocol.wave.model.id.IdUtil;
+import org.waveprotocol.wave.model.id.WaveId;
+import org.waveprotocol.wave.model.id.WaveletId;
+import org.waveprotocol.wave.model.id.WaveletName;
+import org.waveprotocol.wave.model.operation.wave.AddParticipant;
+import org.waveprotocol.wave.model.operation.wave.RemoveParticipant;
+import org.waveprotocol.wave.model.operation.wave.TransformedWaveletDelta;
+import org.waveprotocol.wave.model.operation.wave.WaveletBlipOperation;
+import org.waveprotocol.wave.model.operation.wave.WaveletOperation;
+import org.waveprotocol.wave.model.version.HashedVersion;
+import org.waveprotocol.wave.model.wave.ParticipantId;
+import org.waveprotocol.wave.model.wave.data.ReadableWaveletData;
+import org.waveprotocol.wave.model.waveref.WaveRef;
+
+import cc.kune.core.client.state.SiteTokens;
+import cc.kune.core.server.LogThis;
+import cc.kune.core.server.mail.FormatedString;
+import cc.kune.core.server.notifier.NotificationType;
+import cc.kune.core.server.notifier.PendingNotification;
+import cc.kune.core.server.notifier.PendingNotificationSender;
+import cc.kune.core.server.notifier.SimpleDestinationProvider;
+import cc.kune.core.server.notifier.WaveDestinationProvider;
+import cc.kune.core.server.properties.KuneBasicProperties;
+import cc.kune.core.server.rack.ContainerListener;
+import cc.kune.domain.User;
+import cc.kune.domain.finders.UserFinder;
+import cc.kune.wave.server.KuneWaveServerUtils;
+import cc.kune.wave.server.ParticipantUtils;
+
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+
+@LogThis
+@Singleton
+public class WaveEmailNotifier implements ContainerListener {
+ public static final Log LOG = LogFactory.getLog(WaveEmailNotifier.class);
+ private HashSet<WaveId> updatedWavesInLastHour;
+
+ @Inject
+ public WaveEmailNotifier(final WaveBus waveBus, final PendingNotificationSender notificator,
+ final KuneBasicProperties basicProperties, final ParticipantUtils partUtils,
+ final KuneWaveService waveService, final UserFinder userFinder) {
+
+ final String siteCommonName = basicProperties.getSiteCommonName();
+ final String siteUrl = basicProperties.getSiteUrl();
+ updatedWavesInLastHour = new HashSet<WaveId>();
+ waveBus.subscribe(new Subscriber() {
+
+ private void addPendingNotif(final ParticipantId participant, final FormatedString subject,
+ final FormatedString body) {
+ final String address = participant.getAddress();
+ if (partUtils.isLocal(address)) {
+ final String userName = partUtils.getAddressName(address);
+ try {
+ final User user = userFinder.findByShortName(userName);
+ notificator.add(new PendingNotification(NotificationType.email, subject, body, true, false,
+ new SimpleDestinationProvider(user)));
+ } catch (final NoResultException e) {
+ // Seems is not a local user
+ }
+ }
+ }
+
+ private String getUrl(final ReadableWaveletData wavelet, final WaveletId waveletId) {
+ return KuneWaveServerUtils.getUrl(WaveRef.of(wavelet.getWaveId(), waveletId));
+ }
+
+ private FormatedString newWaveTemplate(final String url) {
+ return FormatedString.build(
+ "Hi there,<br><br>You have a new message in your inbox at %s. <a href=\"%s#%s\">Read more</a>.<br>",
+ siteCommonName, siteUrl, url);
+ }
+
+ private FormatedString removeWaveTemplate(final String by, final String title) {
+ return FormatedString.build(
+ "Hi there,<br><br>You have been removed by '%s' from message '%s' at %s. <a href=\"%s#%s\">Read more</a>.<br>",
+ by, title, siteCommonName, siteUrl, SiteTokens.WAVEINBOX);
+ }
+
+ private FormatedString updatedWaveTemplate(final String by, final String url) {
+ return FormatedString.build(
+ "Hi there,<br><br>You have an updated message by '%s' in your inbox at %s. <a href=\"%s#%s\">Read more</a>.<br>",
+ by, siteCommonName, siteUrl, url);
+ }
+
+ @Override
+ public void waveletCommitted(final WaveletName waveletName, final HashedVersion version) {
+ }
+
+ @Override
+ public void waveletUpdate(final ReadableWaveletData wavelet, final DeltaSequence deltas) {
+ final WaveletId waveletId = wavelet.getWaveletId();
+ if (IdUtil.isUserDataWavelet(waveletId)) {
+ return;
+ }
+ for (final TransformedWaveletDelta delta : deltas) {
+ for (final WaveletOperation op : delta) {
+ if (op instanceof AddParticipant) {
+ final ParticipantId participant = ((AddParticipant) op).getParticipantId();
+ addPendingNotif(participant, FormatedString.build("You have a new message"),
+ newWaveTemplate(getUrl(wavelet, waveletId)));
+ } else if (op instanceof RemoveParticipant) {
+ final ParticipantId participant = ((RemoveParticipant) op).getParticipantId();
+ final ParticipantId by = ((RemoveParticipant) op).getContext().getCreator();
+ final String title = waveService.getTitle(WaveRef.of(wavelet.getWaveId(), waveletId),
+ by.toString());
+ addPendingNotif(participant, FormatedString.build("You have been removed from message"),
+ removeWaveTemplate(by.toString(), title));
+ } else if (op instanceof WaveletBlipOperation) {
+ final WaveId waveId = wavelet.getWaveId();
+ if (!updatedWavesInLastHour.contains(waveId)) {
+ updatedWavesInLastHour.add(waveId);
+ // Replies, etc
+ final ParticipantId by = ((WaveletBlipOperation) op).getContext().getCreator();
+ // Duplicate code above
+ final WaveRef waveref = WaveRef.of(waveId, waveletId);
+ final String url = KuneWaveServerUtils.getUrl(waveref);
+ notificator.add(new PendingNotification(NotificationType.email,
+ FormatedString.build("You have an updated message"), updatedWaveTemplate(
+ by.toString(), url), true, false, new WaveDestinationProvider(waveref,
+ by.toString())));
+ }
+ }
+ }
+ }
+ }
+ });
+ }
+
+ public void clearUpdatedWaves() {
+ updatedWavesInLastHour.clear();
+ }
+
+ @Override
+ public void start() {
+ }
+
+ @Override
+ public void stop() {
+ }
+
+}
Added: trunk/src/test/java/cc/kune/core/server/notifier/AbstractPendingNotificationTest.java
===================================================================
--- trunk/src/test/java/cc/kune/core/server/notifier/AbstractPendingNotificationTest.java (rev 0)
+++ trunk/src/test/java/cc/kune/core/server/notifier/AbstractPendingNotificationTest.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -0,0 +1,32 @@
+package cc.kune.core.server.notifier;
+
+import org.junit.Before;
+
+import cc.kune.core.server.notifier.SimpleDestinationProvider;
+import cc.kune.domain.User;
+
+public abstract class AbstractPendingNotificationTest {
+
+ protected SimpleDestinationProvider diferentProvider;
+ protected User otherDiferentUser;
+ protected User sameUser;
+ protected SimpleDestinationProvider someSimilarUserProvider;
+ protected SimpleDestinationProvider someSimilarUserProvider2;
+ protected SimpleDestinationProvider someUserProvider;
+ protected User user;
+
+ @Before
+ public void before() {
+ user = new User("test1", "test1 name", "falseEmail@", "some passwd", "somediggest".getBytes(),
+ "some salt".getBytes(), null, null, null);
+ sameUser = new User("test1", "test1 name", "falseEmail@", "some passwd", "somediggest".getBytes(),
+ "some salt".getBytes(), null, null, null);
+ otherDiferentUser = new User("test2", "test2 name", "falseEmail@", "some passwd",
+ "somediggest".getBytes(), "some salt".getBytes(), null, null, null);
+ someUserProvider = new SimpleDestinationProvider(user);
+ someSimilarUserProvider = new SimpleDestinationProvider(user);
+ someSimilarUserProvider2 = new SimpleDestinationProvider(sameUser);
+ diferentProvider = new SimpleDestinationProvider(otherDiferentUser);
+ }
+
+}
Copied: trunk/src/test/java/cc/kune/core/server/notifier/NotificationHtmlHelperTest.java (from rev 1655, trunk/src/test/java/cc/kune/core/server/notifier/NotifyHtmlHelperTest.java)
===================================================================
--- trunk/src/test/java/cc/kune/core/server/notifier/NotificationHtmlHelperTest.java (rev 0)
+++ trunk/src/test/java/cc/kune/core/server/notifier/NotificationHtmlHelperTest.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -0,0 +1,30 @@
+package cc.kune.core.server.notifier;
+
+import static org.junit.Assert.assertNotNull;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import cc.kune.core.server.properties.KuneBasicProperties;
+import cc.kune.core.server.properties.KunePropertiesDefault;
+import cc.kune.core.server.utils.AbsoluteFileDownloadUtils;
+
+public class NotificationHtmlHelperTest {
+ private static final String GROUP_NAME = "groupShortName";
+ private static final String MESSAGE = "some message";
+
+ NotificationHtmlHelper helper;
+
+ @Test
+ public void basicTest() {
+ assertNotNull(helper.groupNotification(GROUP_NAME, false, MESSAGE).getString());
+ assertNotNull(helper.groupNotification(GROUP_NAME, true, MESSAGE).getString());
+ }
+
+ @Before
+ public void before() {
+ helper = new NotificationHtmlHelper(new AbsoluteFileDownloadUtils(new KuneBasicProperties(
+ new KunePropertiesDefault("kune.properties"))));
+ }
+
+}
Deleted: trunk/src/test/java/cc/kune/core/server/notifier/NotifyHtmlHelperTest.java
===================================================================
--- trunk/src/test/java/cc/kune/core/server/notifier/NotifyHtmlHelperTest.java 2012-01-09 15:37:06 UTC (rev 1657)
+++ trunk/src/test/java/cc/kune/core/server/notifier/NotifyHtmlHelperTest.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -1,30 +0,0 @@
-package cc.kune.core.server.notifier;
-
-import static org.junit.Assert.assertNotNull;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import cc.kune.core.server.properties.KuneBasicProperties;
-import cc.kune.core.server.properties.KunePropertiesDefault;
-import cc.kune.core.server.utils.AbsoluteFileDownloadUtils;
-
-public class NotifyHtmlHelperTest {
- private static final String GROUP_NAME = "groupShortName";
- private static final String MESSAGE = "some message";
-
- NotifyHtmlHelper helper;
-
- @Test
- public void basicTest() {
- assertNotNull(helper.groupNotification(GROUP_NAME, false, MESSAGE).getString());
- assertNotNull(helper.groupNotification(GROUP_NAME, true, MESSAGE).getString());
- }
-
- @Before
- public void before() {
- helper = new NotifyHtmlHelper(new AbsoluteFileDownloadUtils(new KuneBasicProperties(
- new KunePropertiesDefault("kune.properties"))));
- }
-
-}
Added: trunk/src/test/java/cc/kune/core/server/notifier/PendingNotificationSenderTest.java
===================================================================
--- trunk/src/test/java/cc/kune/core/server/notifier/PendingNotificationSenderTest.java (rev 0)
+++ trunk/src/test/java/cc/kune/core/server/notifier/PendingNotificationSenderTest.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -0,0 +1,85 @@
+package cc.kune.core.server.notifier;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+import cc.kune.core.server.mail.FormatedString;
+
+public class PendingNotificationSenderTest extends AbstractPendingNotificationTest {
+
+ private static final FormatedString BODY = FormatedString.build("Some body");
+ private static final FormatedString OTHER_BODY = FormatedString.build("Some other body");
+ private static final FormatedString OTHER_SUBJECT = FormatedString.build("Some other subject");
+ private static final FormatedString SUBJECT = FormatedString.build("Some subject");
+ private PendingNotificationSender manager;
+ private PendingNotification otherNotif;
+ private NotificationSender sender;
+ private PendingNotification someForcedNotif;
+ private PendingNotification someNotif;
+
+ private void assertQueues(final int i, final int j, final int k) {
+ // TODO Auto-generated method stub
+ assertEquals(manager.getImmediateCount(), i);
+ assertEquals(manager.getHourlyCount(), j);
+ assertEquals(manager.getDailyCount(), k);
+ }
+
+ @Override
+ @Before
+ public void before() {
+ sender = Mockito.mock(NotificationSender.class);
+ manager = new PendingNotificationSender(sender);
+ someNotif = new PendingNotification(NotificationType.email, SUBJECT, BODY, false, false,
+ someUserProvider);
+ otherNotif = new PendingNotification(NotificationType.email, OTHER_SUBJECT, OTHER_BODY, false,
+ false, someUserProvider);
+ someForcedNotif = new PendingNotification(NotificationType.email, SUBJECT, BODY, false, true,
+ someUserProvider);
+ }
+
+ @Test
+ public void testForcePendingNotification() {
+ manager.add(someForcedNotif);
+ assertQueues(1, 0, 0);
+ manager.sendImmediateNotifications();
+ assertQueues(0, 0, 0);
+ }
+
+ @Test
+ public void testMixtureOfNotifications() {
+ manager.add(someNotif);
+ manager.add(someForcedNotif);
+ assertQueues(2, 0, 0);
+ manager.sendImmediateNotifications();
+ assertQueues(0, 1, 0);
+ }
+
+ @Test
+ public void testSimplePendingNotification() {
+ manager.add(someNotif);
+ // we add two times (imagine two editions)
+ manager.add(someNotif);
+ manager.add(otherNotif);
+ assertQueues(2, 0, 0);
+ manager.sendImmediateNotifications();
+ assertQueues(0, 2, 0);
+ // we repeat some notification (for instance an edit) and should be ignored
+ manager.add(someNotif);
+ assertQueues(0, 2, 0);
+ manager.sendHourlyNotifications();
+ assertQueues(0, 0, 2);
+ // we repeat some notification (for instance an edit) and should be ignored
+ manager.add(someNotif);
+ assertQueues(1, 0, 2);
+ manager.sendImmediateNotifications();
+ assertQueues(0, 1, 2);
+ manager.sendHourlyNotifications();
+ assertQueues(0, 0, 2);
+ manager.sendDailyNotifications();
+ assertQueues(0, 0, 0);
+ }
+
+}
Added: trunk/src/test/java/cc/kune/core/server/notifier/SimpleDestinationProviderTest.java
===================================================================
--- trunk/src/test/java/cc/kune/core/server/notifier/SimpleDestinationProviderTest.java (rev 0)
+++ trunk/src/test/java/cc/kune/core/server/notifier/SimpleDestinationProviderTest.java 2012-01-12 01:40:41 UTC (rev 1658)
@@ -0,0 +1,18 @@
+package cc.kune.core.server.notifier;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class SimpleDestinationProviderTest extends AbstractPendingNotificationTest {
+
+ @Test
+ public void shouldCompareWell() {
+ assertTrue(someUserProvider.equals(someSimilarUserProvider));
+ assertTrue(someUserProvider.equals(someSimilarUserProvider2));
+ assertTrue(someSimilarUserProvider.equals(someSimilarUserProvider2));
+ assertFalse(someUserProvider.equals(diferentProvider));
+ }
+
+}
1
0