portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r882786 - in /portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed: layout/impl/PageLayoutComponentImpl.java om/page/impl/ContentFragmentImpl.java
Date Fri, 20 Nov 2009 23:35:35 GMT
Author: rwatler
Date: Fri Nov 20 23:35:35 2009
New Revision: 882786

URL: http://svn.apache.org/viewvc?rev=882786&view=rev
Log:
correct update operations in PageLayoutComponent to properly support manipulation of FragmentReferences
in content page

Modified:
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/layout/impl/PageLayoutComponentImpl.java
    portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/om/page/impl/ContentFragmentImpl.java

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/layout/impl/PageLayoutComponentImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/layout/impl/PageLayoutComponentImpl.java?rev=882786&r1=882785&r2=882786&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/layout/impl/PageLayoutComponentImpl.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/layout/impl/PageLayoutComponentImpl.java
Fri Nov 20 23:35:35 2009
@@ -130,7 +130,7 @@
             
             // update content page context
             ContentFragmentImpl contentFragmentImpl = (ContentFragmentImpl)contentFragment;
-            contentFragmentImpl.initialize(this, page, newFragment, null, false);
+            contentFragmentImpl.initialize(this, page, page, newFragment, null, false);
             if (!Utils.isNull(row))
             {
                 contentFragmentImpl.setLayoutRow(row);
@@ -178,14 +178,14 @@
             {
                 throw new IllegalArgumentException("Locked content fragment is not mutable");
             }
-            boolean contentFragmentDefinitionIsPage = (contentFragmentImpl.getDefinition()
instanceof Page);
+            boolean contentFragmentDefinitionIsPage = ((contentFragmentImpl.getDefinition()
instanceof Page) && contentFragmentImpl.getDefinition().getPath().equals(contentFragmentImpl.getPage().getPath()));
             if (!contentFragmentDefinitionIsPage)
             {
                 throw new IllegalArgumentException("Only page fragments can be modified");
               
             }
 
             // retrieve current page and fragment from page manager
-            Page page = pageManager.getPage(contentFragmentImpl.getDefinition().getPath());
+            Page page = pageManager.getPage(contentFragmentImpl.getPage().getPath());
             BaseFragmentElement parentFragment = page.getFragmentById(contentFragmentImpl.getFragment().getId());
             if (!(parentFragment instanceof Fragment))
             {
@@ -881,14 +881,14 @@
         {
             // validate content fragment
             ContentFragmentImpl contentFragmentImpl = (ContentFragmentImpl)contentFragment;
-            boolean contentFragmentDefinitionIsPage = (contentFragmentImpl.getDefinition()
instanceof Page);
+            boolean contentFragmentDefinitionIsPage = ((contentFragmentImpl.getDefinition()
instanceof Page) && contentFragmentImpl.getDefinition().getPath().equals(contentFragmentImpl.getPage().getPath()));
             if (!contentFragmentDefinitionIsPage && (contentFragmentImpl.getReference()
== null))
             {
                 throw new IllegalArgumentException("Only page fragments and fragment references
are mutable");
             }
             
             // retrieve current fragment and page from page manager
-            Page page = pageManager.getPage(contentFragmentImpl.getDefinition().getPath());
+            Page page = pageManager.getPage(contentFragmentImpl.getPage().getPath());
             String pageFragmentId = (contentFragmentDefinitionIsPage ? contentFragmentImpl.getFragment().getId()
: contentFragmentImpl.getReference().getId());
             BaseFragmentElement fragment = page.getFragmentById(pageFragmentId);
             if (fragment == null)
@@ -1034,14 +1034,14 @@
             {
                 throw new IllegalArgumentException("Locked content fragment is not mutable");
               
             }
-            boolean contentFragmentDefinitionIsPage = (contentFragmentImpl.getDefinition()
instanceof Page);
+            boolean contentFragmentDefinitionIsPage = ((contentFragmentImpl.getDefinition()
instanceof Page) && contentFragmentImpl.getDefinition().getPath().equals(contentFragmentImpl.getPage().getPath()));
             if (!contentFragmentDefinitionIsPage)
             {
                 throw new IllegalArgumentException("Only page fragments can be modified");
               
             }
             
             // retrieve current fragment and page from page manager
-            Page page = pageManager.getPage(contentFragmentImpl.getDefinition().getPath());
+            Page page = pageManager.getPage(contentFragmentImpl.getPage().getPath());
             BaseFragmentElement foundFragment = page.getFragmentById(contentFragmentImpl.getFragment().getId());
             if (!(foundFragment instanceof Fragment))
             {
@@ -1083,14 +1083,14 @@
         {
             // validate content fragment
             ContentFragmentImpl contentFragmentImpl = (ContentFragmentImpl)contentFragment;
-            boolean contentFragmentDefinitionIsPage = (contentFragmentImpl.getDefinition()
instanceof Page);
+            boolean contentFragmentDefinitionIsPage = ((contentFragmentImpl.getDefinition()
instanceof Page) && contentFragmentImpl.getDefinition().getPath().equals(contentFragmentImpl.getPage().getPath()));
             if (!contentFragmentDefinitionIsPage && (contentFragmentImpl.getReference()
== null))
             {
                 throw new IllegalArgumentException("Only page fragments and fragment references
are mutable");
             }
             
             // retrieve current fragment and page from page manager
-            Page page = pageManager.getPage(contentFragmentImpl.getDefinition().getPath());
+            Page page = pageManager.getPage(contentFragmentImpl.getPage().getPath());
             String pageFragmentId = (contentFragmentDefinitionIsPage ? contentFragmentImpl.getFragment().getId()
: contentFragmentImpl.getReference().getId());
             BaseFragmentElement fragment = page.getFragmentById(pageFragmentId);
             if (fragment == null)
@@ -1186,14 +1186,14 @@
         {
             // validate content fragment
             ContentFragmentImpl contentFragmentImpl = (ContentFragmentImpl)contentFragment;
-            boolean contentFragmentDefinitionIsPage = (contentFragmentImpl.getDefinition()
instanceof Page);
+            boolean contentFragmentDefinitionIsPage = ((contentFragmentImpl.getDefinition()
instanceof Page) && contentFragmentImpl.getDefinition().getPath().equals(contentFragmentImpl.getPage().getPath()));
             if (!contentFragmentDefinitionIsPage && (contentFragmentImpl.getReference()
== null))
             {
                 throw new IllegalArgumentException("Only page fragments and fragment references
are mutable");
             }
             
             // retrieve current fragment and page from page manager
-            Page page = pageManager.getPage(contentFragmentImpl.getDefinition().getPath());
+            Page page = pageManager.getPage(contentFragmentImpl.getPage().getPath());
             String pageFragmentId = (contentFragmentDefinitionIsPage ? contentFragmentImpl.getFragment().getId()
: contentFragmentImpl.getReference().getId());
             BaseFragmentElement fragment = page.getFragmentById(pageFragmentId);
             if (fragment == null)
@@ -1263,14 +1263,14 @@
         {
             // validate content fragment
             ContentFragmentImpl contentFragmentImpl = (ContentFragmentImpl)contentFragment;
-            boolean contentFragmentDefinitionIsPage = (contentFragmentImpl.getDefinition()
instanceof Page);
+            boolean contentFragmentDefinitionIsPage = ((contentFragmentImpl.getDefinition()
instanceof Page) && contentFragmentImpl.getDefinition().getPath().equals(contentFragmentImpl.getPage().getPath()));
             if (!contentFragmentDefinitionIsPage && (contentFragmentImpl.getReference()
== null))
             {
                 throw new IllegalArgumentException("Only page fragments and fragment references
are mutable");
             }
             
             // retrieve current fragment and page from page manager
-            Page page = pageManager.getPage(contentFragmentImpl.getDefinition().getPath());
+            Page page = pageManager.getPage(contentFragmentImpl.getPage().getPath());
             String pageFragmentId = (contentFragmentDefinitionIsPage ? contentFragmentImpl.getFragment().getId()
: contentFragmentImpl.getReference().getId());
             BaseFragmentElement fragment = page.getFragmentById(pageFragmentId);
             if (fragment == null)
@@ -1330,14 +1330,14 @@
         {
             // validate content fragment
             ContentFragmentImpl contentFragmentImpl = (ContentFragmentImpl)contentFragment;
-            boolean contentFragmentDefinitionIsPage = (contentFragmentImpl.getDefinition()
instanceof Page);
+            boolean contentFragmentDefinitionIsPage = ((contentFragmentImpl.getDefinition()
instanceof Page) && contentFragmentImpl.getDefinition().getPath().equals(contentFragmentImpl.getPage().getPath()));
             if (!contentFragmentDefinitionIsPage && (contentFragmentImpl.getReference()
== null))
             {
                 throw new IllegalArgumentException("Only page fragments and fragment references
are mutable");
             }
             
             // retrieve current fragment and page from page manager
-            Page page = pageManager.getPage(contentFragmentImpl.getDefinition().getPath());
+            Page page = pageManager.getPage(contentFragmentImpl.getPage().getPath());
             String pageFragmentId = (contentFragmentDefinitionIsPage ? contentFragmentImpl.getFragment().getId()
: contentFragmentImpl.getReference().getId());
             BaseFragmentElement fragment = page.getFragmentById(pageFragmentId);
             if (fragment == null)
@@ -1633,8 +1633,8 @@
         {
             fragmentFragment[0] = (Fragment)fragmentDefinition.getRootFragment();
             String contentFragmentId = parentId+"."+fragmentFragment[0].getId();        
       
-            FragmentReference pageReference = ((definition == page) ? fragmentReference :
null);
-            return newContentFragment(contentFragmentId, page, fragmentDefinitions, definition,
fragmentFragment[0], pageReference, true);
+            FragmentReference pageFragmentReference = ((definition == page) ? fragmentReference
: null);
+            return newContentFragment(contentFragmentId, page, fragmentDefinitions, fragmentDefinition,
fragmentFragment[0], pageFragmentReference, true);
         }
         return null;
     }
@@ -1654,7 +1654,7 @@
     private ContentFragmentImpl newContentFragment(String id, Page page, Map fragmentDefinitions,
BaseFragmentsElement definition, Fragment fragment, FragmentReference reference, boolean locked)
     {
         // generate content fragment hierarchy for fragment
-        ContentFragmentImpl contentFragmentImpl = new ContentFragmentImpl(this, id, definition,
fragment, reference, locked);
+        ContentFragmentImpl contentFragmentImpl = new ContentFragmentImpl(this, id, page,
definition, fragment, reference, locked);
         contentFragmentImpl.setName(fragment.getName());
         contentFragmentImpl.setType(fragment.getType());
 
@@ -1674,7 +1674,7 @@
             }
         }
 
-        log.debug("\tPageLayoutComponentImpl.newContentFragment(): constructed ContentFragment:
id="+contentFragmentImpl.getId()+", name="+contentFragmentImpl.getName()+", locked="+contentFragmentImpl.isLocked());
+        log.debug("PageLayoutComponentImpl.newContentFragment(): constructed ContentFragment:
id="+contentFragmentImpl.getId()+", name="+contentFragmentImpl.getName()+", locked="+contentFragmentImpl.isLocked());
         return contentFragmentImpl;
     }
 

Modified: portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/om/page/impl/ContentFragmentImpl.java
URL: http://svn.apache.org/viewvc/portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/om/page/impl/ContentFragmentImpl.java?rev=882786&r1=882785&r2=882786&view=diff
==============================================================================
--- portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/om/page/impl/ContentFragmentImpl.java
(original)
+++ portals/jetspeed-2/portal/trunk/components/jetspeed-page-layout/src/main/java/org/apache/jetspeed/om/page/impl/ContentFragmentImpl.java
Fri Nov 20 23:35:35 2009
@@ -31,6 +31,7 @@
 import org.apache.jetspeed.om.page.ContentFragment;
 import org.apache.jetspeed.om.page.Fragment;
 import org.apache.jetspeed.om.page.FragmentReference;
+import org.apache.jetspeed.om.page.Page;
 import org.apache.jetspeed.om.preference.FragmentPreference;
 import org.apache.pluto.container.PortletPreference;
 
@@ -49,6 +50,7 @@
 
     private PageLayoutComponent pageLayoutComponent;
     private String id;
+    private Page page;
     private BaseFragmentsElement definition;
     private Fragment fragment;
     private FragmentReference reference;
@@ -108,15 +110,17 @@
      * 
      * @param pageLayoutComponent PageLayoutComponent instance
      * @param id content fragment id
+     * @param page PSML page
      * @param definition PSML page, page template, or fragment definition
      * @param fragment PSML fragment
      * @param reference PSML page fragment reference
      * @param locked locked flag
      */
-    public ContentFragmentImpl(PageLayoutComponent pageLayoutComponent, String id, BaseFragmentsElement
definition, Fragment fragment, FragmentReference reference, boolean locked)
+    public ContentFragmentImpl(PageLayoutComponent pageLayoutComponent, String id, Page page,
BaseFragmentsElement definition, Fragment fragment, FragmentReference reference, boolean locked)
     {
         this.pageLayoutComponent = pageLayoutComponent;
         this.id = id;
+        this.page = page;
         this.definition = definition;
         this.fragment = fragment;
         this.reference = reference;
@@ -805,6 +809,16 @@
     }
     
     /**
+     * Get content page PSML page.
+     * 
+     * @return the PSML page
+     */
+    public Page getPage()
+    {
+        return page;
+    }
+
+    /**
      * Get content fragment PSML page, page template, or
      * fragment definition.
      * 
@@ -839,14 +853,16 @@
      * Initialize content fragment.
      * 
      * @param pageLayoutComponent PageLayoutComponent instance
+     * @param page PSML page
      * @param definition PSML page, page template, or fragment definition
      * @param fragment PSML fragment
      * @param reference PSML page fragment reference
      * @param locked locked flag
      */
-    public void initialize(PageLayoutComponent pageLayoutComponent, BaseFragmentsElement
definition, Fragment fragment, FragmentReference reference, boolean locked)
+    public void initialize(PageLayoutComponent pageLayoutComponent, Page page, BaseFragmentsElement
definition, Fragment fragment, FragmentReference reference, boolean locked)
     {
         this.pageLayoutComponent = pageLayoutComponent;
+        this.page = page;
         this.definition = definition;
         this.fragment = fragment;
         this.reference = reference;



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