portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rwat...@apache.org
Subject svn commit: r367239 - in /portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1: components/registry/src/java/org/apache/jetspeed/components/portletentity/ jetspeed-api/src/java/org/apache/jetspeed/ jetspeed-api/src/java/org/apache/jetspeed/components/port...
Date Mon, 09 Jan 2006 07:42:15 GMT
Author: rwatler
Date: Sun Jan  8 23:42:09 2006
New Revision: 367239

URL: http://svn.apache.org/viewcvs?rev=367239&view=rev
Log:
- explicity update PortletEntity and PortletWindow on root page layout change
  instead of relying on id modification to propagate edits, (id modification
  not supported by DB PageManager for page root fragment).
- add updatePortletEntity() to PortletEntityAccessor component API.
- add PortletWindowAccessor component to LayoutPortlet.


Modified:
    portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/components/registry/src/java/org/apache/jetspeed/components/portletentity/PersistenceBrokerPortletEntityAccess.java
    portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/jetspeed-api/src/java/org/apache/jetspeed/CommonPortletServices.java
    portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/jetspeed-api/src/java/org/apache/jetspeed/components/portletentity/PortletEntityAccessComponent.java
    portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/layout-portlets/src/java/org/apache/jetspeed/portlets/layout/LayoutPortlet.java
    portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/layout-portlets/src/java/org/apache/jetspeed/portlets/layout/MultiColumnPortlet.java
    portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/layout-portlets/src/webapp/WEB-INF/jetspeed-portlet.xml
    portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/src/webapp/WEB-INF/assembly/jetspeed-services.xml

Modified: portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/components/registry/src/java/org/apache/jetspeed/components/portletentity/PersistenceBrokerPortletEntityAccess.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/components/registry/src/java/org/apache/jetspeed/components/portletentity/PersistenceBrokerPortletEntityAccess.java?rev=367239&r1=367238&r2=367239&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/components/registry/src/java/org/apache/jetspeed/components/portletentity/PersistenceBrokerPortletEntityAccess.java
(original)
+++ portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/components/registry/src/java/org/apache/jetspeed/components/portletentity/PersistenceBrokerPortletEntityAccess.java
Sun Jan  8 23:42:09 2006
@@ -315,6 +315,38 @@
         }
     }
 
+    /**
+     * <p>
+     * updatePortletEntity
+     * </p>
+     *
+     * Updates portlet definition associated with the portlet
+     * entity to match the fragment configuration 
+     *
+     * @param portletEntity
+	 * @param fragment
+	 * @throws PortletEntityNotStoredException 
+     */
+    public void updatePortletEntity(PortletEntity portletEntity, ContentFragment fragment)
throws PortletEntityNotStoredException
+    {
+        // validate portlet entity id
+        if (!fragment.getId().equals(portletEntity.getId().toString()))
+        {
+            throw new PortletEntityNotStoredException("Fragment and PortletEntity ids do
not match, update skipped: " + fragment.getId() + " != " + portletEntity.getId() );
+        }
+
+        // update portlet definition from fragment
+        PortletDefinition pd = registry.getPortletDefinitionByUniqueName(fragment.getName());
+        if (pd != null)
+        {
+            ((PortletEntityImpl)portletEntity).setPortletDefinition(pd);
+        }
+        else
+        {
+            throw new PortletEntityNotStoredException("Fragment PortletDefinition not found:
" + fragment.getName() );
+        }
+    }
+
     public void storePortletEntity( PortletEntity portletEntity ) throws PortletEntityNotStoredException
     {
         try
@@ -365,4 +397,4 @@
         String portletName = pd.getName();
         return appName+"::"+portletName+"::"+new UID().toString();
     }
-}
\ No newline at end of file
+}

Modified: portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/jetspeed-api/src/java/org/apache/jetspeed/CommonPortletServices.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/jetspeed-api/src/java/org/apache/jetspeed/CommonPortletServices.java?rev=367239&r1=367238&r2=367239&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/jetspeed-api/src/java/org/apache/jetspeed/CommonPortletServices.java
(original)
+++ portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/jetspeed-api/src/java/org/apache/jetspeed/CommonPortletServices.java
Sun Jan  8 23:42:09 2006
@@ -35,6 +35,7 @@
     public final static String CPS_PORTLET_FACTORY_COMPONENT = "cps:PortletFactory";    
     public final static String CPS_DEPLOYMENT_MANAGER_COMPONENT = "cps:DeploymentManager";
   
     public final static String CPS_ENTITY_ACCESS_COMPONENT = "cps:EntityAccessor";
+    public final static String CPS_WINDOW_ACCESS_COMPONENT = "cps:WindowAccessor";
     public final static String CPS_ID_GENERATOR_COMPONENT = "cps:IdGenerator";
     public final static String CPS_JETSPEED_POWERTOOL_FACTORY = "cps:Powertools";
     public final static String CPS_HEADER_RESOURCE_FACTORY = "cps:HeaderResource";

