You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by ju...@apache.org on 2013/01/28 20:13:32 UTC

svn commit: r1439584 - in /incubator/jspwiki/trunk/src: org/apache/wiki/auth/UserManager.java org/apache/wiki/auth/user/JDBCUserDatabase.java org/apache/wiki/auth/user/XMLUserDatabase.java webdocs/Login.jsp webdocs/UserPreferences.jsp

Author: juanpablo
Date: Mon Jan 28 19:13:31 2013
New Revision: 1439584

URL: http://svn.apache.org/viewvc?rev=1439584&view=rev
Log:
JSPWIKI-143: Unlocalized messages in user management
       
JSPWIKI-150: Unlocalized content at workflow's notification for creating a new user

Modified:
    incubator/jspwiki/trunk/src/org/apache/wiki/auth/UserManager.java
    incubator/jspwiki/trunk/src/org/apache/wiki/auth/user/JDBCUserDatabase.java
    incubator/jspwiki/trunk/src/org/apache/wiki/auth/user/XMLUserDatabase.java
    incubator/jspwiki/trunk/src/webdocs/Login.jsp
    incubator/jspwiki/trunk/src/webdocs/UserPreferences.jsp

Modified: incubator/jspwiki/trunk/src/org/apache/wiki/auth/UserManager.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/org/apache/wiki/auth/UserManager.java?rev=1439584&r1=1439583&r2=1439584&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/org/apache/wiki/auth/UserManager.java (original)
+++ incubator/jspwiki/trunk/src/org/apache/wiki/auth/UserManager.java Mon Jan 28 19:13:31 2013
@@ -305,7 +305,7 @@ public final class UserManager
             otherProfile = getUserDatabase().findByLoginName( profile.getLoginName() );
             if ( otherProfile != null && !otherProfile.equals( oldProfile ) )
             {
-                throw new DuplicateUserException( "The login name '" + profile.getLoginName() + "' is already taken." );
+                throw new DuplicateUserException( "security.error.login.taken", profile.getLoginName() );
             }
         }
         catch( NoSuchPrincipalException e )
@@ -316,7 +316,7 @@ public final class UserManager
             otherProfile = getUserDatabase().findByFullName( profile.getFullname() );
             if ( otherProfile != null && !otherProfile.equals( oldProfile ) )
             {
-                throw new DuplicateUserException( "The full name '" + profile.getFullname() + "' is already taken." );
+                throw new DuplicateUserException( "security.error.fullname.taken", profile.getFullname() );
             }
         }
         catch( NoSuchPrincipalException e )
