You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by rw...@apache.org on 2005/12/04 08:11:24 UTC

svn commit: r353827 - in /portals/jetspeed-2/trunk: components/page-manager/src/java/JETSPEED-INF/ojb/ components/page-manager/src/java/org/apache/jetspeed/om/folder/impl/ components/page-manager/src/java/org/apache/jetspeed/om/page/impl/ components/pa...

Author: rwatler
Date: Sat Dec  3 23:11:13 2005
New Revision: 353827

URL: http://svn.apache.org/viewcvs?rev=353827&view=rev
Log:
- Add support for Link to DB PageManager implementation
- Add required newLink*() om instance constructor methods to PageManager API


Added:
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/LinkImpl.java   (with props)
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/LinkMetadataLocalizedFieldImpl.java   (with props)
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/LinkSecurityConstraintImpl.java   (with props)
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/LinkSecurityConstraintsImpl.java   (with props)
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/LinkSecurityConstraintsRef.java   (with props)
Modified:
    portals/jetspeed-2/trunk/components/page-manager/src/java/JETSPEED-INF/ojb/page-manager-repository.xml
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/folder/impl/FolderImpl.java
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/SecurityConstraintsRefList.java
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/AbstractPageManager.java
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManager.java
    portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/psml/CastorXmlPageManager.java
    portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestDatabasePageManager.java
    portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestSecureDatabasePageManager.java
    portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestSecurePermissionsDatabasePageManager.java
    portals/jetspeed-2/trunk/etc/schema/phase2-schema.xml
    portals/jetspeed-2/trunk/etc/sql/derby/schema/phase2-schema.sql
    portals/jetspeed-2/trunk/etc/sql/drop.sql
    portals/jetspeed-2/trunk/etc/sql/oracle/drop.sql
    portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/page/PageManager.java

