Author: julien(a)jboss.com
Date: 2007-11-30 16:54:15 -0500 (Fri, 30 Nov 2007)
New Revision: 9237
Removed:
branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/model/StructuralStateManagerImpl.java
Modified:
branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/model/StructuralStateContextImpl.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/AbstractStructuralStateContext.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateContext.java
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/MockModel.java
Log:
- correct a few minor stuff
Modified:
branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/model/StructuralStateContextImpl.java
===================================================================
---
branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/model/StructuralStateContextImpl.java 2007-11-30
19:24:56 UTC (rev 9236)
+++
branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/model/StructuralStateContextImpl.java 2007-11-30
21:54:15 UTC (rev 9237)
@@ -35,9 +35,7 @@
import org.jboss.portal.presentation.model.UIWindow;
import org.jboss.portal.presentation.model.state.structural.StructuralState;
import org.jboss.portal.presentation.model.state.structural.StructuralStateContext;
-import org.jboss.portal.presentation.model.state.structural.StructuralStateModification;
import org.jboss.portal.presentation.model.state.StateChangeVetoException;
-import org.jboss.portal.presentation.model.state.StateChange;
import java.util.ArrayList;
import java.util.Collection;
@@ -158,7 +156,7 @@
return type;
}
- public StructuralState create(String parentId, Class<? extends UIObject> type,
String name, Map<String, String> properties) throws StateChangeVetoException
+ public String create(String parentId, Class<? extends UIObject> type, String
name, Map<String, String> properties) throws StateChangeVetoException
{
throw new StateChangeVetoException();
}
@@ -178,16 +176,6 @@
throw new StateChangeVetoException();
}
- public void update(List<StateChange<StructuralStateModification>>
modifications)
- {
- throw new StateChangeVetoException();
- }
-
- public void update(StateChange<StructuralStateModification> modification)
- {
- throw new StateChangeVetoException();
- }
-
/**
*
*
Deleted:
branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/model/StructuralStateManagerImpl.java
===================================================================
---
branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/model/StructuralStateManagerImpl.java 2007-11-30
19:24:56 UTC (rev 9236)
+++
branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/model/StructuralStateManagerImpl.java 2007-11-30
21:54:15 UTC (rev 9237)
@@ -1,197 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, 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.presentation.model;
-
-import org.jboss.portal.core.model.portal.Page;
-import org.jboss.portal.core.model.portal.Portal;
-import org.jboss.portal.core.model.portal.PortalObject;
-import org.jboss.portal.core.model.portal.PortalObjectContainer;
-import org.jboss.portal.core.model.portal.PortalObjectId;
-import org.jboss.portal.core.model.portal.PortalObjectPath;
-import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.presentation.model.UIObject;
-import org.jboss.portal.presentation.model.UIPage;
-import org.jboss.portal.presentation.model.UIPortal;
-import org.jboss.portal.presentation.model.UIWindow;
-import org.jboss.portal.presentation.model.state.structural.StructuralState;
-import org.jboss.portal.presentation.model.state.structural.StructuralStateManager;
-import org.jboss.portal.presentation.model.state.StateChangeVetoException;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
- *
- */
-public class StructuralStateManagerImpl implements StructuralStateManager
-{
- /**
- *
- */
- private PortalObjectContainer portalObjectContainer = null;
-
- /**
- *
- * @return
- */
- public PortalObjectContainer getPortalObjectContainer()
- {
- return portalObjectContainer;
- }
-
- /**
- *
- * @param portalObjectContainer
- */
- public void setPortalObjectContainer(
- PortalObjectContainer portalObjectContainer)
- {
- this.portalObjectContainer = portalObjectContainer;
- }
-
-
- public String getRootId()
- {
- return portalObjectContainer.getContext().getId().toString();
- }
-
- /**
- *
- */
- public StructuralState load(String objectId) throws IllegalArgumentException
- {
- StructuralState structuralState = null;
-
- // Get the PortalObject corresponding to this objectId from the
PortalObjectContainer
- PortalObject portalObject =
this.portalObjectContainer.getObject(PortalObjectId.parse(objectId,
- PortalObjectPath.CANONICAL_FORMAT));
-
- if(portalObject == null)
- {
- // Object by this id was not found in the Portal
- return null;
- }
-
- // Type
- Class<? extends UIObject> type = this.getType(portalObject);
-
- // Name
- String name = portalObject.getName();
-
- // Properties
- Map<String, String> properties = portalObject.getDeclaredProperties();
-
- // Parent Id
- String parentId = null;
- if(portalObject.getParent() != null)
- {
- parentId = portalObject.getParent().getId().toString();
- }
-
- //Children Ids
- List<String> childrenIds = new ArrayList<String>();
- Collection children = portalObject.getChildren();
- for(Iterator itr=children.iterator(); itr.hasNext();)
- {
- PortalObject child = (PortalObject)itr.next();
- childrenIds.add(child.getId().toString());
- }
-
- structuralState = new StructuralState(
- type, //type
- name,
- properties, //properties
- parentId,
- childrenIds // childrenIds
- );
-
- return structuralState;
- }
-
- /**
- *
- * @param portalObject
- * @return
- */
- private Class<? extends UIObject> getType(PortalObject portalObject)
- {
- Class<? extends UIObject> type = null;
-
- if(portalObject instanceof Portal)
- {
- type = UIPortal.class;
- }
- else if(portalObject instanceof Page)
- {
- type = UIPage.class;
- }
- else if(portalObject instanceof Window)
- {
- type = UIWindow.class;
- }
-
- return type;
- }
-
- public StructuralState create(String parentId, Class<? extends UIObject> type,
String name, Map<String, String> properties) throws StateChangeVetoException
- {
- throw new StateChangeVetoException();
- }
-
- public void destroy(String objectId) throws StateChangeVetoException
- {
- throw new StateChangeVetoException();
- }
-
- public void move(String objectId, String parentId) throws StateChangeVetoException
- {
- throw new StateChangeVetoException();
- }
-
- public void update(String objectId, Map<String, String> changes) throws
StateChangeVetoException
- {
- throw new StateChangeVetoException();
- }
-
- /**
- *
- *
- */
- public void start()
- {
-
- }
-
- /**
- *
- *
- */
- public void stop()
- {
-
- }
-}
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java 2007-11-30
19:24:56 UTC (rev 9236)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/impl/model/UIObjectImpl.java 2007-11-30
21:54:15 UTC (rev 9237)
@@ -177,12 +177,8 @@
Map<String, String> changes = new HashMap<String, String>();
changes.put(propertyName, (String)propertyValue);
- // Create change
- StructuralStateModification mod = new
StructuralStateModification.Update(changes);
- StateChange<StructuralStateModification> change = new
StateChange<StructuralStateModification>(id, mod);
-
// Have context process change
- context.structuralStateContext.update(change);
+ context.structuralStateContext.update(id, changes);
// Update state locally to reflect correct state
Map<String, String> updatedProperties = new HashMap<String,
String>(state.getProperties());
@@ -190,6 +186,8 @@
state = new StructuralState(state.getType(), state.getName(),
updatedProperties, state.getParentId(), state.getChildrenIds());
// Broadcast event
+ StructuralStateModification mod = new
StructuralStateModification.Update(changes);
+ StateChange<StructuralStateModification> change = new
StateChange<StructuralStateModification>(id, mod);
StateChangeEvent event = new StateChangeEvent(change);
context.fireEvent(event);
}
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/AbstractStructuralStateContext.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/AbstractStructuralStateContext.java 2007-11-30
19:24:56 UTC (rev 9236)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/AbstractStructuralStateContext.java 2007-11-30
21:54:15 UTC (rev 9237)
@@ -22,11 +22,9 @@
******************************************************************************/
package org.jboss.portal.presentation.model.state.structural;
-import org.jboss.portal.presentation.model.state.StateChange;
import org.jboss.portal.presentation.model.state.StateChangeVetoException;
import org.jboss.portal.presentation.model.UIObject;
-import java.util.List;
import java.util.Map;
/**
@@ -36,34 +34,23 @@
public abstract class AbstractStructuralStateContext implements StructuralStateContext
{
- public void update(List<StateChange<StructuralStateModification>>
changes)
+ public String create(String parentId, Class<? extends UIObject> type, String
name, Map<String, String> properties) throws StateChangeVetoException
{
- for (StateChange<StructuralStateModification> change : changes)
- {
- update(change);
- }
+ throw new StateChangeVetoException();
}
- public StructuralState create(String parentId, Class<? extends UIObject> type,
String name, Map<String, String> properties) throws StateChangeVetoException
- {
- update(new StateChange<StructuralStateModification>(parentId, new
StructuralStateModification.Create(type, name, properties)));
-
- //
- return load(parentId);
- }
-
public void destroy(String objectId) throws StateChangeVetoException
{
- update(new StateChange<StructuralStateModification>(objectId, new
StructuralStateModification.Destroy()));
+ throw new StateChangeVetoException();
}
public void move(String objectId, String parentId) throws StateChangeVetoException
{
- update(new StateChange<StructuralStateModification>(objectId, new
StructuralStateModification.Move(parentId)));
+ throw new StateChangeVetoException();
}
public void update(String objectId, Map<String, String> changes) throws
StateChangeVetoException
{
- update(new StateChange<StructuralStateModification>(objectId, new
StructuralStateModification.Update(changes)));
+ throw new StateChangeVetoException();
}
}
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateContext.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateContext.java 2007-11-30
19:24:56 UTC (rev 9236)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateContext.java 2007-11-30
21:54:15 UTC (rev 9237)
@@ -56,10 +56,6 @@
*/
String getRootId();
- void update(List<StateChange<StructuralStateModification>>
modifications);
-
- void update(StateChange<StructuralStateModification> modification);
-
/**
* Create an object.
*
@@ -67,13 +63,13 @@
* @param type the type of the child
* @param name the name of the child
* @param properties the initial properties of the child
- * @return the structural state of the child
+ * @return the id of the newly created structural state
* @throws StateChangeVetoException if the creation is vetoed
* @throws StateException a generic state exception
* @throws NoSuchStateException if the parent id does not point a valid state
* @throws IllegalArgumentException if an argument is null or not valid
*/
- StructuralState create(String parentId, Class<? extends UIObject> type, String
name, Map<String, String> properties) throws StateChangeVetoException,
StateException, IllegalArgumentException;
+ String create(String parentId, Class<? extends UIObject> type, String name,
Map<String, String> properties) throws StateChangeVetoException, StateException,
IllegalArgumentException;
/**
* Destroy a specified object.
Modified:
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/MockModel.java
===================================================================
---
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/MockModel.java 2007-11-30
19:24:56 UTC (rev 9236)
+++
branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/MockModel.java 2007-11-30
21:54:15 UTC (rev 9237)
@@ -23,13 +23,11 @@
package org.jboss.portal.presentation.test.model;
import org.jboss.portal.presentation.model.state.NoSuchStateException;
-import org.jboss.portal.presentation.model.state.StateChange;
import org.jboss.portal.presentation.model.state.StateChangeVetoException;
import org.jboss.portal.presentation.model.state.StateException;
import
org.jboss.portal.presentation.model.state.structural.AbstractStructuralStateContext;
import org.jboss.portal.presentation.model.state.structural.StructuralState;
import org.jboss.portal.presentation.model.state.structural.StructuralStateContext;
-import org.jboss.portal.presentation.model.state.structural.StructuralStateModification;
import java.util.ArrayList;
import java.util.HashMap;
@@ -65,59 +63,49 @@
return object != null ? object.takeSnapshot() : null;
}
- public void update(StateChange<StructuralStateModification> change)
+ public String getRootId()
{
- if (change.getModification() instanceof StructuralStateModification.Update)
+ return root.id;
+ }
+
+ public void update(String objectId, Map<String, String> changes) throws
StateChangeVetoException
+ {
+ MockObjectImpl object = universe.get(objectId);
+ if (object == null)
{
- StructuralStateModification.Update sp =
(StructuralStateModification.Update)change.getModification();
+ throw new NoSuchStateException();
+ }
- //
- MockObjectImpl object = universe.get(change.getTargetId());
- if (object == null)
+ //
+ for (Map.Entry<String, String> entry : changes.entrySet())
+ {
+ String propertyName = entry.getKey();
+ MockObject.UpdateBehavior behavior =
object.propertyBehaviors.get(propertyName);
+ if (behavior instanceof MockObject.Veto)
{
- throw new NoSuchStateException();
+ throw new StateChangeVetoException("Cannot modify non behavior
property");
}
-
- //
- for (Map.Entry<String, String> entry : sp.getChanges().entrySet())
+ else if (behavior instanceof MockObject.Failure)
{
- String propertyName = entry.getKey();
- MockObject.UpdateBehavior behavior =
object.propertyBehaviors.get(propertyName);
- if (behavior instanceof MockObject.Veto)
+ MockObject.Failure failure = (MockObject.Failure)behavior;
+ failure.throwAs(IllegalArgumentException.class).
+ throwAs(StateChangeVetoException.class).
+ throwAs(StateException.class);
+ }
+ else
+ {
+ String propertyValue = entry.getValue();
+ if (propertyValue != null)
{
- throw new StateChangeVetoException("Cannot modify non behavior
property");
+ object.propertyValues.put(propertyName, propertyValue);
}
- else if (behavior instanceof MockObject.Failure)
- {
- MockObject.Failure failure = (MockObject.Failure)behavior;
- failure.throwAs(IllegalArgumentException.class).
- throwAs(StateChangeVetoException.class).
- throwAs(StateException.class);
- }
else
{
- String propertyValue = entry.getValue();
- if (propertyValue != null)
- {
- object.propertyValues.put(propertyName, propertyValue);
- }
- else
- {
- object.propertyValues.remove(propertyName);
- }
+ object.propertyValues.remove(propertyName);
}
}
}
- else
- {
- throw new StateChangeVetoException();
- }
}
-
- public String getRootId()
- {
- return root.id;
- }
};
public StructuralStateContext getStructuralStateContext()