Author: chris.laprun(a)jboss.com
Date: 2009-02-23 08:28:47 -0500 (Mon, 23 Feb 2009)
New Revision: 12865
Added:
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/test/faces/ManagedBeanTestCase.java
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/WEB-INF/classes/Resource.properties
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/Resource.properties
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/Resource_fr.properties
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/ManagedBean.java
Log:
- JBPORTAL-2317: Fixed name validation checking for WSRP.
- Fixed an improper update of consumers information when a consumer's id was changed.
- Fixed improper handling of null in ManagedBean.normalizeStringIfNeeded and added test
cases.
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/WEB-INF/classes/Resource.properties
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/WEB-INF/classes/Resource.properties 2009-02-23
13:08:33 UTC (rev 12864)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/WEB-INF/classes/Resource.properties 2009-02-23
13:28:47 UTC (rev 12865)
@@ -326,7 +326,7 @@
INVALID_NAME_ERROR=''{0}'' is an invalid {1} name: Cannot be null, empty
or contain '\\' or '%5c'
NO_SELECTED_PORTLET_ERROR=No portlet was selected!
-DUPLICATE_ERROR=A(n) {1} named ''{0}'' already exists!
+DUPLICATE_ERROR=A {1} named ''{0}'' already exists!
bean_support_unexpected_error=Unexpected error:
bean_support_cause=Cause:
Modified:
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java 2009-02-23
13:08:33 UTC (rev 12864)
+++
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java 2009-02-23
13:28:47 UTC (rev 12865)
@@ -127,11 +127,14 @@
// need to check that the new id is valid
if (isOldAndNewDifferent(oldId, id))
{
- id = checkNameValidity(id, "id");
+ id = checkNameValidity(id, "edit-cons-form:id");
if (id != null)
{
info.setId(id);
+ // properly update the registry after change of id
+ registry.updateProducerInfo(info);
+
// we're not using modifyIfNeeded here to avoid double equality check,
so we need to set modified manually
modified = true;
}
@@ -572,6 +575,6 @@
public boolean isAlreadyExisting(String objectName)
{
- return false;
+ return registry.getConsumer(objectName) != null;
}
}
Modified:
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java 2009-02-23
13:08:33 UTC (rev 12864)
+++
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java 2009-02-23
13:28:47 UTC (rev 12865)
@@ -59,6 +59,7 @@
static final String REFRESH_MODIFY = "bean_consumermanager_refresh_modify";
static final String REQUESTED_CONSUMER_ID = "id";
static final String SESSION_CONSUMER_ID = "consumerId";
+ private static final String MESSAGE_TARGET = "createConsumer:consumerName";
public ConsumerRegistry getRegistry()
{
@@ -172,7 +173,7 @@
public String createConsumer()
{
- selectedId = checkNameValidity(selectedId, "consumerName");
+ selectedId = checkNameValidity(selectedId, MESSAGE_TARGET);
if (selectedId != null)
{
try
@@ -183,7 +184,7 @@
}
catch (Exception e)
{
- beanContext.createErrorMessageFrom("consumerName", e);
+ beanContext.createErrorMessageFrom(MESSAGE_TARGET, e);
return null;
}
}
Modified:
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/Resource.properties
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/Resource.properties 2009-02-23
13:08:33 UTC (rev 12864)
+++
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/Resource.properties 2009-02-23
13:28:47 UTC (rev 12865)
@@ -176,4 +176,7 @@
registration_property_status_invalid_value = Invalid value
registration_property_status_valid = Valid
-org.jboss.portal.object.name.admin.WSRP=WSRP
\ No newline at end of file
+org.jboss.portal.object.name.admin.WSRP=WSRP
+
+INVALID_NAME_ERROR=''{0}'' is an invalid {1} name: Cannot be null, empty
or contain '\\' or '%5c'
+DUPLICATE_ERROR=A {1} named ''{0}'' already exists!
\ No newline at end of file
Modified:
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/Resource_fr.properties
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/Resource_fr.properties 2009-02-23
13:08:33 UTC (rev 12864)
+++
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/classes/Resource_fr.properties 2009-02-23
13:28:47 UTC (rev 12865)
@@ -145,4 +145,6 @@
registration_property_status_valid=Valide
org.jboss.portal.object.name.admin.WSRP=WSRP
consumers_table_reload=Recharger consommateurs
-CONSUMER_TYPE=Consommateur
\ No newline at end of file
+CONSUMER_TYPE=Consommateur
+DUPLICATE_ERROR=Un {1} nomm\u00e9 ''{0}'' existe d\u00e9j\u00e0!
+INVALID_NAME_ERROR=''{0}'' est un nom invalide pour un {1} : Ne peut pas
\u00eatre null, vide ou contenir '\\' ou '%5c'
\ No newline at end of file
Modified:
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/ManagedBean.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/ManagedBean.java 2009-02-23
13:08:33 UTC (rev 12864)
+++
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/ManagedBean.java 2009-02-23
13:28:47 UTC (rev 12865)
@@ -87,7 +87,13 @@
public abstract boolean isAlreadyExisting(String objectName);
- protected boolean isOldAndNewDifferent(Object oldValue, Object newValue)
+ /**
+ * @param oldValue
+ * @param newValue
+ * @return
+ * @todo public for test cases
+ */
+ public boolean isOldAndNewDifferent(Object oldValue, Object newValue)
{
oldValue = normalizeStringIfNeeded(oldValue);
newValue = normalizeStringIfNeeded(newValue);
@@ -100,10 +106,26 @@
*
* @param value
* @return
+ * @todo public for test cases
*/
- protected Object normalizeStringIfNeeded(Object value)
+ public Object normalizeStringIfNeeded(Object value)
{
- return (value instanceof String && ((String)value).length() == 0) ? null :
((String)value).trim();
+ if (value == null)
+ {
+ return null;
+ }
+ else
+ {
+ if (value instanceof String)
+ {
+ String stringValue = (String)value;
+ return stringValue.length() == 0 ? null : stringValue.trim();
+ }
+ else
+ {
+ return value;
+ }
+ }
}
private class MessageValidationHandler extends
ParameterValidation.ValidationErrorHandler
Added:
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/test/faces/ManagedBeanTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/test/faces/ManagedBeanTestCase.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/test/faces/ManagedBeanTestCase.java 2009-02-23
13:28:47 UTC (rev 12865)
@@ -0,0 +1,71 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * 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 *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+
+package org.jboss.portal.test.faces;
+
+import junit.framework.TestCase;
+import org.jboss.portal.faces.gui.ManagedBean;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class ManagedBeanTestCase extends TestCase
+{
+ private ManagedBean bean;
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ bean = new ManagedBean()
+ {
+ @Override
+ protected String getObjectTypeName()
+ {
+ return "test";
+ }
+
+ @Override
+ public boolean isAlreadyExisting(String objectName)
+ {
+ return false;
+ }
+ };
+ }
+
+ public void testNormalizeStringIfNeeded()
+ {
+ assertEquals("foo", bean.normalizeStringIfNeeded("foo"));
+ assertEquals("foo", bean.normalizeStringIfNeeded(" foo "));
+ assertEquals("foo",
bean.normalizeStringIfNeeded("\t\nfoo\t"));
+ assertNull(bean.normalizeStringIfNeeded(null));
+ assertEquals(bean, bean.normalizeStringIfNeeded(bean));
+ }
+
+ public void testIsOldAndNewDifferent()
+ {
+ assertTrue(bean.isOldAndNewDifferent("foo", null));
+ assertTrue(bean.isOldAndNewDifferent(null, "foo"));
+ assertFalse(bean.isOldAndNewDifferent(null, null));
+ }
+}