portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r731466 [2/12] - in /portals/jetspeed-2/portal/branches/JPA_BRANCH: ./ components/jetspeed-cm/src/main/java/org/apache/jetspeed/components/ components/jetspeed-cm/src/main/java/org/apache/jetspeed/test/ components/jetspeed-page-manager/ com...
Date Mon, 05 Jan 2009 06:04:18 GMT
Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderImpl.java?rev=731466&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderImpl.java Sun Jan  4 22:04:13 2009
@@ -0,0 +1,1479 @@
+/*
+ * 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.folder.jpa;
+
+import java.security.AccessController;
+import java.security.Permission;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.persistence.AttributeOverride;
+import javax.persistence.AttributeOverrides;
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.NamedQuery;
+import javax.persistence.NamedQueries;
+import javax.persistence.OneToMany;
+import javax.persistence.OrderBy;
+import javax.persistence.PostLoad;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+import org.apache.jetspeed.JetspeedActions;
+import org.apache.jetspeed.om.common.SecurityConstraint;
+import org.apache.jetspeed.om.common.SecurityConstraintsContext;
+import org.apache.jetspeed.om.folder.Folder;
+import org.apache.jetspeed.om.folder.FolderNotFoundException;
+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.Link;
+import org.apache.jetspeed.om.page.Page;
+import org.apache.jetspeed.om.page.PageMetadataImpl;
+import org.apache.jetspeed.om.page.PageSecurity;
+import org.apache.jetspeed.om.page.jpa.GenericSecurityConstraintsContextImpl;
+import org.apache.jetspeed.om.page.jpa.LinkImpl;
+import org.apache.jetspeed.om.page.jpa.MetadataLocalizedFieldCollection;
+import org.apache.jetspeed.om.page.jpa.PageImpl;
+import org.apache.jetspeed.om.page.jpa.PageSecurityImpl;
+import org.apache.jetspeed.om.page.jpa.SecurityConstraintsContextImpl;
+import org.apache.jetspeed.page.PageNotFoundException;
+import org.apache.jetspeed.page.document.DocumentException;
+import org.apache.jetspeed.page.document.DocumentNotFoundException;
+import org.apache.jetspeed.page.document.Node;
+import org.apache.jetspeed.page.document.NodeException;
+import org.apache.jetspeed.page.document.NodeNotFoundException;
+import org.apache.jetspeed.page.document.NodeSet;
+import org.apache.jetspeed.page.document.jpa.NodeImpl;
+import org.apache.jetspeed.page.document.jpa.NodeSetImpl;
+import org.apache.jetspeed.page.jpa.DatabasePageManagerUtils;
+import org.apache.jetspeed.security.PermissionFactory;
+
+/**
+ * FolderImpl
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+@Entity (name="Folder")
+@Inheritance (strategy=InheritanceType.TABLE_PER_CLASS)
+@Table (name="FOLDER")
+@AttributeOverrides ({@AttributeOverride (name="id", column=@Column(name="FOLDER_ID"))})
+@NamedQueries({@NamedQuery(name="FOLDER_FOLDERS", query="select f from Folder f where f.parent = :folder"), 
+               @NamedQuery(name="FOLDER", query="select f from Folder f where f.path = :path")})
+public class FolderImpl extends NodeImpl implements Folder
+{
+    @Basic
+    @Column (name="TITLE")
+    private String title;
+    @Basic
+    @Column (name="SHORT_TITLE")
+    private String shortTitle;
+    @Basic
+    @Column (name="IS_HIDDEN")
+    private boolean hidden;
+
+    @ManyToOne (targetEntity=FolderImpl.class, fetch=FetchType.LAZY, optional=true, cascade=CascadeType.PERSIST)
+    @JoinColumn (name="PARENT_ID", referencedColumnName="FOLDER_ID")
+    private FolderImpl parent;
+    @OneToMany (targetEntity=FolderMetadataLocalizedFieldImpl.class, mappedBy="folder", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    private Collection metadataFields;
+    @Basic
+    @Column (name="DEFAULT_PAGE_NAME")
+    private String defaultPage;
+    @Basic
+    @Column (name="SKIN")
+    private String skin;
+    @Basic
+    @Column (name="DEFAULT_LAYOUT_DECORATOR")
+    private String defaultLayoutDecorator;
+    @Basic
+    @Column (name="DEFAULT_PORTLET_DECORATOR")
+    private String defaultPortletDecorator;
+    @OneToMany (targetEntity=FolderOrder.class, mappedBy="folder", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    @OrderBy (value="sortOrder ASC")
+    private List orders;
+    @OneToMany (targetEntity=FolderMenuDefinitionImpl.class, mappedBy="folder", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    @OrderBy (value="name ASC")
+    private List menus;
+
+    @PostLoad
+    private void eagerFetchCollections()
+    {
+        if (metadataFields != null)
+        {
+            metadataFields.size();
+        }
+        if (orders != null)
+        {
+            orders.size();
+        }
+        if (menus != null)
+        {
+            menus.size();
+        }
+        eagerFetchEmbeddedCollections();
+    }
+    
+    @Transient
+    private Object cacheLock;
+    @Transient
+    private List folders;
+    @Transient
+    private boolean foldersCached;
+    @Transient
+    private List pages;
+    @Transient
+    private boolean pagesCached;
+    @Transient
+    private List links;
+    @Transient
+    private boolean linksCached;
+    @Transient
+    private PageSecurityImpl pageSecurity;
+    @Transient
+    private boolean pageSecurityCached;
+    @Transient
+    private List all;
+    @Transient
+    private boolean allCached;
+    @Transient
+    private FolderOrderList documentOrder;
+    @Transient
+    private boolean documentOrderComparatorValid;
+    @Transient
+    private Comparator documentOrderComparator;
+    @Transient
+    private NodeSet foldersNodeSet;
+    @Transient
+    private NodeSet pagesNodeSet;
+    @Transient
+    private NodeSet linksNodeSet;
+    @Transient
+    private NodeSet allNodeSet;
+    @Transient
+    private FolderMenuDefinitionList menuDefinitions;
+
+    private static PermissionFactory pf;
+    
+    public static void setPermissionsFactory(PermissionFactory pf)
+    {
+        FolderImpl.pf = pf;
+    }
+    
+    /**
+     * Default constructor.
+     */
+    public FolderImpl()
+    {
+        cacheLock = new Object();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecuredResource#newSecurityConstraintsContext()
+     */
+    public SecurityConstraintsContext newSecurityConstraintsContext()
+    {
+        // return generic security constraints context instance
+        // since the context is embedded in this, (see below).
+        return new GenericSecurityConstraintsContextImpl();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecuredResource#newSecurityConstraint()
+     */
+    public SecurityConstraint newSecurityConstraint()
+    {
+        // return constraints specific security constraint instance
+        return new FolderSecurityConstraintImpl();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.document.jpa.NodeImpl#getMetadataFields()
+     */
+    protected Collection getMetadataFields()
+    {
+        // create initial collection if necessary
+        if (metadataFields == null)
+        {
+            metadataFields = DatabasePageManagerUtils.createList();
+        }
+        // wrap collection to maintain JPA inverse relationships
+        return new MetadataLocalizedFieldCollection(this, metadataFields);        
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.document.jpa.NodeImpl#getParentNode()
+     */
+    protected Node getParentNode()
+    {
+        return parent;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.document.jpa.NodeImpl#setParentNode(org.apache.jetspeed.page.document.Node)
+     */
+    protected void setParentNode(Node parent)
+    {
+        this.parent = (FolderImpl)parent;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.jpa.BaseElementImpl#accessSecurityConstraintsContext()
+     */
+    protected SecurityConstraintsContextImpl accessSecurityConstraintsContext()
+    {
+        // return this since the context is embedded in this, (see below).
+        return this;
+    }
+    
+    /**
+     * accessFolderOrders
+     *
+     * Access mutable persistent collection member for List wrappers.
+     *
+     * @return persistent collection
+     */
+    List accessFolderOrders()
+    {
+        // create initial collection if necessary
+        if (orders == null)
+        {
+            orders = DatabasePageManagerUtils.createList();
+        }
+        return orders;
+    }
+
+    /**
+     * 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;
+    }
+
+    /**
+     * Access cache lock for used by PageManager to synchronize cached state.
+     *
+     * @return access cache lock
+     */
+    public Object accessCacheLock()
+    {
+        return cacheLock;
+    }
+
+    /**
+     * accessFolders
+     *
+     * Access folders transient cache collection for use by PageManager.
+     *
+     * @return folders collection
+     */
+    public List accessFolders()
+    {
+        synchronized (cacheLock)
+        {
+            // create initial collection if necessary
+            if (folders == null)
+            {
+                folders = new ArrayList();
+            }
+            return folders;
+        }
+    }
+
+    /**
+     * resetFolders
+     *
+     * Reset folders transient caches for use by PageManager.
+     *
+     * @param cached set cached state for folders
+     */
+    public void resetFolders(boolean cached)
+    {
+        synchronized (cacheLock)
+        {
+            // save cached state
+            foldersCached = cached;
+            allCached = false;
+
+            // update node caches
+            if (!cached)
+            {
+                accessFolders().clear();
+            }
+            accessAll().clear();
+
+            // reset cached node sets
+            foldersNodeSet = null;
+            allNodeSet = null;
+        }
+    }
+
+    /**
+     * accessPages
+     *
+     * Access pages transient cache collection for use by PageManager.
+     *
+     * @return pages collection
+     */
+    public List accessPages()
+    {
+        synchronized (cacheLock)
+        {
+            // create initial collection if necessary
+            if (pages == null)
+            {
+                pages = new ArrayList();
+            }
+            return pages;
+        }
+    }
+
+    /**
+     * resetPages
+     *
+     * Reset pages transient caches for use by PageManager.
+     *
+     * @param cached set cached state for pages
+     */
+    public void resetPages(boolean cached)
+    {
+        synchronized (cacheLock)
+        {
+            // save cached state
+            pagesCached = cached;
+            allCached = false;
+
+            // update node caches
+            if (!cached)
+            {
+                accessPages().clear();
+            }
+            accessAll().clear();
+
+            // reset cached node sets
+            pagesNodeSet = null;
+            allNodeSet = null;
+        }
+    }
+
+    /**
+     * accessLinks
+     *
+     * Access links transient cache collection for use by PageManager.
+     *
+     * @return links collection
+     */
+    public List accessLinks()
+    {
+        synchronized (cacheLock)
+        {
+            // create initial collection if necessary
+            if (links == null)
+            {
+                links = new ArrayList();
+            }
+            return links;
+        }
+    }
+
+    /**
+     * resetLinks
+     *
+     * Reset links transient caches for use by PageManager.
+     *
+     * @param cached set cached state for links
+     */
+    public void resetLinks(boolean cached)
+    {
+        synchronized (cacheLock)
+        {
+            // save cached state
+            linksCached = cached;
+            allCached = false;
+
+            // update node caches
+            if (!cached)
+            {
+                accessLinks().clear();
+            }
+            accessAll().clear();
+
+            // reset cached node sets
+            linksNodeSet = null;
+            allNodeSet = null;
+        }
+    }
+
+    /**
+     * accessPageSecurity
+     *
+     * Access pageSecurity cached instance for use by PageManager.
+     *
+     * @return pageSecurity instance
+     */
+    public PageSecurityImpl accessPageSecurity()
+    {
+        synchronized (cacheLock)
+        {
+            return pageSecurity;
+        }
+    }
+
+    /**
+     * resetPageSecurity
+     *
+     * Reset pageSecurity transient cache instance for use by PageManager.
+     *
+     * @param newPageSecurty cached page security instance.
+     * @param cached set cached state for page security
+     */
+    public void resetPageSecurity(PageSecurityImpl newPageSecurity, boolean cached)
+    {
+        synchronized (cacheLock)
+        {
+            // save cached state
+            pageSecurity = newPageSecurity;
+            pageSecurityCached = cached;
+            allCached = false;
+
+            // update node caches
+            accessAll().clear();
+
+            // reset cached node sets
+            allNodeSet = null;
+        }
+    }
+
+    /**
+     * accessAll
+     *
+     * Access all transient cache collection for use by PageManager.
+     *
+     * @return all collection
+     */
+    public List accessAll()
+    {
+        synchronized (cacheLock)
+        {
+            // create initial collection if necessary
+            if (all == null)
+            {
+                all = new ArrayList();
+            }
+            return all;
+        }
+    }
+
+    /**
+     * resetAll
+     *
+     * Reset all transient caches for use by PageManager.
+     *
+     * @param cached set cached state for all
+     */
+    public void resetAll(boolean cached)
+    {
+        synchronized (cacheLock)
+        {
+            // save cached state
+            allCached = cached;
+            foldersCached = cached;
+            pagesCached = cached;
+            linksCached = cached;
+            pageSecurityCached = cached;
+
+            // update node caches
+            accessFolders().clear();
+            accessPages().clear();
+            accessLinks().clear();
+            pageSecurity = null;
+            if (cached)
+            {
+                // populate node caches
+                Iterator nodeIter = accessAll().iterator();
+                while (nodeIter.hasNext())
+                {
+                    Node node = (Node)nodeIter.next();
+                    if (node instanceof PageImpl)
+                    {
+                        pages.add(node);
+                    }
+                    else if (node instanceof FolderImpl)
+                    {
+                        folders.add(node);
+                    }
+                    else if (node instanceof LinkImpl)
+                    {
+                        links.add(node);
+                    }
+                    else if (node instanceof PageSecurityImpl)
+                    {
+                        pageSecurity = (PageSecurityImpl)node;
+                    }
+                }
+            }
+            else
+            {
+                accessAll().clear();
+            }
+
+            // reset cached node sets
+            allNodeSet = null;
+            foldersNodeSet = null;
+            pagesNodeSet = null;
+            linksNodeSet = null;
+        }
+    }
+
+    /**
+     * Create document order comparator,
+     * (assume cacheLock synchronized by caller).
+     *
+     * @return document order comparator
+     */
+    private Comparator createDocumentOrderComparator()
+    {
+        if (!documentOrderComparatorValid)
+        {
+            documentOrderComparatorValid = true;
+            // return null if no document order exists;
+            // (null implies natural ordering by name)
+            final List documentOrder = getDocumentOrder();
+            if ((documentOrder == null) || documentOrder.isEmpty())
+            {
+                return null;
+            }
+            // create new document order comparator
+            documentOrderComparator = new Comparator()
+            {
+                /* (non-Javadoc)
+                 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+                 */
+                public int compare(Object o1, Object o2)
+                {
+                    // Compare node names using document order;
+                    // use indices as names if found in document
+                    // order to force explicitly ordered items
+                    // ahead of unordered items
+                    String name1 = (String)o1;
+                    int index1 = documentOrder.indexOf(name1);
+                    if (index1 >= 0)
+                    {
+                        // use order index as name1
+                        name1 = String.valueOf(index1);
+                    }
+                    String name2 = (String)o2;
+                    int index2 = documentOrder.indexOf(name2);
+                    if (index2 >= 0)
+                    {
+                        // use order index as name2
+                        name2 = String.valueOf(index2);
+                        if (index1 >= 0)
+                        {
+                            // pad order indices for numeric string compare
+                            while (name1.length() != name2.length())
+                            {
+                                if (name1.length() < name2.length())
+                                {
+                                    name1 = "0" + name1;
+                                }
+                                else
+                                {
+                                    name2 = "0" + name2;
+                                }
+                            }
+                        }
+                    }
+                    // compare names and/or indices
+                    return name1.compareTo(name2);                        
+                }
+            };
+        }
+        return documentOrderComparator;
+    }
+
+    /**
+     * Clear cached document order comparator and related cached data.
+     */
+    void clearDocumentOrderComparator()
+    {
+        synchronized (cacheLock)
+        {
+            // clear node set ordering
+            documentOrderComparatorValid = false;
+            documentOrderComparator = null;
+            // clear previously cached node sets
+            allNodeSet = null;
+            foldersNodeSet = null;
+            pagesNodeSet = null;
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.document.jpa.NodeImpl#newPageMetadata(java.util.Collection)
+     */
+    public PageMetadataImpl newPageMetadata(Collection fields)
+    {
+        PageMetadataImpl pageMetadata = new PageMetadataImpl(FolderMetadataLocalizedFieldImpl.class);
+        pageMetadata.setFields(fields);
+        return pageMetadata;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.jpa.BaseElementImpl#getEffectivePageSecurity()
+     */
+    public PageSecurity getEffectivePageSecurity()
+    {
+        // return page security instance if available
+        synchronized (cacheLock)
+        {
+            if (!pageSecurityCached)
+            {
+                // use PageManager to get and cache page security
+                // instance for this folder
+                try
+                {
+                    return getPageManager().getPageSecurity(this);
+                }
+                catch (NodeException ne)
+                {
+                }
+                catch (NodeNotFoundException nnfe)
+                {
+                }
+            }
+            else if (pageSecurity != null)
+            {
+                return pageSecurity;
+            }
+        }
+
+        // delegate to real parent folder implementation
+        FolderImpl parentFolderImpl = (FolderImpl)getParent();
+        if (parentFolderImpl != null)
+        {
+            return parentFolderImpl.getEffectivePageSecurity();
+        }
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.jpa.BaseElementImpl#checkPermissions(java.lang.String, int, boolean, boolean)
+     */
+    public void checkPermissions(String path, int mask, boolean checkNodeOnly, boolean checkParentsOnly) throws SecurityException
+    {
+        // check granted folder permissions unless the check is
+        // to be skipped due to explicitly granted access
+        if (!checkParentsOnly)
+        {
+            AccessController.checkPermission((Permission)pf.newPermission(pf.FOLDER_PERMISSION, path, mask));
+        }
+
+        // if not checking node only, recursively check
+        // all parent permissions in hierarchy
+        if (!checkNodeOnly)
+        {
+            FolderImpl parentFolderImpl = (FolderImpl)getParent();
+            if (parentFolderImpl != null)
+            {
+                parentFolderImpl.checkPermissions(mask, false, false);
+            }
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.Folder#getSkin()
+     */
+    public String getSkin()
+    {
+        return skin;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.Folder#setSkin(java.lang.String)
+     */
+    public void setSkin(String skinName)
+    {
+        this.skin = skinName;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.Folder#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;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.Folder#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.folder.Folder#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.folder.Folder#getDocumentOrder()
+     */
+    public List getDocumentOrder()
+    {
+        // return mutable document order list
+        // by using list wrapper to manage sort
+        // order and element uniqueness
+        if (documentOrder == null)
+        {
+            documentOrder = new FolderOrderList(this);
+        }
+        return documentOrder;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.Folder#setDocumentOrder(java.util.List)
+     */
+    public void setDocumentOrder(List docNames)
+    {
+        // set document order using ordered document
+        // names by replacing existing entries with
+        // new elements if new collection is specified
+        List documentOrder = getDocumentOrder();
+        if (docNames != documentOrder)
+        {
+            // replace all document order names
+            documentOrder.clear();
+            if (docNames != null)
+            {
+                documentOrder.addAll(docNames);
+            }
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.Folder#getDefaultPage()
+     */
+    public String getDefaultPage()
+    {
+        return defaultPage;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.Folder#setDefaultPage(java.lang.String)
+     */
+    public void setDefaultPage(String defaultPage)
+    {
+        this.defaultPage = defaultPage;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.Folder#getFolders()
+     */
+    public NodeSet getFolders() throws DocumentException
+    {
+        NodeSet nodes = null;
+        synchronized (cacheLock)
+        {
+            // get folders collection
+            if (!foldersCached)
+            {
+                // use PageManager to get and cache folders
+                // collection for this folder
+                return getPageManager().getFolders(this);
+            }
+
+            // return cached nodes
+            nodes = getFoldersNodeSet();
+        }
+        
+        // return nodes with view access
+        return filterNodeSetByAccess(nodes);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.Folder#getFolder(java.lang.String)
+     */
+    public Folder getFolder(String name) throws FolderNotFoundException, DocumentException
+    {
+        Folder folder = null;
+        synchronized (cacheLock)
+        {
+            // get folder instance if folders collection not available
+            if (!foldersCached)
+            {
+                // use PageManager to get folder instance without
+                // caching the folders collection for this folder
+                return getPageManager().getFolder(this, name);
+            }
+
+            // select folder by name from cached folders collection
+            folder = (Folder)getFoldersNodeSet().get(name);
+        }
+        if (folder == null)
+        {
+            throw new FolderNotFoundException("Folder not found: " + name);
+        }
+
+        // check for view access on folder
+        folder.checkAccess(JetspeedActions.VIEW);
+
+        return folder;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.Folder#getPages()
+     */
+    public NodeSet getPages() throws NodeException
+    {
+        NodeSet nodes = null;
+        synchronized (cacheLock)
+        {
+            // get pages collection
+            if (!pagesCached)
+            {
+                // use PageManager to get and cache pages
+                // collection for this folder
+                return getPageManager().getPages(this);
+            }
+
+            // return cached nodes
+            nodes = getPagesNodeSet();
+        }
+
+        // return nodes with view access
+        return filterNodeSetByAccess(nodes);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.Folder#getPage(java.lang.String)
+     */
+    public Page getPage(String name) throws PageNotFoundException, NodeException
+    {
+        Page page = null;
+        synchronized (cacheLock)
+        {
+            // get page instance if pages collection not available
+            if (!pagesCached)
+            {
+                // use PageManager to get page instance without
+                // caching the pages collection for this folder
+                return getPageManager().getPage(this, name);
+            }
+
+            // select page by name from cached pages collection
+            page = (Page)getPagesNodeSet().get(name);
+        }
+        if (page == null)
+        {
+            throw new PageNotFoundException("Page not found: " + name);
+        }
+
+        // check for view access on page
+        page.checkAccess(JetspeedActions.VIEW);
+
+        return page;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.Folder#getLinks()
+     */
+    public NodeSet getLinks() throws NodeException
+    {
+        NodeSet nodes = null;
+        synchronized (cacheLock)
+        {
+            // get links collection
+            if (!linksCached)
+            {
+                // use PageManager to get and cache links
+                // collection for this folder
+                return getPageManager().getLinks(this);
+            }
+
+            // return cached nodes
+            nodes = getLinksNodeSet();
+        }
+
+        // return nodes with view access
+        return filterNodeSetByAccess(nodes);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.Folder#getLink(java.lang.String)
+     */
+    public Link getLink(String name) throws DocumentNotFoundException, NodeException
+    {
+        Link link = null;
+        synchronized (cacheLock)
+        {
+            // get link instance if links collection not available
+            if (!linksCached)
+            {
+                // use PageManager to get link instance without
+                // caching the links collection for this folder
+                return getPageManager().getLink(this, name);
+            }
+
+            // select link by name from cached links collection
+            link = (Link)getLinksNodeSet().get(name);
+        }
+        if (link == null)
+        {
+            throw new DocumentNotFoundException("Link not found: " + name);
+        }
+
+        // check for view access on link
+        link.checkAccess(JetspeedActions.VIEW);
+
+        return link;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.Folder#getPageSecurity()
+     */
+    public PageSecurity getPageSecurity() throws DocumentNotFoundException, NodeException
+    {
+        PageSecurity pageSecurity = null;
+        synchronized (cacheLock)
+        {
+            // get page security instance
+            if (!pageSecurityCached)
+            {
+                // use PageManager to get and cache page security
+                // instance for this folder
+                return getPageManager().getPageSecurity(this);
+            }
+            pageSecurity = this.pageSecurity;
+        }
+        if (pageSecurity == null)
+        {
+            throw new DocumentNotFoundException("Page security document not found");
+        }
+
+        // check for view access on document
+        pageSecurity.checkAccess(JetspeedActions.VIEW);
+
+        return pageSecurity;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.Folder#getAll()
+     */
+    public NodeSet getAll() throws DocumentException
+    {
+        NodeSet nodes = null;
+        synchronized (cacheLock)
+        {
+            // get all nodes collection
+            if (!allCached)
+            {
+                // use PageManager to get and cache all nodes
+                // collection for this folder
+                return getPageManager().getAll(this);
+            }
+
+            // return cached nodes
+            nodes = getAllNodeSet();
+        }
+        
+        // return nodes with view access
+        return filterNodeSetByAccess(nodes);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.Folder#getMenuDefinitions()
+     */
+    public List getMenuDefinitions()
+    {
+        // return mutable menu definition list
+        // by using list wrapper to manage
+        // element uniqueness
+        if (menuDefinitions == null)
+        {
+            menuDefinitions = new FolderMenuDefinitionList(this);
+        }
+        return menuDefinitions;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.Folder#newMenuDefinition()
+     */
+    public MenuDefinition newMenuDefinition()
+    {
+        return new FolderMenuDefinitionImpl();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.Folder#newMenuExcludeDefinition()
+     */
+    public MenuExcludeDefinition newMenuExcludeDefinition()
+    {
+        return new FolderMenuExcludeDefinitionImpl();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.Folder#newMenuIncludeDefinition()
+     */
+    public MenuIncludeDefinition newMenuIncludeDefinition()
+    {
+        return new FolderMenuIncludeDefinitionImpl();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.Folder#newMenuOptionsDefinition()
+     */
+    public MenuOptionsDefinition newMenuOptionsDefinition()
+    {
+        return new FolderMenuOptionsDefinitionImpl();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.Folder#newMenuSeparatorDefinition()
+     */
+    public MenuSeparatorDefinition newMenuSeparatorDefinition()
+    {
+        return new FolderMenuSeparatorDefinitionImpl();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.Folder#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);
+            }
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.Folder#isReserved()
+     */
+    public boolean isReserved()
+    {
+        // folders are always concrete in this implementation
+        return false;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.Folder#getReservedType()
+     */
+    public int getReservedType()
+    {
+        // folders are always concrete in this implementation
+        return RESERVED_FOLDER_NONE;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.document.Node#getType()
+     */
+    public String getType()
+    {
+        return FOLDER_TYPE;
+    }
+
+    /**
+     * getFoldersNodeSet
+     *
+     * Latently create and access folders node set,
+     * (assume cacheLock synchronized by caller).
+     *
+     * @return folders node set
+     */
+    private NodeSet getFoldersNodeSet()
+    {
+        if (foldersNodeSet == null)
+        {
+            if ((folders != null) && !folders.isEmpty())
+            {
+                foldersNodeSet = new NodeSetImpl(folders, createDocumentOrderComparator());
+            }
+            else
+            {
+                foldersNodeSet = NodeSetImpl.EMPTY_NODE_SET;
+            }
+        }
+        return foldersNodeSet;
+    }
+    
+    /**
+     * getPagesNodeSet
+     *
+     * Latently create and access pages node set,
+     * (assume cacheLock synchronized by caller).
+     *
+     * @return folders node set
+     */
+    private NodeSet getPagesNodeSet() throws NodeException
+    {
+        if (pagesNodeSet == null)
+        {
+            if ((pages != null) && !pages.isEmpty())
+            {
+                pagesNodeSet = new NodeSetImpl(pages, createDocumentOrderComparator());
+            }
+            else
+            {
+                pagesNodeSet = NodeSetImpl.EMPTY_NODE_SET;
+            }
+        }
+        return pagesNodeSet;
+    }
+    
+    /**
+     * getLinksNodeSet
+     *
+     * Latently create and access links node set.
+     * (assume cacheLock synchronized by caller).
+     *
+     * @return folders node set
+     */
+    private NodeSet getLinksNodeSet() throws NodeException
+    {
+        if (linksNodeSet == null)
+        {
+            if ((links != null) && !links.isEmpty())
+            {
+                linksNodeSet = new NodeSetImpl(links, createDocumentOrderComparator());
+            }
+            else
+            {
+                linksNodeSet = NodeSetImpl.EMPTY_NODE_SET;
+            }
+        }
+        return linksNodeSet;
+    }
+    
+    /**
+     * getAllNodeSet
+     *
+     * Latently create and access all nodes node set,
+     * (assume cacheLock synchronized by caller).
+     *
+     * @return all nodes node set
+     */
+    private NodeSet getAllNodeSet()
+    {
+        if (allNodeSet == null)
+        {
+            if ((all != null) && !all.isEmpty())
+            {
+                allNodeSet = new NodeSetImpl(all, createDocumentOrderComparator());
+            }
+            else
+            {
+                allNodeSet = NodeSetImpl.EMPTY_NODE_SET;
+            }
+        }
+        return allNodeSet;
+    }
+
+    /**
+     * filterNodeSetByAccess
+     *
+     * Filter node set elements for view access.
+     *
+     * @param nodes node set containing nodes to check
+     * @return checked subset of nodes
+     */
+    static NodeSet filterNodeSetByAccess(NodeSet nodes)
+    {
+        if ((nodes != null) && !nodes.isEmpty())
+        {
+            // check permissions and constraints, filter nodes as required
+            NodeSetImpl filteredNodes = null;
+            Iterator checkAccessIter = nodes.iterator();
+            while (checkAccessIter.hasNext())
+            {
+                Node node = (Node)checkAccessIter.next();
+                try
+                {
+                    // check access
+                    node.checkAccess(JetspeedActions.VIEW);
+
+                    // add to filteredNodes nodes if copying
+                    if (filteredNodes != null)
+                    {
+                        // permitted, add to filteredNodes nodes
+                        filteredNodes.add(node);
+                    }
+                }
+                catch (SecurityException se)
+                {
+                    // create filteredNodes nodes if not already copying
+                    if (filteredNodes == null)
+                    {
+                        // not permitted, copy previously permitted nodes
+                        // to new filteredNodes node set with same comparator
+                        filteredNodes = new NodeSetImpl(nodes);
+                        Iterator copyIter = nodes.iterator();
+                        while (copyIter.hasNext())
+                        {
+                            Node copyNode = (Node)copyIter.next();
+                            if (copyNode != node)
+                            {
+                                filteredNodes.add(copyNode);
+                            }
+                            else
+                            {
+                                break;
+                            }
+                        }
+                    }
+                }
+            }
+
+            // return filteredNodes nodes if generated
+            if (filteredNodes != null)
+            {
+                return filteredNodes;
+            }
+        }
+        return nodes;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseElement#getTitle()
+     */
+    public String getTitle()
+    {
+        // default title to folder name
+        if (title == null)
+        {
+            title = defaultTitleFromName();
+        }
+        return title;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseElement#setTitle(java.lang.String)
+     */
+    public void setTitle(String title)
+    {
+        this.title = title;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseElement#getShortTitle()
+     */
+    public String getShortTitle()
+    {
+        return shortTitle;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.BaseElement#setShortTitle(java.lang.String)
+     */
+    public void setShortTitle(String shortTitle)
+    {
+        this.shortTitle = shortTitle;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.document.Node#isHidden()
+     */
+    public boolean isHidden()
+    {
+        return hidden;
+    }    
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.document.Node#setHidden(boolean)
+     */
+    public void setHidden(boolean hidden)
+    {
+        this.hidden = hidden;
+    }    
+
+    // **************************************************************************
+    // Begin Embedded SecurityConstraintsContextImpl
+    //
+    // Embeddable/Embedded with relationships not supported in JPA 1.0;
+    // otherwise, this should have been implemented as an embedded type
+    // derived from SecurityConstraintsContextImpl. Instead, BaseElementImpl
+    // derives from SecurityConstraintsContextImpl and the context
+    // protocol is implemented on this object.
+
+    @Basic
+    @Column (name="OWNER_PRINCIPAL")
+    private String owner;
+    @OneToMany (targetEntity=FolderSecurityConstraintImpl.class, mappedBy="folder", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    @OrderBy (value="applyOrder ASC")
+    private List constraints;
+    @OneToMany (targetEntity=FolderSecurityConstraintsRef.class, mappedBy="folder", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    @OrderBy (value="applyOrder ASC")
+    private List constraintsRefs;
+
+    private void eagerFetchEmbeddedCollections()
+    {
+        if (constraints != null)
+        {
+            constraints.size();
+        }
+        if (constraintsRefs != null)
+        {
+            constraintsRefs.size();
+        }
+    }    
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecurityConstraints#getOwner()
+     */
+    public String getOwner()
+    {
+        return owner;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecurityConstraints#setOwner(java.lang.String)
+     */
+    public void setOwner(String owner)
+    {
+        // save new setting and reset cached security constraints
+        this.owner = owner;
+        clearAllSecurityConstraints();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.jpa.SecurityConstraintsContextImpl#accessConstraintsRefs()
+     */
+    protected List accessConstraintsRefs()
+    {
+        // create initial collection if necessary
+        if (constraintsRefs == null)
+        {
+            constraintsRefs = DatabasePageManagerUtils.createList();
+        }
+        return constraintsRefs;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.jpa.SecurityConstraintsContextImpl#accessConstraints()
+     */
+    protected List accessConstraints()
+    {
+        // create initial collection if necessary
+        if (constraints == null)
+        {
+            constraints = DatabasePageManagerUtils.createList();
+        }
+        return constraints;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.jpa.SecurityConstraintsContextImpl#getSecurityConstraintClass()
+     */
+    protected Class getSecurityConstraintClass()
+    {
+        return FolderSecurityConstraintImpl.class;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.jpa.SecurityConstraintsContextImpl#getSecurityConstraintsRefClass()
+     */
+    protected Class getSecurityConstraintsRefClass()
+    {
+        return FolderSecurityConstraintsRef.class;        
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.common.SecurityConstraints#isEmpty()
+     */
+    public boolean isEmpty()
+    {
+        // test only persistent members for any specified constraints
+        return ((owner == null) &&
+                ((constraints == null) || constraints.isEmpty()) &&
+                ((constraintsRefs == null) || constraintsRefs.isEmpty()));
+    }
+
+    // End Embedded SecurityConstraintsContextImpl
+    // **************************************************************************
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderMenuDefinitionElementList.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderMenuDefinitionElementList.java?rev=731466&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderMenuDefinitionElementList.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderMenuDefinitionElementList.java Sun Jan  4 22:04:13 2009
@@ -0,0 +1,147 @@
+/*
+ * 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.folder.jpa;
+
+import java.util.AbstractList;
+
+/**
+ * FolderMenuDefinitionElementList
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+class FolderMenuDefinitionElementList extends AbstractList
+{
+    private FolderMenuDefinitionImpl menuDefinition;
+
+    FolderMenuDefinitionElementList(FolderMenuDefinitionImpl menuDefinition)
+    {
+        super();
+        this.menuDefinition = menuDefinition;
+    }
+
+    /**
+     * validateMenuElementForAdd
+     *
+     * Validates element to be added to this list.
+     *
+     * @param menuElement element to add
+     * @return list element to add
+     */
+    private FolderBaseMenuDefinitionElement validateMenuElementForAdd(FolderBaseMenuDefinitionElement menuElement)
+    {
+        // validate element instance class
+        if (menuElement == null)
+        {
+            throw new NullPointerException("Unable to add null to list.");
+        }
+        return menuElement;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#add(int,java.lang.Object)
+     */
+    public synchronized void add(int index, Object element)
+    {
+        // implement for modifiable AbstractList:
+        // validate index
+        if ((index < 0) || (index > menuDefinition.accessElements().size()))
+        {
+            throw new IndexOutOfBoundsException("Unable to add to list at index: " + index);
+        }
+        // verify element
+        FolderBaseMenuDefinitionElement menuElement = validateMenuElementForAdd((FolderBaseMenuDefinitionElement)element);
+        // add to underlying ordered list
+        menuElement.setInverseRelationship(menuDefinition);
+        menuDefinition.accessElements().add(index, menuElement);
+        // set element order in added element
+        if (index > 0)
+        {
+            menuElement.setElementOrder(((FolderBaseMenuDefinitionElement)menuDefinition.accessElements().get(index-1)).getElementOrder() + 1);
+        }
+        else
+        {
+            menuElement.setElementOrder(0);
+        }
+        // maintain element order in subsequent elements
+        for (int i = index, limit = menuDefinition.accessElements().size() - 1; (i < limit); i++)
+        {
+            FolderBaseMenuDefinitionElement nextMenuElement = (FolderBaseMenuDefinitionElement)menuDefinition.accessElements().get(i + 1);
+            if (nextMenuElement.getElementOrder() <= menuElement.getElementOrder())
+            {
+                // adjust element order for next element
+                nextMenuElement.setElementOrder(menuElement.getElementOrder() + 1);
+                menuElement = nextMenuElement;
+            }
+            else
+            {
+                // element order maintained for remaining list elements
+                break;
+            }
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#get(int)
+     */
+    public synchronized Object get(int index)
+    {
+        // implement for modifiable AbstractList
+        return menuDefinition.accessElements().get(index);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#remove(int)
+     */
+    public synchronized Object remove(int index)
+    {
+        // implement for modifiable AbstractList
+        FolderBaseMenuDefinitionElement removed = (FolderBaseMenuDefinitionElement)menuDefinition.accessElements().remove(index);
+        if (removed != null)
+        {
+            removed.setInverseRelationship(null);
+        }
+        return removed;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#set(int,java.lang.Object)
+     */
+    public synchronized Object set(int index, Object element)
+    {
+        // implement for modifiable AbstractList:
+        // verify element
+        FolderBaseMenuDefinitionElement newMenuElement = validateMenuElementForAdd((FolderBaseMenuDefinitionElement)element);
+        // set in underlying ordered list
+        newMenuElement.setInverseRelationship(menuDefinition);
+        FolderBaseMenuDefinitionElement menuElement = (FolderBaseMenuDefinitionElement)menuDefinition.accessElements().set(index, newMenuElement);
+        menuElement.setInverseRelationship(null);
+        // set element order in new element
+        newMenuElement.setElementOrder(menuElement.getElementOrder());
+        // return element
+        return menuElement;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#size()
+     */
+    public synchronized int size()
+    {
+        // implement for modifiable AbstractList
+        return menuDefinition.accessElements().size();
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderMenuDefinitionImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderMenuDefinitionImpl.java?rev=731466&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderMenuDefinitionImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderMenuDefinitionImpl.java Sun Jan  4 22:04:13 2009
@@ -0,0 +1,370 @@
+/*
+ * 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.folder.jpa;
+
+import java.util.Collection;
+import java.util.List;
+
+import javax.persistence.Basic;
+import javax.persistence.CascadeType;
+import javax.persistence.Column;
+import javax.persistence.FetchType;
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
+import javax.persistence.OrderBy;
+import javax.persistence.PostLoad;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+
+import org.apache.jetspeed.om.folder.MenuDefinition;
+import org.apache.jetspeed.om.folder.jpa.FolderImpl;
+import org.apache.jetspeed.om.page.PageMetadataImpl;
+import org.apache.jetspeed.page.jpa.DatabasePageManagerUtils;
+
+/**
+ * FolderMenuDefinitionImpl
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id:$
+ */
+@Entity (name="FolderMenuDefinition")
+@Inheritance (strategy=InheritanceType.SINGLE_TABLE)
+@Table (name="FOLDER_MENU")
+@DiscriminatorColumn (name="CLASS_NAME")
+@DiscriminatorValue (value="org.apache.jetspeed.om.folder.impl.FolderMenuDefinitionImpl")
+public class FolderMenuDefinitionImpl extends FolderBaseMenuDefinitionMetadata implements MenuDefinition
+{
+    @ManyToOne (targetEntity=FolderImpl.class, fetch=FetchType.LAZY, optional=true)
+    @JoinColumn (name="FOLDER_ID", referencedColumnName="FOLDER_ID")
+    private FolderImpl folder;
+    @Basic
+    @Column (name="NAME")
+    private String name;
+    @Basic
+    @Column (name="OPTIONS")
+    private String options;
+    @Basic
+    @Column (name="DEPTH")
+    private int depth;
+    @Basic
+    @Column (name="IS_PATHS")
+    private boolean paths;
+    @Basic
+    @Column (name="IS_REGEXP")
+    private boolean regexp;
+    @Basic
+    @Column (name="PROFILE")
+    private String profile;
+    @Basic
+    @Column (name="OPTIONS_ORDER")
+    private String order;
+    @Basic
+    @Column (name="SKIN")
+    private String skin;
+    @Basic
+    @Column (name="TITLE")
+    private String title;
+    @Basic
+    @Column (name="SHORT_TITLE")
+    private String shortTitle;
+    @OneToMany (targetEntity=FolderBaseMenuDefinitionElement.class, mappedBy="parent", fetch=FetchType.LAZY, cascade=CascadeType.ALL)
+    @OrderBy (value="elementOrder ASC")
+    private List elements;
+
+    @PostLoad
+    private void eagerFetchCollections()
+    {
+        if (elements != null)
+        {
+            elements.size();
+        }
+    }
+    
+    @Transient
+    private FolderMenuDefinitionElementList menuElements;
+
+    /**
+     * Explicitly set inverse relationship when this object
+     * is added to a one-to-many collection. JPA does not
+     * manage bidirectional relationships.
+     * 
+     * @param inverse inverse relationship owning object.
+     */
+    public void setInverseTopLevelRelationship(Object inverse)
+    {
+        folder = (FolderImpl)inverse;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.jpa.FolderBaseMenuDefinitionMetadata#newPageMetadata()
+     */
+    public PageMetadataImpl newPageMetadata(Collection fields)
+    {
+        PageMetadataImpl pageMetadata = new PageMetadataImpl(FolderMenuMetadataLocalizedFieldImpl.class);
+        pageMetadata.setFields(fields);
+        return pageMetadata;
+    }
+
+    /**
+     * accessElements
+     *
+     * Access mutable persistent collection member for List wrappers.
+     *
+     * @return persistent collection
+     */
+    List accessElements()
+    {
+        // create initial collection if necessary
+        if (elements == null)
+        {
+            elements = DatabasePageManagerUtils.createList();
+        }
+        return elements;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuDefinition#getName()
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuDefinition#setName(java.lang.String)
+     */
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuDefinition#getOptions()
+     */
+    public String getOptions()
+    {
+        return options;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuDefinition#setOptions(java.lang.String)
+     */
+    public void setOptions(String options)
+    {
+        this.options = options;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuDefinition#getDepth()
+     */
+    public int getDepth()
+    {
+        return depth;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuDefinition#setDepth(int)
+     */
+    public void setDepth(int depth)
+    {
+        this.depth = depth;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuDefinition#getPaths()
+     */
+    public boolean isPaths()
+    {
+        return paths;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuDefinition#setPaths(boolean)
+     */
+    public void setPaths(boolean paths)
+    {
+        this.paths = paths;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuDefinition#getRegexp()
+     */
+    public boolean isRegexp()
+    {
+        return regexp;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuDefinition#setRegexp(boolean)
+     */
+    public void setRegexp(boolean regexp)
+    {
+        this.regexp = regexp;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuDefinition#getProfile()
+     */
+    public String getProfile()
+    {
+        return profile;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuDefinition#setProfile(java.lang.String)
+     */
+    public void setProfile(String locatorName)
+    {
+        profile = locatorName;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuDefinition#getOrder()
+     */
+    public String getOrder()
+    {
+        return order;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuDefinition#setOrder(java.lang.String)
+     */
+    public void setOrder(String order)
+    {
+        this.order = order;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuDefinition#getSkin()
+     */
+    public String getSkin()
+    {
+        return skin;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuDefinition#setSkin(java.lang.String)
+     */
+    public void setSkin(String name)
+    {
+        skin = name;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuDefinition#getTitle()
+     */
+    public String getTitle()
+    {
+        return title;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuDefinition#setTitle(java.lang.String)
+     */
+    public void setTitle(String title)
+    {
+        this.title = title;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuDefinition#getShortTitle()
+     */
+    public String getShortTitle()
+    {
+        return shortTitle; 
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuDefinition#setShortTitle(java.lang.String)
+     */
+    public void setShortTitle(String title)
+    {
+        this.shortTitle = title;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuDefinition#getMenuElements()
+     */
+    public List getMenuElements()
+    {
+        // return mutable menu element list
+        // by using list wrapper to manage
+        // element order
+        if (menuElements == null)
+        {
+            menuElements = new FolderMenuDefinitionElementList(this);
+        }
+        return menuElements;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuDefinition#setMenuElements(java.util.List)
+     */
+    public void setMenuElements(List elements)
+    {
+        // set menu elements by replacing
+        // existing entries with new elements if
+        // new collection is specified
+        List menuElements = getMenuElements();
+        if (elements != menuElements)
+        {
+            // replace all menu elements
+            menuElements.clear();
+            if (elements != null)
+            {
+                menuElements.addAll(elements);
+            }
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    public boolean equals(Object o)
+    {
+        if (o instanceof FolderMenuDefinitionImpl)
+        {
+            if (name != null)
+            {
+                return name.equals(((FolderMenuDefinitionImpl)o).getName());
+            }
+            else
+            {
+                return (((FolderMenuDefinitionImpl)o).getName() == null);
+            }
+        }
+        return false;
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#hashCode()
+     */
+    public int hashCode()
+    {
+        if (name != null)
+        {
+            return name.hashCode();
+        }
+        return 0;
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderMenuDefinitionList.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderMenuDefinitionList.java?rev=731466&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderMenuDefinitionList.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderMenuDefinitionList.java Sun Jan  4 22:04:13 2009
@@ -0,0 +1,182 @@
+/*
+ * 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.folder.jpa;
+
+import java.util.AbstractList;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * FolderMenuDefinitionList
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+class FolderMenuDefinitionList extends AbstractList
+{
+    private FolderImpl folder;
+
+    private List removedMenuDefinitions;
+
+    FolderMenuDefinitionList(FolderImpl folder)
+    {
+        super();
+        this.folder = folder;
+    }
+
+    /**
+     * validateDefinitionForAdd
+     *
+     * Validates menu definition to be added to this list.
+     *
+     * @param definition menu definition to add
+     * @return list element to add
+     */
+    private FolderMenuDefinitionImpl validateDefinitionForAdd(FolderMenuDefinitionImpl definition)
+    {
+        // only non-null definitions supported
+        if (definition == null)
+        {
+            throw new NullPointerException("Unable to add null to list.");
+        }
+        // make sure element is unique
+        if (folder.accessMenus().contains(definition))
+        {
+            throw new IllegalArgumentException("Unable to add duplicate entry to list: " + (definition).getName());
+        }
+        // retrieve from removed list to reuse
+        // previously removed element copying
+        // menu definition data
+        if (removedMenuDefinitions != null)
+        {
+            int removedIndex = removedMenuDefinitions.indexOf(definition);
+            if (removedIndex >= 0)
+            {
+                // reuse menu definition with matching name
+                FolderMenuDefinitionImpl addDefinition = definition;
+                definition = (FolderMenuDefinitionImpl)removedMenuDefinitions.remove(removedIndex);
+                // TODO: move this logic to copy methods on implementations
+                // copy menu definition members
+                definition.setOptions(addDefinition.getOptions());
+                definition.setDepth(addDefinition.getDepth());
+                definition.setPaths(addDefinition.isPaths());
+                definition.setRegexp(addDefinition.isRegexp());
+                definition.setProfile(addDefinition.getProfile());
+                definition.setOrder(addDefinition.getOrder());
+                definition.setSkin(addDefinition.getSkin());
+                definition.setTitle(addDefinition.getTitle());
+                definition.setShortTitle(addDefinition.getShortTitle());
+                definition.setMenuElements(addDefinition.getMenuElements());
+                // copy menu definition metadata members
+                // TODO: strengthen... this code is not robust
+                // and may fail if multiple edits without a db
+                // update occur and duplicate metadata members
+                // are removed in one operation and reinserted
+                // in a subsequent operation because the
+                // metadata members are required to be unique
+                // and a removal list is not maintained for the
+                // metadata fields collections yet
+                definition.getMetadata().copyFields(addDefinition.getMetadata().getFields());
+            }
+        }
+        return definition;
+    }
+
+    /**
+     * getRemovedMenuDefinitions
+     *
+     * @return removed menu definitions tracking collection
+     */
+    private List getRemovedMenuDefinitions()
+    {
+        if (removedMenuDefinitions == null)
+        {
+            removedMenuDefinitions = new ArrayList();
+        }
+        return removedMenuDefinitions;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#add(int,java.lang.Object)
+     */
+    public synchronized void add(int index, Object element)
+    {
+        // implement for modifiable AbstractList:
+        // validate index
+        if ((index < 0) || (index > folder.accessMenus().size()))
+        {
+            throw new IndexOutOfBoundsException("Unable to add to list at index: " + index);
+        }
+        // verify menu definition
+        FolderMenuDefinitionImpl definition = validateDefinitionForAdd((FolderMenuDefinitionImpl)element);
+        // add to underlying ordered list
+        definition.setInverseTopLevelRelationship(folder);
+        folder.accessMenus().add(index, definition);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#get(int)
+     */
+    public synchronized Object get(int index)
+    {
+        // implement for modifiable AbstractList
+        return folder.accessMenus().get(index);
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#remove(int)
+     */
+    public synchronized Object remove(int index)
+    {
+        // implement for modifiable AbstractList:
+        // save removed element 
+        FolderMenuDefinitionImpl removed = (FolderMenuDefinitionImpl)folder.accessMenus().remove(index);
+        if (removed != null)
+        {
+            removed.setInverseTopLevelRelationship(null);
+            getRemovedMenuDefinitions().add(removed);
+        }
+        return removed;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#set(int,java.lang.Object)
+     */
+    public synchronized Object set(int index, Object element)
+    {
+        // implement for modifiable AbstractList:
+        // verify menu definition
+        FolderMenuDefinitionImpl newDefinition = validateDefinitionForAdd((FolderMenuDefinitionImpl)element);
+        // set in underlying ordered list
+        newDefinition.setInverseTopLevelRelationship(folder);
+        FolderMenuDefinitionImpl definition = (FolderMenuDefinitionImpl)folder.accessMenus().set(index, newDefinition);
+        definition.setInverseTopLevelRelationship(null);
+        // save replaced element
+        getRemovedMenuDefinitions().add(definition);
+        // return menu definition
+        return definition;
+    }
+
+    /* (non-Javadoc)
+     * @see java.util.List#size()
+     */
+    public synchronized int size()
+    {
+        // implement for modifiable AbstractList
+        return folder.accessMenus().size();
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderMenuExcludeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderMenuExcludeDefinitionImpl.java?rev=731466&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderMenuExcludeDefinitionImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderMenuExcludeDefinitionImpl.java Sun Jan  4 22:04:13 2009
@@ -0,0 +1,62 @@
+/*
+ * 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.folder.jpa;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+
+import org.apache.jetspeed.om.folder.MenuExcludeDefinition;
+
+/**
+ * FolderMenuExcludeDefinitionImpl
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id:$
+ */
+@Entity (name="FolderMenuExcludeDefinition")
+@Inheritance (strategy=InheritanceType.SINGLE_TABLE)
+@Table (name="FOLDER_MENU")
+@DiscriminatorColumn (name="CLASS_NAME")
+@DiscriminatorValue (value="org.apache.jetspeed.om.folder.impl.FolderMenuExcludeDefinitionImpl")
+public class FolderMenuExcludeDefinitionImpl extends FolderBaseMenuDefinitionElement implements MenuExcludeDefinition
+{
+    @Basic
+    @Column (name="NAME")
+    private String name;
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuExcludeDefinition#getName()
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuExcludeDefinition#setName(java.lang.String)
+     */
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderMenuIncludeDefinitionImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderMenuIncludeDefinitionImpl.java?rev=731466&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderMenuIncludeDefinitionImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderMenuIncludeDefinitionImpl.java Sun Jan  4 22:04:13 2009
@@ -0,0 +1,81 @@
+/*
+ * 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.folder.jpa;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+
+import org.apache.jetspeed.om.folder.MenuIncludeDefinition;
+
+/**
+ * FolderMenuIncludeDefinitionImpl
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id:$
+ */
+@Entity (name="FolderMenuIncludeDefinition")
+@Inheritance (strategy=InheritanceType.SINGLE_TABLE)
+@Table (name="FOLDER_MENU")
+@DiscriminatorColumn (name="CLASS_NAME")
+@DiscriminatorValue (value="org.apache.jetspeed.om.folder.impl.FolderMenuIncludeDefinitionImpl")
+public class FolderMenuIncludeDefinitionImpl extends FolderBaseMenuDefinitionElement implements MenuIncludeDefinition
+{
+    @Basic
+    @Column (name="NAME")
+    private String name;
+    @Basic
+    @Column (name="IS_NEST")
+    private boolean nest;
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuIncludeDefinition#getName()
+     */
+    public String getName()
+    {
+        return name;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuIncludeDefinition#setName(java.lang.String)
+     */
+    public void setName(String name)
+    {
+        this.name = name;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuIncludeDefinition#isNest()
+     */
+    public boolean isNest()
+    {
+        return nest;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuIncludeDefinition#setNest(boolean)
+     */
+    public void setNest(boolean nest)
+    {
+        this.nest = nest;
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderMenuMetadataLocalizedFieldImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderMenuMetadataLocalizedFieldImpl.java?rev=731466&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderMenuMetadataLocalizedFieldImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderMenuMetadataLocalizedFieldImpl.java Sun Jan  4 22:04:13 2009
@@ -0,0 +1,53 @@
+/*
+ * 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.folder.jpa;
+
+import javax.persistence.Entity;
+import javax.persistence.FetchType;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
+import javax.persistence.Table;
+
+import org.apache.jetspeed.om.page.jpa.BaseMetadataLocalizedFieldImpl;
+
+/**
+ * FolderMenuMetadataLocalizedFieldImpl
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+@Entity (name="FolderMenuMetadata")
+@Inheritance (strategy=InheritanceType.TABLE_PER_CLASS)
+@Table (name="FOLDER_MENU_METADATA")
+public class FolderMenuMetadataLocalizedFieldImpl extends BaseMetadataLocalizedFieldImpl
+{
+    // new class defined only to facilitate JPA table/class mapping
+
+    @ManyToOne (targetEntity=FolderBaseMenuDefinitionMetadata.class, fetch=FetchType.LAZY, optional=false)
+    @JoinColumn (name="MENU_ID", referencedColumnName="MENU_ID")
+    private FolderBaseMenuDefinitionMetadata menu;
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.jpa.BaseMetadataLocalizedFieldImpl#setInverseRelationship(java.lang.Object)
+     */
+    public void setInverseRelationship(Object inverse)
+    {
+        menu = (FolderBaseMenuDefinitionMetadata)inverse;
+    }
+}

Added: portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderMenuOptionsDefinitionImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderMenuOptionsDefinitionImpl.java?rev=731466&view=auto
==============================================================================
--- portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderMenuOptionsDefinitionImpl.java (added)
+++ portals/jetspeed-2/portal/branches/JPA_BRANCH/components/jetspeed-page-manager/src/main/java/org/apache/jetspeed/om/folder/jpa/FolderMenuOptionsDefinitionImpl.java Sun Jan  4 22:04:13 2009
@@ -0,0 +1,176 @@
+/*
+ * 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.folder.jpa;
+
+import javax.persistence.Basic;
+import javax.persistence.Column;
+import javax.persistence.DiscriminatorColumn;
+import javax.persistence.DiscriminatorValue;
+import javax.persistence.Entity;
+import javax.persistence.Inheritance;
+import javax.persistence.InheritanceType;
+import javax.persistence.Table;
+
+import org.apache.jetspeed.om.folder.MenuOptionsDefinition;
+
+/**
+ * FolderMenuOptionsDefinitionImpl
+ * 
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id:$
+ */
+@Entity (name="FolderMenuOptionsDefinition")
+@Inheritance (strategy=InheritanceType.SINGLE_TABLE)
+@Table (name="FOLDER_MENU")
+@DiscriminatorColumn (name="CLASS_NAME")
+@DiscriminatorValue (value="org.apache.jetspeed.om.folder.impl.FolderMenuOptionsDefinitionImpl")
+public class FolderMenuOptionsDefinitionImpl extends FolderBaseMenuDefinitionElement implements MenuOptionsDefinition
+{
+    @Basic
+    @Column (name="OPTIONS")
+    private String options;
+    @Basic
+    @Column (name="DEPTH")
+    private int depth;
+    @Basic
+    @Column (name="IS_PATHS")
+    private boolean paths;
+    @Basic
+    @Column (name="IS_REGEXP")
+    private boolean regexp;
+    @Basic
+    @Column (name="PROFILE")
+    private String profile;
+    @Basic
+    @Column (name="OPTIONS_ORDER")
+    private String order;
+    @Basic
+    @Column (name="SKIN")
+    private String skin;
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuOptionsDefinition#getOptions()
+     */
+    public String getOptions()
+    {
+        return options;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuOptionsDefinition#setOptions(java.lang.String)
+     */
+    public void setOptions(String options)
+    {
+        this.options = options;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuOptionsDefinition#getDepth()
+     */
+    public int getDepth()
+    {
+        return depth;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuOptionsDefinition#setDepth(int)
+     */
+    public void setDepth(int depth)
+    {
+        this.depth = depth;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuOptionsDefinition#isPaths()
+     */
+    public boolean isPaths()
+    {
+        return paths;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuOptionsDefinition#setPaths(boolean)
+     */
+    public void setPaths(boolean paths)
+    {
+        this.paths = paths;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuOptionsDefinition#isRegexp()
+     */
+    public boolean isRegexp()
+    {
+        return regexp;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuOptionsDefinition#setRegexp(boolean)
+     */
+    public void setRegexp(boolean regexp)
+    {
+        this.regexp = regexp;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuOptionsDefinition#getProfile()
+     */
+    public String getProfile()
+    {
+        return profile;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuOptionsDefinition#setProfile(java.lang.String)
+     */
+    public void setProfile(String locatorName)
+    {
+        profile = locatorName;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuOptionsDefinition#getOrder()
+     */
+    public String getOrder()
+    {
+        return order;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuOptionsDefinition#setOrder(java.lang.String)
+     */
+    public void setOrder(String order)
+    {
+        this.order = order;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuOptionsDefinition#getSkin()
+     */
+    public String getSkin()
+    {
+        return skin;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.folder.MenuOptionsDefinition#setSkin(java.lang.String)
+     */
+    public void setSkin(String name)
+    {
+        skin = name;
+    }
+}



---------------------------------------------------------------------
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