[portal-commits] JBoss Portal SVN: r9131 - in branches/presentation: presentation/src/main/org/jboss/portal/presentation/model/state and 2 other directories.

portal-commits at lists.jboss.org portal-commits at lists.jboss.org
Tue Nov 27 11:55:35 EST 2007


Author: julien at jboss.com
Date: 2007-11-27 11:55:35 -0500 (Tue, 27 Nov 2007)
New Revision: 9131

Added:
   branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/StateChangeVetoException.java
Removed:
   branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/model/ModelLoaderImpl.java
Modified:
   branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/model/StructuralStateManagerImpl.java
   branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateManager.java
   branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/MockModel.java
   branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/UIModelTester.java
Log:
- added StateChangeVetoException for signaling a non possible state change
- added state modifying operations on StructuralStateManager although those for now throw StateChangeVetoException at the moment

Deleted: branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/model/ModelLoaderImpl.java
===================================================================
--- branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/model/ModelLoaderImpl.java	2007-11-27 16:55:27 UTC (rev 9130)
+++ branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/model/ModelLoaderImpl.java	2007-11-27 16:55:35 UTC (rev 9131)
@@ -1,179 +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 java.util.StringTokenizer;
-import java.util.Map;
-import java.util.List;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.ArrayList;
-
-import org.jboss.portal.presentation.model.UIObject;
-import org.jboss.portal.presentation.model.UIPortal;
-import org.jboss.portal.presentation.model.UIPage;
-import org.jboss.portal.presentation.model.UIWindow;
-import org.jboss.portal.presentation.model.state.ModelLoader;
-import org.jboss.portal.presentation.model.state.ObjectState;
-
-import org.jboss.portal.core.model.portal.PortalObjectContainer;
-import org.jboss.portal.core.model.portal.PortalContainer;
-import org.jboss.portal.core.model.portal.PortalObject;
-import org.jboss.portal.core.model.portal.PortalObjectId;
-import org.jboss.portal.core.model.portal.PortalObjectPath;
-import org.jboss.portal.core.model.portal.Page;
-import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.core.model.portal.Portal;
-
-/**
- * @author <a href="mailto:sshah at redhat.com">Sohil Shah</a>
- *
- */
-public class ModelLoaderImpl implements ModelLoader
-{
-   /**
-    * 
-    */
-   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 ObjectState loadState(String objectId) throws IllegalArgumentException
-   {
-      ObjectState objectState = 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());
-      }
-      
-      objectState = new ObjectState(
-            type, //type
-            name,
-            properties, //properties
-            parentId,
-            childrenIds // childrenIds
-      );
-      
-      return objectState;
-   }
-   
-   /**
-    * 
-    * @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 void start()
-   {
-      
-   }
-   
-   /**
-    * 
-    *
-    */
-   public void stop()
-   {
-      
-   }
-}

Modified: 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-27 16:55:27 UTC (rev 9130)
+++ branches/presentation/core-presentation/src/main/org/jboss/portal/core/presentation/model/StructuralStateManagerImpl.java	2007-11-27 16:55:35 UTC (rev 9131)
@@ -22,26 +22,26 @@
  ******************************************************************************/
 package org.jboss.portal.core.presentation.model;
 
-import java.util.Map;
-import java.util.List;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.ArrayList;
-
+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.UIPage;
 import org.jboss.portal.presentation.model.UIWindow;
+import org.jboss.portal.presentation.model.state.structural.ObjectState;
 import org.jboss.portal.presentation.model.state.structural.StructuralStateManager;
-import org.jboss.portal.presentation.model.state.structural.ObjectState;
+import org.jboss.portal.presentation.model.state.StateChangeVetoException;
 
-import org.jboss.portal.core.model.portal.PortalObjectContainer;
-import org.jboss.portal.core.model.portal.PortalObject;
-import org.jboss.portal.core.model.portal.PortalObjectId;
-import org.jboss.portal.core.model.portal.PortalObjectPath;
-import org.jboss.portal.core.model.portal.Page;
-import org.jboss.portal.core.model.portal.Window;
-import org.jboss.portal.core.model.portal.Portal;
+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 at redhat.com">Sohil Shah</a>
@@ -156,7 +156,22 @@
       
       return type;
    }
-   
+
+   public ObjectState createState(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();
+   }
+
    /**
     * 
     *

Added: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/StateChangeVetoException.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/StateChangeVetoException.java	                        (rev 0)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/StateChangeVetoException.java	2007-11-27 16:55:35 UTC (rev 9131)
@@ -0,0 +1,49 @@
+/******************************************************************************
+ * 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.presentation.model.state;
+
+/**
+ * @author <a href="mailto:julien at jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class StateChangeVetoException extends Exception
+{
+   public StateChangeVetoException()
+   {
+   }
+
+   public StateChangeVetoException(String s)
+   {
+      super(s);
+   }
+
+   public StateChangeVetoException(String s, Throwable throwable)
+   {
+      super(s, throwable);
+   }
+
+   public StateChangeVetoException(Throwable throwable)
+   {
+      super(throwable);
+   }
+}

Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateManager.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateManager.java	2007-11-27 16:55:27 UTC (rev 9130)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/model/state/structural/StructuralStateManager.java	2007-11-27 16:55:35 UTC (rev 9131)
@@ -22,6 +22,11 @@
  ******************************************************************************/
 package org.jboss.portal.presentation.model.state.structural;
 
+import org.jboss.portal.presentation.model.UIObject;
+import org.jboss.portal.presentation.model.state.StateChangeVetoException;
+
+import java.util.Map;
+
 /**
  * The structural state manager.
  * 
@@ -42,4 +47,10 @@
 
    String getRootId();
 
+   ObjectState createState(String parentId, Class<? extends UIObject> type, String name, Map<String, String> properties) throws StateChangeVetoException;
+
+   void destroy(String objectId) throws StateChangeVetoException;
+
+   void move(String objectId, String parentId) throws StateChangeVetoException;
+
 }

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-27 16:55:27 UTC (rev 9130)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/MockModel.java	2007-11-27 16:55:35 UTC (rev 9131)
@@ -24,6 +24,8 @@
 
 import org.jboss.portal.presentation.model.state.structural.StructuralStateManager;
 import org.jboss.portal.presentation.model.state.structural.ObjectState;
+import org.jboss.portal.presentation.model.state.StateChangeVetoException;
+import org.jboss.portal.presentation.model.UIObject;
 
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -177,4 +179,19 @@
          }
       }
    }
+
+   public ObjectState createState(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();
+   }
 }

Modified: branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/UIModelTester.java
===================================================================
--- branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/UIModelTester.java	2007-11-27 16:55:27 UTC (rev 9130)
+++ branches/presentation/presentation/src/main/org/jboss/portal/presentation/test/model/UIModelTester.java	2007-11-27 16:55:35 UTC (rev 9131)
@@ -25,10 +25,6 @@
 import junit.framework.TestCase;
 import org.apache.log4j.Logger;
 
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
-
 import org.jboss.portal.presentation.model.*;
 import org.jboss.portal.presentation.impl.model.UIContextImpl;
 
@@ -46,7 +42,7 @@
     */
    protected void setUp() throws Exception
    {
-      this.uiContext = new UIContextImpl(new MockModelLoaderImpl());      
+      this.uiContext = new UIContextImpl(new MockModel());
    }
 
    /**




More information about the portal-commits mailing list