portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r881862 [7/16] - in /portals/jetspeed-2/portal/trunk: ./ applications/jetspeed/src/main/webapp/WEB-INF/jetui/yui/ applications/jetspeed/src/main/webapp/WEB-INF/templates/ applications/jetspeed/src/main/webapp/decorations/layout/greenearth/ ...
Date Wed, 18 Nov 2009 18:24:53 GMT
Added: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageFragmentImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageFragmentImpl.java?rev=881862&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageFragmentImpl.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageFragmentImpl.java Wed Nov 18 18:24:48 2009
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.om.page.impl;
+
+import org.apache.jetspeed.om.page.PageFragment;
+
+public class PageFragmentImpl extends BaseFragmentElementImpl implements PageFragment
+{
+}

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageImpl.java?rev=881862&r1=881861&r2=881862&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageImpl.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageImpl.java Wed Nov 18 18:24:48 2009
@@ -16,22 +16,7 @@
  */
 package org.apache.jetspeed.om.page.impl;
 
-import java.util.Collection;
-import java.util.List;
-
-import org.apache.jetspeed.JetspeedActions;
-import org.apache.jetspeed.om.folder.Folder;
-import org.apache.jetspeed.om.folder.MenuDefinition;
-import org.apache.jetspeed.om.folder.MenuExcludeDefinition;
-import org.apache.jetspeed.om.folder.MenuIncludeDefinition;
-import org.apache.jetspeed.om.folder.MenuOptionsDefinition;
-import org.apache.jetspeed.om.folder.MenuSeparatorDefinition;
-import org.apache.jetspeed.om.page.Fragment;
 import org.apache.jetspeed.om.page.Page;
-import org.apache.jetspeed.om.page.PageMetadataImpl;
-import org.apache.jetspeed.page.document.impl.DocumentImpl;
-import org.apache.jetspeed.page.impl.DatabasePageManagerUtils;
-import org.apache.ojb.broker.core.proxy.ProxyHelper;
 
 /**
  * PageImpl
@@ -39,354 +24,9 @@
  * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
  * @version $Id$
  */