@@ -328,7 +328,7 @@ public final class UserManager
         {
             WorkflowBuilder builder = WorkflowBuilder.getBuilder( m_engine );
             Principal submitter = session.getUserPrincipal();
-            Task completionTask = new SaveUserProfileTask( m_engine );
+            Task completionTask = new SaveUserProfileTask( m_engine, session.getLocale() );
 
             // Add user profile attribute as Facts for the approver (if required)
             boolean hasEmail = profile.getEmail() != null;
@@ -715,16 +715,28 @@ public final class UserManager
         private static final long serialVersionUID = 6994297086560480285L;
         private final UserDatabase m_db;
         private final WikiEngine m_engine;
+        private final Locale m_loc;
 
         /**
          * Constructs a new Task for saving a user profile.
          * @param engine the wiki engine
+         * @deprecated will be removed in 2.10 scope. Consider using {@link SaveUserProfileTask(WikiEngine, Locale)} instead
          */
+        @Deprecated
         public SaveUserProfileTask( WikiEngine engine )
         {
             super( SAVE_TASK_MESSAGE_KEY );
             m_engine = engine;
             m_db = engine.getUserManager().getUserDatabase();
+            m_loc = null;
+        }
+        
+        public SaveUserProfileTask( WikiEngine engine, Locale loc )
+        {
+            super( SAVE_TASK_MESSAGE_KEY );
+            m_engine = engine;
+            m_db = engine.getUserManager().getUserDatabase();
+            m_loc = loc;
         }
 
         /**
@@ -746,24 +758,27 @@ public final class UserManager
             {
                 try
                 {
+                    InternationalizationManager i18n = m_engine.getInternationalizationManager();
+                    i18n.get( InternationalizationManager.DEF_TEMPLATE, m_loc, "", "" );
                     String app = m_engine.getApplicationName();
                     String to = profile.getEmail();
-                    String subject = "Welcome to " + app;
-                    String content = "Congratulations! Your new profile on "
-                        + app + " has been created. Your profile details are as follows: \n\n"
-                        + "Login name: " + profile.getLoginName() + "\n"
-                        + "Your name : " + profile.getFullname() + "\n"
-                        + "E-mail    : " + profile.getEmail() + "\n\n"
-                        + "If you forget your password, you can reset it at "
-                        + m_engine.getURL(WikiContext.LOGIN, null, null, true);
+                    String subject = i18n.get( InternationalizationManager.DEF_TEMPLATE, m_loc, 
+                                               "notification.createUserProfile.accept.subject", app );
+                    
+                    String content = i18n.get( InternationalizationManager.DEF_TEMPLATE, m_loc, 
+                                               "notification.createUserProfile.accept.content", app, 
+                                               profile.getLoginName(), 
+                                               profile.getFullname(),
+                                               profile.getEmail(),
+                                               m_engine.getURL( WikiContext.LOGIN, null, null, true ) );
                     MailUtil.sendMessage( m_engine, to, subject, content);
                 }
                 catch ( AddressException e)
                 {
                 }
-                catch ( MessagingException e )
+                catch ( MessagingException me )
                 {
-                    log.error( "Could not send registration confirmation e-mail. Is the e-mail server running?" );
+                    log.error( "Could not send registration confirmation e-mail. Is the e-mail server running?", me );
                 }
             }
 

Modified: incubator/jspwiki/trunk/src/org/apache/wiki/auth/user/JDBCUserDatabase.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/org/apache/wiki/auth/user/JDBCUserDatabase.java?rev=1439584&r1=1439583&r2=1439584&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/org/apache/wiki/auth/user/JDBCUserDatabase.java (original)
+++ incubator/jspwiki/trunk/src/org/apache/wiki/auth/user/JDBCUserDatabase.java Mon Jan 28 19:13:31 2013
@@ -595,7 +595,7 @@ public class JDBCUserDatabase extends Ab
             UserProfile otherProfile = findByLoginName( newName );
             if( otherProfile != null )
             {
-                throw new DuplicateUserException( "Cannot rename: the login name '" + newName + "' is already taken." );
+                throw new DuplicateUserException( "security.error.cannot.rename", newName );
             }
         }
         catch( NoSuchPrincipalException e )

Modified: incubator/jspwiki/trunk/src/org/apache/wiki/auth/user/XMLUserDatabase.java
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/org/apache/wiki/auth/user/XMLUserDatabase.java?rev=1439584&r1=1439583&r2=1439584&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/org/apache/wiki/auth/user/XMLUserDatabase.java (original)
+++ incubator/jspwiki/trunk/src/org/apache/wiki/auth/user/XMLUserDatabase.java Mon Jan 28 19:13:31 2013
@@ -461,7 +461,7 @@ public class XMLUserDatabase extends Abs
             UserProfile otherProfile = findByLoginName( newName );
             if ( otherProfile != null )
             {
-                throw ( new DuplicateUserException( "Cannot rename: the login name '" + newName + "' is already taken." ) );
+                throw new DuplicateUserException( "security.error.cannot.rename", newName );
             }
         }
         catch ( NoSuchPrincipalException e )

Modified: incubator/jspwiki/trunk/src/webdocs/Login.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/webdocs/Login.jsp?rev=1439584&r1=1439583&r2=1439584&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/webdocs/Login.jsp (original)
+++ incubator/jspwiki/trunk/src/webdocs/Login.jsp Mon Jan 28 19:13:31 2013
@@ -25,6 +25,7 @@
 <%@ page import="org.apache.wiki.auth.login.CookieAuthenticationLoginModule" %>
 <%@ page import="org.apache.wiki.auth.user.DuplicateUserException" %>
 <%@ page import="org.apache.wiki.auth.user.UserProfile" %>
+<%@ page import="org.apache.wiki.i18n.InternationalizationManager" %>
 <%@ page import="org.apache.wiki.workflow.DecisionRequiredException" %>
 <%@ page import="org.apache.wiki.tags.WikiTagBase" %>
 <%@ page errorPage="/Error.jsp" %>
@@ -70,10 +71,13 @@
                 userMgr.setUserProfile( wikiSession, profile );
                 CookieAssertionLoginModule.setUserCookie( response, profile.getFullname() );
             }
-            catch( DuplicateUserException e )
+            catch( DuplicateUserException due )
             {
                 // User collision! (full name or wiki name already taken)
-                wikiSession.addMessage( "profile", e.getMessage() );
+                wikiSession.addMessage( "profile", wiki.getInternationalizationManager()
+                		                               .get( InternationalizationManager.CORE_BUNDLE,
+                		                            		 WikiContext.getLocale( wikiContext ), 
+                		                            		 due.getMessage(), due.getArgs() ) );
             }
             catch( DecisionRequiredException e )
             {

Modified: incubator/jspwiki/trunk/src/webdocs/UserPreferences.jsp
URL: http://svn.apache.org/viewvc/incubator/jspwiki/trunk/src/webdocs/UserPreferences.jsp?rev=1439584&r1=1439583&r2=1439584&view=diff
==============================================================================
--- incubator/jspwiki/trunk/src/webdocs/UserPreferences.jsp (original)
+++ incubator/jspwiki/trunk/src/webdocs/UserPreferences.jsp Mon Jan 28 19:13:31 2013
@@ -27,10 +27,11 @@
 <%@ page import="org.apache.wiki.auth.login.CookieAssertionLoginModule" %>
 <%@ page import="org.apache.wiki.auth.user.DuplicateUserException" %>
 <%@ page import="org.apache.wiki.auth.user.UserProfile" %>
-<%@ page import="org.apache.wiki.workflow.DecisionRequiredException" %>
+<%@ page import="org.apache.wiki.i18n.InternationalizationManager" %>
+<%@ page import="org.apache.wiki.preferences.*" %>
 <%@ page import="org.apache.wiki.ui.EditorManager" %>
 <%@ page import="org.apache.wiki.ui.TemplateManager" %>
-<%@ page import="org.apache.wiki.preferences.*" %>
+<%@ page import="org.apache.wiki.workflow.DecisionRequiredException" %>
 <%@ page errorPage="/Error.jsp" %>
 <%@ taglib uri="/WEB-INF/jspwiki.tld" prefix="wiki" %>
 
@@ -72,10 +73,13 @@
                 userMgr.setUserProfile( wikiSession, profile );
                 CookieAssertionLoginModule.setUserCookie( response, profile.getFullname() );
             }
-            catch( DuplicateUserException e )
+            catch( DuplicateUserException due )
             {
                 // User collision! (full name or wiki name already taken)
-                wikiSession.addMessage( "profile", e.getMessage() );
+                wikiSession.addMessage( "profile", wiki.getInternationalizationManager()
+                                                       .get( InternationalizationManager.CORE_BUNDLE,
+                                                    		 WikiContext.getLocale( wikiContext ), 
+                                                             due.getMessage(), due.getArgs() ) );
             }
             catch( DecisionRequiredException e )
             {