Author: chris.laprun(a)jboss.com
Date: 2012-03-14 12:19:17 -0400 (Wed, 14 Mar 2012)
New Revision: 8597
Modified:
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/AbstractApplicationMessage.java
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/ApplicationMessage.java
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/CompoundApplicationMessage.java
Log:
- 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:
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/AbstractApplicationMessage.java
===================================================================
---
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/AbstractApplicationMessage.java 2012-03-14
16:19:07 UTC (rev 8596)
+++
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/AbstractApplicationMessage.java 2012-03-14
16:19:17 UTC (rev 8597)
@@ -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(a)yahoo.com
+ * minhdv81(a)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:
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/ApplicationMessage.java
===================================================================
---
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/ApplicationMessage.java 2012-03-14
16:19:07 UTC (rev 8596)
+++
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/ApplicationMessage.java 2012-03-14
16:19:17 UTC (rev 8597)
@@ -23,6 +23,7 @@
package org.exoplatform.web.application;
import java.io.Serializable;
+import java.util.Arrays;
/** @author <a href="mailto:chris.laprun@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:
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/CompoundApplicationMessage.java
===================================================================
---
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/CompoundApplicationMessage.java 2012-03-14
16:19:07 UTC (rev 8596)
+++
portal/trunk/component/web/controller/src/main/java/org/exoplatform/web/application/CompoundApplicationMessage.java 2012-03-14
16:19:17 UTC (rev 8597)
@@ -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@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()
Show replies by date