Author: taylor
Date: Wed Nov 30 22:03:42 2005
New Revision: 350183

URL: http://svn.apache.org/viewcvs?rev=350183&view=rev
Log:
patch from Chris Schaefer, localization of ForgottenPassword and 
UserRegistration
Im committing this, but would prefer to use the Template Locator to better 
partition the email templates

Added:
    
portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/view/userreg/forgottenPasswdEmail_en.vm
    
portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/view/userreg/userRegistrationEmail_en.vm
Modified:
    
portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/registration/ForgottenPasswordPortlet.java
    
portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/registration/UserRegistrationPortlet.java
    
portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/registration/resources/ForgottenPasswordResources_en.properties
    
portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/registration/resources/UserRegistrationResources_en.properties
    
portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/view/userreg/forgottenPasswd.vm
    
portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/view/userreg/userRegistration.vm

Modified: 
portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/registration/ForgottenPasswordPortlet.java
URL: 
http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/registration/ForgottenPasswordPortlet.java?rev=350183&r1=350182&r2=350183&view=diff
==============================================================================
--- 
portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/registration/ForgottenPasswordPortlet.java
 (original)
+++ 
portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/registration/ForgottenPasswordPortlet.java
 Wed Nov 30 22:03:42 2005
@@ -17,11 +17,13 @@
 
 import java.io.IOException;
 import java.security.Principal;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.ResourceBundle;
 import java.util.Set;
@@ -115,6 +117,7 @@
         String password;
     }
 
+    
     public void init(PortletConfig config) throws PortletException
     {
         super.init(config);
@@ -130,7 +133,12 @@
         this.returnUrlPath = config.getInitParameter(IP_RETURN_URL);
         this.redirectPath = config.getInitParameter(IP_REDIRECT_PATH);
         this.template = config.getInitParameter(IP_TEMPLATE);
-
+        
+        List l = new ArrayList();
+        l.add(config.getInitParameter(IP_TEMPLATE));
+        String appRoot = "root";
+        
+        
         hackMap = new HashMap();
     }
 
@@ -215,12 +223,13 @@
         List errors = new LinkedList();
 
         String email = request.getParameter(RP_EMAIL_ADDRESS);
-        ResourceBundle resource = 
getPortletConfig().getResourceBundle(request.getLocale());
+        Locale locale = request.getLocale();
+
+        ResourceBundle resource = getPortletConfig().getResourceBundle(locale);
 
         // validation
         if (!ValidationHelper.isEmailAddress(email, true, 80))
         {
-            // TODO: get error message from localized resource
             
errors.add(resource.getString("forgotten.invalid_email_format_entered"));
         }
 
@@ -236,7 +245,6 @@
             user = admin.lookupUserFromEmail(email);
         } catch (Exception e)
         {
-            // TODO: get message from localized messages
             publishRenderMessage(
                     request,
                     MSG_MESSAGE,
@@ -269,10 +277,47 @@
                     response, urlGUID));
             userAttributes.put(CTX_NEW_PASSWORD, newPassword);
             userAttributes.put(CTX_USER_NAME, userName);
-            if (this.template == null) { throw new Exception(
-                    "email template not available"); }
+
+/*
+ *         this code is my first attempt to get things working with a template 
locator... it's not going to work given the way things are partitioned in the 
jetspeed
+
+        TemplateLocator templateLocator;
+        try
+        {
+            templateLocator = new JetspeedTemplateLocator(l, appRoot);
+        } catch (FileNotFoundException e)
+        {
+            throw new PortletException("can't init 
TemplateLocator:"+e.getMessage());
+        }
+            LocatorDescriptor ld = 
templateLocator.createLocatorDescriptor(null);
+            RequestContext requestContext = (RequestContext) 
request.getAttribute(PortalReservedParameters.REQUEST_CONTEXT_ATTRIBUTE);
+    
+            CapabilityMap capabilityMap = requestContext.getCapabilityMap();
+            ld.setMediaType(capabilityMap.getPreferredMediaType().getName());
+            
+            Locale locale = requestContext.getLocale();
+            ld.setCountry(locale.getCountry());
+            ld.setLanguage(locale.getLanguage());
+            
+            TemplateDescriptor td = templateLocator.locateTemplate( ld);
+            
+            this.template = td.getAbsolutePath();
+            */
+            
+            String language = locale.getLanguage();
+            String templ = this.template;
+            int period = templ.lastIndexOf(".");
+            if(period >0) {
+                String fixedTempl = templ.substring(0,period)+ 
"_"+language+"."+templ.substring(period+1);
+                this.template = fixedTempl;
+            }
+            
+            if (this.template == null) 
+            { 
+                throw new Exception("email template not available"); 
+            }
             admin.sendEmail(this.getPortletConfig(), email,
-                    getEmailSubject(request), this.template, userAttributes);
+                    getEmailSubject(request),this.template, userAttributes);
 
             //TODO this is currently hacked with a hashmap... needs to move to 
