[cvs] expresso commit by lhamel: add ability for schema param to specify

JCorporate Ltd jcorp at jcorporate.com
Fri Aug 12 06:24:02 UTC 2005


Log Message:
-----------
add ability for schema param to specify bundle message override

Modified Files:
--------------
    expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/services/validation:
        LoginEmailValidator.java

Revision Data
-------------
Index: LoginEmailValidator.java
===================================================================
RCS file: /home/javacorp/.cvs/expresso/expresso/expresso-web/WEB-INF/src/com/jcorporate/expresso/services/validation/LoginEmailValidator.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/services/validation/LoginEmailValidator.java -Lexpresso-web/WEB-INF/src/com/jcorporate/expresso/services/validation/LoginEmailValidator.java -u -r1.19 -r1.20
--- expresso-web/WEB-INF/src/com/jcorporate/expresso/services/validation/LoginEmailValidator.java
+++ expresso-web/WEB-INF/src/com/jcorporate/expresso/services/validation/LoginEmailValidator.java
@@ -63,9 +63,7 @@
  */
 package com.jcorporate.expresso.services.validation;
 
-import java.util.Hashtable;
-import java.util.Locale;
-import java.util.Vector;
+import com.jcorporate.expresso.core.ExpressoSchema;
 import com.jcorporate.expresso.core.controller.Controller;
 import com.jcorporate.expresso.core.controller.ControllerException;
 import com.jcorporate.expresso.core.controller.ExpressoRequest;
@@ -78,6 +76,11 @@
 import com.jcorporate.expresso.core.security.User;
 import com.jcorporate.expresso.services.dbobj.Setup;
 
+import java.util.Hashtable;
+import java.util.Locale;
+import java.util.Stack;
+import java.util.Vector;
+
 
 /**
  * This class is a helper class that allows the LoginController controller to
@@ -116,8 +119,6 @@
         // The db context for the user (Note: this is different from the Validation entry context, which
         // could very well be in a different DB context)
         String dbName = (String) params.get("db");
-
-        // The login name of the user
         String loginName = (String) params.get("UserName");
 
         try {
@@ -132,12 +133,12 @@
             }
 
             // Create the list of addresses to notify, in this case just the user
-            Vector addresses = new Vector(0);
+            Vector addresses = new Vector(1);
             addresses.add(myUser.getEmail());
 
             Object[] args = {
-                loginName, URL, Setup.getValue(dbName, "CompanyName"),
-                Setup.getValue(dbName, "HomePageURL")
+                    loginName, URL, Setup.getValue(dbName, "CompanyName"),
+                    Setup.getValue(dbName, "HomePageURL")
             };
 
             String localeCountry = (String) params.get(ValidationEntry.PRM_LOC_COUNTRY);
@@ -145,24 +146,28 @@
             Locale locale = null;
             if (localeCountry != null && localeLanguage != null) {
                 locale = new Locale(localeLanguage, localeCountry);
+            } else {
+                locale = Messages.getDefaultLocale();
             }
 
-            // Send email notification
-            if (locale != null) {
-                ValidationEntry.notifyByEmail(dbName,
-                        Setup.getValue(dbName, "MAILFrom"),
-                        addresses,
-                        Messages.getString(locale, "loginReqSubject"),
-                        Messages.getString(locale, "loginReqEM1", args));
+            // provide ability to use different schema, and thereby different message bundle, if param for alternate schema exists
+            Stack schemaStack = new Stack();
+            schemaStack.add(ExpressoSchema.class.getName()); // default schema always at root
+            String schemaClass = (String) params.get("schema");
+            if (schemaClass != null) {
+                schemaStack.add(
+                        schemaClass);  // this schema's message bundle will be searched first for overriding string definitions.
             }
-            else {
-                ValidationEntry.notifyByEmail(dbName,
-                        Setup.getValue(dbName, "MAILFrom"),
-                        addresses,
-                        Messages.getString("loginReqSubject"),
-                        Messages.getString("loginReqEM1", args));
 
-            }
+            Object[] emptyArgs = {};
+
+            // Send email notification
+            ValidationEntry.notifyByEmail(
+                    dbName,
+                    Setup.getValue(dbName, "MAILFrom"),
+                    addresses,
+                    Messages.getString(schemaStack, locale, "loginReqSubject", emptyArgs),
+                    Messages.getString(schemaStack, locale, "loginReqEM1", args));
 
 
         } catch (DBException dbe) {
@@ -190,7 +195,10 @@
      * @throws NonHandleableException upon fatal error
      * @see com.jcorporate.expresso.services.controller.ValidationController
      */
-    public ExpressoResponse validated(Hashtable params, ExpressoRequest request, ExpressoResponse response, Controller ctlr)
+    public ExpressoResponse validated(Hashtable params,
+                                      ExpressoRequest request,
+                                      ExpressoResponse response,
+                                      Controller ctlr)
             throws ControllerException, NonHandleableException {
         // The db context for the user (Note: this is different from the Validation entry context, which
         // could very well be in a different DB context)


More information about the cvs mailing list