Author: chris.laprun(a)jboss.com
Date: 2008-08-28 19:14:38 -0400 (Thu, 28 Aug 2008)
New Revision: 11765
Added:
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/jsf/renameCoordination.xhtml
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/EventWiringManagerBean.java
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/coordination/WindowBindingManagerBean.java
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/jsf/confirmDeleteCoordination.xhtml
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/jsf/editCoordination.xhtml
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/coordination/CoordinationConfigurator.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/coordination/CoordinationService.java
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/model/portal/coordination/CoordinationServiceTestCase.java
Log:
- Added rename operations on CoordinationConfigurator and associated test cases.
- Implemented rename behavior.
- Next step is looking at backend since operations don't seem to be persisted properly
and creation of wiring doesn't work.
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/coordination/CoordinationConfigurator.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/coordination/CoordinationConfigurator.java 2008-08-28
20:52:43 UTC (rev 11764)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/controller/coordination/CoordinationConfigurator.java 2008-08-28
23:14:38 UTC (rev 11765)
@@ -58,8 +58,8 @@
void removeEventWiring(EventWiringInfo eventWiringInfo) throws
IllegalCoordinationException;
/**
- * Set event wiring implicit mode for a given page container. This will be inherited
recursively
- * by all children page containers
+ * Set event wiring implicit mode for a given page container. This will be inherited
recursively by all children page
+ * containers
*
* @param pageContainer
* @param mode
@@ -68,6 +68,15 @@
void setEventWiringImplicitMode(PageContainer pageContainer, boolean mode) throws
IllegalCoordinationException;
/**
+ * Renames the specified wiring to the new name
+ *
+ * @param eventWiring the wiring to be renamed
+ * @param newName the wiring new name
+ * @throws IllegalCoordinationException
+ */
+ void renameEventWiring(EventWiringInfo eventWiring, String newName) throws
IllegalCoordinationException;
+
+ /**
* Checks if implicit event wiring is enabled for a given page container. May return
null if no implicit mode is not
* set for this portal object
*
@@ -84,9 +93,8 @@
*/
void removeEventWiringImplicitMode(PageContainer pageContainer) throws
IllegalCoordinationException;
-
/**
- * @param page
+ * @param page
* @param eventQName
* @return all wirings defined for a given qname
*/
@@ -127,10 +135,18 @@
*/
void removeWindowBinding(WindowBindingInfo parameterBinding) throws
IllegalCoordinationException;
+ /**
+ * Renames the specified window binding to the new name
+ *
+ * @param windowBinding the window binding to be renamed
+ * @param newName the binding new name
+ * @throws IllegalCoordinationException
+ */
+ void renameWindowBinding(WindowBindingInfo windowBinding, String newName) throws
IllegalCoordinationException;
/**
- * Set parameter binding implicit mode for a given page container. This will be
inherited recursively by
- * all children page containers
+ * Set parameter binding implicit mode for a given page container. This will be
inherited recursively by all children
+ * page containers
*
* @param pageContainer
* @param mode
@@ -138,7 +154,6 @@
*/
void setParameterBindingImplicitMode(PageContainer pageContainer, boolean mode) throws
IllegalCoordinationException;
-
/**
* Removes parameter binding implicit mode entry for a given page container
*
@@ -156,8 +171,6 @@
*/
Boolean isParameterBindingImplicitModeEnabled(PageContainer pageContainer);
-
-
/**
* Set alias binding for a given page. If alias with given name already exists it will
be overwritten
*
@@ -177,6 +190,15 @@
void removeAliasBinding(AliasBindingInfo aliasInfo) throws
IllegalCoordinationException;
/**
+ * Renames the specified alias to the new name
+ *
+ * @param aliasBinding the alias binding to be renamed
+ * @param newName the alias new name
+ * @throws IllegalCoordinationException
+ */
+ void renameAliasBinding(AliasBindingInfo aliasBinding, String newName) throws
IllegalCoordinationException;
+
+ /**
* @param page
* @return collection of alias bindings connected to the given page
*/
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/coordination/CoordinationService.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/coordination/CoordinationService.java 2008-08-28
20:52:43 UTC (rev 11764)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/core/impl/coordination/CoordinationService.java 2008-08-28
23:14:38 UTC (rev 11765)
@@ -22,6 +22,7 @@
package org.jboss.portal.core.impl.coordination;
+import org.jboss.portal.common.util.ParameterValidation;
import org.jboss.portal.core.controller.coordination.AliasBindingInfo;
import org.jboss.portal.core.controller.coordination.CoordinationConfigurator;
import org.jboss.portal.core.controller.coordination.CoordinationManager;
@@ -52,46 +53,30 @@
/**
* @author <a href="mailto:boleslaw dot dawidowicz at redhat anotherdot
com">Boleslaw Dawidowicz</a>
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
* @version : 0.1 $
*/
public class CoordinationService extends AbstractJBossService
implements CoordinationManager, CoordinationConfigurator
{
public static final String SOURCE = "source";
-
public static final String DESTINATION = "destination";
-
public static final String BINDING = "binding";
-
public static final String PREFIX = "coordination";
-
public static final String QNAME_SEPARATOR = ";";
-
public static final String PREFIX_EVENT = PREFIX + ".event";
-
public static final String PREFIX_PARAMETER = PREFIX + ".parameter";
-
public static final String PREFIX_PARAMETER_ALIAS = PREFIX_PARAMETER +
".alias";
-
public static final String PREFIX_EVENT_NAME = PREFIX_EVENT + ".name";
-
public static final String PREFIX_EVENT_WIRING = PREFIX_EVENT + ".wiring";
-
public static final String PREFIX_PARAMETER_NAME = PREFIX_PARAMETER +
".name";
-
public static final String PREFIX_PARAMETER_BINDING = PREFIX_PARAMETER +
".binding";
-
public static final String PREFIX_PARAMETER_ALIAS_NAME = PREFIX_PARAMETER_ALIAS +
".name";
-
public static final String PREFIX_EVENT_IMPLICIT_MODE = PREFIX_EVENT +
".implicit_mode";
-
public static final String PREFIX_PARAMETER_IMPLICIT_MODE = PREFIX_PARAMETER +
".implicit_mode";
-
public static final Boolean DEFAULT_IMPLICIT_MODE = true;
-
protected EventConverter eventConverter = new SimpleEventConverter();
-
protected PortalObjectContainer portalObjectContainer;
protected void startService() throws Exception
@@ -107,34 +92,20 @@
public Map<Window, PortletWindowEvent> getEventWindows(PortletWindowEvent event,
ControllerPortletControllerContext context) throws IllegalCoordinationException
{
+ ParameterValidation.throwIllegalArgExceptionIfNull(event, "event");
+ ParameterValidation.throwIllegalArgExceptionIfNull(context, "context");
- if (event == null)
- {
- throw new IllegalArgumentException("event is null");
- }
-
- if (context == null)
- {
- throw new IllegalArgumentException("context is null");
- }
-
// Obtain page for which we scope this event
-
Page page = context.getWindow(event.getWindowId()).getPage();
-
boolean implicitMode = resolveEventWiringImplicitModeEnabled(page);
- Map<Window, PortletWindowEvent> windows = new HashMap<Window,
PortletWindowEvent>();
-
// Only explicit wirings
-
+ Map<Window, PortletWindowEvent> windows;
if(!implicitMode)
{
windows = getEventWindowsExplicit(page, event, context);
}
-
// If no explicit wirings for this event fallback to implicit
-
else
{
windows = getEventWindowsExplicit(page, event, context);
@@ -152,7 +123,6 @@
{
Set<String> names = new HashSet<String>();
- //
for (WindowBindingInfo info : getWindowBindings(window))
{
for (Map.Entry<Window, QName> entry : info.getWindows().entrySet())
@@ -176,16 +146,13 @@
}
}
- //
return names;
}
private Map<Window, PortletWindowEvent> getEventWindowsExplicit(Page page,
PortletWindowEvent event, ControllerPortletControllerContext context)
{
Map<Window, PortletWindowEvent> windows = new HashMap<Window,
PortletWindowEvent>();
-
Collection<EventWiringInfo> infos = getEventWirings(page);
-
for (EventWiringInfo info : infos)
{
for (Map.Entry<Window, QName> entry : info.getSources().entrySet())
@@ -207,7 +174,6 @@
break;
}
}
-
}
return windows;
@@ -216,7 +182,6 @@
private Map<Window, PortletWindowEvent> getEventWindowsImplicit(Page page,
PortletWindowEvent event, ControllerPortletControllerContext context)
{
Map<Window, PortletWindowEvent> windows = new HashMap<Window,
PortletWindowEvent>();
-
for (String windowName : context.getWindowNames())
{
PortletInfo info = context.getPortletInfo(windowName);
@@ -234,22 +199,10 @@
public void setEventWiring(Map<Window, QName> sources, Map<Window, QName>
destinations, String eventName) throws IllegalCoordinationException
{
-
- if (sources == null)
- {
- throw new IllegalArgumentException("sources are null");
- }
-
- if (destinations == null)
- {
- throw new IllegalArgumentException("destinations are null");
- }
-
- if (eventName == null)
- {
- throw new IllegalArgumentException("eventName is null");
- }
-
+ ParameterValidation.throwIllegalArgExceptionIfNull(sources, "sources");
+ ParameterValidation.throwIllegalArgExceptionIfNull(destinations,
"destinations");
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(eventName, "event
name", null);
+
if (sources.isEmpty())
{
throw new IllegalArgumentException("empty sources map");
@@ -318,10 +271,7 @@
public void removeEventWiring(EventWiringInfo info) throws
IllegalCoordinationException
{
- if (info == null)
- {
- throw new IllegalArgumentException("EventWiringInfo is null");
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(info,
"EventWiringInfo");
// Remove all entries
@@ -339,60 +289,41 @@
}
}
- public void setEventWiringImplicitMode(PageContainer pageContainer, boolean mode)
throws IllegalCoordinationException
+ public void renameEventWiring(EventWiringInfo eventWiring, String newName) throws
IllegalCoordinationException
{
- if (pageContainer == null)
- {
- throw new IllegalArgumentException("pageContainer is null");
- }
+ removeEventWiring(eventWiring);
+ setEventWiring(eventWiring.getSources(), eventWiring.getDestinations(), newName);
+ }
-
+ public void setEventWiringImplicitMode(PageContainer pageContainer, boolean mode)
throws IllegalCoordinationException
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(pageContainer,
"PageContainer");
setImplicitMode(pageContainer, mode, PREFIX_EVENT_IMPLICIT_MODE);
}
public void removeEventWiringImplicitMode(PageContainer pageContainer) throws
IllegalCoordinationException
{
- if (pageContainer == null)
- {
- throw new IllegalArgumentException("pageContainer is null");
- }
-
+ ParameterValidation.throwIllegalArgExceptionIfNull(pageContainer,
"PageContainer");
setImplicitMode(pageContainer, null, PREFIX_EVENT_IMPLICIT_MODE);
}
public Boolean isEventWiringImplicitModeEnabled(PageContainer pageContainer)
{
- if (pageContainer == null)
- {
- throw new IllegalArgumentException("page is null");
- }
-
+ ParameterValidation.throwIllegalArgExceptionIfNull(pageContainer,
"PageContainer");
return decodeImplicitMode(pageContainer, PREFIX_EVENT_IMPLICIT_MODE);
}
public Boolean resolveEventWiringImplicitModeEnabled(PageContainer page)
{
- if (page == null)
- {
- throw new IllegalArgumentException("page is null");
- }
-
+ ParameterValidation.throwIllegalArgExceptionIfNull(page,
"PageContainer");
return resolveImplicitMode(page, PREFIX_EVENT_IMPLICIT_MODE);
}
public Collection<EventWiringInfo> getEventWirings(Page page, QName eventQName)
{
+ ParameterValidation.throwIllegalArgExceptionIfNull(page, "Page");
+ ParameterValidation.throwIllegalArgExceptionIfNull(eventQName, "event
QName");
- if (page == null)
- {
- throw new IllegalArgumentException("page is null");
- }
-
- if (eventQName == null)
- {
- throw new IllegalArgumentException("eventQName is null");
- }
-
Collection<EventWiringInfo> pageEvents = getEventWirings(page);
Set<EventWiringInfo> events = new HashSet<EventWiringInfo>();
@@ -410,10 +341,7 @@
public Collection<EventWiringInfo> getEventWirings(Page page)
{
- if (page == null)
- {
- throw new IllegalArgumentException("page is null");
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(page, "Page");
// Examine window properties and create page events
@@ -445,7 +373,7 @@
String role = window.getProperty(propName);
- //TODO: if the imformation from properties is not consistent should we
throw exception?
+ //TODO: if information from properties is not consistent should we throw
exception?
if (name != null)
{
@@ -517,14 +445,8 @@
public void setWindowBinding(String name, Map<Window, QName> windows) throws
IllegalCoordinationException
{
- if (windows == null)
- {
- throw new IllegalArgumentException("windows are null");
- }
- if (name == null)
- {
- throw new IllegalArgumentException("name is null");
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(windows, "windows");
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(name, "name",
"window binding");
if (windows.isEmpty())
{
throw new IllegalArgumentException("empty windows map");
@@ -556,80 +478,56 @@
public void removeWindowBinding(WindowBindingInfo info) throws
IllegalCoordinationException
{
- if (info == null)
- {
- throw new IllegalArgumentException("ParameterBindingInfo is null");
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(info,
"WindowBindingInfo");
// Remove all entries
String prop_wiring = PREFIX_PARAMETER_BINDING + "." + info.getName();
-
- //
for (Window window : info.getWindows().keySet())
{
window.setDeclaredProperty(prop_wiring, null);
}
}
- public Boolean isParameterBindingImplicitModeEnabled(PageContainer pageContainer)
+ public void renameWindowBinding(WindowBindingInfo windowBinding, String newName)
throws IllegalCoordinationException
{
- if (pageContainer == null)
- {
- throw new IllegalArgumentException("page is null");
- }
+ removeWindowBinding(windowBinding);
+ setWindowBinding(newName, windowBinding.getWindows());
+ }
- //
+ public Boolean isParameterBindingImplicitModeEnabled(PageContainer pageContainer)
+ {
+ ParameterValidation.throwIllegalArgExceptionIfNull(pageContainer,
"PageContainer");
return decodeImplicitMode(pageContainer, PREFIX_PARAMETER_IMPLICIT_MODE);
}
public void setParameterBindingImplicitMode(PageContainer pageContainer, boolean mode)
throws IllegalCoordinationException
{
- if (pageContainer == null)
- {
- throw new IllegalArgumentException("pageContainer is null");
- }
-
- //
+ ParameterValidation.throwIllegalArgExceptionIfNull(pageContainer,
"PageContainer");
setImplicitMode(pageContainer, mode, PREFIX_PARAMETER_IMPLICIT_MODE);
}
public Boolean resolveParameterBindingImplicitModeEnabled(PageContainer
pageContainer)
{
- if (pageContainer == null)
- {
- throw new IllegalArgumentException("page is null");
- }
-
- //
+ ParameterValidation.throwIllegalArgExceptionIfNull(pageContainer,
"PageContainer");
return resolveImplicitMode(pageContainer, PREFIX_PARAMETER_IMPLICIT_MODE);
}
public void removeParameterBindingImplicitMode(PageContainer pageContainer) throws
IllegalCoordinationException
{
- if (pageContainer == null)
- {
- throw new IllegalArgumentException("pageContainer is null");
- }
-
+ ParameterValidation.throwIllegalArgExceptionIfNull(pageContainer,
"PageContainer");
setImplicitMode(pageContainer, null, PREFIX_PARAMETER_IMPLICIT_MODE);
}
public void setAliasBinding(Page page, String aliasName, Set<QName> qnames)
throws IllegalCoordinationException
{
- if (page == null)
+ ParameterValidation.throwIllegalArgExceptionIfNull(page, "Page");
+ ParameterValidation.throwIllegalArgExceptionIfNullOrEmpty(aliasName,
"name", "alias binding");
+ ParameterValidation.throwIllegalArgExceptionIfNull(qnames, "aliased
QNames");
+ if(qnames.isEmpty())
{
- throw new IllegalArgumentException("page is null");
+ throw new IllegalArgumentException("Aliased QNames set is empty!");
}
- if (aliasName == null)
- {
- throw new IllegalArgumentException("alias name is null");
- }
- if (qnames == null)
- {
- throw new IllegalArgumentException("qnames set is null");
- }
- //
String propName = PREFIX_PARAMETER_ALIAS_NAME + "." + aliasName;
// Check if qname consist separator string
@@ -641,10 +539,7 @@
}
}
- //
StringBuilder qnameList = new StringBuilder();
-
- //
for (Iterator i = qnames.iterator(); i.hasNext(); )
{
QName qname = (QName)i.next();
@@ -655,21 +550,14 @@
}
}
- //
page.setDeclaredProperty(propName, qnameList.toString());
}
public void removeAliasBinding(AliasBindingInfo aliasInfo) throws
IllegalCoordinationException
{
- if (aliasInfo == null)
- {
- throw new IllegalArgumentException("alias info is null");
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(aliasInfo,
"AliasBindingInfo");
- //
AliasInfoPOJO alias = (AliasInfoPOJO)aliasInfo;
-
- //
String propName = PREFIX_PARAMETER_ALIAS_NAME + "." +
aliasInfo.getName();
if (alias.page.getProperties().keySet().contains(propName))
{
@@ -677,17 +565,19 @@
}
}
+ public void renameAliasBinding(AliasBindingInfo aliasBinding, String newName) throws
IllegalCoordinationException
+ {
+ removeAliasBinding(aliasBinding);
+ AliasInfoPOJO alias = (AliasInfoPOJO)aliasBinding;
+ setAliasBinding(alias.page, newName, alias.getNames());
+ }
+
public Collection<AliasBindingInfo> getAliasBindings(Page page)
{
- if (page == null)
- {
- throw new IllegalArgumentException("page is null");
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(page, "Page");
- //
HashSet<AliasBindingInfo> aliases = new HashSet<AliasBindingInfo>();
- //
for (String propertyName : page.getProperties().keySet())
{
if (propertyName.startsWith(PREFIX_PARAMETER_ALIAS_NAME))
@@ -708,30 +598,16 @@
}
}
- //
return aliases;
}
public Collection<? extends WindowBindingInfo> getWindowBindings(Page page,
QName parameterName)
{
- if (page == null)
- {
- throw new IllegalArgumentException("Page is null");
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(page, "Page");
+ ParameterValidation.throwIllegalArgExceptionIfNull(parameterName, "parameter
QName");
- //
- if (parameterName == null)
- {
- throw new IllegalArgumentException("Name is null");
- }
-
- //
Collection<? extends WindowBindingInfo> pageParams =
getWindowBindings(page);
-
- //
Collection<WindowBindingInfo> infos = new
HashSet<WindowBindingInfo>();
-
- //
for (WindowBindingInfo pageParam : pageParams)
{
if (pageParam.getWindows().containsValue(parameterName))
@@ -739,8 +615,6 @@
infos.add(pageParam);
}
}
-
- //
return infos;
}
@@ -760,15 +634,11 @@
public Collection<? extends WindowBindingInfo> getWindowBindings(Page page)
{
- if (page == null)
- {
- throw new IllegalArgumentException("page is null");
- }
+ ParameterValidation.throwIllegalArgExceptionIfNull(page, "Page");
// Examine window properties and create page parameters
Collection<PortalObject> children =
page.getChildren(PortalObject.WINDOW_MASK);
- //
Map<String, WindowInfoPOJO> params = new HashMap<String,
WindowInfoPOJO>();
for (PortalObject child : children)
{
@@ -779,8 +649,7 @@
if(propName.startsWith(PREFIX_PARAMETER_BINDING))
{
String pn = propName.substring(PREFIX_PARAMETER_BINDING.length() + 1);
- WindowInfoPOJO info = null;
-
+ WindowInfoPOJO info;
if (!params.keySet().contains(pn))
{
info = new WindowInfoPOJO(pn);
@@ -791,15 +660,11 @@
info = params.get(pn);
}
- //
String binding = child.getProperty(propName);
-
//TODO: if the information from properties is not consistent should we
throw exception?
if (binding != null)
{
QName qname = decodeQName(binding);
-
- //
if (qname != null)
{
info.windows.put((Window)child, qname);
@@ -809,7 +674,6 @@
}
}
- //
return Collections.unmodifiableCollection(params.values());
}
@@ -853,7 +717,6 @@
private Boolean decodeImplicitMode(PageContainer pageContainer, String prefix)
{
String value = pageContainer.getDeclaredProperty(prefix);
-
return value != null ? Boolean.valueOf(value) : null;
}
@@ -862,12 +725,9 @@
private Boolean resolveImplicitMode(PageContainer pageContainer, String prefix)
{
String value = pageContainer.getDeclaredProperty(prefix);
+ Boolean mode;
- Boolean mode = null;
-
-
// Try to obtain recursive implicit mode from parents
-
if (value == null)
{
mode = resolveRecursiveImplicitMode(pageContainer, prefix);
@@ -961,14 +821,8 @@
private class WindowInfoPOJO implements WindowBindingInfo
{
-
- /** . */
private final String name;
-
- /** . */
private final Map<Window, QName> windows;
-
- /** . */
private final Map<Window, QName> immutableWindows;
private WindowInfoPOJO(String name)
@@ -991,17 +845,9 @@
private class AliasInfoPOJO implements AliasBindingInfo
{
-
- /** . */
private final String name;
-
- /** . */
private final Page page;
-
- /** . */
private final Set<QName> names;
-
- /** . */
private final Set<QName> immutableNames;
private AliasInfoPOJO(String name, Page page)
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/model/portal/coordination/CoordinationServiceTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/model/portal/coordination/CoordinationServiceTestCase.java 2008-08-28
20:52:43 UTC (rev 11764)
+++
branches/JBoss_Portal_Branch_2_7/core/src/main/org/jboss/portal/test/core/model/portal/coordination/CoordinationServiceTestCase.java 2008-08-28
23:14:38 UTC (rev 11765)
@@ -31,6 +31,7 @@
import org.jboss.portal.common.junit.TransactionAssert;
import org.jboss.portal.core.controller.coordination.AliasBindingInfo;
import org.jboss.portal.core.controller.coordination.EventWiringInfo;
+import org.jboss.portal.core.controller.coordination.IllegalCoordinationException;
import org.jboss.portal.core.controller.coordination.WindowBindingInfo;
import org.jboss.portal.core.impl.coordination.CoordinationService;
import org.jboss.portal.core.model.content.ContentType;
@@ -55,7 +56,6 @@
public class CoordinationServiceTestCase extends AbstractPortalObjectContainerTestCase
{
-
static
{
Appender appender = new ConsoleAppender(new SimpleLayout());
@@ -405,6 +405,109 @@
TransactionAssert.commitTransaction();
}
+ public void testRenameEventWiring() throws IllegalCoordinationException
+ {
+ TransactionAssert.beginTransaction();
+
+ Portal portal1 =
container.getContext("").getPortal("Portal_1");
+ Page page1 = portal1.getPage("Page_1");
+
+ Window w1 = page1.getWindow("Window_1");
+ Window w2 = page1.getWindow("Window_2");
+
+ Map<Window, QName> s1 = new HashMap<Window, QName>();
+ s1.put(w1, new QName("juju", "foo"));
+
+ Map<Window, QName> d1 = new HashMap<Window, QName>();
+ d1.put(w2, new QName("bobo", "bar"));
+
+ cos.setEventWiring(s1, d1, "event1");
+
+ Collection<EventWiringInfo> events = cos.getEventWirings(page1);
+ assertNotNull(events);
+ assertEquals(1, events.size());
+
+ EventWiringInfo info = events.iterator().next();
+ assertEquals("event1", info.getName());
+
+ cos.renameEventWiring(info, "new");
+
+ events = cos.getEventWirings(page1);
+ assertEquals(1, events.size());
+
+ info = events.iterator().next();
+ assertEquals("new", info.getName());
+
+ TransactionAssert.commitTransaction();
+ }
+
+ public void testRenameWindowBinding() throws Exception
+ {
+ TransactionAssert.beginTransaction();
+
+ Portal portal1 =
container.getContext("").getPortal("Portal_1");
+ Page page1 = portal1.getPage("Page_1");
+
+ Window w1 = page1.getWindow("Window_1");
+ Window w2 = page1.getWindow("Window_2");
+
+ Map<Window, QName> ws = new HashMap<Window, QName>();
+ ws.put(w1, new QName("juju", "foo"));
+ ws.put(w2, new QName("juju", "foo1"));
+
+ cos.setWindowBinding("binding1", ws);
+
+ Collection<? extends WindowBindingInfo> bindings =
cos.getWindowBindings(page1);
+ assertEquals(1, bindings.size());
+
+ WindowBindingInfo info = bindings.iterator().next();
+ assertEquals("binding1", info.getName());
+
+ cos.renameWindowBinding(info, "new");
+
+ bindings = cos.getWindowBindings(w1);
+ assertEquals(1, bindings.size());
+ info = bindings.iterator().next();
+ assertEquals("new", info.getName());
+
+ TransactionAssert.commitTransaction();
+ }
+
+ public void testRenameAliasBinding() throws Exception
+ {
+ TransactionAssert.beginTransaction();
+
+ Portal portal1 =
container.getContext("").getPortal("Portal_1");
+ Page page1 = portal1.getPage("Page_1");
+
+ QName qname1 = new QName("nm1", "local1");
+ QName qname2 = new QName("nm2", "local2");
+ QName qname3 = new QName("nm3", "local3");
+
+ HashSet<QName> qnames1 = new HashSet<QName>();
+ qnames1.add(qname1);
+ qnames1.add(qname2);
+ qnames1.add(qname3);
+
+ cos.setAliasBinding(page1, "alias1", qnames1);
+
+ Collection<AliasBindingInfo> bindings1 = cos.getAliasBindings(page1);
+
+ assertTrue(bindings1.size() == 1);
+ AliasBindingInfo info = bindings1.iterator().next();
+
+ assertEquals("alias1", info.getName());
+
+ cos.renameAliasBinding(info, "new");
+ bindings1 = cos.getAliasBindings(page1);
+ assertEquals(1, bindings1.size());
+
+ info = bindings1.iterator().next();
+ assertEquals("new", info.getName());
+
+ TransactionAssert.commitTransaction();
+ }
+
public CoordinationService getCos()
{
return cos;
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 2008-08-28
20:52:43 UTC (rev 11764)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/coordination/CoordinationManagerBean.java 2008-08-28
23:14:38 UTC (rev 11765)
@@ -67,6 +67,8 @@
private CoordinationType selectedType;
private static ThreadLocal<EventWiringManagerBean> eventManagerHolder = new
ThreadLocal<EventWiringManagerBean>();
private static ThreadLocal<WindowBindingManagerBean> windowManagerHolder = new
ThreadLocal<WindowBindingManagerBean>();
+ private String newName;
+ private static final String EDIT_COORDINATION = "editCoordination";
private enum CoordinationType
{
@@ -110,7 +112,7 @@
public abstract String delete(String name) throws IllegalCoordinationException;
- public abstract String rename(String name);
+ public abstract String rename(String oldName, String newName) throws
IllegalCoordinationException;
public abstract void extractInfoFrom(Window window, PortletInfo info);
}
@@ -282,7 +284,7 @@
e.printStackTrace();
}
- return "editCoordination";
+ return EDIT_COORDINATION;
}
// JSF helper methods
@@ -350,19 +352,30 @@
// reset selection
selectedType = null;
selectedName = null;
- return null;
+ return EDIT_COORDINATION;
}
- public String renameSelected()
+ public void setNewName(String newName)
{
+ this.newName = newName;
+ }
+
+ public String getNewName()
+ {
+ return newName;
+ }
+
+ public String renameSelected() throws IllegalCoordinationException
+ {
if(selectedType != null)
{
- selectedType.bean().rename(selectedName);
+ selectedType.bean().rename(selectedName, newName);
}
// reset selection
selectedType = null;
selectedName = null;
- return null;
+ newName = null;
+ return EDIT_COORDINATION;
}
}
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 2008-08-28
20:52:43 UTC (rev 11764)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/coordination/EventWiringManagerBean.java 2008-08-28
23:14:38 UTC (rev 11765)
@@ -22,7 +22,6 @@
package org.jboss.portal.core.admin.ui.coordination;
-import org.jboss.portal.common.NotYetImplemented;
import org.jboss.portal.core.controller.coordination.EventWiringInfo;
import org.jboss.portal.core.controller.coordination.IllegalCoordinationException;
import org.jboss.portal.core.model.portal.Page;
@@ -334,16 +333,19 @@
return null;
}
- public String rename(String name)
+ public String rename(String oldName, String newName) throws
IllegalCoordinationException
{
- DisplayEventWiring displayEvent = displayEventWirings.get(name);
+ DisplayEventWiring displayEvent = displayEventWirings.get(oldName);
if (displayEvent != null)
{
- //todo: implement, rename operation should be on CoordinationConfigurator
EventWiringInfo event = displayEvent.getEventInfo();
+ managerBean.getCoordinationService().renameEventWiring(event, newName);
+
+ // reload event information
+ loadInfoFrom(managerBean.getSelectedPage());
}
- throw new NotYetImplemented("renameWiring not yet implemented!");
+ return null;
}
public void extractInfoFrom(Window window, PortletInfo info)
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/coordination/WindowBindingManagerBean.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/coordination/WindowBindingManagerBean.java 2008-08-28
20:52:43 UTC (rev 11764)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/main/org/jboss/portal/core/admin/ui/coordination/WindowBindingManagerBean.java 2008-08-28
23:14:38 UTC (rev 11765)
@@ -22,7 +22,6 @@
package org.jboss.portal.core.admin.ui.coordination;
-import org.jboss.portal.common.NotYetImplemented;
import org.jboss.portal.core.controller.coordination.AliasBindingInfo;
import org.jboss.portal.core.controller.coordination.IllegalCoordinationException;
import org.jboss.portal.core.controller.coordination.WindowBindingInfo;
@@ -304,15 +303,18 @@
return null;
}
- public String rename(String name)
+ public String rename(String name, String newName) throws IllegalCoordinationException
{
DisplayParameterBinding displayParam = displayParameterBindings.get(name);
if (displayParam != null)
{
- //todo: implement, rename operation should be on CoordinationConfigurator
WindowBindingInfo bindingInfo = displayParam.getBindingInfo();
+ managerBean.getCoordinationService().renameWindowBinding(bindingInfo, newName);
+
+ // reload event information
+ loadInfoFrom(managerBean.getSelectedPage());
}
- throw new NotYetImplemented("renameWiring not yet implemented!");
+ return null;
}
}
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml 2008-08-28
20:52:43 UTC (rev 11764)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml 2008-08-28
23:14:38 UTC (rev 11765)
@@ -541,6 +541,10 @@
<from-outcome>confirmCoordinationDeletion</from-outcome>
<to-view-id>/jsf/confirmDeleteCoordination.xhtml</to-view-id>
</navigation-case>
+ <navigation-case>
+ <from-outcome>renameCoordination</from-outcome>
+ <to-view-id>/jsf/renameCoordination.xhtml</to-view-id>
+ </navigation-case>
</navigation-rule>
<lifecycle>
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/jsf/confirmDeleteCoordination.xhtml
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/jsf/confirmDeleteCoordination.xhtml 2008-08-28
20:52:43 UTC (rev 11764)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/jsf/confirmDeleteCoordination.xhtml 2008-08-28
23:14:38 UTC (rev 11765)
@@ -20,7 +20,7 @@
<div class="portlet-msg">
<div class="portlet-msg-icon"><h:graphicImage
url="/img/msgIcon_Warning.gif" alt="/!\"/></div>
<div class="portlet-msg-body">
- <h3>#{bundle.COMMON_DELETE}  <h:outputText
value="#{coordinationManager.selectedType}"/></h3>
+ <h3>#{bundle.COMMON_DELETE}
#{coordinationManager.selectedType}</h3>
<p class="portlet-msg-alert">
#{bundle.COMMON_DELETING}
Modified:
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/jsf/editCoordination.xhtml
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/jsf/editCoordination.xhtml 2008-08-28
20:52:43 UTC (rev 11764)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/jsf/editCoordination.xhtml 2008-08-28
23:14:38 UTC (rev 11765)
@@ -79,7 +79,7 @@
</h:column>
<h:column>
<f:facet name="header">Actions</f:facet>
- <h:commandLink
action="#{coordinationManager.renameSelected}"
actionListener="#{coordinationManager.select}">
+ <h:commandLink action="renameCoordination"
actionListener="#{coordinationManager.select}">
<h:outputText styleClass="actionRename"
value="#{bundle.RENAME}"/>
<f:param name="name"
value="#{binding.name}"/>
<f:param name="type"
value="parameter"/>
@@ -197,7 +197,7 @@
<h:outputText
value="#{bundle.COORDINATION_EVENT_EXISTING_ACTIONS}"/>
</f:facet>
- <h:commandLink action="#{coordinationManager.renameSelected}"
actionListener="#{coordinationManager.select}">
+ <h:commandLink action="renameCoordination"
actionListener="#{coordinationManager.select}">
<h:outputText styleClass="actionRename"
value="#{bundle.RENAME}"/>
<f:param name="name"
value="#{wiring.name}"/>
<f:param name="type" value="wiring"/>
Added:
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/jsf/renameCoordination.xhtml
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/jsf/renameCoordination.xhtml
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/core-admin/src/resources/portal-admin-war/jsf/renameCoordination.xhtml 2008-08-28
23:14:38 UTC (rev 11765)
@@ -0,0 +1,22 @@
+<div
+
xmlns="http://www.w3.org/1999/xhtml"
+
xmlns:ui="http://java.sun.com/jsf/facelets"
+
xmlns:h="http://java.sun.com/jsf/html"
+
xmlns:f="http://java.sun.com/jsf/core"
+
xmlns:c="http://java.sun.com/jstl/core">
+ <ui:composition template="objectTemplate.xhtml">
+ <ui:param name="portalObjectScreen"
value="#{bundle.RENAME}"/>
+ <ui:define name="content">
+ <h3>#{bundle.RENAME} #{coordinationManager.selectedType}</h3>
+ <h:form id="renameForm">
+ <h:message for="newName"/>
+
+ <p>#{bundle.RENAME_THE} <span
class="objectName">#{coordinationManager.selectedName}</span>
+ #{coordinationManager.selectedType} #{bundle.TO}:
+ <h:inputText id="newName"
value="#{coordinationManager.newName}"/>
+ <h:commandButton value="#{bundle.RENAME}"
action="#{coordinationManager.renameSelected}"
styleClass="portlet-form-button"/>
+ </p>
+ </h:form>
+ </ui:define>
+ </ui:composition>
+</div>