either a DB table
             // or to some sort of credential
@@ -284,7 +329,6 @@
             publishRenderMessage(
                     request,
                     MSG_CHANGEDPW_MSG,
-                    // TODO: localize this!
                     makeMessage(resource.getString("an_email_has_been_sent")));
             
             response.sendRedirect(generateRedirectURL(request, response));

Modified: 
portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/registration/UserRegistrationPortlet.java
URL: 
http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/registration/UserRegistrationPortlet.java?rev=350183&r1=350182&r2=350183&view=diff
==============================================================================
--- 
portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/registration/UserRegistrationPortlet.java
 (original)
+++ 
portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/registration/UserRegistrationPortlet.java
 Wed Nov 30 22:03:42 2005
@@ -22,6 +22,7 @@
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.ResourceBundle;
 
@@ -298,25 +299,21 @@
         if (!ValidationHelper.isAny((String) userInfo.get("user.name.given"),
                 true, 30))
         {
-            // TODO: get error message from localized resource
             errors.add(resource.getString("error.lacking.first_name"));
         }
         if (!ValidationHelper.isAny((String) userInfo.get("user.name.family"),
                 true, 30))
         {
-            // TODO: get error message from localized resource
             errors.add(resource.getString("error.lacking.last_name"));
         }
         if (!ValidationHelper.isAny((String) userInfo.get("user.name"), true,
                 80))
         {
-            // TODO: get error message from localized resource
             errors.add(resource.getString("error.lacking.username"));
         }
         if (!ValidationHelper.isEmailAddress((String) userInfo
                 .get(USER_ATTRIBUTE_EMAIL), true, 80))
         {
-            // TODO: get error message from localized resource
             errors.add(resource.getString("error.email_invalid_format"));
         }
         if (!this.optionForceGeneratedPasswords)
@@ -324,7 +321,6 @@
             if (!ValidationHelper.isAny((String) userInfo.get("password"),
                     true, 25))
             {
-                // TODO: get error message from localized resource
                 errors.add(resource.getString("error.lacking.password"));
             }
         }
@@ -346,9 +342,7 @@
         //
         if (userIdExistsFlag)
         {
-            // TODO: localize messages
-            errors
-                    .add(resource.getString("error.userid_already_exists"));
+            errors.add(resource.getString("error.userid_already_exists"));
             publishRenderMessage(actionRequest, MSG_MESSAGE, errors);
             return;
         }
@@ -366,9 +360,7 @@
             }
             if ((emailExistsFlag) || (user != null))
             {
-                // TODO: localize messages
-                errors
-                        .add(resource.getString("error.email_already_exists"));
+                errors.add(resource.getString("error.email_already_exists"));
                 publishRenderMessage(actionRequest, MSG_MESSAGE, errors);
                 return;
             }
@@ -391,9 +383,7 @@
                 } 
                 else
                 {
-                    //                  TODO: localize messages
-                    errors
-                            
.add(resource.getString("error.two_passwords_do_not_match"));
+                    
errors.add(resource.getString("error.two_passwords_do_not_match"));
                     publishRenderMessage(actionRequest, MSG_MESSAGE, errors);
                     return;
                 }
@@ -401,7 +391,6 @@
         } 
         catch (Exception e)
         {
-            // TODO: localize messages
             errors.add(resource.getString("error.failed_to_add") + 
e.toString());
             publishRenderMessage(actionRequest, MSG_MESSAGE, errors);
         }
@@ -427,6 +416,17 @@
             userInfo.put(CTX_RETURN_URL, generateReturnURL(actionRequest,
                     actionResponse, urlGUID));
 
+
+            Locale locale = actionRequest.getLocale();
+
+            String language = locale.getLanguage();
+            String templ = this.emailTemplate;
+            int period = templ.lastIndexOf(".");
+            if(period >0) {
+                String fixedTempl = templ.substring(0,period)+ 
"_"+language+"."+templ.substring(period+1);
+                this.emailTemplate = fixedTempl;
+            }
+            
             if (this.emailTemplate == null) 
             { 
                 throw new Exception("email template not available"); 
@@ -446,7 +446,6 @@
         } 
         catch (Exception e)
         {
-            // TODO: localize messages
             errors.add(resource.getString("error.failed_to_add") + 
e.toString());
             publishRenderMessage(actionRequest, MSG_MESSAGE, errors);
         }

Modified: 
portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/registration/resources/ForgottenPasswordResources_en.properties
URL: 
http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/registration/resources/ForgottenPasswordResources_en.properties?rev=350183&r1=350182&r2=350183&view=diff
==============================================================================
--- 
portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/registration/resources/ForgottenPasswordResources_en.properties
 (original)