Modified: portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/jetspeed-api/src/java/org/apache/jetspeed/components/portletentity/PortletEntityAccessComponent.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/jetspeed-api/src/java/org/apache/jetspeed/components/portletentity/PortletEntityAccessComponent.java?rev=367239&r1=367238&r2=367239&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/jetspeed-api/src/java/org/apache/jetspeed/components/portletentity/PortletEntityAccessComponent.java
(original)
+++ portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/jetspeed-api/src/java/org/apache/jetspeed/components/portletentity/PortletEntityAccessComponent.java
Sun Jan  8 23:42:09 2006
@@ -146,6 +146,20 @@
 	void removeFromCache(PortletEntity entity);
 
     /**
+     * <p>
+     * updatePortletEntity
+     * </p>
+     *
+     * Updates portlet definition associated with the portlet
+     * entity to match the fragment configuration 
+     *
+     * @param portletEntity
+	 * @param fragment
+	 * @throws PortletEntityNotStoredException 
+     */
+    void updatePortletEntity(PortletEntity portletEntity, ContentFragment fragment) throws
PortletEntityNotStoredException;
+
+    /**
      * 
      * <p>
      * storePortletEntity

Modified: portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/layout-portlets/src/java/org/apache/jetspeed/portlets/layout/LayoutPortlet.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/layout-portlets/src/java/org/apache/jetspeed/portlets/layout/LayoutPortlet.java?rev=367239&r1=367238&r2=367239&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/layout-portlets/src/java/org/apache/jetspeed/portlets/layout/LayoutPortlet.java
(original)
+++ portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/layout-portlets/src/java/org/apache/jetspeed/portlets/layout/LayoutPortlet.java
Sun Jan  8 23:42:09 2006
@@ -37,6 +37,7 @@
 import org.apache.jetspeed.capabilities.CapabilityMap;
 import org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent;
 import org.apache.jetspeed.components.portletregistry.PortletRegistry;
+import org.apache.jetspeed.container.window.PortletWindowAccessor;
 import org.apache.jetspeed.locator.LocatorDescriptor;
 import org.apache.jetspeed.locator.TemplateDescriptor;
 import org.apache.jetspeed.locator.TemplateLocator;
@@ -76,6 +77,7 @@
     protected JetspeedPowerToolFactory jptFactory;
     protected TemplateLocator templateLocator;
     protected PortletEntityAccessComponent entityAccess;
+    protected PortletWindowAccessor windowAccess;
     protected TemplateLocator decorationLocator;
     
     public void init( PortletConfig config ) throws PortletException
@@ -103,6 +105,12 @@
         {
             throw new PortletException("Failed to find the Entity Access on portlet initialization");
         }                
+        
+        windowAccess = (PortletWindowAccessor) getPortletContext().getAttribute(CommonPortletServices.CPS_WINDOW_ACCESS_COMPONENT);
+        if (null == windowAccess)
+        {
+            throw new PortletException("Failed to find the Window Access on portlet initialization");
+        }        
         
         templateLocator = (TemplateLocator) getPortletContext().getAttribute("TemplateLocator");
         decorationLocator = (TemplateLocator) getPortletContext().getAttribute("DecorationLocator");

Modified: portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/layout-portlets/src/java/org/apache/jetspeed/portlets/layout/MultiColumnPortlet.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/layout-portlets/src/java/org/apache/jetspeed/portlets/layout/MultiColumnPortlet.java?rev=367239&r1=367238&r2=367239&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/layout-portlets/src/java/org/apache/jetspeed/portlets/layout/MultiColumnPortlet.java
(original)
+++ portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/layout-portlets/src/java/org/apache/jetspeed/portlets/layout/MultiColumnPortlet.java
Sun Jan  8 23:42:09 2006
@@ -218,7 +218,7 @@
             }
             catch (Exception e)
             {
-                throw new PortletException("Unable to access page for editing: "+e.getMessage());
+                throw new PortletException("Unable to access page for editing: "+e.getMessage(),
e);
             }                        
         }
         else if (request.getParameter("move") != null 
@@ -232,7 +232,7 @@
             }
             catch (Exception e)
             {
-                throw new PortletException("Unable to access page for editing: "+e.getMessage());
+                throw new PortletException("Unable to access page for editing: "+e.getMessage(),
e);
             }
           
             Fragment rootFragment = page.getRootFragment();
@@ -294,14 +294,14 @@
                 && fragmentChange != null                
                 && editingPage != null)
         {
-            Page page;
+            ContentPage page;
             try
             {
-                page = pageManager.getPage(editingPage);
+                page = pageManager.getContentPage(editingPage);
             }
             catch (Exception e)
             {
-                throw new PortletException("Unable to access page for editing: "+e.getMessage());
+                throw new PortletException("Unable to access page for editing: "+e.getMessage(),
e);
             }
           
             Fragment fragment = page.getFragmentById(fragmentChange);
@@ -318,45 +318,58 @@
             }
             catch (Exception e)
             {
-                throw new PortletException("Unable to update page for fragment decorator:
"+e.getMessage());
+                throw new PortletException("Unable to update page for fragment decorator:
"+e.getMessage(), e);
             }
         }
         else if (themeChange != null &&
                  layoutChange != null &&
                  editingPage != null)                
         {
+            // get page to be edited
             ContentPage page;
             try
             {
+                // access content page to be edited
                 page = pageManager.getContentPage(editingPage);
             }
             catch (Exception e)
             {
-                throw new PortletException("Unable to access page for editing: "+e.getMessage());
+                throw new PortletException("Unable to access page for editing: "+e.getMessage(),
e);
             }
-            
-            page.setDefaultDecorator(themeChange, Fragment.LAYOUT);
-            
+
+            // edit and update page
+            boolean layoutPortletChanged = !layoutChange.equals(page.getRootFragment().getName());
             try
             {
-                PortletEntity oldEntity = this.entityAccess.getPortletEntity(page.getRootFragment().getId());
-                if (oldEntity != null)
-                {
-                    PortletEntity newEntity = 
-                        this.entityAccess.generateEntityFromFragment((ContentFragment)page.getRootFragment(),
null);
-                    this.entityAccess.removePortletEntity(oldEntity);
-                    Fragment newFragment = pageManager.copyFragment(page.getRootFragment(),
layoutChange);
-                    page.setRootFragment(newFragment);
-                    
-                    this.entityAccess.storePortletEntity(newEntity);
-                    pageManager.updatePage(page);
-                }                
+                // update page theme and/or root fragment
+                // layout portlet change
+                page.setDefaultDecorator(themeChange, Fragment.LAYOUT);
+                page.getRootFragment().setName(layoutChange);
+                pageManager.updatePage(page);
             }
             catch (Exception e)
             {
-                throw new PortletException("Unable to update page for fragment decorator:
"+e.getMessage());
+                throw new PortletException("Unable to update page: "+e.getMessage(), e);
             }
             
+            // update portlet entity and portlet window if layout portlet modified
+            if (layoutPortletChanged)
+            {
+                try
+                {
+                    // update matching portlet entity
+                    PortletEntity portletEntity = this.entityAccess.getPortletEntity(page.getRootFragment().getId());
+                    this.entityAccess.updatePortletEntity(portletEntity, (ContentFragment)page.getRootFragment());
+                    this.entityAccess.storePortletEntity(portletEntity);
+
+                    // update matching portlet window
+                    this.windowAccess.createPortletWindow(portletEntity, page.getRootFragment().getId());
+                }
+                catch (Exception e)
+                {
+                    throw new PortletException("Unable to update portlet entity or window:
"+e.getMessage(), e);
+                }
+            }
         }
         else
         {        

Modified: portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/layout-portlets/src/webapp/WEB-INF/jetspeed-portlet.xml
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/layout-portlets/src/webapp/WEB-INF/jetspeed-portlet.xml?rev=367239&r1=367238&r2=367239&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/layout-portlets/src/webapp/WEB-INF/jetspeed-portlet.xml
(original)
+++ portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/layout-portlets/src/webapp/WEB-INF/jetspeed-portlet.xml
Sun Jan  8 23:42:09 2006
@@ -33,6 +33,7 @@
 		<js:service name='Powertools'/>    
 		<js:service name='DecorationFactory'/>		    
 		<js:service name='EntityAccessor'/>				
+		<js:service name='WindowAccessor'/>		
 	</js:services>
 	
 </portlet-app>

Modified: portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/src/webapp/WEB-INF/assembly/jetspeed-services.xml
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/src/webapp/WEB-INF/assembly/jetspeed-services.xml?rev=367239&r1=367238&r2=367239&view=diff
==============================================================================
--- portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/src/webapp/WEB-INF/assembly/jetspeed-services.xml
(original)
+++ portals/jetspeed-2/branches/JETSPEED-BRANCH-2.0.1/src/webapp/WEB-INF/assembly/jetspeed-services.xml
Sun Jan  8 23:42:09 2006
@@ -52,6 +52,9 @@
   	   	  <entry key="EntityAccessor">
   	   	  	 <ref bean='org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent'/>
   	   	  </entry>
+  	   	  <entry key="WindowAccessor">
+  	   	  	 <ref bean='org.apache.jetspeed.container.window.PortletWindowAccessor'/>
+  	   	  </entry>
           <!-- ApplicationServerManager currently only supported for Tomcat. Comment out
for others like JBoss -->
           <entry key="ApplicationServerManager">
             <ref bean="org.apache.jetspeed.tools.pamanager.servletcontainer.ApplicationServerManager"/>



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