[gatein-commits] gatein SVN: r8592 - epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/application.

do-not-reply at jboss.org do-not-reply at jboss.org
Wed Mar 14 12:16:18 EDT 2012


Author: chris.laprun at jboss.com
Date: 2012-03-14 12:16:17 -0400 (Wed, 14 Mar 2012)
New Revision: 8592

Modified:
   epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/application/AbstractApplicationMessage.java
   epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/application/ApplicationMessage.java
   epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/application/CompoundApplicationMessage.java
Log:
bz 801207 GTNPORTAL-2377: 
  + Only output one message of each type in CompoundApplicationMessage
  + Fixed UsernameValidator and improved IdentifierValidator and ResourceValidator to fail fast when we have an error condition in a loop
  + Fixed improper/missing localization in EN and FR properties, would need to be done for other languages as well

Modified: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/application/AbstractApplicationMessage.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/application/AbstractApplicationMessage.java	2012-03-14 15:32:03 UTC (rev 8591)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/application/AbstractApplicationMessage.java	2012-03-14 16:16:17 UTC (rev 8592)
@@ -1,16 +1,16 @@
 /**
  * Copyright (C) 2009 eXo Platform SAS.
- * 
+ *
  * This is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as
  * published by the Free Software Foundation; either version 2.1 of
  * the License, or (at your option) any later version.
- * 
+ *
  * This software 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
  * Lesser General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
@@ -30,23 +30,23 @@
 /**
  * Created by The eXo Platform SARL
  * Author : Dang Van Minh
- *          minhdv81 at yahoo.com
+ * minhdv81 at yahoo.com
  * Jun 7, 2006
  */
 public abstract class AbstractApplicationMessage implements Serializable
 {
    private static Log log = ExoLogger.getLogger(ApplicationMessage.class);
-   
+
    final public static int ERROR = 0, WARNING = 1, INFO = 2;
 
    private int type_ = INFO;
-   
+
    private transient ResourceBundle resourceBundle;
 
    private boolean argsLocalized = true;
 
    public abstract String getMessage();
-   
+
    public void setResourceBundle(ResourceBundle resourceBundle)
    {
       this.resourceBundle = resourceBundle;
@@ -83,19 +83,19 @@
       {
          return key;
       }
-      
+
       String value;
       try
-      {         
-         value = resourceBundle.getString(key);         
+      {
+         value = resourceBundle.getString(key);
       }
       catch (MissingResourceException ex)
       {
          if (PropertyManager.isDevelopping())
          {
-            log.warn("Can not find resource bundle for key : " + key);            
+            log.warn("Can not find resource bundle for key : " + key);
          }
-          value = key.substring(key.lastIndexOf('.') + 1);
+         value = key.substring(key.lastIndexOf('.') + 1);
       }
       return value;
    }

Modified: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/application/ApplicationMessage.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/application/ApplicationMessage.java	2012-03-14 15:32:03 UTC (rev 8591)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/application/ApplicationMessage.java	2012-03-14 16:16:17 UTC (rev 8592)
@@ -23,6 +23,7 @@
 package org.exoplatform.web.application;
 
 import java.io.Serializable;
+import java.util.Arrays;
 
 /** @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a> */
 public class ApplicationMessage extends AbstractApplicationMessage implements Serializable
@@ -36,6 +37,40 @@
       this.messageArgs_ = args;
    }
 
+   @Override
+   public boolean equals(Object o)
+   {
+      if (this == o)
+      {
+         return true;
+      }
+      if (o == null || getClass() != o.getClass())
+      {
+         return false;
+      }
+
+      ApplicationMessage that = (ApplicationMessage)o;
+
+      if (!Arrays.equals(messageArgs_, that.messageArgs_))
+      {
+         return false;
+      }
+      if (!messageKey_.equals(that.messageKey_))
+      {
+         return false;
+      }
+
+      return true;
+   }
+
+   @Override
+   public int hashCode()
+   {
+      int result = messageKey_.hashCode();
+      result = 31 * result + (messageArgs_ != null ? Arrays.hashCode(messageArgs_) : 0);
+      return result;
+   }
+
    public ApplicationMessage(String key, Object[] args, int type)
    {
       this.messageKey_ = key;

Modified: epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/application/CompoundApplicationMessage.java
===================================================================
--- epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/application/CompoundApplicationMessage.java	2012-03-14 15:32:03 UTC (rev 8591)
+++ epp/portal/branches/EPP_5_2_Branch/component/web/controller/src/main/java/org/exoplatform/web/application/CompoundApplicationMessage.java	2012-03-14 16:16:17 UTC (rev 8592)
@@ -24,13 +24,15 @@
 
 import java.io.Serializable;
 import java.util.ArrayList;
+import java.util.HashSet;
 import java.util.List;
 import java.util.ResourceBundle;
+import java.util.Set;
 
 /** @author <a href="mailto:chris.laprun at jboss.com">Chris Laprun</a> */
 public class CompoundApplicationMessage extends AbstractApplicationMessage implements Serializable
 {
-   private List<AbstractApplicationMessage> messages = new ArrayList<AbstractApplicationMessage>(5);
+   private Set<AbstractApplicationMessage> messages = new HashSet<AbstractApplicationMessage>(5);
 
    public CompoundApplicationMessage()
    {
@@ -70,7 +72,9 @@
 
    public void addMessage(String messageKey, Object[] args)
    {
-      messages.add(new ApplicationMessage(messageKey, args, AbstractApplicationMessage.WARNING));
+      final ApplicationMessage message = new ApplicationMessage(messageKey, args, AbstractApplicationMessage.WARNING);
+      message.setArgsLocalized(false);
+      messages.add(message);
    }
 
    public boolean isEmpty()



More information about the gatein-commits mailing list