+++ 
portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/registration/resources/ForgottenPasswordResources_en.properties
 Wed Nov 30 22:03:42 2005
@@ -5,4 +5,7 @@
 forgotten.email_address_not_found=Sorry but we could not find this email 
address on file. Are you sure you typed it in correctly?
 an_email_has_been_sent=An email has been sent to you.  Please follow the link 
in the email
 email.subject.forgotten.password=Password Notification
-failed_to_send=Failed to send password:
\ No newline at end of file
+failed_to_send=Failed to send password:
+page.message=If you have forgotten your password, we can create a new one and 
send it to you via your email address. You must enter the exact same email 
address with which you originally registered. 
+page.email=email address:                              
+page.button=Request New Password
\ No newline at end of file

Modified: 
portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/registration/resources/UserRegistrationResources_en.properties
URL: 
http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/registration/resources/UserRegistrationResources_en.properties?rev=350183&r1=350182&r2=350183&view=diff
==============================================================================
--- 
portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/registration/resources/UserRegistrationResources_en.properties
 (original)
+++ 
portals/jetspeed-2/trunk/applications/j2-admin/src/java/org/apache/jetspeed/portlets/registration/resources/UserRegistrationResources_en.properties
 Wed Nov 30 22:03:42 2005
@@ -8,4 +8,16 @@
 error.two_passwords_do_not_match=The two passwords do not match, please 
re-type them
 error.failed_to_add=Failed to add user.
 success.login_above=You have completed the user registration process.  Please 
login above
+
+# stuff for the template
+page.welcome=Welcome.  Please fill out the following form to become a 
registered user.
+page.username=username:
+page.firstname=first name:
+page.lastname=last name:
+page.department=department:<font color="blue" size="-2">(optional)</font>
+page.employer=employer:<font color="blue" size="-2">(optional)</font>
+page.email.address=email address:
+page.password=password:
+page.passwordVerify=password (verify):
+page.button=Register Me
        

Modified: 
portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/view/userreg/forgottenPasswd.vm
URL: 
http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/view/userreg/forgottenPasswd.vm?rev=350183&r1=350182&r2=350183&view=diff
==============================================================================
--- 
portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/view/userreg/forgottenPasswd.vm
 (original)
+++ 
portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/view/userreg/forgottenPasswd.vm
 Wed Nov 30 22:03:42 2005
@@ -1,3 +1,5 @@
+#set ($MESSAGES = $portletConfig.getResourceBundle($renderRequest.Locale))
+
 <div id="ForgottenPassword"  class="portlet-section-text"> 
        #if($updatedPWMsg)
                <table>
@@ -6,17 +8,16 @@
        #else   
                <form name="forgottenPasswordForm" 
action="$renderResponse.createActionURL()" method="post" >
                <table>
-                       <tr><td colspan="2" > 
-                               If you have forgotten your password, we can 
create a new one and send it to you via your email address.
-                               You must enter the exact same email address 
with which you originally registered. 
+                       <tr><td colspan="2" >
+                               $MESSAGES.getString('page.message') 
                                #if($MSG )
                                        <br>
                                        <p class="portlet-msg-error">$!MSG</p>
                                #end
                        </td></tr>
                        
-                       <tr><td>email address:</td><td><input type="text" 
name="email" value="$!email" /></td></tr>
-                       <tr><td colspan="2" > <input type="submit" 
value="Request New Password"  name="Request New Password" /> </td></tr>
+                       
<tr><td>$MESSAGES.getString('page.email')</td><td><input type="text" 
name="email" value="$!email" /></td></tr>
+                       <tr><td colspan="2" > <input type="submit" 
value="$MESSAGES.getString('page.button')"  name="Request New Password" /> 
</td></tr>
                </table>
            </form>
     #end

Added: 
portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/view/userreg/forgottenPasswdEmail_en.vm
URL: 
http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/view/userreg/forgottenPasswdEmail_en.vm?rev=350183&view=auto
==============================================================================
--- 
portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/view/userreg/forgottenPasswdEmail_en.vm
 (added)
+++ 
portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/view/userreg/forgottenPasswdEmail_en.vm
 Wed Nov 30 22:03:42 2005
@@ -0,0 +1,15 @@
+Hello  $!{map.get("user.name.given")} $!{map.get("user.name.family")}:
+
+You have requested a new password for your account. 
+The account username: $!{map.get("username")}
+The new password is : $!{map.get("password")}
+To activate the new password you MUST click on the following link:
+$!{map.get("returnURL")}
+If you have received this email in error, and do NOT want to update your 
password,
+please do NOT click on the link above, and your account will remain using your
+original password.
+
+Thanks,  
+
+The Jetspeed Team.
+

