Author: chris.laprun(a)jboss.com
Date: 2009-02-21 11:12:51 -0500 (Sat, 21 Feb 2009)
New Revision: 12854
Removed:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/Action.java
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/AddPageAction.java
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/CreateInstanceAction.java
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/DisplayNameAction.java
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalAction.java
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/RenameAction.java
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/coordination/AliasBindingManagerBean.java
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/coordination/CoordinationManagerBean.java
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/coordination/EventWiringManagerBean.java
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/coordination/ParameterBindingManagerBean.java
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/main/org/jboss/portal/wsrp/admin/ui/ProducerBean.java
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/BeanContext.java
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/JSFBeanContext.java
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/ManagedBean.java
Log:
- JBPORTAL-2317:
+ Moved Action code up to ManagedBean as it can be used outside of core-admin
+ Fixed incorrect behavior in PropertyAction.updateProperty
+ Renamed RenameAction.pageContainer to renamedObject as it is more correct and fixed
behavior
+ Adapted CoordinationBean hierarchy to ManagedBean changes (this needs more testing)
+ Adapted WSRP backing beans to ManagedBean changes (this needs more testing)
+ Renamed ConsumerBean.isOldAndNewEqual to isOldAndNewDifferent since that is the
behavior that is
implemented and moved it to ManagedBean along with normalizeStringIfNeeded
+ Fixed implementation of JSFContextBean.createMessage
Deleted:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/Action.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/Action.java 2009-02-21
15:23:55 UTC (rev 12853)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/Action.java 2009-02-21
16:12:51 UTC (rev 12854)
@@ -1,97 +0,0 @@
-/******************************************************************************
- * 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.core.admin.ui.actions;
-
-import org.jboss.portal.common.util.ParameterValidation;
-import org.jboss.portal.faces.gui.ManagedBean;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- */
-public abstract class Action extends ManagedBean
-{
- public static final String INVALID_NAME = "INVALID_NAME_ERROR";
- public static final String DUPLICATE = "DUPLICATE_ERROR";
- protected static final String INSTANCE_TYPE = "INSTANCE_TYPE";
- protected static final String PAGE_TYPE = "PAGE_TYPE";
- protected static final String PORTAL_TYPE = "PORTAL_TYPE";
- protected static final String DISPLAY_NAME_TYPE = "DISPLAY_NAME_TYPE";
- protected static final String PROPERTY_TYPE = "PROPERTY_TYPE";
- protected static final String PORTAL_OBJECT_TYPE = "PORTAL_OBJECT_TYPE";
-
- public String checkNameValidity(String name, String targetForErrorMessage)
- {
- if (ParameterValidation.isNullOrEmpty(name))
- {
- beanContext.createTargetedErrorMessage(targetForErrorMessage, INVALID_NAME,
name, getLocalizedType());
- return null;
- }
- else
- {
- // Trim name
- name = name.trim();
-
- ParameterValidation.sanitizeFromPatternWithHandler(name,
ParameterValidation.XSS_CHECK,
- new MessageValidationHandler(null, targetForErrorMessage, name));
-
- // Check for duplicate
- if (isAlreadyExisting(name))
- {
- beanContext.createTargetedErrorMessage(targetForErrorMessage, DUPLICATE,
name, getLocalizedType());
- return null;
- }
-
- return name;
- }
- }
-
- private String getLocalizedType()
- {
- return beanContext.getMessageFromBundle(getObjectTypeName());
- }
-
- protected abstract String getObjectTypeName();
-
- public abstract boolean isAlreadyExisting(String objectName);
-
- private class MessageValidationHandler extends
ParameterValidation.ValidationErrorHandler
- {
- private String targetForErrorMessage;
- private String validatedName;
-
- private MessageValidationHandler(String defaultValue, String targetForErrorMessage,
String validatedName)
- {
- super(defaultValue);
- this.targetForErrorMessage = targetForErrorMessage;
- this.validatedName = validatedName;
- }
-
- protected String internalValidationErrorHandling(String s)
- {
- beanContext.createTargetedErrorMessage(targetForErrorMessage, INVALID_NAME,
validatedName, getLocalizedType());
- return null;
- }
- }
-}
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/AddPageAction.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/AddPageAction.java 2009-02-21
15:23:55 UTC (rev 12853)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/AddPageAction.java 2009-02-21
16:12:51 UTC (rev 12854)
@@ -20,17 +20,19 @@
* 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.core.admin.ui.actions;
import org.jboss.logging.Logger;
import org.jboss.portal.core.model.portal.Page;
import org.jboss.portal.core.model.portal.PageContainer;
+import org.jboss.portal.faces.gui.ManagedBean;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public class AddPageAction extends Action
+public class AddPageAction extends ManagedBean
{
/** . */
@@ -47,6 +49,7 @@
/** The message id when an error happens. */
public String messageTarget;
+ protected static final String PAGE_TYPE = "PAGE_TYPE";
public void execute()
{
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/CreateInstanceAction.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/CreateInstanceAction.java 2009-02-21
15:23:55 UTC (rev 12853)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/CreateInstanceAction.java 2009-02-21
16:12:51 UTC (rev 12854)
@@ -20,12 +20,14 @@
* 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.core.admin.ui.actions;
import org.jboss.portal.core.admin.ui.InstanceManagerBean;
import org.jboss.portal.core.admin.ui.PortletManagerBean;
import org.jboss.portal.core.model.instance.Instance;
import org.jboss.portal.core.model.instance.InstanceContainer;
+import org.jboss.portal.faces.gui.ManagedBean;
import org.jboss.portal.portlet.Portlet;
import org.jboss.portal.security.RoleSecurityBinding;
import org.jboss.portal.security.SecurityConstants;
@@ -38,7 +40,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public class CreateInstanceAction extends Action
+public class CreateInstanceAction extends ManagedBean
{
/** . */
@@ -50,6 +52,7 @@
/** . */
private InstanceManagerBean instanceMgr;
private static final String MESSAGE_TARGET =
"add_instance_form:instanceId";
+ protected static final String INSTANCE_TYPE = "INSTANCE_TYPE";
public String getInstanceId()
{
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/DisplayNameAction.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/DisplayNameAction.java 2009-02-21
15:23:55 UTC (rev 12853)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/DisplayNameAction.java 2009-02-21
16:12:51 UTC (rev 12854)
@@ -28,6 +28,7 @@
import org.jboss.portal.common.util.ConversionException;
import org.jboss.portal.core.admin.ui.DisplayNameBean;
import org.jboss.portal.core.model.HasDisplayName;
+import org.jboss.portal.faces.gui.ManagedBean;
import java.util.Collection;
import java.util.HashMap;
@@ -40,13 +41,14 @@
* @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
* @version $Revision$
*/
-public abstract class DisplayNameAction extends Action
+public abstract class DisplayNameAction extends ManagedBean
{
protected Object managerBean;
protected String newLocale;
protected String newText;
protected DisplayNameBean displayNameBean;
protected HasDisplayName target;
+ protected static final String DISPLAY_NAME_TYPE = "DISPLAY_NAME_TYPE";
public Object getManagerBean()
{
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalAction.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalAction.java 2009-02-21
15:23:55 UTC (rev 12853)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PortalAction.java 2009-02-21
16:12:51 UTC (rev 12854)
@@ -20,6 +20,7 @@
* 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.core.admin.ui.actions;
import org.jboss.portal.Mode;
@@ -32,6 +33,7 @@
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.PortalObjectPath;
import org.jboss.portal.core.model.portal.PortalObjectPermission;
+import org.jboss.portal.faces.gui.ManagedBean;
import org.jboss.portal.security.RoleSecurityBinding;
import org.jboss.portal.security.SecurityConstants;
import org.jboss.portal.security.spi.provider.DomainConfigurator;
@@ -46,7 +48,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision$
*/
-public class PortalAction extends Action
+public class PortalAction extends ManagedBean
{
/** . */
@@ -56,6 +58,7 @@
private String portalName;
private static final String MESSAGE_TARGET = "create-portal-form:name";
+ protected static final String PORTAL_TYPE = "PORTAL_TYPE";
public PortalObjectManagerBean getPortalObjectManager()
{
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java 2009-02-21
15:23:55 UTC (rev 12853)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/PropertyAction.java 2009-02-21
16:12:51 UTC (rev 12854)
@@ -20,17 +20,18 @@
* 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.core.admin.ui.actions;
import org.jboss.portal.core.admin.ui.PortalObjectManagerBean;
import org.jboss.portal.core.impl.model.portal.PortalObjectImpl;
-import org.jboss.portal.faces.gui.BeanContext;
+import org.jboss.portal.faces.gui.ManagedBean;
/**
* @author <a href="mailto:boleslaw dot dawidowicz at jboss.org">Boleslaw
Dawidowicz</a>
* @version $Revision$
*/
-public class PropertyAction extends Action
+public class PropertyAction extends ManagedBean
{
/** . */
@@ -44,6 +45,7 @@
/** . */
private String otherPropertyName;
+ protected static final String PROPERTY_TYPE = "PROPERTY_TYPE";
public PropertyAction(PortalObjectManagerBean pomgr)
@@ -83,22 +85,23 @@
public void updateProperty()
{
- String propertyName = checkNameValidity(otherPropertyName, BeanContext.STATUS);
- String value = "";
- //
- if (propertyName.length() == 0 && selectedProperty != null)
+ String propertyName = checkNameValidity(otherPropertyName,
"common-edit-prop-form:property");
+ if (propertyName != null)
{
- propertyName = selectedProperty.trim();
- }
+ if (propertyName.length() == 0 && selectedProperty != null)
+ {
+ propertyName = selectedProperty.trim();
+ }
- //
- if (propertyName.length() > 0)
- {
- if (getPropertyValue() != null)
+ if (propertyName.length() > 0)
{
- value = getPropertyValue().trim();
+ String value = "";
+ if (getPropertyValue() != null)
+ {
+ value = getPropertyValue().trim();
+ }
+ pomgr.getSelectedObject().setDeclaredProperty(propertyName, value);
}
- pomgr.getSelectedObject().setDeclaredProperty(propertyName, value);
}
}
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/RenameAction.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/RenameAction.java 2009-02-21
15:23:55 UTC (rev 12853)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/actions/RenameAction.java 2009-02-21
16:12:51 UTC (rev 12854)
@@ -20,12 +20,14 @@
* 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.core.admin.ui.actions;
import org.jboss.portal.core.admin.ui.PortalObjectManagerBean;
import org.jboss.portal.core.admin.ui.dashboard.DashboardBean;
import org.jboss.portal.core.model.portal.PortalObject;
import org.jboss.portal.core.model.portal.PortalObjectPath;
+import org.jboss.portal.faces.gui.ManagedBean;
import org.jboss.portal.security.spi.provider.DomainConfigurator;
import java.util.Set;
@@ -34,17 +36,18 @@
* @author <a href="mailto:theute@jboss.org">Thomas Heute</a>
* @version $Revision$
*/
-public class RenameAction extends Action
+public class RenameAction extends ManagedBean
{
private String newName;
- /** The page container that will create the child. */
- public PortalObject pageContainer;
+ /** The portal object we're trying to rename. */
+ public PortalObject renamedObject;
private DomainConfigurator domainConfigurator;
private Object bean;
private static final String MESSAGE_TARGET = "renameForm:newName";
+ protected static final String PORTAL_OBJECT_TYPE = "PORTAL_OBJECT_TYPE";
public void setNewName(String newName)
{
@@ -55,7 +58,7 @@
{
if (newName == null)
{
- newName = pageContainer.getName();
+ newName = renamedObject.getName();
}
return newName;
}
@@ -71,46 +74,53 @@
this.domainConfigurator = domainConfigurator;
}
- public PortalObject getPageContainer()
+ public PortalObject getRenamedObject()
{
- return pageContainer;
+ return renamedObject;
}
- public void setPageContainer(PortalObject pageContainer)
+ public void setRenamedObject(PortalObject renamedObject)
{
- this.pageContainer = pageContainer;
+ this.renamedObject = renamedObject;
}
public String execute()
{
+ // if the new name is equal to the current name, do nothing
+ String currentName = renamedObject.getName();
+ if (!isOldAndNewDifferent(currentName, newName))
+ {
+ return null;
+ }
+
newName = checkNameValidity(newName, MESSAGE_TARGET);
if (newName != null)
{
- PortalObject parent = pageContainer.getParent();
+ PortalObject parent = renamedObject.getParent();
PortalObject newObject = null;
try
{
// TODO: Should be in a tx
// Clone portal object
- newObject = pageContainer.copy(parent, newName, true);
+ newObject = renamedObject.copy(parent, newName, true);
// Copy security settings
- Set set =
domainConfigurator.getSecurityBindings(pageContainer.getId().toString(PortalObjectPath.CANONICAL_FORMAT));
+ Set set =
domainConfigurator.getSecurityBindings(renamedObject.getId().toString(PortalObjectPath.CANONICAL_FORMAT));
domainConfigurator.setSecurityBindings(newObject.getId().toString(PortalObjectPath.CANONICAL_FORMAT),
set);
String defaultObject =
parent.getDeclaredProperties().get(PortalObject.PORTAL_PROP_DEFAULT_OBJECT_NAME);
- if (pageContainer.getName().equals(defaultObject))
+ if (currentName.equals(defaultObject))
{
parent.setDeclaredProperty(PortalObject.PORTAL_PROP_DEFAULT_OBJECT_NAME,
newName);
}
// Destroy previous object
- parent.destroyChild(pageContainer.getName());
+ parent.destroyChild(currentName);
}
catch (Exception e)
{
- log.error("An error occurred while attempting to rename " +
pageContainer + "to " + newName);
+ log.error("An error occurred while attempting to rename " +
renamedObject + "to " + newName);
beanContext.createErrorMessageFrom(MESSAGE_TARGET, e);
}
@@ -146,6 +156,6 @@
public boolean isAlreadyExisting(String objectName)
{
- return pageContainer.getChild(objectName) != null;
+ return renamedObject.getParent().getChild(objectName) != null;
}
}
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/coordination/AliasBindingManagerBean.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/coordination/AliasBindingManagerBean.java 2009-02-21
15:23:55 UTC (rev 12853)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/coordination/AliasBindingManagerBean.java 2009-02-21
16:12:51 UTC (rev 12854)
@@ -1,24 +1,25 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, 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.
-*/
+/******************************************************************************
+ * 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.core.admin.ui.coordination;
@@ -216,4 +217,21 @@
return getName().compareTo(other.getName());
}
}
+
+ @Override
+ public String getObjectTypeName()
+ {
+ return "COORDINATION_ALIAS";
+ }
+
+ @Override
+ public String getCreationTargetName()
+ {
+ return "aliasName";
+ }
+
+ public boolean isAlreadyExisting(String objectName)
+ {
+ return displayAliasBindings.containsKey(objectName);
+ }
}
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/coordination/CoordinationManagerBean.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/coordination/CoordinationManagerBean.java 2009-02-21
15:23:55 UTC (rev 12853)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/coordination/CoordinationManagerBean.java 2009-02-21
16:12:51 UTC (rev 12854)
@@ -1,24 +1,25 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, 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.
-*/
+/******************************************************************************
+ * 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.core.admin.ui.coordination;
@@ -153,6 +154,21 @@
}
public abstract void initKnowing(Collection<PortalObject> children);
+
+ /**
+ * Made public to get access to it in CoordinationManagerBean.getObjectTypeName()
+ *
+ * @return
+ */
+ public abstract String getObjectTypeName();
+
+ /**
+ * Returns the name of the target for errors when creating/renaming a Coordination
element. Made public so that it
+ * can be accessed from CoordinationManagerBean
+ *
+ * @return
+ */
+ public abstract String getCreationTargetName();
}
public Page getSelectedPage()
@@ -413,8 +429,19 @@
{
if (selectedType != null)
{
- selectedType.getBean().rename(selectedName, newName);
- refresh();
+ if (!isOldAndNewDifferent(selectedName, newName))
+ {
+ return null;
+ }
+
+ CoordinationBean coordinationBean = selectedType.getBean();
+ newName = checkNameValidity(newName, coordinationBean.getCreationTargetName());
+ if (newName != null)
+ {
+ coordinationBean.rename(selectedName, newName);
+ refresh();
+ }
+
}
// reset selection
@@ -423,4 +450,14 @@
newName = null;
return EDIT_COORDINATION;
}
+
+ protected String getObjectTypeName()
+ {
+ return selectedType.getBean().getObjectTypeName();
+ }
+
+ public boolean isAlreadyExisting(String objectName)
+ {
+ return selectedType.getBean().isAlreadyExisting(objectName);
+ }
}
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/coordination/EventWiringManagerBean.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/coordination/EventWiringManagerBean.java 2009-02-21
15:23:55 UTC (rev 12853)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/coordination/EventWiringManagerBean.java 2009-02-21
16:12:51 UTC (rev 12854)
@@ -1,24 +1,25 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, 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.
-*/
+/******************************************************************************
+ * 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.core.admin.ui.coordination;
@@ -478,4 +479,20 @@
this.destinations = destinations;
}
}
+
+ public String getObjectTypeName()
+ {
+ return "COORDINATION_WIRING";
+ }
+
+ @Override
+ public String getCreationTargetName()
+ {
+ return "wiringName";
+ }
+
+ public boolean isAlreadyExisting(String objectName)
+ {
+ return displayEventWirings.containsKey(objectName);
+ }
}
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/coordination/ParameterBindingManagerBean.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/coordination/ParameterBindingManagerBean.java 2009-02-21
15:23:55 UTC (rev 12853)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/coordination/ParameterBindingManagerBean.java 2009-02-21
16:12:51 UTC (rev 12854)
@@ -1,24 +1,25 @@
-/*
-* JBoss, a division of Red Hat
-* Copyright 2008, 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.
-*/
+/******************************************************************************
+ * 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.core.admin.ui.coordination;
@@ -69,11 +70,11 @@
public List<? extends SelectItem> getAvailableParameterWindowPairs()
{
- if(availableParameterWindowPairs == null ||
availableParameterWindowPairs.isEmpty())
+ if (availableParameterWindowPairs == null ||
availableParameterWindowPairs.isEmpty())
{
return Collections.emptyList();
}
-
+
List<WindowSelectItemGroup> result = new
LinkedList<WindowSelectItemGroup>(availableParameterWindowPairs.values());
Collections.sort(result);
return result;
@@ -367,5 +368,22 @@
return o1.getLabel().compareTo(o2.getLabel());
}
}
+
private final static Comparator<SelectItem> COMP = new
ParameterWindowSelectItemComparator();
+
+ public String getObjectTypeName()
+ {
+ return "COORDINATION_PARAMETER";
+ }
+
+ @Override
+ public String getCreationTargetName()
+ {
+ return "bindingName";
+ }
+
+ public boolean isAlreadyExisting(String objectName)
+ {
+ return displayParameterBindings.containsKey(objectName);
+ }
}
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-21
15:23:55 UTC (rev 12853)
+++
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerBean.java 2009-02-21
16:12:51 UTC (rev 12854)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2007, Red Hat Middleware, LLC, and individual *
+ * 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. *
@@ -69,6 +69,7 @@
private static final String CANNOT_ERASE_REG =
"bean_consumer_cannot_erase_reg";
private static final String MALFORMED_URL = "bean_consumer_malformed_url";
private static final String UPDATE_SUCCESS =
"bean_consumer_update_success";
+ private static final String CONSUMER_TYPE = "CONSUMER_TYPE";
public ConsumerBean()
{
@@ -119,12 +120,26 @@
{
if (consumer != null)
{
+ // renaming scenario
ProducerInfo info = getProducerInfo();
String oldId = info.getId();
- info.setId((String)modifyIfNeeded(oldId, id, "id", false));
+
+ // need to check that the new id is valid
+ if (isOldAndNewDifferent(oldId, id))
+ {
+ id = checkNameValidity(id, "id");
+ if (id != null)
+ {
+ info.setId(id);
+
+ // we're not using modifyIfNeeded here to avoid double equality check,
so we need to set modified manually
+ modified = true;
+ }
+ }
}
else
{
+ // initialization scenario
consumer = registry.getConsumer(id);
if (consumer != null)
{
@@ -449,7 +464,7 @@
if (!isRegistrationLocallyModified())
{
IllegalStateException e =
- new IllegalStateException("Registration not locally
modified: there should be expected registration from producer!");
+ new IllegalStateException("Registration not locally modified:
there should be expected registration from producer!");
log.debug(e);
throw e;
}
@@ -504,7 +519,7 @@
private Object modifyIfNeeded(Object oldValue, Object newValue, String target, boolean
checkURL)
{
- if (isOldAndNewEqual(oldValue, newValue))
+ if (isOldAndNewDifferent(oldValue, newValue))
{
if (checkURL)
{
@@ -526,25 +541,6 @@
return oldValue;
}
- private boolean isOldAndNewEqual(Object oldValue, Object newValue)
- {
- oldValue = normalizeStringIfNeeded(oldValue);
- newValue = normalizeStringIfNeeded(newValue);
-
- return (oldValue != null && !oldValue.equals(newValue)) || (oldValue ==
null && newValue != null);
- }
-
- /**
- * Normalizes Strings by considering empty String as null as JSF would give either
- *
- * @param value
- * @return
- */
- private Object normalizeStringIfNeeded(Object value)
- {
- return (value instanceof String && ((String)value).length() == 0) ? null :
value;
- }
-
// Listeners
public void useWSDLListener(ValueChangeEvent event)
@@ -564,8 +560,18 @@
Object oldValue = normalizeStringIfNeeded(event.getOldValue());
if (oldValue != null)
{
- registrationLocallyModified = isOldAndNewEqual(oldValue,
event.getNewValue());
+ registrationLocallyModified = isOldAndNewDifferent(oldValue,
event.getNewValue());
}
}
}
+
+ protected String getObjectTypeName()
+ {
+ return CONSUMER_TYPE;
+ }
+
+ public boolean isAlreadyExisting(String objectName)
+ {
+ return false;
+ }
}
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-21
15:23:55 UTC (rev 12853)
+++
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ConsumerManagerBean.java 2009-02-21
16:12:51 UTC (rev 12854)
@@ -172,6 +172,7 @@
public String createConsumer()
{
+ selectedId = checkNameValidity(selectedId, "consumerName");
if (selectedId != null)
{
try
@@ -182,15 +183,12 @@
}
catch (Exception e)
{
- beanContext.createErrorMessageFrom(e);
+ beanContext.createErrorMessageFrom("consumerName", e);
return null;
}
}
- else
- {
- beanContext.createErrorMessage(INVALID_NEW_CONSUMER_NAME);
- return null;
- }
+
+ return null;
}
public String destroyConsumer()
@@ -368,4 +366,14 @@
{
beanContext.createErrorMessage(NO_CONSUMER);
}
+
+ protected String getObjectTypeName()
+ {
+ return "CONSUMER_TYPE";
+ }
+
+ public boolean isAlreadyExisting(String objectName)
+ {
+ return registry.getConsumer(objectName) != null;
+ }
}
Modified:
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ProducerBean.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ProducerBean.java 2009-02-21
15:23:55 UTC (rev 12853)
+++
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/ProducerBean.java 2009-02-21
16:12:51 UTC (rev 12854)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2007, Red Hat Middleware, LLC, and individual *
+ * 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. *
@@ -226,4 +226,14 @@
{
selectedProp = beanContext.getParameter("propName");
}
+
+ protected String getObjectTypeName()
+ {
+ return null; // default implementation as not used
+ }
+
+ public boolean isAlreadyExisting(String objectName)
+ {
+ return false; // default implementation as not used
+ }
}
Modified:
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/BeanContext.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/BeanContext.java 2009-02-21
15:23:55 UTC (rev 12853)
+++
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/BeanContext.java 2009-02-21
16:12:51 UTC (rev 12854)
@@ -52,6 +52,11 @@
*/
public abstract String getParameter(String key);
+ /**
+ * @param target
+ * @param message
+ * @param severity
+ */
protected abstract void createMessage(String target, String message, Object
severity);
protected abstract Object getErrorSeverity();
Modified:
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/JSFBeanContext.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/JSFBeanContext.java 2009-02-21
15:23:55 UTC (rev 12853)
+++
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/JSFBeanContext.java 2009-02-21
16:12:51 UTC (rev 12854)
@@ -26,6 +26,8 @@
import org.jboss.portal.common.util.ParameterValidation;
import javax.faces.application.FacesMessage;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIViewRoot;
import javax.faces.context.FacesContext;
import java.util.Locale;
import java.util.Map;
@@ -75,8 +77,22 @@
jsfSeverity = FacesMessage.SEVERITY_ERROR;
}
+ // Get the component id from the target
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ UIViewRoot viewRoot = facesContext.getViewRoot();
+ UIComponent component = viewRoot.findComponent(target);
+ if (component != null)
+ {
+ target = component.getClientId(facesContext);
+ }
+ else
+ {
+ // todo: do something better here
+ System.out.println("Couldn't resolve component target: " +
target);
+ }
+
FacesMessage msg = new FacesMessage(jsfSeverity, message, message);
- FacesContext.getCurrentInstance().addMessage(target, msg);
+ facesContext.addMessage(target, msg);
}
protected Object getErrorSeverity()
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-21
15:23:55 UTC (rev 12853)
+++
branches/JBoss_Portal_Branch_2_7/faces/src/main/org/jboss/portal/faces/gui/ManagedBean.java 2009-02-21
16:12:51 UTC (rev 12854)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2007, Red Hat Middleware, LLC, and individual *
+ * 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. *
@@ -24,6 +24,7 @@
package org.jboss.portal.faces.gui;
import org.apache.log4j.Logger;
+import org.jboss.portal.common.util.ParameterValidation;
/**
@@ -31,14 +32,96 @@
* @version $Revision$
* @since 2.6
*/
-public class ManagedBean
+public abstract class ManagedBean
{
protected Logger log = Logger.getLogger(getClass());
protected BeanContext beanContext;
+ public static final String INVALID_NAME = "INVALID_NAME_ERROR";
+ public static final String DUPLICATE = "DUPLICATE_ERROR";
public void setBeanContext(BeanContext beanContext)
{
this.beanContext = beanContext;
}
+
+ public String checkNameValidity(String name, String targetForErrorMessage)
+ {
+ if (ParameterValidation.isNullOrEmpty(name))
+ {
+ beanContext.createTargetedErrorMessage(targetForErrorMessage, INVALID_NAME,
name, getLocalizedType());
+ return null;
+ }
+ else
+ {
+ // Trim name
+ name = name.trim();
+
+ // "sanitize" name: if it's invalid, return null and output
message
+ name = ParameterValidation.sanitizeFromPatternWithHandler(name,
ParameterValidation.XSS_CHECK,
+ new MessageValidationHandler(null, targetForErrorMessage, name));
+
+ // we got an invalid name, fail!
+ if (name == null)
+ {
+ return null;
+ }
+
+ // Check for duplicate
+ if (isAlreadyExisting(name))
+ {
+ beanContext.createTargetedErrorMessage(targetForErrorMessage, DUPLICATE,
name, getLocalizedType());
+ return null;
+ }
+
+ return name;
+ }
+ }
+
+ private String getLocalizedType()
+ {
+ return beanContext.getMessageFromBundle(getObjectTypeName());
+ }
+
+ protected abstract String getObjectTypeName();
+
+ public abstract boolean isAlreadyExisting(String objectName);
+
+ protected boolean isOldAndNewDifferent(Object oldValue, Object newValue)
+ {
+ oldValue = normalizeStringIfNeeded(oldValue);
+ newValue = normalizeStringIfNeeded(newValue);
+
+ return (oldValue != null && !oldValue.equals(newValue)) || (oldValue ==
null && newValue != null);
+ }
+
+ /**
+ * Normalizes String by considering empty String as null as JSF would give either and
trim non-null Strings.
+ *
+ * @param value
+ * @return
+ */
+ protected Object normalizeStringIfNeeded(Object value)
+ {
+ return (value instanceof String && ((String)value).length() == 0) ? null :
((String)value).trim();
+ }
+
+ private class MessageValidationHandler extends
ParameterValidation.ValidationErrorHandler
+ {
+ private String targetForErrorMessage;
+ private String validatedName;
+
+ private MessageValidationHandler(String defaultValue, String targetForErrorMessage,
String validatedName)
+ {
+ super(defaultValue);
+ this.targetForErrorMessage = targetForErrorMessage;
+ this.validatedName = validatedName;
+ }
+
+ protected String internalValidationErrorHandling(String s)
+ {
+ beanContext.createTargetedErrorMessage(targetForErrorMessage, INVALID_NAME,
validatedName, getLocalizedType());
+ return null;
+ }
+ }
}