-public class PageImpl extends DocumentImpl implements Page
+public class PageImpl extends BaseConcretePageElementImpl implements Page
 {
-    private Collection fragment;
-    private String skin;
-    private String defaultLayoutDecorator;
-    private String defaultPortletDecorator;
-    private List menus;
-
-    private PageMenuDefinitionList menuDefinitions;
-    private FragmentImpl removedFragment;
-
-    public PageImpl()
-    {
-        super(new PageSecurityConstraintsImpl());
-    }
-
-    /**
-     * accessMenus
-     *
-     * Access mutable persistent collection member for List wrappers.
-     *
-     * @return persistent collection
-     */
-    List accessMenus()
-    {
-        // create initial collection if necessary
-        if (menus == null)
-        {
-            menus = DatabasePageManagerUtils.createList();;
-        }
-        return menus;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.om.page.impl.BaseElementImpl#resetCachedSecurityConstraints()
-     */
-    public void resetCachedSecurityConstraints()
-    {
-        // propagate to super and fragments
-        super.resetCachedSecurityConstraints();
-        FragmentImpl rootFragment = (FragmentImpl)getRootFragment();
-        if (rootFragment != null)
-        {
-            rootFragment.resetCachedSecurityConstraints();
-        }
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.page.document.impl.NodeImpl#newPageMetadata(java.util.Collection)
-     */
-    public PageMetadataImpl newPageMetadata(Collection fields)
-    {
-        PageMetadataImpl pageMetadata = new PageMetadataImpl(PageMetadataLocalizedFieldImpl.class);
-        pageMetadata.setFields(fields);
-        return pageMetadata;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.om.page.Page#getSkin()
-     */
-    public String getSkin()
-    {
-        return skin;
-    }
-    
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.om.page.Page#setSkin(java.lang.String)
-     */
-    public void setSkin(String skinName)
-    {
-        this.skin = skinName;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.om.page.Page#getEffectiveDefaultDecorator(java.lang.String)
-     */
-    public String getEffectiveDefaultDecorator(String fragmentType)
-    {
-        // get locally defined decorator
-        String decorator = getDefaultDecorator(fragmentType);
-        if (decorator == null)
-        {
-            // delegate to parent folder
-            Folder parentFolder = (Folder)ProxyHelper.getRealObject(getParent());
-            if (parentFolder != null)
-            {
-                return parentFolder.getEffectiveDefaultDecorator(fragmentType);
-            }
-        }
-        return decorator;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.om.page.Page#getDefaultDecorator(java.lang.String)
-     */
-    public String getDefaultDecorator(String fragmentType)
-    {
-        // retrieve supported decorator types
-        if (fragmentType != null)
-        {
-            if (fragmentType.equals(Fragment.LAYOUT))
-            {
-                return defaultLayoutDecorator; 
-            }
-            if (fragmentType.equals(Fragment.PORTLET))
-            {
-                return defaultPortletDecorator; 
-            }
-        }
-        return null;
-    }
-    
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.om.page.Page#getDefaultDecorator(java.lang.String,java.lang.String)
-     */
-    public void setDefaultDecorator(String decoratorName, String fragmentType)
-    {
-        // save supported decorator types
-        if (fragmentType != null)
-        {
-            if (fragmentType.equals(Fragment.LAYOUT))
-            {
-                defaultLayoutDecorator = decoratorName; 
-            }
-            if (fragmentType.equals(Fragment.PORTLET))
-            {
-                defaultPortletDecorator = decoratorName; 
-            }
-        }
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.om.page.Page#getRootFragment()
-     */
-    public Fragment getRootFragment()
-    {
-        // get singleton fragment; no access checks to
-        // be made for root fragment
-        if ((fragment != null) && !fragment.isEmpty())
-        {
-            FragmentImpl rootFragment = (FragmentImpl)fragment.iterator().next();
-            if (rootFragment.getPage() == null)
-            {
-                // set page implementation in root and children fragments
-                rootFragment.setPage(this);
-            }
-            return rootFragment;
-        }
-        return null;
-    }
-    
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.om.page.Page#setRootFragment(org.apache.jetspeed.om.page.Fragment)
-     */
-    public void setRootFragment(Fragment fragment)
-    {
-        // add new or reuse singleton fragment
-        if (fragment instanceof FragmentImpl)
-        {
-            // create singleton collection or remove existing
-            // root fragment and save for reuse
-            if (this.fragment == null)
-            {
-                this.fragment = DatabasePageManagerUtils.createList();
-            }
-            else if (!this.fragment.isEmpty())
-            {
-                removedFragment = (FragmentImpl)this.fragment.iterator().next();
-                this.fragment.clear();
-            }
-
-            // add new fragment or copy configuration
-            // from previously removed fragment
-            if (removedFragment != null)
-            {
-                // reuse previously removed fragment
-                FragmentImpl addFragment = (FragmentImpl)fragment;
-                fragment = removedFragment;
-                removedFragment = null;
-                // TODO: move this logic to copy methods on implementations
-                fragment.setName(addFragment.getName());
-                fragment.setTitle(addFragment.getTitle());
-                fragment.setShortTitle(addFragment.getShortTitle());
-                fragment.setType(addFragment.getType());
-                fragment.setSkin(addFragment.getSkin());
-                fragment.setDecorator(addFragment.getDecorator());
-                fragment.setState(addFragment.getState());
-                fragment.setSecurityConstraints(addFragment.getSecurityConstraints());
-                fragment.getProperties().clear();
-                fragment.getProperties().putAll(addFragment.getProperties());
-                fragment.setPreferences(addFragment.getPreferences());
-                fragment.getFragments().clear();
-                fragment.getFragments().addAll(addFragment.getFragments());
-            }
-            this.fragment.add(fragment);
-
-            // set page implementation in root and children fragments
-            ((FragmentImpl)fragment).setPage(this);
-        }
-        else if (fragment == null)
-        {
-            // delete existing fragment if required, saving
-            // removed fragment for later reuse
-            if ((this.fragment != null) && !this.fragment.isEmpty())
-            {
-                removedFragment = (FragmentImpl)this.fragment.iterator().next();
-                this.fragment.clear();
-            }
-        }
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.om.page.Page#getFragmentById(java.lang.String)
-     */
-    public Fragment getFragmentById(String id)
-    {
-        // get fragment by id and check access
-        FragmentImpl rootFragment = (FragmentImpl)getRootFragment();
-        if (rootFragment != null)
-        {
-            Fragment fragment = rootFragment.getFragmentById(id);
-            if (fragment != null)
-            {
-                try
-                {
-                    fragment.checkAccess(JetspeedActions.VIEW);
-                }
-                catch (SecurityException se)
-                {
-                    fragment = null;
-                }
-            }
-            return fragment;
-        }
-        return null;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.om.page.Page#removeFragmentById(java.lang.String)
-     */
-    public Fragment removeFragmentById(String id)
-    {
-        // remove fragment by id
-        FragmentImpl rootFragment = (FragmentImpl)getRootFragment();
-        if (rootFragment != null)
-        {
-            if (rootFragment.getId().equals(id))
-            {
-                setRootFragment(null);
-                return rootFragment;
-            }
-            else
-            {
-                return rootFragment.removeFragmentById(id);
-            }
-        }
-        return null;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.om.page.Page#getFragmentsByName(java.lang.String)
-     */
-    public List getFragmentsByName(String name)
-    {
-        // get fragments by name and filter by access
-        FragmentImpl rootFragment = (FragmentImpl)getRootFragment();
-        if (rootFragment != null)
-        {
-            // return immutable filtered fragment list
-            return rootFragment.filterFragmentsByAccess(rootFragment.getFragmentsByName(name), false);
-        }
-        return null;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.om.page.Page#getMenuDefinitions()
-     */
-    public List getMenuDefinitions()
-    {
-        // return mutable menu definition list
-        // by using list wrapper to manage
-        // element uniqueness
-        if (menuDefinitions == null)
-        {
-            menuDefinitions = new PageMenuDefinitionList(this);
-        }
-        return menuDefinitions;
-    }
-    
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.om.page.Page#newMenuDefinition()
-     */
-    public MenuDefinition newMenuDefinition()
-    {
-        return new PageMenuDefinitionImpl();
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.om.page.Page#newMenuExcludeDefinition()
-     */
-    public MenuExcludeDefinition newMenuExcludeDefinition()
-    {
-        return new PageMenuExcludeDefinitionImpl();
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.om.page.Page#newMenuIncludeDefinition()
-     */
-    public MenuIncludeDefinition newMenuIncludeDefinition()
-    {
-        return new PageMenuIncludeDefinitionImpl();
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.om.page.Page#newMenuOptionsDefinition()
-     */
-    public MenuOptionsDefinition newMenuOptionsDefinition()
-    {
-        return new PageMenuOptionsDefinitionImpl();
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.om.page.Page#newMenuSeparatorDefinition()
-     */
-    public MenuSeparatorDefinition newMenuSeparatorDefinition()
-    {
-        return new PageMenuSeparatorDefinitionImpl();
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.jetspeed.om.page.Page#setMenuDefinitions(java.util.List)
-     */
-    public void setMenuDefinitions(List definitions)
-    {
-        // set menu definitions by replacing
-        // existing entries with new elements if
-        // new collection is specified
-        List menuDefinitions = getMenuDefinitions();
-        if (definitions != menuDefinitions)
-        {
-            // replace all menu definitions
-            menuDefinitions.clear();
-            if (definitions != null)
-            {
-                menuDefinitions.addAll(definitions);
-            }
-        }
-    }
+    private static final long serialVersionUID = 1L;
 
     /* (non-Javadoc)
      * @see org.apache.jetspeed.page.document.Node#getType()

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageMenuDefinitionList.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageMenuDefinitionList.java?rev=881862&r1=881861&r2=881862&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageMenuDefinitionList.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageMenuDefinitionList.java Wed Nov 18 18:24:48 2009
@@ -30,11 +30,11 @@
  */
 class PageMenuDefinitionList extends AbstractList
 {
-    private PageImpl page;
+    private BasePageElementImpl page;
 
     private List removedMenuDefinitions;
 
-    PageMenuDefinitionList(PageImpl page)
+    PageMenuDefinitionList(BasePageElementImpl page)
     {
         super();
         this.page = page;

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageTemplateImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageTemplateImpl.java?rev=881862&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageTemplateImpl.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/impl/PageTemplateImpl.java Wed Nov 18 18:24:48 2009
@@ -0,0 +1,94 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.om.page.impl;
+
+import org.apache.jetspeed.om.page.PageTemplate;
+import org.apache.jetspeed.om.page.BaseFragmentElement;
+import org.apache.jetspeed.om.page.BaseFragmentValidationListener;
+import org.apache.jetspeed.om.page.PageFragment;
+
+/**
+ * PageTemplateImpl
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class PageTemplateImpl extends BasePageElementImpl implements PageTemplate
+{
+    private static final long serialVersionUID = 1L;
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.document.impl.NodeImpl#getType()
+     */
+    public String getType()
+    {
+        return DOCUMENT_TYPE;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.document.impl.NodeImpl#isHidden()
+     */
+    public boolean isHidden()
+    {
+        return false;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.document.impl.NodeImpl#setHidden(boolean)
+     */
+    public void setHidden(boolean hidden)
+    {
+        throw new UnsupportedOperationException("PageTemplate.setHidden()");
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.impl.BaseFragmentsElementImpl#newBaseFragmentValidationListener()
+     */
+    protected BaseFragmentValidationListener newBaseFragmentValidationListener()
+    {
+        return new BaseFragmentValidationListener()
+        {
+            private boolean valid;
+            
+            /* (non-Javadoc)
+             * @see org.apache.jetspeed.om.page.BaseFragmentValidationListener#validate(org.apache.jetspeed.om.page.BaseFragmentElement)
+             */
+            public boolean validate(BaseFragmentElement fragmentElement)
+            {
+                // one PageFragment required
+                if (!valid)
+                {
+                    valid = (fragmentElement instanceof PageFragment);
+                    return true;
+                }
+                else
+                {
+                    return !(fragmentElement instanceof PageFragment);
+                }
+            }
+
+            /* (non-Javadoc)
+             * @see org.apache.jetspeed.om.page.BaseFragmentValidationListener#validate()
+             */
+            public boolean validate()
+            {
+                // one PageFragment required
+                return valid;
+            }
+        };
+    }
+}

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/AbstractBaseConcretePageElement.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/AbstractBaseConcretePageElement.java?rev=881862&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/AbstractBaseConcretePageElement.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/AbstractBaseConcretePageElement.java Wed Nov 18 18:24:48 2009
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jetspeed.om.page.psml;
+
+import org.apache.jetspeed.idgenerator.IdGenerator;
+import org.apache.jetspeed.om.folder.Folder;
+import org.apache.jetspeed.om.page.BaseConcretePageElement;
+import org.apache.jetspeed.om.page.BaseFragmentElement;
+import org.apache.jetspeed.om.page.BaseFragmentValidationListener;
+import org.apache.jetspeed.om.page.PageFragment;
+
+/**
+ * AbstractBaseConcretePageElement
+ *
+ * @version $Id:$
+ */
+public abstract class AbstractBaseConcretePageElement extends AbstractBasePageElement implements BaseConcretePageElement
+{
+    private static final long serialVersionUID = 1L;
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Page#getEffectiveDefaultDecorator(java.lang.String)
+     */
+    public String getEffectiveDefaultDecorator(String fragmentType)
+    {
+        // get locally defined decorator
+        String decorator = getDefaultDecorator(fragmentType);
+        if (decorator == null)
+        {
+            // delegate to parent folder
+            Folder parentFolder = (Folder)getParent();
+            if (parentFolder != null)
+            {
+                return parentFolder.getEffectiveDefaultDecorator(fragmentType);
+            }
+        }
+        return decorator;
+    }
+
+    /**
+     * unmarshalled - notification that this instance has been
+     *                loaded from the persistent store
+     * @param generator id generator
+     * @return dirty flag
+     */
+    public boolean unmarshalled(IdGenerator generator)
+    {
+        // notify super class implementation
+        boolean dirty = super.unmarshalled(generator);
+
+        // default title of concrete pages to name
+        if (getTitle() == null)
+        {
+            setTitle(getTitleName());
+        }
+        
+        return dirty;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.psml.AbstractBaseFragmentsElement#newBaseFragmentValidationListener()
+     */
+    protected BaseFragmentValidationListener newBaseFragmentValidationListener()
+    {
+        return new BaseFragmentValidationListener()
+        {
+            /* (non-Javadoc)
+             * @see org.apache.jetspeed.om.page.BaseFragmentValidationListener#validate(org.apache.jetspeed.om.page.BaseFragmentElement)
+             */
+            public boolean validate(BaseFragmentElement fragmentElement)
+            {
+                // PageFragments can only appear in PageTemplates
+                return !(fragmentElement instanceof PageFragment);
+            }
+
+            /* (non-Javadoc)
+             * @see org.apache.jetspeed.om.page.BaseFragmentValidationListener#validate()
+             */
+            public boolean validate()
+            {
+                return true;
+            }
+        };
+    }
+}

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/AbstractBaseElement.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/AbstractBaseElement.java?rev=881862&r1=881861&r2=881862&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/AbstractBaseElement.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/AbstractBaseElement.java Wed Nov 18 18:24:48 2009
@@ -70,7 +70,7 @@
     
     private DocumentHandlerFactory handlerFactory = null;
 
-    private static PermissionFactory pf;
+    protected static PermissionFactory pf;
     
     public static void setPermissionsFactory(PermissionFactory pf)
     {

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/AbstractBaseFragmentElement.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/AbstractBaseFragmentElement.java?rev=881862&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/AbstractBaseFragmentElement.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/AbstractBaseFragmentElement.java Wed Nov 18 18:24:48 2009
@@ -0,0 +1,542 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jetspeed.om.page.psml;
+
+import java.security.AccessController;
+import java.security.Permission;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.jetspeed.idgenerator.IdGenerator;
+import org.apache.jetspeed.om.page.BaseFragmentElement;
+import org.apache.jetspeed.om.page.BaseFragmentValidationListener;
+import org.apache.jetspeed.om.page.PageSecurity;
+
+/**
+ * AbstractBaseFragmentElement
+ *
+ * @version $Id:$
+ */
+public abstract class AbstractBaseFragmentElement extends AbstractBaseElement implements BaseFragmentElement
+{
+    private static final long serialVersionUID = 1L;
+
+    private String state = null;
+
+    private String mode = null;
+
+    private String decorator = null;
+
+    private String skin = null;
+
+    private List propertiesList = new ArrayList();
+    
+    private List preferences = new ArrayList();
+    
+    private Map propertiesMap = new HashMap();
+
+    private String name;
+
+    private AbstractBaseFragmentsElement baseFragmentsElement;
+
+    private boolean dirty = false;
+    
+    /**
+     * <p>
+     * Default Constructor.
+     * </p>
+     */
+    public AbstractBaseFragmentElement()
+    {
+    }
+
+    public String getState()
+    {
+        return this.state;
+    }
+
+    public void setState( String state )
+    {
+        this.state = state;
+    }
+
+    public String getMode()
+    {
+        return this.mode;
+    }
+
+    public void setMode( String mode )
+    {
+        this.mode = mode;
+    }
+
+    public String getDecorator()
+    {
+        return this.decorator;
+    }
+
+    public void setDecorator( String decoratorName )
+    {
+        this.decorator = decoratorName;
+    }
+
+    public String getSkin()
+    {
+        return this.skin;
+    }
+
+    public void setSkin( String skin )
+    {
+        this.skin = skin;
+    }
+
+    public List getPropertiesList()
+    {
+        return (List) this.propertiesList;
+    }
+    
+    /**
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#getProperty(java.lang.String)
+     */
+    public String getProperty(String propName)
+    {
+        return (String)propertiesMap.get(propName);
+    }
+    
+    /**
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#getIntProperty(java.lang.String)
+     */
+    public int getIntProperty(String propName)
+    {
+        String prop = (String)propertiesMap.get(propName);
+        if (prop != null)
+        {
+            return Integer.parseInt(prop);
+        }
+        return -1;
+    }
+    
+    /**
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#getFloatProperty(java.lang.String)
+     */
+    public float getFloatProperty(String propName)
+    {
+        String prop = (String)propertiesMap.get(propName);
+        if (prop != null)
+        {
+            return Float.parseFloat(prop);
+        }
+        return -1.0F;
+    }
+    
+    /**
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#getProperties()
+     */
+    public Map getProperties()
+    {
+        return propertiesMap;
+    }
+
+    /**
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#getLayoutRow()
+     */
+    public int getLayoutRow()
+    {
+        return getIntProperty(ROW_PROPERTY_NAME);
+    }
+
+    /**
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#setLayoutRow(int)
+     */
+    public void setLayoutRow(int row)
+    {
+        if (row >= 0)
+        {
+            propertiesMap.put(ROW_PROPERTY_NAME, String.valueOf(row));
+        }
+        else
+        {
+            propertiesMap.remove(ROW_PROPERTY_NAME);
+        }
+    }
+    
+    /**
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#getLayoutColumn()
+     */
+    public int getLayoutColumn()
+    {
+        return getIntProperty(COLUMN_PROPERTY_NAME);
+    }
+
+    /**
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#setLayoutColumn(int)
+     */
+    public void setLayoutColumn(int column)
+    {
+        if (column >= 0)
+        {
+            propertiesMap.put(COLUMN_PROPERTY_NAME, String.valueOf(column));
+        }
+        else
+        {
+            propertiesMap.remove(COLUMN_PROPERTY_NAME);
+        }
+    }
+    
+    /**
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#getLayoutSizes()
+     */
+    public String getLayoutSizes()
+    {
+        return (String)propertiesMap.get(SIZES_PROPERTY_NAME);
+    }
+    
+    /**
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#setLayoutSizes(java.lang.String)
+     */
+    public void setLayoutSizes(String sizes)
+    {
+        if (sizes != null)
+        {
+            propertiesMap.put(SIZES_PROPERTY_NAME, sizes);
+        }
+        else
+        {
+            propertiesMap.remove(SIZES_PROPERTY_NAME);
+        }
+    }
+
+    /**
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#getLayoutX()
+     */
+    public float getLayoutX()
+    {
+        return getFloatProperty(X_PROPERTY_NAME);
+    }
+
+    /**
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#setLayoutX(float)
+     */
+    public void setLayoutX(float x)
+    {
+        if (x >= 0.0F)
+        {
+            propertiesMap.put(X_PROPERTY_NAME, String.valueOf(x));
+        }
+        else
+        {
+            propertiesMap.remove(X_PROPERTY_NAME);
+        }
+    }
+    
+    /**
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#getLayoutY()
+     */
+    public float getLayoutY()
+    {
+        return getFloatProperty(Y_PROPERTY_NAME);
+    }
+
+    /**
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#setLayoutY(float)
+     */
+    public void setLayoutY(float y)
+    {
+        if (y >= 0.0F)
+        {
+            propertiesMap.put(Y_PROPERTY_NAME, String.valueOf(y));
+        }
+        else
+        {
+            propertiesMap.remove(Y_PROPERTY_NAME);
+        }
+    }
+
+    /**
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#getLayoutZ()
+     */
+    public float getLayoutZ()
+    {
+        return getFloatProperty(Z_PROPERTY_NAME);
+    }
+
+    /**
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#setLayoutZ(float)
+     */
+    public void setLayoutZ(float z)
+    {
+        if (z >= 0.0F)
+        {
+            propertiesMap.put(Z_PROPERTY_NAME, String.valueOf(z));
+        }
+        else
+        {
+            propertiesMap.remove(Z_PROPERTY_NAME);
+        }
+    }
+
+    /**
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#getLayoutWidth()
+     */
+    public float getLayoutWidth()
+    {
+        return getFloatProperty(WIDTH_PROPERTY_NAME);
+    }
+
+    /**
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#setLayoutWidth(float)
+     */
+    public void setLayoutWidth(float width)
+    {
+        if (width >= 0.0F)
+        {
+            propertiesMap.put(WIDTH_PROPERTY_NAME, String.valueOf(width));
+        }
+        else
+        {
+            propertiesMap.remove(WIDTH_PROPERTY_NAME);
+        }
+    }
+
+    /**
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#getLayoutHeight()
+     */
+    public float getLayoutHeight()
+    {
+        return getFloatProperty(HEIGHT_PROPERTY_NAME);
+    }
+
+    /**
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#setLayoutHeight(float)
+     */
+    public void setLayoutHeight(float height)
+    {
+        if (height >= 0.0F)
+        {
+            propertiesMap.put(HEIGHT_PROPERTY_NAME, String.valueOf(height));
+        }
+        else
+        {
+            propertiesMap.remove(HEIGHT_PROPERTY_NAME);
+        }
+    }
+
+    /**
+     * <p>
+     * equals
+     * </p>
+     * 
+     * @see java.lang.Object#equals(java.lang.Object)
+     * @param obj
+     * @return
+     */
+    public boolean equals( Object obj )
+    {
+        boolean isEqual = false;
+        if (obj != null && obj instanceof BaseFragmentElement)
+        {
+            BaseFragmentElement aFragment = (BaseFragmentElement) obj;
+            if ((null != aFragment.getId()) && (null != getId()) && (getId().equals(aFragment.getId())))
+            {
+                isEqual = true;
+            }
+        }
+        return isEqual;
+    }
+
+    /**
+     * <p>
+     * hashCode
+     * </p>
+     * 
+     * @see java.lang.Object#hashCode()
+     * @return
+     */
+    public int hashCode()
+    {
+        if (getId() != null)
+        {
+            return (BaseFragmentElement.class.getName() + ":" + getId()).hashCode();
+        }
+        else
+        {
+            return super.hashCode();
+        }
+    }
+
+    /**
+     * <p>
+     * getPreferences
+     * </p>
+     * 
+     * @see org.apache.jetspeed.om.page.BaseFragmentElement#getPreferences()
+     * @param name
+     */
+    public List getPreferences()
+    {
+        return preferences;
+    }
+
+    public void setPreferences(List preferences)
+    {
+        this.preferences = preferences;  
+    } 
+    
+    AbstractBaseFragmentsElement getBaseFragmentsElement()
+    {
+        return baseFragmentsElement;
+    }
+
+    void setBaseFragmentsElement(AbstractBaseFragmentsElement baseFragmentsElement)
+    {
+        // set base fragments implementation
+        this.baseFragmentsElement = baseFragmentsElement;
+        if (dirty){
+            baseFragmentsElement.setDirty(dirty);   
+        }        
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.psml.AbstractElementImpl#getEffectivePageSecurity()
+     */
+    public PageSecurity getEffectivePageSecurity()
+    {
+        // delegate to base fragments implementation
+        if (baseFragmentsElement != null)
+        {
+            return baseFragmentsElement.getEffectivePageSecurity();
+        }
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.psml.AbstractElementImpl#checkPermissions(java.lang.String, int, boolean, boolean)
+     */
+    public void checkPermissions(String path, int mask, boolean checkNodeOnly, boolean checkParentsOnly) throws SecurityException
+    {
+        // always check for granted fragment permissions
+        AccessController.checkPermission((Permission)pf.newPermission(pf.FRAGMENT_PERMISSION, path, mask));
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecuredResource#getConstraintsEnabled()
+     */
+    public boolean getConstraintsEnabled()
+    {
+        // delegate to base fragments implementation
+        if (baseFragmentsElement != null)
+        {
+            return baseFragmentsElement.getConstraintsEnabled();
+        }
+        return false;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecuredResource#getPermissionsEnabled()
+     */
+    public boolean getPermissionsEnabled()
+    {
+        // delegate to base fragments implementation
+        if (baseFragmentsElement != null)
+        {
+            return baseFragmentsElement.getPermissionsEnabled();
+        }
+        return false;
+    }
+    
+    /**
+     * unmarshalled - notification that this instance has been
+     *                loaded from the persistent store
+     * @param generator id generator
+     * @return dirty flag
+     */
+    public boolean unmarshalled(IdGenerator generator)
+    {
+        // notify super class implementation
+        boolean dirty = super.unmarshalled(generator);
+        
+        // generate id if required
+        if (getId() == null)
+        {
+            setId(generator.getNextPeid());
+            dirty = true;
+        }
+
+        // load the properties map from list
+        propertiesMap.clear();
+        Iterator propsIter = propertiesList.iterator();
+        while (propsIter.hasNext())
+        {
+            PropertyImpl prop = (PropertyImpl) propsIter.next();
+            propertiesMap.put(prop.getName(), prop.getValue());
+        }
+        
+        return dirty;
+    }
+
+    /**
+     * marshalling - notification that this instance is to
+     *               be saved to the persistent store
+     */
+    public void marshalling()
+    {
+        // update the properties list from the map
+        // if change/edit detected
+        boolean changed = (propertiesMap.size() != propertiesList.size());
+        if (!changed)
+        {
+            Iterator propsIter = propertiesList.iterator();
+            while (!changed && propsIter.hasNext())
+            {
+                PropertyImpl prop = (PropertyImpl) propsIter.next();
+                changed = (prop.getValue() != propertiesMap.get(prop.getName()));
+            }
+        }
+        if (changed)
+        {
+            propertiesList.clear();
+            Iterator propsIter = propertiesMap.entrySet().iterator();
+            while (propsIter.hasNext())
+            {
+                Map.Entry prop = (Map.Entry) propsIter.next();
+                PropertyImpl listProp = new PropertyImpl();
+                listProp.setName((String)prop.getKey());
+                listProp.setValue((String)prop.getValue());
+                propertiesList.add(listProp);
+            }
+        }
+
+        // notify super class implementation
+        super.marshalling();
+    }
+    
+    /**
+     * Validate fragment using specified validation listener.
+     * 
+     * @param validationListener validation listener
+     * @return validated flag
+     */
+    protected boolean validateFragments(BaseFragmentValidationListener validationListener)
+    {
+        // validate fragment using validation listener
+        return validationListener.validate(this);
+    }    
+}

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/AbstractBaseFragmentsElement.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/AbstractBaseFragmentsElement.java?rev=881862&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/AbstractBaseFragmentsElement.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/AbstractBaseFragmentsElement.java Wed Nov 18 18:24:48 2009
@@ -0,0 +1,361 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jetspeed.om.page.psml;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Stack;
+
+import org.apache.jetspeed.idgenerator.IdGenerator;
+import org.apache.jetspeed.om.folder.MenuDefinition;
+import org.apache.jetspeed.om.folder.MenuExcludeDefinition;
+import org.apache.jetspeed.om.folder.MenuIncludeDefinition;
+import org.apache.jetspeed.om.folder.MenuOptionsDefinition;
+import org.apache.jetspeed.om.folder.MenuSeparatorDefinition;
+import org.apache.jetspeed.om.folder.psml.MenuDefinitionImpl;
+import org.apache.jetspeed.om.folder.psml.MenuExcludeDefinitionImpl;
+import org.apache.jetspeed.om.folder.psml.MenuIncludeDefinitionImpl;
+import org.apache.jetspeed.om.folder.psml.MenuOptionsDefinitionImpl;
+import org.apache.jetspeed.om.folder.psml.MenuSeparatorDefinitionImpl;
+import org.apache.jetspeed.om.page.BaseFragmentElement;
+import org.apache.jetspeed.om.page.BaseFragmentsElement;
+import org.apache.jetspeed.om.page.BaseFragmentValidationListener;
+import org.apache.jetspeed.om.page.BasePageElement;
+import org.apache.jetspeed.om.page.Fragment;
+import org.apache.jetspeed.page.impl.DatabasePageManagerUtils;
+
+/**
+ * AbstractBaseFragmentsElement
+ *
+ * @version $Id:$
+ */
+public abstract class AbstractBaseFragmentsElement extends DocumentImpl implements BaseFragmentsElement
+{
+    private static final long serialVersionUID = 1L;
+
+    private BaseFragmentElement root = null;
+    
+    private FragmentElementImpl rootFragmentElementImpl = null;
+
+    private int hashCode;
+
+    /**
+     * <p>
+     * setId
+     * </p>
+     *
+     * @see org.apache.jetspeed.om.page.psml.AbstractBaseElement#setId(java.lang.String)
+     * @param id
+     */
+    public void setId( String id )
+    {
+        // Cheaper to generate the hash code now then every call to hashCode()
+        hashCode = (getClass().getName()+":"+id).hashCode();
+        super.setId(id);        
+    }
+    
+    /**
+     * <p>
+     * equals
+     * </p>
+     * 
+     * @see java.lang.Object#equals(java.lang.Object)
+     * @param obj
+     * @return
+     */
+    public boolean equals( Object obj )
+    {
+        if (obj instanceof BaseFragmentsElement)
+        {
+            BaseFragmentsElement fragmentsElement = (BaseFragmentsElement) obj;
+            return fragmentsElement.getId() != null && getId() != null && getId().equals(fragmentsElement.getId());
+        }
+        return false;
+    }
+
+    /**
+     * <p>
+     * hashCode
+     * </p>
+     * 
+     * @see java.lang.Object#hashCode()
+     * @return
+     */
+    public int hashCode()
+    {       
+        return hashCode;
+    }
+
+    public BaseFragmentElement getRootFragment()
+    {
+        return this.root;
+    }
+
+    public void setRootFragment( BaseFragmentElement root )
+    {
+        this.root = root;
+        if (root instanceof AbstractBaseFragmentElement)
+        {
+            ((AbstractBaseFragmentElement)root).setBaseFragmentsElement(this);
+        }        
+    }
+
+    /**
+     * getRootFragmentElementImpl - get wrapped fragment element
+     *
+     * @return wrapped element
+     */
+    public FragmentElementImpl getRootFragmentElementImpl()
+    {
+        return rootFragmentElementImpl;
+    }
+
+    /**
+     * setRootFragmentElementImpl - set wrapped fragment element
+     *
+     * @param element wrapped element
+     */
+    public void setRootFragmentElementImpl(FragmentElementImpl element)
+    {
+        rootFragmentElementImpl = element;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseFragmentsElement#getFragmentById(java.lang.String)
+     */
+    public BaseFragmentElement getFragmentById( String id )
+    {
+        Stack stack = new Stack();
+        if (getRootFragment() != null)
+        {
+            stack.push(getRootFragment());
+        }
+
+        BaseFragmentElement f = (BaseFragmentElement) stack.pop();
+
+        while ((f != null) && (!(f.getId().equals(id))))
+        {
+            if (f instanceof Fragment)
+            {
+                Iterator i = ((Fragment)f).getFragments().iterator();
+
+                while (i.hasNext())
+                {
+                    stack.push(i.next());
+                }
+            }
+
+            if (stack.size() > 0)
+            {
+                f = (BaseFragmentElement) stack.pop();
+            }
+            else
+            {
+                f = null;
+            }
+        }
+
+        return f;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseFragmentsElement#removeFragmentById(java.lang.String)
+     */
+    public BaseFragmentElement removeFragmentById( String id )
+    {
+        // find fragment by id, tracking fragment parent
+        Map parents = new HashMap();
+        Stack stack = new Stack();
+        if (getRootFragment() != null)
+        {
+            stack.push(getRootFragment());
+        }
+        BaseFragmentElement f = (BaseFragmentElement) stack.pop();
+        while ((f != null) && (!(f.getId().equals(id))))
+        {
+            if (f instanceof Fragment)
+            {
+                Iterator i = ((Fragment)f).getFragments().iterator();
+
+                while (i.hasNext())
+                {
+                    BaseFragmentElement child = (BaseFragmentElement)i.next();
+                    stack.push(child);
+                    parents.put(child, f);
+                }
+            }
+
+            if (stack.size() > 0)
+            {
+                f = (BaseFragmentElement) stack.pop();
+            }
+            else
+            {
+                f = null;
+            }
+        }
+
+        // remove fragment from parent/page root
+        if (f != null)
+        {
+            BaseFragmentElement parent = (BaseFragmentElement)parents.get(f);
+            if (parent != null)
+            {
+                if (parent instanceof Fragment)
+                {
+                    if (((Fragment)parent).getFragments().remove(f))
+                    {
+                        return f;
+                    }
+                }
+            }
+            else
+            {
+                if (f == root)
+                {
+                    root = null;
+                    return f;
+                }
+            }
+        }
+
+        // not found or removed
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseFragmentsElement#getFragmentsByName(java.lang.String)
+     */
+    public List getFragmentsByName( String name )
+    {
+        List fragments = DatabasePageManagerUtils.createList();
+
+        Stack stack = new Stack();
+        if (getRootFragment() != null)
+        {
+            stack.push(getRootFragment());
+        }
+
+        BaseFragmentElement f = (BaseFragmentElement) stack.pop();
+
+        while (f != null)
+        {
+            if (f instanceof Fragment)
+            {
+                Fragment fragment = (Fragment)f;
+                if ((fragment.getName() != null) && fragment.getName().equals(name))
+                {
+                    fragments.add(fragment);
+                }
+
+                Iterator i = fragment.getFragments().iterator();
+
+                while (i.hasNext())
+                {
+                    stack.push(i.next());
+                }
+            }
+
+            if (stack.size() > 0)
+            {
+                f = (BaseFragmentElement) stack.pop();
+            }
+            else
+            {
+                f = null;
+            }
+        }
+
+        return fragments;
+    }
+
+    /**
+     * unmarshalled - notification that this instance has been
+     *                loaded from the persistent store
+     * @param generator id generator
+     * @return dirty flag
+     */
+    public boolean unmarshalled(IdGenerator generator)
+    {
+        // notify super class implementation
+        boolean dirty = super.unmarshalled(generator);
+
+        // unwrap fragment element
+        root = (AbstractBaseFragmentElement)((rootFragmentElementImpl != null) ? rootFragmentElementImpl.getElement() : null);
+        
+        // propagate unmarshalled notification
+        // and page to root fragment
+        if (root != null)
+        {
+            // propagate unmarshalled notification
+            AbstractBaseFragmentElement rootFragment = (AbstractBaseFragmentElement)root;
+            dirty = (rootFragment.unmarshalled(generator) || dirty);
+
+            // propagate page
+            rootFragment.setBaseFragmentsElement(this);
+        }
+
+        return dirty;
+    }
+
+    /**
+     * marshalling - notification that this instance is to
+     *               be saved to the persistent store
+     */
+    public void marshalling()
+    {
+        // wrap fragment element
+        rootFragmentElementImpl = ((root != null) ? new FragmentElementImpl(root) : null);
+
+        // propagate marshalling notification
+        // to root fragment
+        if (root != null)
+        {
+            ((AbstractBaseFragmentElement)root).marshalling();
+        }
+
+        // notify super class implementation
+        super.marshalling();
+    }
+    
+    /**
+     * Validate fragments.
+     * 
+     * @return validated flag
+     */
+    public boolean validateFragments()
+    {
+        // validate fragments using validation listener
+        AbstractBaseFragmentElement rootFragment = (AbstractBaseFragmentElement)getRootFragment();
+        if (rootFragment != null)
+        {
+            BaseFragmentValidationListener validationListener = newBaseFragmentValidationListener();
+            return (rootFragment.validateFragments(validationListener) && validationListener.validate());
+        }
+        return false;
+    }
+    
+    /**
+     * Fragment validation listener.
+     * 
+     * @return validation listener
+     */
+    protected abstract BaseFragmentValidationListener newBaseFragmentValidationListener();
+}

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/AbstractBasePageElement.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/AbstractBasePageElement.java?rev=881862&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/AbstractBasePageElement.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/AbstractBasePageElement.java Wed Nov 18 18:24:48 2009
@@ -0,0 +1,197 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jetspeed.om.page.psml;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.jetspeed.idgenerator.IdGenerator;
+import org.apache.jetspeed.om.folder.MenuDefinition;
+import org.apache.jetspeed.om.folder.MenuExcludeDefinition;
+import org.apache.jetspeed.om.folder.MenuIncludeDefinition;
+import org.apache.jetspeed.om.folder.MenuOptionsDefinition;
+import org.apache.jetspeed.om.folder.MenuSeparatorDefinition;
+import org.apache.jetspeed.om.folder.psml.MenuDefinitionImpl;
+import org.apache.jetspeed.om.folder.psml.MenuExcludeDefinitionImpl;
+import org.apache.jetspeed.om.folder.psml.MenuIncludeDefinitionImpl;
+import org.apache.jetspeed.om.folder.psml.MenuOptionsDefinitionImpl;
+import org.apache.jetspeed.om.folder.psml.MenuSeparatorDefinitionImpl;
+import org.apache.jetspeed.om.page.BasePageElement;
+
+/**
+ * AbstractBasePageElement
+ *
+ * @version $Id:$
+ */
+public abstract class AbstractBasePageElement extends AbstractBaseFragmentsElement implements BasePageElement
+{
+    private static final long serialVersionUID = 1L;
+
+    private DefaultsImpl defaults = new DefaultsImpl();
+
+    /**
+     * menuDefinitions - menu definitions for page
+     */
+    private List menuDefinitions;
+    
+    public String getSkin()
+    {
+        return defaults.getSkin();
+    }
+
+    public void setSkin( String skinName )
+    {
+        defaults.setSkin(skinName);
+    }
+
+    public String getDefaultDecorator( String fragmentType )
+    {
+        return defaults.getDecorator(fragmentType);
+    }
+
+    public void setDefaultDecorator( String decoratorName, String fragmentType )
+    {
+        defaults.setDecorator(fragmentType, decoratorName);
+    }
+
+    public DefaultsImpl getDefaults()
+    {
+        return this.defaults;
+    }
+
+    public void setDefaults( DefaultsImpl defaults )
+    {
+        this.defaults = defaults;
+    }
+
+    /**
+     * getMenuDefinitions - get list of menu definitions
+     *
+     * @return definition list
+     */
+    public List getMenuDefinitions()
+    {
+        return menuDefinitions;
+    }
+
+    /**
+     * newMenuDefinition - creates a new empty menu definition
+     *
+     * @return a newly created MenuDefinition object for use in Page
+     */
+    public MenuDefinition newMenuDefinition()
+    {
+        return new MenuDefinitionImpl();
+    }
+
+    /**
+     * newMenuExcludeDefinition - creates a new empty menu exclude definition
+     *
+     * @return a newly created MenuExcludeDefinition object for use in Page
+     */
+    public MenuExcludeDefinition newMenuExcludeDefinition()
+    {
+        return new MenuExcludeDefinitionImpl();
+    }
+
+    /**
+     * newMenuIncludeDefinition - creates a new empty menu include definition
+     *
+     * @return a newly created MenuIncludeDefinition object for use in Page
+     */
+    public MenuIncludeDefinition newMenuIncludeDefinition()
+    {
+        return new MenuIncludeDefinitionImpl();
+    }
+
+    /**
+     * newMenuOptionsDefinition - creates a new empty menu options definition
+     *
+     * @return a newly created MenuOptionsDefinition object for use in Page
+     */
+    public MenuOptionsDefinition newMenuOptionsDefinition()
+    {
+        return new MenuOptionsDefinitionImpl();
+    }
+
+    /**
+     * newMenuSeparatorDefinition - creates a new empty menu separator definition
+     *
+     * @return a newly created MenuSeparatorDefinition object for use in Page
+     */
+    public MenuSeparatorDefinition newMenuSeparatorDefinition()
+    {
+        return new MenuSeparatorDefinitionImpl();
+    }
+
+    /**
+     * setMenuDefinitions - set list of menu definitions
+     *
+     * @param definitions definition list
+     */
+    public void setMenuDefinitions(List definitions)
+    {
+        menuDefinitions = definitions;
+    }
+
+    /**
+     * unmarshalled - notification that this instance has been
+     *                loaded from the persistent store
+     * @param generator id generator
+     * @return dirty flag
+     */
+    public boolean unmarshalled(IdGenerator generator)
+    {
+        // notify super class implementation
+        boolean dirty = super.unmarshalled(generator);
+
+        // propagate unmarshalled notification
+        // to all menu definitions
+        if (menuDefinitions != null)
+        {
+            Iterator menuIter = menuDefinitions.iterator();
+            while (menuIter.hasNext())
+            {
+                ((MenuDefinitionImpl)menuIter.next()).unmarshalled();
+            }
+        }
+        
+        return dirty;
+    }
+
+    /**
+     * marshalling - notification that this instance is to
+     *               be saved to the persistent store
+     */
+    public void marshalling()
+    {
+        // propagate marshalling notification
+        // to all menu definitions
+        if (menuDefinitions != null)
+        {
+            Iterator menuIter = menuDefinitions.iterator();
+            while (menuIter.hasNext())
+            {
+                ((MenuDefinitionImpl)menuIter.next()).marshalling();
+            }
+        }
+
+        // notify super class implementation
+        super.marshalling();
+    }
+}

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/DynamicPageImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/DynamicPageImpl.java?rev=881862&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/DynamicPageImpl.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/DynamicPageImpl.java Wed Nov 18 18:24:48 2009
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jetspeed.om.page.psml;
+
+import org.apache.jetspeed.om.page.DynamicPage;
+
+/**
+ * Portal dynamic page definition implementation.
+ * 
+ * @version $Id:$
+ */
+public class DynamicPageImpl extends AbstractBaseConcretePageElement implements DynamicPage
+{
+    private static final long serialVersionUID = 1L;
+
+    private String pageType;
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.DynamicPage#getPageType()
+     */
+    public String getPageType()
+    {
+        return pageType;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.DynamicPage#setPageType(java.lang.String)
+     */
+    public void setPageType(String pageType)
+    {
+        this.pageType = pageType;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.document.Node#getType()
+     */
+    public String getType()
+    {
+        return DOCUMENT_TYPE;
+    }
+}

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/FilteredFragmentList.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/FilteredFragmentList.java?rev=881862&r1=881861&r2=881862&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/FilteredFragmentList.java (original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/FilteredFragmentList.java Wed Nov 18 18:24:48 2009
@@ -47,10 +47,10 @@
         filteredList.add(index, element);
         // add object to persistent list
         fragment.accessFragments().add(element);
-        // maintain page implementation reference
-        if ((fragment.getPage() != null) && (element instanceof FragmentImpl))
+        // maintain base fragments implementation reference
+        if ((fragment.getBaseFragmentsElement() != null) && (element instanceof FragmentImpl))
         {
-            ((FragmentImpl)element).setPage(fragment.getPage());
+            ((FragmentImpl)element).setBaseFragmentsElement(fragment.getBaseFragmentsElement());
         }
     }
 
@@ -106,10 +106,10 @@
                 }
             }
         }
-        // maintain page implementation reference
-        if ((fragment.getPage() != null) && (element instanceof FragmentImpl))
+        // maintain base fragments implementation reference
+        if ((fragment.getBaseFragmentsElement() != null) && (element instanceof FragmentImpl))
         {
-            ((FragmentImpl)element).setPage(fragment.getPage());
+            ((FragmentImpl)element).setBaseFragmentsElement(fragment.getBaseFragmentsElement());
         }
         return o;
     }

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/FragmentDefinitionImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/FragmentDefinitionImpl.java?rev=881862&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/FragmentDefinitionImpl.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/FragmentDefinitionImpl.java Wed Nov 18 18:24:48 2009
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jetspeed.om.page.psml;
+
+import org.apache.jetspeed.om.page.BaseFragmentElement;
+import org.apache.jetspeed.om.page.FragmentDefinition;
+import org.apache.jetspeed.om.page.FragmentReference;
+import org.apache.jetspeed.om.page.BaseFragmentValidationListener;
+import org.apache.jetspeed.om.page.PageFragment;
+
+/**
+ * Portal fragment definition implementation.
+ * 
+ * @version $Id:$
+ */
+public class FragmentDefinitionImpl extends AbstractBaseFragmentsElement implements FragmentDefinition
+{
+    private static final long serialVersionUID = 1L;
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.FragmentDefinition#getDefId()
+     */
+    public String getDefId()
+    {
+        BaseFragmentElement rootFragment = getRootFragment();
+        return ((rootFragment != null) ? rootFragment.getId() : null);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.document.Node#getType()
+     */
+    public String getType()
+    {
+        return DOCUMENT_TYPE;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.document.psml.AbstractNode#isHidden()
+     */
+    public boolean isHidden()
+    {
+        return false;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.document.psml.AbstractNode#setHidden(boolean)
+     */
+    public void setHidden(boolean hidden)
+    {
+        throw new UnsupportedOperationException("PageTemplate.setHidden()");
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.psml.AbstractBaseFragmentsElement#newBaseFragmentValidationListener()
+     */
+    protected BaseFragmentValidationListener newBaseFragmentValidationListener()
+    {
+        return new BaseFragmentValidationListener()
+        {
+            /* (non-Javadoc)
+             * @see org.apache.jetspeed.om.page.BaseFragmentValidationListener#validate(org.apache.jetspeed.om.page.BaseFragmentElement)
+             */
+            public boolean validate(BaseFragmentElement fragmentElement)
+            {
+                // PageFragments can only appear in PageTemplates; recursive FragmentReference not supported
+                return (!(fragmentElement instanceof PageFragment) && !(fragmentElement instanceof FragmentReference));
+            }
+
+            /* (non-Javadoc)
+             * @see org.apache.jetspeed.om.page.BaseFragmentValidationListener#validate()
+             */
+            public boolean validate()
+            {
+                return true;
+            }
+        };
+    }
+}

Added: portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/FragmentElementImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/FragmentElementImpl.java?rev=881862&view=auto
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/FragmentElementImpl.java (added)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/page/psml/FragmentElementImpl.java Wed Nov 18 18:24:48 2009
@@ -0,0 +1,123 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jetspeed.om.page.psml;
+
+import java.io.Serializable;
+
+/**
+ * This class implements a wrapper used to implement
+ * the ordered polymorphic fragment elements collection.
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id:$
+ */
+public class FragmentElementImpl implements Serializable
+{
+    /**
+     * element - wrapped menu element
+     */
+    private Object element;
+
+    /**
+     * MenuElementImpl - constructor
+     */
+    public FragmentElementImpl()
+    {
+    }
+
+    /**
+     * MenuElementImpl - constructor
+     */
+    public FragmentElementImpl(Object element)
+    {
+        this.element = element;
+    }
+
+    /**
+     * getOption - get wrapped menu element
+     */
+    public Object getElement()
+    {
+        return element;
+    }
+
+    /**
+     * getFragment - get wrapped fragment definition
+     */
+    public FragmentImpl getFragment()
+    {
+        if (element instanceof FragmentImpl)
+        {
+            return (FragmentImpl)element;
+        }
+        return null;
+    }
+
+    /**
+     * setFragment - set wrapped fragment definition
+     *
+     * @param fragment fragment definition
+     */
+    public void setFragment(FragmentImpl fragment)
+    {
+        this.element = fragment;
+    }
+
+    /**
+     * getFragmentReference - get wrapped fragment reference definition
+     */
+    public FragmentReferenceImpl getFragmentReference()
+    {
+        if (element instanceof FragmentReferenceImpl)
+        {
+            return (FragmentReferenceImpl)element;
+        }
+        return null;
+    }
+
+    /**
+     * setFragmentReference - set wrapped fragment reference definition
+     *
+     * @param fragmentReference fragment reference definition
+     */
+    public void setFragmentReference(FragmentReferenceImpl fragmentReference)
+    {
+        this.element = fragmentReference;
+    }
+
+    /**
+     * getPageFragment - get wrapped page fragment definition
+     */
+    public PageFragmentImpl getPageFragment()
+    {
+        if (element instanceof PageFragmentImpl)
+        {
+            return (PageFragmentImpl)element;
+        }
+        return null;
+    }
+
+    /**
+     * setPageFragment - set wrapped page fragment definition
+     *
+     * @param pageFragment page fragment definition
+     */
+    public void setPageFragment(PageFragmentImpl pageFragment)
+    {
+        this.element = pageFragment;
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message