Modified: 
portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/view/userreg/userRegistration.vm
URL: 
http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/view/userreg/userRegistration.vm?rev=350183&r1=350182&r2=350183&view=diff
==============================================================================
--- 
portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/view/userreg/userRegistration.vm
 (original)
+++ 
portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/view/userreg/userRegistration.vm
 Wed Nov 30 22:03:42 2005
@@ -1,3 +1,4 @@
+#set ($MESSAGES = $portletConfig.getResourceBundle($renderRequest.Locale))
 <div id="UserRegistration"  class="portlet-section-text"> 
        #if($registeredUserMsg)
                <table >
@@ -7,7 +8,7 @@
        <form name="userRegistrationForm" 
action="$renderResponse.createActionURL()" method="post" >
        <table>
                <tr><td colspan="2" > 
-                       Welcome.  Please fill out the following form to become 
a registered user.
+                       $MESSAGES.getString('page.welcome')
                        #if($MSG )
                                <p class="portlet-msg-error">$!MSG</p>
                        #end    
@@ -15,21 +16,21 @@
                
                #if($CTX_Option_Use_Email_As_Username)
                #else
-               <tr><td>username:</td><td><input type="text" name="user.name" 
value="$!{user.get("user.name")}" /></td></tr>
+               <tr><td>$MESSAGES.getString('page.username')</td><td><input 
type="text" name="user.name" value="$!{user.get("user.name")}" /></td></tr>
                #end
-               <tr><td>first name:</td><td><input type="text" 
name="user.name.given" value="$!{user.get("user.name.given")}" /></td></tr>
-               <tr><td>last name:</td><td><input type="text" 
name="user.name.family" value="$!{user.get("user.name.family")}" /></td></tr>
-               <tr><td>department: <font color="blue" 
size="-2">(optional)</font></td><td><input type="text" name="user.department" 
value="$!{user.get("user.department")}" /></td></tr>
-               <tr><td>employer: <font color="blue" 
size="-2">(optional)</font></td><td><input type="text" name="user.employer" 
value="$!{user.get("user.employer")}" /></td></tr>
-               <tr><td>email address:</td><td><input type="text" 
name="user.business-info.online.email" 
value="$!{user.get("user.business-info.online.email")}" /></td></tr>
+               <tr><td>$MESSAGES.getString('page.firstname')</td><td><input 
type="text" name="user.name.given" value="$!{user.get("user.name.given")}" 
/></td></tr>
+               <tr><td>$MESSAGES.getString('page.lastname')</td><td><input 
type="text" name="user.name.family" value="$!{user.get("user.name.family")}" 
/></td></tr>
+               <tr><td>$MESSAGES.getString('page.department')</td><td><input 
type="text" name="user.department" value="$!{user.get("user.department")}" 
/></td></tr>
+               <tr><td>$MESSAGES.getString('page.employer') </td><td><input 
type="text" name="user.employer" value="$!{user.get("user.employer")}" 
/></td></tr>
+               
<tr><td>$MESSAGES.getString('page.email.address')</td><td><input type="text" 
name="user.business-info.online.email" 
value="$!{user.get("user.business-info.online.email")}" /></td></tr>
                
                #if($CTX_Option_Generate_Passwords)
                #else
-               <tr><td>password:</td><td><input type="password" 
name="password" value="" /></td></tr>
-               <tr><td>password (verify):</td><td><input type="password" 
name="verifyPassword" value="" /></td></tr>
+               <tr><td>$MESSAGES.getString('page.password')</td><td><input 
type="password" name="password" value="" /></td></tr>
+               
<tr><td>$MESSAGES.getString('page.passwordVerify')</td><td><input 
type="password" name="verifyPassword" value="" /></td></tr>
                #end
                
-               <tr><td colspan="2" > <input type="submit" value="Register Me!" 
name="Register Me" /> </td></tr>
+               <tr><td colspan="2" > <input type="submit" 
value="$MESSAGES.getString('page.button')" name="Register Me" /> </td></tr>
        </table>
     </form>
     #end

Added: 
portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/view/userreg/userRegistrationEmail_en.vm
URL: 
http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/view/userreg/userRegistrationEmail_en.vm?rev=350183&view=auto
==============================================================================
--- 
portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/view/userreg/userRegistrationEmail_en.vm
 (added)
+++ 
portals/jetspeed-2/trunk/applications/j2-admin/src/webapp/WEB-INF/view/userreg/userRegistrationEmail_en.vm
 Wed Nov 30 22:03:42 2005
@@ -0,0 +1,13 @@
+Hello $!{map.get("user.name.given")} $!{map.get("user.name.family")}:
+
+Welcome to Jetspeed! 
+Thanks you for registering.  Jetspeed is a powerful component based
+portlet container system conforming to JSR-168.
+
+Your username is: $!{map.get("user.name")}
+Your password is: $!{map.get("password")}
+
+You may change your password online.
+
+Thanks
+



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to