Modified: portals/jetspeed-2/trunk/components/page-manager/src/java/JETSPEED-INF/ojb/page-manager-repository.xml
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/JETSPEED-INF/ojb/page-manager-repository.xml?rev=353827&r1=353826&r2=353827&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/JETSPEED-INF/ojb/page-manager-repository.xml (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/JETSPEED-INF/ojb/page-manager-repository.xml Sat Dec  3 23:11:13 2005
@@ -75,6 +75,18 @@
       </collection-descriptor>
 
       <collection-descriptor
+          name="links"
+          element-class-ref="org.apache.jetspeed.om.page.impl.LinkImpl"
+          auto-retrieve="true"
+          auto-delete="object"
+          auto-update="object"
+          proxy="true"
+      >
+         <orderby name="name" sort="ASC"/>
+         <inverse-foreignkey field-ref="parentId"/>
+      </collection-descriptor>
+
+      <collection-descriptor
           name="pageSecurity"
           element-class-ref="org.apache.jetspeed.om.page.impl.PageSecurityImpl"
           auto-retrieve="true"
@@ -1828,6 +1840,305 @@
       <field-descriptor
          name="value"
          column="VALUE"
+         jdbc-type="VARCHAR"
+      />
+   </class-descriptor>
+
+   <!-- Link mapping -->
+
+   <class-descriptor
+      class="org.apache.jetspeed.om.page.impl.LinkImpl"
+      table="LINK"
+   >
+      <object-cache class="org.apache.jetspeed.page.impl.DatabasePageManagerCache"/>
+
+      <field-descriptor
+         name="id"
+         column="LINK_ID"
+         jdbc-type="INTEGER"
+         primarykey="true"
+         autoincrement="true"
+      />
+
+      <field-descriptor
+        name="parentId"
+        column="PARENT_ID"
+        jdbc-type="INTEGER"
+        access="anonymous"
+      />
+
+      <reference-descriptor
+          name="parent"
+          class-ref="org.apache.jetspeed.om.folder.impl.FolderImpl"
+          auto-retrieve="true"
+          auto-delete="none"
+          auto-update="none"
+          proxy="true"
+          >
+         <foreignkey field-ref="parentId"/>
+      </reference-descriptor>
+
+      <collection-descriptor
+          name="metadataFields"
+          element-class-ref="org.apache.jetspeed.om.page.impl.LinkMetadataLocalizedFieldImpl"
+          auto-retrieve="true"
+          auto-delete="object"
+          auto-update="object"
+          proxy="true"
+      >
+         <inverse-foreignkey field-ref="pageId"/>
+      </collection-descriptor>
+
+      <field-descriptor
+         name="path"
+         column="PATH"
+         jdbc-type="VARCHAR"
+      />
+
+      <field-descriptor
+         name="name"
+         column="NAME"
+         jdbc-type="VARCHAR"
+      />
+
+      <field-descriptor
+         name="version"
+         column="VERSION"
+         jdbc-type="VARCHAR"
+      />
+
+      <field-descriptor
+         name="title"
+         column="TITLE"
+         jdbc-type="VARCHAR"
+      />
+
+      <field-descriptor
+         name="shortTitle"
+         column="SHORT_TITLE"
+         jdbc-type="VARCHAR"
+      />
+
+      <field-descriptor
+         name="hidden"
+         column="IS_HIDDEN"
+         jdbc-type="INTEGER"
+         conversion="org.apache.ojb.broker.accesslayer.conversions.Boolean2IntFieldConversion"
+      />
+
+      <field-descriptor
+         name="target"
+         column="TARGET"
+         jdbc-type="VARCHAR"
+      />
+
+      <field-descriptor
+         name="url"
+         column="URL"
+         jdbc-type="VARCHAR"
+      />
+
+      <field-descriptor
+         name="subsite"
+         column="SUBSITE"
+         jdbc-type="VARCHAR"
+      />
+
+      <field-descriptor
+         name="user"
+         column="USER_PRINCIPAL"
+         jdbc-type="VARCHAR"
+      />
+
+      <field-descriptor
+         name="role"
+         column="ROLE_PRINCIPAL"
+         jdbc-type="VARCHAR"
+      />
+
+      <field-descriptor
+         name="group"
+         column="GROUP_PRINCIPAL"
+         jdbc-type="VARCHAR"
+      />
+
+      <field-descriptor
+         name="mediatype"
+         column="MEDIATYPE"
+         jdbc-type="VARCHAR"
+      />
+
+      <field-descriptor
+         name="locale"
+         column="LOCALE"
+         jdbc-type="VARCHAR"
+      />
+
+      <field-descriptor
+         name="extendedAttributeName"
+         column="EXT_ATTR_NAME"
+         jdbc-type="VARCHAR"
+      />
+
+      <field-descriptor
+         name="extendedAttributeValue"
+         column="EXT_ATTR_VALUE"
+         jdbc-type="VARCHAR"
+      />
+
+      <field-descriptor
+         name="constraints::owner"
+         column="OWNER_PRINCIPAL"
+         jdbc-type="VARCHAR"
+      />
+
+      <collection-descriptor
+          name="constraints::constraints"
+          element-class-ref="org.apache.jetspeed.om.page.impl.LinkSecurityConstraintImpl"
+          auto-retrieve="true"
+          auto-delete="object"
+          auto-update="object"
+          proxy="true"
+      >
+         <orderby name="applyOrder" sort="ASC"/>
+         <inverse-foreignkey field-ref="pageId"/>
+      </collection-descriptor>
+
+      <collection-descriptor
+          name="constraints::constraintsRefs"
+          element-class-ref="org.apache.jetspeed.om.page.impl.LinkSecurityConstraintsRef"
+          auto-retrieve="true"
+          auto-delete="object"
+          auto-update="object"
+          proxy="true"
+      >
+         <orderby name="applyOrder" sort="ASC"/>
+         <inverse-foreignkey field-ref="pageId"/>
+      </collection-descriptor>
+
+   </class-descriptor>
+
+   <class-descriptor
+      class="org.apache.jetspeed.om.page.impl.LinkMetadataLocalizedFieldImpl"
+      table="LINK_METADATA"
+   >
+      <field-descriptor
+         name="id"
+         column="METADATA_ID"
+         jdbc-type="INTEGER"
+         primarykey="true"
+         autoincrement="true"
+      />
+
+      <field-descriptor
+        name="pageId"
+        column="LINK_ID"
+        jdbc-type="INTEGER"
+        access="anonymous"
+      />
+
+      <field-descriptor
+         name="name"
+         column="NAME"
+         jdbc-type="VARCHAR"
+      />
+
+      <field-descriptor
+         name="locale"
+         column="LOCALE"
+         jdbc-type="VARCHAR"
+         conversion="org.apache.jetspeed.util.ojb.LocaleFieldConversion"
+      />
+
+      <field-descriptor
+         name="value"
+         column="VALUE"
+         jdbc-type="VARCHAR"
+      />
+   </class-descriptor>
+
+   <class-descriptor
+      class="org.apache.jetspeed.om.page.impl.LinkSecurityConstraintImpl"
+      table="LINK_CONSTRAINT"
+   >
+      <field-descriptor
+         name="id"
+         column="CONSTRAINT_ID"
+         jdbc-type="INTEGER"
+         primarykey="true"
+         autoincrement="true"
+      />
+
+      <field-descriptor
+        name="pageId"
+        column="LINK_ID"
+        jdbc-type="INTEGER"
+        access="anonymous"
+      />
+
+      <field-descriptor
+         name="applyOrder"
+         column="APPLY_ORDER"
+         jdbc-type="INTEGER"
+      />
+
+      <field-descriptor
+         name="usersList"
+         column="USER_PRINCIPALS_ACL"
+         jdbc-type="VARCHAR"
+         conversion="org.apache.jetspeed.util.ojb.CSVtoCollectionFieldConversion"
+      />
+
+      <field-descriptor
+         name="rolesList"
+         column="ROLE_PRINCIPALS_ACL"
+         jdbc-type="VARCHAR"
+         conversion="org.apache.jetspeed.util.ojb.CSVtoCollectionFieldConversion"
+      />
+
+      <field-descriptor
+         name="groupsList"
+         column="GROUP_PRINCIPALS_ACL"
+         jdbc-type="VARCHAR"
+         conversion="org.apache.jetspeed.util.ojb.CSVtoCollectionFieldConversion"
+      />
+
+      <field-descriptor
+         name="permissionsList"
+         column="PERMISSIONS_ACL"
+         jdbc-type="VARCHAR"
+         conversion="org.apache.jetspeed.util.ojb.CSVtoCollectionFieldConversion"
+      />
+   </class-descriptor>
+
+   <class-descriptor
+      class="org.apache.jetspeed.om.page.impl.LinkSecurityConstraintsRef"
+      table="LINK_CONSTRAINTS_REF"
+   >
+      <field-descriptor
+         name="id"
+         column="CONSTRAINTS_REF_ID"
+         jdbc-type="INTEGER"
+         primarykey="true"
+         autoincrement="true"
+      />
+
+      <field-descriptor
+        name="pageId"
+        column="LINK_ID"
+        jdbc-type="INTEGER"
+        access="anonymous"
+      />
+
+      <field-descriptor
+         name="applyOrder"
+         column="APPLY_ORDER"
+         jdbc-type="INTEGER"
+      />
+
+      <field-descriptor
+         name="name"
+         column="NAME"
          jdbc-type="VARCHAR"
       />
    </class-descriptor>

Modified: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/folder/impl/FolderImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/folder/impl/FolderImpl.java?rev=353827&r1=353826&r2=353827&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/folder/impl/FolderImpl.java (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/folder/impl/FolderImpl.java Sat Dec  3 23:11:13 2005
@@ -35,6 +35,7 @@
 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.impl.LinkImpl;
 import org.apache.jetspeed.om.page.impl.PageImpl;
 import org.apache.jetspeed.om.page.impl.PageSecurityImpl;
 import org.apache.jetspeed.page.PageNotFoundException;
@@ -59,6 +60,7 @@
     private String defaultPage;
     private List folders;
     private List pages;
+    private List links;
     private List pageSecurity;
     private List orders;
     private List menus;
@@ -69,6 +71,7 @@
     private NodeSet allNodeSet;
     private NodeSet foldersNodeSet;
     private NodeSet pagesNodeSet;
+    private NodeSet linksNodeSet;
     private FolderMenuDefinitionList menuDefinitions;
 
     public FolderImpl()
@@ -193,6 +196,47 @@
     }
 
     /**
+     * addLink
+     *
+     * Adds a link to the persistent collection and resets cached node sets.
+     *
+     * @param link new link impl
+     */
+    public void addLink(LinkImpl newLink)
+    {
+        // add to links collection
+        if (links == null)
+        {
+            links = new ArrayList(4);
+        }
+        links.add(newLink);
+
+        // reset cached node sets
+        allNodeSet = null;
+        linksNodeSet = null;
+    }
+    
+    /**
+     * removeLink
+     *
+     * Removes a link to the persistent collection and resets cached node sets.
+     *
+     * @param link remove link impl
+     */
+    public void removeLink(LinkImpl removeLink)
+    {
+        // remove from links collection
+        if (links != null)
+        {
+            links.remove(removeLink);
+        }
+
+        // reset cached node sets
+        allNodeSet = null;
+        linksNodeSet = null;
+    }
+
+    /**
      * setPageSecurity
      *
      * Sets the single page security in the persistent collection and resets cached node sets.
@@ -469,7 +513,8 @@
      */
     public NodeSet getLinks() throws NodeException
     {
-        return null; // NYI
+        // return nodes with view access
+        return filterNodeSetByAccess(getLinksNodeSet());
     }
     
     /* (non-Javadoc)
@@ -477,7 +522,17 @@
      */
     public Link getLink(String name) throws DocumentNotFoundException, NodeException
     {
-        return null; // NYI
+        // select link by name
+        Link link = (Link)getLinksNodeSet().get(name);
+        if (link == null)
+        {
+            throw new DocumentNotFoundException("Link not found: " + name);
+        }
+
+        // check for view access on link
+        link.checkAccess(SecuredResource.VIEW_ACTION);
+
+        return link;
     }
     
     /* (non-Javadoc)
@@ -655,6 +710,29 @@
     }
     
     /**
+     * getLinksNodeSet
+     *
+     * Latently create and access links node set.
+     *
+     * @return folders node set
+     */
+    private NodeSet getLinksNodeSet() throws NodeException
+    {
+        if (linksNodeSet == null)
+        {
+            if (links != null)
+            {
+                linksNodeSet = new NodeSetImpl(links, createDocumentOrderComparator());
+            }
+            else
+            {
+                linksNodeSet = NodeSetImpl.EMPTY_NODE_SET;
+            }
+        }
+        return linksNodeSet;
+    }
+    
+    /**
      * getAllNodeSet
      *
      * Latently create and access all nodes node set.
@@ -673,6 +751,10 @@
             if (pages != null)
             {
                 all.addAll(pages);
+            }
+            if (links != null)
+            {
+                all.addAll(links);
             }
             if (pageSecurity != null)
             {

Added: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/LinkImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/LinkImpl.java?rev=353827&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/LinkImpl.java (added)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/LinkImpl.java Sat Dec  3 23:11:13 2005
@@ -0,0 +1,101 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed 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 java.util.Collection;
+
+import org.apache.jetspeed.om.page.Link;
+import org.apache.jetspeed.om.page.PageMetadataImpl;
+import org.apache.jetspeed.page.document.impl.DocumentImpl;
+
+/**
+ * LinkImpl
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class LinkImpl extends DocumentImpl implements Link
+{
+    private String target;
+    private String url;
+
+    public LinkImpl()
+    {
+        super(new LinkSecurityConstraintsImpl());
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.document.impl.NodeImpl#newPageMetadata(java.util.Collection)
+     */
+    public PageMetadataImpl newPageMetadata(Collection fields)
+    {
+        PageMetadataImpl pageMetadata = new PageMetadataImpl(LinkMetadataLocalizedFieldImpl.class);
+        pageMetadata.setFields(fields);
+        return pageMetadata;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.impl.BaseElementImpl#grantViewActionAccess()
+     */
+    public boolean grantViewActionAccess()
+    {
+        // always allow links that reference absolute urls since these
+        // are probably not a security related concern but rather
+        // should always be viewable, (subject to folder access)
+        String hrefUrl = getUrl();
+        return ((hrefUrl != null) && (hrefUrl.startsWith("http://") || hrefUrl.startsWith("https://")));
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.document.Node#getUrl()
+     */
+    public String getUrl()
+    {
+        return url;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Link#setUrl(java.lang.String)
+     */
+    public void setUrl(String url)
+    {
+        this.url = url;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Link#getTarget()
+     */
+    public String getTarget()
+    {
+        return target;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.Link#setTarget(java.lang.String)
+     */
+    public void setTarget(String target)
+    {
+        this.target = target;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.document.Node#getType()
+     */
+    public String getType()
+    {
+        return DOCUMENT_TYPE;
+    }
+}

Propchange: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/LinkImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/LinkMetadataLocalizedFieldImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/LinkMetadataLocalizedFieldImpl.java?rev=353827&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/LinkMetadataLocalizedFieldImpl.java (added)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/LinkMetadataLocalizedFieldImpl.java Sat Dec  3 23:11:13 2005
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed 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.PageLocalizedFieldImpl;
+
+/**
+ * LinkMetadataLocalizedFieldImpl
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class LinkMetadataLocalizedFieldImpl extends PageLocalizedFieldImpl
+{
+    // new class defined only to facilitate OJB table/class mapping
+}

Propchange: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/LinkMetadataLocalizedFieldImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/LinkSecurityConstraintImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/LinkSecurityConstraintImpl.java?rev=353827&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/LinkSecurityConstraintImpl.java (added)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/LinkSecurityConstraintImpl.java Sat Dec  3 23:11:13 2005
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed 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.SecurityConstraintImpl;
+
+/**
+ * LinkSecurityConstraintImpl
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class LinkSecurityConstraintImpl extends SecurityConstraintImpl
+{
+    // new class defined only to facilitate OJB table/class mapping
+}

Propchange: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/LinkSecurityConstraintImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/LinkSecurityConstraintsImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/LinkSecurityConstraintsImpl.java?rev=353827&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/LinkSecurityConstraintsImpl.java (added)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/LinkSecurityConstraintsImpl.java Sat Dec  3 23:11:13 2005
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed 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;
+
+/**
+ * LinkSecurityConstraintsImpl
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class LinkSecurityConstraintsImpl extends SecurityConstraintsImpl
+{
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.impl.SecurityConstraintsImpl#getSecurityConstraintClass()
+     */
+    public Class getSecurityConstraintClass()
+    {
+        return LinkSecurityConstraintImpl.class;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jetspeed.om.page.impl.SecurityConstraintsImpl#getSecurityConstraintsRefClass()
+     */
+    public Class getSecurityConstraintsRefClass()
+    {
+        return LinkSecurityConstraintsRef.class;
+    }
+}

Propchange: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/LinkSecurityConstraintsImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/LinkSecurityConstraintsRef.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/LinkSecurityConstraintsRef.java?rev=353827&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/LinkSecurityConstraintsRef.java (added)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/LinkSecurityConstraintsRef.java Sat Dec  3 23:11:13 2005
@@ -0,0 +1,27 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ * 
+ * Licensed 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;
+
+/**
+ * LinkSecurityConstraintsRef
+ *
+ * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
+ * @version $Id$
+ */
+public class LinkSecurityConstraintsRef extends BaseSecurityConstraintsRef
+{
+    // new class defined only to facilitate OJB table/class mapping
+}

Propchange: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/LinkSecurityConstraintsRef.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/SecurityConstraintsRefList.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/SecurityConstraintsRefList.java?rev=353827&r1=353826&r2=353827&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/SecurityConstraintsRefList.java (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/om/page/impl/SecurityConstraintsRefList.java Sat Dec  3 23:11:13 2005
@@ -53,11 +53,11 @@
         {
             throw new NullPointerException("Unable to add null to list.");
         }
-        // wrap constraints ref name string
+        // wrap constraints ref name string; use
+        // specific constraints ref name string wrapper
         BaseSecurityConstraintsRef constraintsRef = null;
         if (constraints.getSecurityConstraintsRefClass() != null)
         {
-            // use specific constraints ref name string wrapper
             try
             {
                 constraintsRef = (BaseSecurityConstraintsRef)constraints.getSecurityConstraintsRefClass().newInstance();
@@ -73,7 +73,6 @@
         }
         else
         {
-            // use generic constraints ref name string wrapper
             constraintsRef = new BaseSecurityConstraintsRef();
         }
         constraintsRef.setName(name);

Modified: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/AbstractPageManager.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/AbstractPageManager.java?rev=353827&r1=353826&r2=353827&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/AbstractPageManager.java (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/AbstractPageManager.java Sat Dec  3 23:11:13 2005
@@ -73,6 +73,7 @@
     protected Class folderSecurityConstraintClass;
     protected Class pageSecurityConstraintClass;
     protected Class fragmentSecurityConstraintClass;
+    protected Class linkSecurityConstraintClass;
     protected Class pageSecuritySecurityConstraintClass;
     protected Class securityConstraintsDefClass;
     protected Class fragmentPreferenceClass;
@@ -112,6 +113,7 @@
         this.folderSecurityConstraintClass = (Class)modelClasses.get("FolderSecurityConstraintImpl");
         this.pageSecurityConstraintClass = (Class)modelClasses.get("PageSecurityConstraintImpl");
         this.fragmentSecurityConstraintClass = (Class)modelClasses.get("FragmentSecurityConstraintImpl");
+        this.linkSecurityConstraintClass = (Class)modelClasses.get("LinkSecurityConstraintImpl");
         this.pageSecuritySecurityConstraintClass = (Class)modelClasses.get("PageSecuritySecurityConstraintImpl");
         this.securityConstraintsDefClass = (Class)modelClasses.get("SecurityConstraintsDefImpl");
         this.fragmentPreferenceClass = (Class)modelClasses.get("FragmentPreferenceImpl");
@@ -544,6 +546,25 @@
         catch (ClassCastException e)
         {
             String message = "Failed to create security constraint definition object for " + this.fragmentSecurityConstraintClass;
+            log.error(message, e);
+        }
+        return null;
+    }
+
+    /**
+     * newLinkSecurityConstraint - creates a new security constraint definition
+     *
+     * @return a newly created SecurityConstraint object
+     */
+    public SecurityConstraint newLinkSecurityConstraint()
+    {
+        try
+        {
+            return (SecurityConstraint)createObject(this.linkSecurityConstraintClass);
+        }
+        catch (ClassCastException e)
+        {
+            String message = "Failed to create security constraint definition object for " + this.linkSecurityConstraintClass;
             log.error(message, e);
         }
         return null;

Modified: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManager.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManager.java?rev=353827&r1=353826&r2=353827&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManager.java (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/impl/DatabasePageManager.java Sat Dec  3 23:11:13 2005
@@ -48,6 +48,8 @@
 import org.apache.jetspeed.om.page.impl.FragmentImpl;
 import org.apache.jetspeed.om.page.impl.FragmentPreferenceImpl;
 import org.apache.jetspeed.om.page.impl.FragmentSecurityConstraintImpl;
+import org.apache.jetspeed.om.page.impl.LinkImpl;
+import org.apache.jetspeed.om.page.impl.LinkSecurityConstraintImpl;
 import org.apache.jetspeed.om.page.impl.PageImpl;
 import org.apache.jetspeed.om.page.impl.PageMenuDefinitionImpl;
 import org.apache.jetspeed.om.page.impl.PageMenuExcludeDefinitionImpl;
@@ -100,7 +102,7 @@
         modelClasses.put("FragmentImpl", FragmentImpl.class);
         modelClasses.put("PageImpl", PageImpl.class);
         modelClasses.put("FolderImpl", FolderImpl.class);
-        //modelClasses.put("LinkImpl", LinkImpl.class);
+        modelClasses.put("LinkImpl", LinkImpl.class);
         modelClasses.put("PageSecurityImpl", PageSecurityImpl.class);
         modelClasses.put("FolderMenuDefinitionImpl", FolderMenuDefinitionImpl.class);
         modelClasses.put("FolderMenuExcludeDefinitionImpl", FolderMenuExcludeDefinitionImpl.class);
@@ -116,6 +118,7 @@
         modelClasses.put("FolderSecurityConstraintImpl", FolderSecurityConstraintImpl.class);
         modelClasses.put("PageSecurityConstraintImpl", PageSecurityConstraintImpl.class);
         modelClasses.put("FragmentSecurityConstraintImpl", FragmentSecurityConstraintImpl.class);
+        modelClasses.put("LinkSecurityConstraintImpl", LinkSecurityConstraintImpl.class);
         modelClasses.put("PageSecuritySecurityConstraintImpl", PageSecuritySecurityConstraintImpl.class);
         modelClasses.put("SecurityConstraintsDefImpl", SecurityConstraintsDefImpl.class);
         modelClasses.put("FragmentPreferenceImpl", FragmentPreferenceImpl.class);
@@ -348,6 +351,14 @@
     }
 
     /* (non-Javadoc)
+     * @see org.apache.jetspeed.page.PageManager#newLinkSecurityConstraint()
+     */
+    public SecurityConstraint newLinkSecurityConstraint()
+    {
+        return delegator.newLinkSecurityConstraint();
+    }
+
+    /* (non-Javadoc)
      * @see org.apache.jetspeed.page.PageManager#newPageSecuritySecurityConstraint()
      */
     public SecurityConstraint newPageSecuritySecurityConstraint()
@@ -462,10 +473,52 @@
     /* (non-Javadoc)
      * @see org.apache.jetspeed.page.PageManager#getLink(java.lang.String)
      */
-    public Link getLink(String name) throws DocumentNotFoundException, UnsupportedDocumentTypeException, FolderNotFoundException, NodeException
+    public Link getLink(String path) throws DocumentNotFoundException, UnsupportedDocumentTypeException, FolderNotFoundException, NodeException
     {
-        // TODO Auto-generated method stub
-        return null;
+        // construct link attributes from path
+        path = NodeImpl.getCanonicalNodePath(path);
+
+        // optimized retrieval from cache by path if available
+        NodeImpl cachedNode = DatabasePageManagerCache.cacheLookup(path);
+        if (cachedNode instanceof Link)
+        {
+            // check for view access on link
+            cachedNode.checkAccess(SecuredResource.VIEW_ACTION);
+
+            return (Link)cachedNode;
+        }
+
+        // retrieve link from database
+        try
+        {
+            Criteria filter = new Criteria();
+            filter.addEqualTo("path", path);
+            QueryByCriteria query = QueryFactory.newQuery(LinkImpl.class, filter);
+            Link link = (Link) getPersistenceBrokerTemplate().getObjectByQuery(query);
+            
+            // return link or throw exception
+            if (link == null)
+            {
+                throw new DocumentNotFoundException("Link " + path + " not found.");
+            }
+
+            // check for view access on link
+            link.checkAccess(SecuredResource.VIEW_ACTION);
+
+            return link;
+        }
+        catch (DocumentNotFoundException dnfe)
+        {
+            throw dnfe;
+        }
+        catch (SecurityException se)
+        {
+            throw se;
+        }
+        catch (Exception e)
+        {
+            throw new DocumentNotFoundException("Link " + path + " not found.", e);
+        }
     }
 
     /* (non-Javadoc)
@@ -832,8 +885,76 @@
      */
     public void updateLink(Link link) throws JetspeedException, LinkNotUpdatedException
     {
-        // TODO Auto-generated method stub
+        try
+        {
+            // dereference link in case proxy is supplied
+            link = (Link)ProxyHelper.getRealObject(link);
+
+            // look up and set parent folder if necessary
+            if (link.getParent() == null)
+            {
+                // access folder by path
+                String linkPath = link.getPath();
+                String parentPath = linkPath.substring(0, linkPath.lastIndexOf(Folder.PATH_SEPARATOR));
+                if (parentPath.length() == 0)
+                {
+                    parentPath = Folder.PATH_SEPARATOR;
+                }
+                FolderImpl parent = null;
+                try
+                {
+                    parent = (FolderImpl)getFolder(parentPath);
+                }
+                catch (FolderNotFoundException fnfe)
+                {
+                    throw new FailedToUpdateDocumentException("Missing parent folder: " + parentPath);
+                }
+                
+                // check for edit access on parent folder; link
+                // access not checked on create
+                parent.checkAccess(SecuredResource.EDIT_ACTION);
+
+                try
+                {
+                    // update parent folder with added link
+                    parent.addLink((LinkImpl)link);
+                    link.setParent(parent);
+                    getPersistenceBrokerTemplate().store(parent);
+                }
+                catch (Exception e)
+                {
+                    // cleanup parent folder on error
+                    parent.removeLink((LinkImpl)link);
+                    throw e;
+                }
+
+                // notify page manager listeners
+                delegator.notifyNewNode(link);
+            }
+            else
+            {
+                // check for edit access on link and parent folder
+                link.checkAccess(SecuredResource.EDIT_ACTION);
+
+                // update link
+                getPersistenceBrokerTemplate().store(link);
 
+                // notify page manager listeners
+                delegator.notifyUpdatedNode(link);
+            }
+        }
+        catch (FailedToUpdateDocumentException fude)
+        {
+            throw fude;
+        }
+        catch (SecurityException se)
+        {
+            throw se;
+        }
+        catch (Exception e)
+        {
+            throw new FailedToUpdateDocumentException("Link " + link.getPath() + " not updated.", e);
+        }
     }
 
     /* (non-Javadoc)
@@ -841,8 +962,39 @@
      */
     public void removeLink(Link link) throws JetspeedException, LinkNotRemovedException
     {
-        // TODO Auto-generated method stub
+        try
+        {
+            // dereference link in case proxy is supplied
+            link = (Link)ProxyHelper.getRealObject(link);
+
+            // check for edit access on link and parent folder
+            link.checkAccess(SecuredResource.EDIT_ACTION);
+
+            // look up and update parent folder if necessary
+            if (link.getParent() != null)
+            {
+                // update parent folder with removed link; deletes link
+                FolderImpl parent = (FolderImpl)ProxyHelper.getRealObject(link.getParent());
+                parent.removeLink((LinkImpl)link);
+                getPersistenceBrokerTemplate().store(parent);
+            }
+            else
+            {
+                // delete link
+                getPersistenceBrokerTemplate().delete(link);
+            }
 
+            // notify page manager listeners
+            delegator.notifyRemovedNode(link);
+        }
+        catch (SecurityException se)
+        {
+            throw se;
+        }
+        catch (Exception e)
+        {
+            throw new FailedToDeleteDocumentException("Link " + link.getPath() + " not removed.", e);
+        }
     }
 
     /* (non-Javadoc)

Modified: portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/psml/CastorXmlPageManager.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/psml/CastorXmlPageManager.java?rev=353827&r1=353826&r2=353827&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/psml/CastorXmlPageManager.java (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/java/org/apache/jetspeed/page/psml/CastorXmlPageManager.java Sat Dec  3 23:11:13 2005
@@ -100,6 +100,7 @@
         modelClasses.put("FolderSecurityConstraintImpl", SecurityConstraintImpl.class);
         modelClasses.put("PageSecurityConstraintImpl", SecurityConstraintImpl.class);
         modelClasses.put("FragmentSecurityConstraintImpl", SecurityConstraintImpl.class);
+        modelClasses.put("LinkSecurityConstraintImpl", SecurityConstraintImpl.class);
         modelClasses.put("PageSecuritySecurityConstraintImpl", SecurityConstraintImpl.class);
         modelClasses.put("SecurityConstraintsDefImpl", SecurityConstraintsDefImpl.class);
         modelClasses.put("FragmentPreferenceImpl", FragmentPreferenceImpl.class);

Modified: portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestDatabasePageManager.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestDatabasePageManager.java?rev=353827&r1=353826&r2=353827&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestDatabasePageManager.java (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestDatabasePageManager.java Sat Dec  3 23:11:13 2005
@@ -33,6 +33,7 @@
 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.PageSecurity;
 import org.apache.jetspeed.om.page.SecurityConstraintsDef;
@@ -340,6 +341,35 @@
         assertEquals(page.getParent().getId(), folder.getId());
         assertEquals(3, folder.getPages().size());
 
+        Link link = pageManager.newLink("/default.link");
+        link.setTitle("Default Link");
+        link.setVersion("1.23");
+        link.setShortTitle("Default");
+        link.setTarget("top");
+        link.setUrl("http://www.default.org/");
+        metadata = link.getMetadata();
+        metadata.addField(Locale.FRENCH, "title", "[fr] Default Link");
+        metadata.addField(Locale.GERMAN, "title", "[de] Default Link");
+        SecurityConstraints linkConstraints = link.newSecurityConstraints();
+        linkConstraints.setOwner("user");
+        List inlineLinkConstraints = new ArrayList(1);
+        SecurityConstraint linkConstraint = link.newSecurityConstraint();
+        linkConstraint.setUsers(Shared.makeListFromCSV("jetspeed"));
+        linkConstraint.setPermissions(Shared.makeListFromCSV("edit"));
+        inlineLinkConstraints.add(linkConstraint);
+        linkConstraints.setSecurityConstraints(inlineLinkConstraints);
+        List linkConstraintsRefs = new ArrayList(1);
+        linkConstraintsRefs.add("manager-edit");
+        linkConstraints.setSecurityConstraintsRefs(linkConstraintsRefs);
+        link.setSecurityConstraints(linkConstraints);
+
+        pageManager.updateLink(link);
+
+        assertNotNull(link.getParent());
+        assertEquals(link.getParent().getId(), folder.getId());
+        assertNotNull(folder.getLinks());
+        assertEquals(1, folder.getLinks().size());
+
         PageSecurity pageSecurity = pageManager.newPageSecurity();
         List constraintsDefs = new ArrayList(2);
         SecurityConstraintsDef constraintsDef = pageManager.newSecurityConstraintsDef();
@@ -396,6 +426,15 @@
         }
         try
         {
+            Link dupLink = pageManager.newLink("/default.link");
+            pageManager.updateLink(dupLink);
+            assertTrue("Duplicate Link / CREATED", false);
+        }
+        catch (FailedToUpdateDocumentException e)
+        {
+        }
+        try
+        {
             PageSecurity dupPageSecurity = pageManager.newPageSecurity();
             pageManager.updatePageSecurity(dupPageSecurity);
             assertTrue("Duplicate PageSecurity / CREATED", false);
@@ -437,12 +476,13 @@
         assertNotNull(folder.getFolders());
         assertEquals(1, folder.getFolders().size());
         assertNotNull(folder.getAll());
-        assertEquals(5, folder.getAll().size());
+        assertEquals(6, folder.getAll().size());
         Iterator all = folder.getAll().iterator();
         assertEquals("some-other-page.psml", ((Node)all.next()).getName());
         assertEquals("default-page.psml", ((Node)all.next()).getName());
         assertEquals("__subsite-rootx", ((Node)all.next()).getName());
         assertEquals("another-page.psml", ((Node)all.next()).getName());
+        assertEquals("default.link", ((Node)all.next()).getName());
         assertEquals("page.security", ((Node)all.next()).getName());
         assertNotNull(folder.getAll().subset(Page.DOCUMENT_TYPE));
         assertEquals(3, folder.getAll().subset(Page.DOCUMENT_TYPE).size());
@@ -450,7 +490,7 @@
         assertEquals(2, folder.getAll().inclusiveSubset(".*other.*").size());
         assertNull(folder.getAll().inclusiveSubset("nomatch"));
         assertNotNull(folder.getAll().exclusiveSubset(".*-page.psml"));
-        assertEquals(2, folder.getAll().exclusiveSubset(".*-page.psml").size());
+        assertEquals(3, folder.getAll().exclusiveSubset(".*-page.psml").size());
     }
 
     public void testGets() throws Exception
@@ -464,6 +504,7 @@
             PageSecurity check = pageManager.getPageSecurity();
             assertEquals("/page.security", check.getPath());
             assertEquals("page.security", check.getName());
+            assertEquals("/page.security", check.getUrl());
             assertNotNull(check.getSecurityConstraintsDefs());
             assertEquals(2, check.getSecurityConstraintsDefs().size());
             assertEquals("admin-all", ((SecurityConstraintsDef)check.getSecurityConstraintsDefs().get(0)).getName());
@@ -486,9 +527,37 @@
         }
         try
         {
+            Link check = pageManager.getLink("/default.link");
+            assertEquals("/default.link", check.getPath());
+            assertEquals("default.link", check.getName());
+            assertEquals("Default Link", check.getTitle());
+            assertEquals("1.23", check.getVersion());            
+            assertEquals("Default", check.getShortTitle());
+            assertEquals("top", check.getTarget());
+            assertEquals("http://www.default.org/", check.getUrl());
+            assertNotNull(check.getMetadata());
+            assertEquals("[fr] Default Link", check.getTitle(Locale.FRENCH));
+            assertEquals("[de] Default Link", check.getTitle(Locale.GERMAN));
+            assertNotNull(check.getSecurityConstraints());
+            assertEquals("user", check.getSecurityConstraints().getOwner());
+            assertNotNull(check.getSecurityConstraints().getSecurityConstraintsRefs());
+            assertEquals(1, check.getSecurityConstraints().getSecurityConstraintsRefs().size());
+            assertEquals("manager-edit", (String)check.getSecurityConstraints().getSecurityConstraintsRefs().get(0));
+            assertNotNull(check.getSecurityConstraints().getSecurityConstraints());
+            assertEquals(1, check.getSecurityConstraints().getSecurityConstraints().size());
+            assertEquals("jetspeed", Shared.makeCSVFromList(((SecurityConstraint)check.getSecurityConstraints().getSecurityConstraints().get(0)).getUsers()));
+            assertNotNull(check.getParent());
+        }
+        catch (PageNotFoundException e)
+        {
+            assertTrue("Link /default.link NOT FOUND", false);
+        }
+        try
+        {
             Page check = pageManager.getPage("/default-page.psml");
             assertEquals("/default-page.psml", check.getPath());
             assertEquals("default-page.psml", check.getName());
+            assertEquals("/default-page.psml", check.getUrl());
             assertEquals("Default Page", check.getTitle());
             assertEquals("6.89", check.getVersion());            
             assertEquals("tigris", check.getDefaultDecorator(Fragment.LAYOUT));
@@ -585,6 +654,7 @@
             Folder check = pageManager.getFolder("/");
             assertEquals("/", check.getPath());
             assertEquals("/", check.getName());
+            assertEquals("/", check.getUrl());
             assertEquals("Root Folder", check.getTitle());
             assertEquals("default-page.psml", check.getDefaultPage());
             assertEquals("Root", check.getShortTitle());
@@ -609,15 +679,18 @@
             assertNotNull(check.getPageSecurity());
             assertNotNull(check.getPages());
             assertEquals(3, check.getPages().size());
+            assertNotNull(check.getLinks());
+            assertEquals(1, check.getLinks().size());
             assertNotNull(check.getFolders());
             assertEquals(1, check.getFolders().size());
             assertNotNull(check.getAll());
-            assertEquals(5, check.getAll().size());
+            assertEquals(6, check.getAll().size());
             Iterator all = check.getAll().iterator();
             assertEquals("some-other-page.psml", ((Node)all.next()).getName());
             assertEquals("default-page.psml", ((Node)all.next()).getName());
             assertEquals("__subsite-rootx", ((Node)all.next()).getName());
             assertEquals("another-page.psml", ((Node)all.next()).getName());
+            assertEquals("default.link", ((Node)all.next()).getName());
             assertEquals("page.security", ((Node)all.next()).getName());
             assertNotNull(check.getMenuDefinitions());
             assertEquals(2, check.getMenuDefinitions().size());
@@ -715,6 +788,12 @@
         page.getSecurityConstraints().getSecurityConstraints().add(0, pageConstraint);
         pageManager.updatePage(page);
 
+        Link link = pageManager.getLink("/default.link");
+        assertEquals("/default.link", link.getPath());
+        link.setTitle("UPDATED");
+        link.getSecurityConstraints().setOwner("UPDATED");
+        pageManager.updateLink(link);
+
         Folder folder = pageManager.getFolder("/");
         assertEquals("/", folder.getPath());
         folder.setTitle("UPDATED");
@@ -729,7 +808,7 @@
         pageManager.updateFolder(folder);
 
         assertNotNull(folder.getAll());
-        assertEquals(5, folder.getAll().size());
+        assertEquals(6, folder.getAll().size());
         Iterator all = folder.getAll().iterator();
         assertEquals("default-page.psml", ((Node)all.next()).getName());
         assertEquals("some-other-page.psml", ((Node)all.next()).getName());
@@ -774,6 +853,14 @@
         }
         try
         {
+            Link check = pageManager.getLink("/default.link");
+            assertTrue("Link /default.link FOUND", false);
+        }
+        catch (DocumentNotFoundException e)
+        {
+        }
+        try
+        {
             Page check = pageManager.getPage("/default-page.psml");
             assertTrue("Page /default-page.psml FOUND", false);
         }
@@ -809,8 +896,8 @@
     public void testEvents() throws Exception
     {
         // verify listener functionality and operation counts
-        assertEquals(21, newNodeCount);
-        assertEquals(3, updatedNodeCount);
+        assertEquals(22, newNodeCount);
+        assertEquals(4, updatedNodeCount);
         assertEquals(1, removedNodeCount);
     }
 }

Modified: portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestSecureDatabasePageManager.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestSecureDatabasePageManager.java?rev=353827&r1=353826&r2=353827&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestSecureDatabasePageManager.java (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestSecureDatabasePageManager.java Sat Dec  3 23:11:13 2005
@@ -30,6 +30,7 @@
 import org.apache.jetspeed.om.folder.Folder;
 import org.apache.jetspeed.om.folder.FolderNotFoundException;
 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.PageSecurity;
 import org.apache.jetspeed.om.page.SecurityConstraintsDef;
@@ -194,6 +195,19 @@
                         page.setSecurityConstraints(constraints);
                         pageManager.updatePage(page);
 
+                        Link link = pageManager.newLink("/default.link");
+                        link.setUrl("http://www.default.org/");
+                        constraints = pageManager.newSecurityConstraints();
+                        constraints.setOwner("admin");
+                        inlineConstraints = new ArrayList(1);
+                        constraint = pageManager.newLinkSecurityConstraint();
+                        constraint.setRoles(Shared.makeListFromCSV("manager"));
+                        constraint.setPermissions(Shared.makeListFromCSV("edit"));
+                        inlineConstraints.add(constraint);
+                        constraints.setSecurityConstraints(inlineConstraints);
+                        link.setSecurityConstraints(constraints);                        
+                        pageManager.updateLink(link);
+
                         return null;
                     }
                     catch (Exception e)
@@ -228,11 +242,13 @@
                         assertNotNull(page0.getFragmentsByName("some-app::SomePortlet"));
                         assertEquals(1, page0.getFragmentsByName("some-app::SomePortlet").size());
                         Page page1 = pageManager.getPage("/user-page.psml");
+                        Link link = pageManager.getLink("/default.link");
                         // test edit access
                         pageManager.updateFolder(folder);
                         pageManager.updatePageSecurity(pageSecurity);
                         pageManager.updatePage(page0);
                         pageManager.updatePage(page1);
+                        pageManager.updateLink(link);
                         return null;
                     }
                     catch (Exception e)
@@ -267,6 +283,7 @@
                         assertNotNull(page0.getFragmentsByName("some-app::SomePortlet"));
                         assertEquals(1, page0.getFragmentsByName("some-app::SomePortlet").size());
                         Page page1 = pageManager.getPage("/user-page.psml");
+                        Link link = pageManager.getLink("/default.link");
                         // test edit access
                         try
                         {
@@ -293,6 +310,14 @@
                         {
                         }
                         pageManager.updatePage(page1);
+                        try
+                        {
+                            pageManager.updateLink(link);
+                            assertTrue("Page /default.link not editable for user", false);
+                        }
+                        catch (SecurityException se)
+                        {
+                        }
                         return null;
                     }
                     catch (Exception e)
@@ -325,6 +350,7 @@
                         assertEquals(1, page0.getRootFragment().getFragments().size());
                         assertNull(page0.getFragmentById(TestSecureDatabasePageManager.this.somePortletId));
                         assertNull(page0.getFragmentsByName("some-app::SomePortlet"));
+                        Link link = pageManager.getLink("/default.link");
                         try
                         {
                             Page page1 = pageManager.getPage("/user-page.psml");
@@ -351,6 +377,7 @@
                         {
                         }
                         pageManager.updatePage(page0);
+                        pageManager.updateLink(link);
                         return null;
                     }
                     catch (Exception e)
@@ -383,6 +410,7 @@
                         assertEquals(1, page0.getRootFragment().getFragments().size());
                         assertNull(page0.getFragmentById(TestSecureDatabasePageManager.this.somePortletId));
                         assertNull(page0.getFragmentsByName("some-app::SomePortlet"));
+                        Link link = pageManager.getLink("/default.link");
                         try
                         {
                             Page page1 = pageManager.getPage("/user-page.psml");
@@ -412,6 +440,14 @@
                         {
                             pageManager.updatePage(page0);
                             assertTrue("Page /default-page.psml not editable for guest", false);
+                        }
+                        catch (SecurityException se)
+                        {
+                        }
+                        try
+                        {
+                            pageManager.updateLink(link);
+                            assertTrue("Page /default.link not editable for guest", false);
                         }
                         catch (SecurityException se)
                         {

Modified: portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestSecurePermissionsDatabasePageManager.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestSecurePermissionsDatabasePageManager.java?rev=353827&r1=353826&r2=353827&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestSecurePermissionsDatabasePageManager.java (original)
+++ portals/jetspeed-2/trunk/components/page-manager/src/test/org/apache/jetspeed/page/TestSecurePermissionsDatabasePageManager.java Sat Dec  3 23:11:13 2005
@@ -108,6 +108,7 @@
                         {
                             // granted permissions
                             permissions.add(new PagePermission("/default-page.psml", "edit"));
+                            permissions.add(new PagePermission("/default.link", "edit"));
                         }
                     }
                 }

Modified: portals/jetspeed-2/trunk/etc/schema/phase2-schema.xml
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/etc/schema/phase2-schema.xml?rev=353827&r1=353826&r2=353827&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/etc/schema/phase2-schema.xml (original)
+++ portals/jetspeed-2/trunk/etc/schema/phase2-schema.xml Sat Dec  3 23:11:13 2005
@@ -416,6 +416,94 @@
     </table>
 
     <!--
+       Link Definition
+    -->
+
+    <table name="LINK">
+        <column name="LINK_ID" primaryKey="true" required="true" type="INTEGER"/>
+        <column name="PARENT_ID" type="INTEGER" required="true"/>
+        <column name="PATH" required="true" size="240" type="VARCHAR"/>
+        <column name="NAME" required="true" size="80" type="VARCHAR"/>
+        <column name="VERSION" required="false" size="40" type="VARCHAR"/>        
+        <column name="TITLE" size="100" type="VARCHAR"/>
+        <column name="SHORT_TITLE" size="40" type="VARCHAR"/>
+        <column name="IS_HIDDEN" required="true" type="BOOLEANINT"/>
+        <column name="TARGET" size="80" type="VARCHAR"/>
+        <column name="URL" size="255" type="VARCHAR"/>
+        <column name="SUBSITE" size="40" type="VARCHAR"/>
+        <column name="USER_PRINCIPAL" size="40" type="VARCHAR"/>
+        <column name="ROLE_PRINCIPAL" size="40" type="VARCHAR"/>
+        <column name="GROUP_PRINCIPAL" size="40" type="VARCHAR"/>
+        <column name="MEDIATYPE" size="15" type="VARCHAR"/>
+        <column name="LOCALE" size="20" type="VARCHAR"/>
+        <column name="EXT_ATTR_NAME" size="15" type="VARCHAR"/>
+        <column name="EXT_ATTR_VALUE" size="40" type="VARCHAR"/>
+        <column name="OWNER_PRINCIPAL" size="40" type="VARCHAR"/>
+        <foreign-key foreignTable="FOLDER" onDelete="cascade">
+            <reference foreign="FOLDER_ID" local="PARENT_ID"/>
+        </foreign-key>
+        <index name="IX_LINK_1">
+            <index-column name="PARENT_ID"/>
+        </index>
+        <unique name="UN_LINK_1">
+            <unique-column name="PATH"/>
+        </unique>
+    </table>
+    
+    <table name="LINK_METADATA">
+        <column name="METADATA_ID" primaryKey="true" required="true" type="INTEGER"/>
+        <column name="LINK_ID" type="INTEGER" required="true"/>
+        <column name="NAME" required="true" size="15" type="VARCHAR"/>
+        <column name="LOCALE" required="true" size="20" type="VARCHAR"/>
+        <column name="VALUE" required="true" size="100" type="VARCHAR"/>
+        <foreign-key foreignTable="LINK" onDelete="cascade">
+            <reference foreign="LINK_ID" local="LINK_ID"/>
+        </foreign-key>
+        <index name="IX_LINK_METADATA_1">
+            <index-column name="LINK_ID"/>
+        </index>
+        <unique name="UN_LINK_METADATA_1">
+            <unique-column name="LINK_ID"/>
+            <unique-column name="NAME"/>
+            <unique-column name="LOCALE"/>
+            <unique-column name="VALUE"/>
+        </unique>
+    </table>
+
+    <table name="LINK_CONSTRAINT">
+        <column name="CONSTRAINT_ID" primaryKey="true" required="true" type="INTEGER"/>
+        <column name="LINK_ID" type="INTEGER" required="true"/>
+        <column name="APPLY_ORDER" type="INTEGER" required="true"/>
+        <column name="USER_PRINCIPALS_ACL" size="120" type="VARCHAR"/>
+        <column name="ROLE_PRINCIPALS_ACL" size="120" type="VARCHAR"/>
+        <column name="GROUP_PRINCIPALS_ACL" size="120" type="VARCHAR"/>
+        <column name="PERMISSIONS_ACL" size="120" type="VARCHAR"/>
+        <foreign-key foreignTable="LINK" onDelete="cascade">
+            <reference foreign="LINK_ID" local="LINK_ID"/>
+        </foreign-key>
+        <index name="IX_LINK_CONSTRAINT_1">
+            <index-column name="LINK_ID"/>
+        </index>
+    </table>
+
+    <table name="LINK_CONSTRAINTS_REF">
+        <column name="CONSTRAINTS_REF_ID" primaryKey="true" required="true" type="INTEGER"/>
+        <column name="LINK_ID" type="INTEGER" required="true"/>
+        <column name="APPLY_ORDER" type="INTEGER" required="true"/>
+        <column name="NAME" size="40" type="VARCHAR" required="true"/>
+        <foreign-key foreignTable="LINK" onDelete="cascade">
+            <reference foreign="LINK_ID" local="LINK_ID"/>
+        </foreign-key>
+        <index name="IX_LINK_CONSTRAINTS_REF_1">
+            <index-column name="LINK_ID"/>
+        </index>
+        <unique name="UN_LINK_CONSTRAINTS_REF_1">
+            <unique-column name="LINK_ID"/>
+            <unique-column name="NAME"/>
+        </unique>
+    </table>
+
+    <!--
        Page Security Definition
     -->
 

Modified: portals/jetspeed-2/trunk/etc/sql/derby/schema/phase2-schema.sql
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/etc/sql/derby/schema/phase2-schema.sql?rev=353827&r1=353826&r2=353827&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/etc/sql/derby/schema/phase2-schema.sql (original)
+++ portals/jetspeed-2/trunk/etc/sql/derby/schema/phase2-schema.sql Sat Dec  3 23:11:13 2005
@@ -397,6 +397,92 @@
 
 CREATE  INDEX IX_FRAGMENT_PREF_VALUE_1 ON FRAGMENT_PREF_VALUE (PREF_ID);
 -----------------------------------------------------------------------------
+-- LINK
+-----------------------------------------------------------------------------
+
+CREATE TABLE LINK
+(
+    LINK_ID INTEGER NOT NULL,
+    PARENT_ID INTEGER NOT NULL,
+    PATH VARCHAR(240) NOT NULL,
+    NAME VARCHAR(80) NOT NULL,
+    VERSION VARCHAR (40),
+    TITLE VARCHAR(100),
+    SHORT_TITLE VARCHAR(40),
+    IS_HIDDEN INTEGER NOT NULL,
+    TARGET VARCHAR(80),
+    URL VARCHAR(255),
+    SUBSITE VARCHAR(40),
+    USER_PRINCIPAL VARCHAR(40),
+    ROLE_PRINCIPAL VARCHAR(40),
+    GROUP_PRINCIPAL VARCHAR(40),
+    MEDIATYPE VARCHAR(15),
+    LOCALE VARCHAR(20),
+    EXT_ATTR_NAME VARCHAR(15),
+    EXT_ATTR_VALUE VARCHAR(40),
+    OWNER_PRINCIPAL VARCHAR(40),
+    PRIMARY KEY(LINK_ID),
+    FOREIGN KEY (PARENT_ID) REFERENCES FOLDER (FOLDER_ID)
+        ON DELETE CASCADE 
+  ,
+    UNIQUE (PATH));
+
+CREATE  INDEX IX_LINK_1 ON LINK (PARENT_ID);
+-----------------------------------------------------------------------------
+-- LINK_METADATA
+-----------------------------------------------------------------------------
+
+CREATE TABLE LINK_METADATA
+(
+    METADATA_ID INTEGER NOT NULL,
+    LINK_ID INTEGER NOT NULL,
+    NAME VARCHAR(15) NOT NULL,
+    LOCALE VARCHAR(20) NOT NULL,
+    VALUE VARCHAR(100) NOT NULL,
+    PRIMARY KEY(METADATA_ID),
+    FOREIGN KEY (LINK_ID) REFERENCES LINK (LINK_ID)
+        ON DELETE CASCADE 
+  ,
+    UNIQUE (LINK_ID, NAME, LOCALE, VALUE));
+
+CREATE  INDEX IX_LINK_METADATA_1 ON LINK_METADATA (LINK_ID);
+-----------------------------------------------------------------------------
+-- LINK_CONSTRAINT
+-----------------------------------------------------------------------------
+
+CREATE TABLE LINK_CONSTRAINT
+(
+    CONSTRAINT_ID INTEGER NOT NULL,
+    LINK_ID INTEGER NOT NULL,
+    APPLY_ORDER INTEGER NOT NULL,
+    USER_PRINCIPALS_ACL VARCHAR(120),
+    ROLE_PRINCIPALS_ACL VARCHAR(120),
+    GROUP_PRINCIPALS_ACL VARCHAR(120),
+    PERMISSIONS_ACL VARCHAR(120),
+    PRIMARY KEY(CONSTRAINT_ID),
+    FOREIGN KEY (LINK_ID) REFERENCES LINK (LINK_ID)
+        ON DELETE CASCADE 
+);
+
+CREATE  INDEX IX_LINK_CONSTRAINT_1 ON LINK_CONSTRAINT (LINK_ID);
+-----------------------------------------------------------------------------
+-- LINK_CONSTRAINTS_REF
+-----------------------------------------------------------------------------
+
+CREATE TABLE LINK_CONSTRAINTS_REF
+(
+    CONSTRAINTS_REF_ID INTEGER NOT NULL,
+    LINK_ID INTEGER NOT NULL,
+    APPLY_ORDER INTEGER NOT NULL,
+    NAME VARCHAR(40) NOT NULL,
+    PRIMARY KEY(CONSTRAINTS_REF_ID),
+    FOREIGN KEY (LINK_ID) REFERENCES LINK (LINK_ID)
+        ON DELETE CASCADE 
+  ,
+    UNIQUE (LINK_ID, NAME));
+
+CREATE  INDEX IX_LINK_CONSTRAINTS_REF_1 ON LINK_CONSTRAINTS_REF (LINK_ID);
+-----------------------------------------------------------------------------
 -- PAGE_SECURITY
 -----------------------------------------------------------------------------
 

Modified: portals/jetspeed-2/trunk/etc/sql/drop.sql
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/etc/sql/drop.sql?rev=353827&r1=353826&r2=353827&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/etc/sql/drop.sql (original)
+++ portals/jetspeed-2/trunk/etc/sql/drop.sql Sat Dec  3 23:11:13 2005
@@ -20,6 +20,10 @@
 DROP TABLE PAGE_SEC_CONSTRAINT_DEF;
 DROP TABLE PAGE_SEC_CONSTRAINTS_DEF;
 DROP TABLE PAGE_SECURITY;
+DROP TABLE LINK_CONSTRAINTS_REF;
+DROP TABLE LINK_CONSTRAINT;
+DROP TABLE LINK_METADATA;
+DROP TABLE LINK;
 DROP TABLE FRAGMENT_PREF_VALUE;
 DROP TABLE FRAGMENT_PREF;
 DROP TABLE FRAGMENT_CONSTRAINTS_REF;

Modified: portals/jetspeed-2/trunk/etc/sql/oracle/drop.sql
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/etc/sql/oracle/drop.sql?rev=353827&r1=353826&r2=353827&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/etc/sql/oracle/drop.sql (original)
+++ portals/jetspeed-2/trunk/etc/sql/oracle/drop.sql Sat Dec  3 23:11:13 2005
@@ -25,6 +25,10 @@
 DROP TABLE PAGE_SEC_CONSTRAINT_DEF;
 DROP TABLE PAGE_SEC_CONSTRAINTS_DEF;
 DROP TABLE PAGE_SECURITY;
+DROP TABLE LINK_CONSTRAINTS_REF;
+DROP TABLE LINK_CONSTRAINT;
+DROP TABLE LINK_METADATA;
+DROP TABLE LINK;
 DROP TABLE FRAGMENT_PREF_VALUE;
 DROP TABLE FRAGMENT_PREF;
 DROP TABLE FRAGMENT_CONSTRAINTS_REF;

Modified: portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/page/PageManager.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/page/PageManager.java?rev=353827&r1=353826&r2=353827&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/page/PageManager.java (original)
+++ portals/jetspeed-2/trunk/jetspeed-api/src/java/org/apache/jetspeed/page/PageManager.java Sat Dec  3 23:11:13 2005
@@ -211,6 +211,13 @@
     public SecurityConstraint newFragmentSecurityConstraint();
 
     /**
+     * newLinkSecurityConstraint - creates a new security constraint definition
+     *
+     * @return a newly created SecurityConstraint object to be used in Link
+     */
+    public SecurityConstraint newLinkSecurityConstraint();
+
+    /**
      * newPageSecuritySecurityConstraint - creates a new security constraint definition
      *
      * @return a newly created SecurityConstraint object to be used in PageSecurity



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