[pal-cvs 2626] [358] update a fragment dynamically.

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2007年 7月 23日 (月) 22:42:36 JST


Revision: 358
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=pal&view=rev&rev=358
Author:   shinsuke
Date:     2007-07-23 22:42:36 +0900 (Mon, 23 Jul 2007)

Log Message:
-----------
update a fragment dynamically.

Modified Paths:
--------------
    pal-admin/trunk/src/main/java/jp/sf/pal/admin/PALAdminConstants.java
    pal-admin/trunk/src/main/java/jp/sf/pal/admin/filter/SiteEditorFilter.java
    pal-admin/trunk/src/main/java/jp/sf/pal/admin/logic/SiteEditorLogic.java
    pal-admin/trunk/src/main/java/jp/sf/pal/admin/util/PortalComponentUtil.java
    pal-admin/trunk/src/main/resources/appMessages.properties
    pal-admin/trunk/src/main/webapp/WEB-INF/jetspeed-portlet.xml


-------------- next part --------------
Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/PALAdminConstants.java
===================================================================
--- pal-admin/trunk/src/main/java/jp/sf/pal/admin/PALAdminConstants.java	2007-07-23 13:40:52 UTC (rev 357)
+++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/PALAdminConstants.java	2007-07-23 13:42:36 UTC (rev 358)
@@ -48,6 +48,12 @@
     public static final String PERMISSION_MANAGER_COMPONENT = PREFIX
             + "PermissionManager";
 
+    public static final String PORTLET_ENTITY_ACCESS_COMPONENT = PREFIX
+            + "PortletEntityAccess";
+
+    public static final String PORTLET_WINDOW_ACCESSOR_COMPONENT = PREFIX
+            + "PortletWindowAccessor";
+
     public static final String PORTLET_FACTORY_COMPONENT = PREFIX
             + "PortletFactory";
 

Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/filter/SiteEditorFilter.java
===================================================================
--- pal-admin/trunk/src/main/java/jp/sf/pal/admin/filter/SiteEditorFilter.java	2007-07-23 13:40:52 UTC (rev 357)
+++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/filter/SiteEditorFilter.java	2007-07-23 13:42:36 UTC (rev 358)
@@ -28,7 +28,9 @@
 import jp.sf.pal.admin.PALAdminConstants;
 
 import org.apache.jetspeed.CommonPortletServices;
+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.decoration.DecorationFactory;
 import org.apache.jetspeed.page.PageManager;
 import org.apache.jetspeed.profiler.Profiler;
@@ -48,12 +50,18 @@
 
     private PermissionManager permissionManager;
 
+    private PortletEntityAccessComponent portletEntityAccessComponent;
+
+    private PortletWindowAccessor portletWindowAccessor;
+
     public void destroy() {
         pageManager = null;
         profiler = null;
         decorationFactory = null;
         portletRegistry = null;
         permissionManager = null;
+        portletEntityAccessComponent = null;
+        portletWindowAccessor = null;
     }
 
     public void init(PortletFilterConfig filterConfig) throws PortletException {
@@ -99,6 +107,22 @@
             throw new PortletException(
                     "Failed to find the Profiler on portlet initialization");
         }
+
+        // portletEntityAccessComponent
+        portletEntityAccessComponent = (PortletEntityAccessComponent) portletContext
+                .getAttribute(CommonPortletServices.CPS_ENTITY_ACCESS_COMPONENT);
+        if (null == portletEntityAccessComponent) {
+            throw new PortletException(
+                    "Failed to find the Profiler on portlet initialization");
+        }
+
+        // portletWindowAccessor
+        portletWindowAccessor = (PortletWindowAccessor) portletContext
+                .getAttribute(CommonPortletServices.CPS_WINDOW_ACCESS_COMPONENT);
+        if (null == portletWindowAccessor) {
+            throw new PortletException(
+                    "Failed to find the Profiler on portlet initialization");
+        }
     }
 
     public void processActionFilter(ActionRequest request,
@@ -113,6 +137,11 @@
                 portletRegistry);
         request.setAttribute(PALAdminConstants.PERMISSION_MANAGER_COMPONENT,
                 permissionManager);
+        request.setAttribute(PALAdminConstants.PORTLET_ENTITY_ACCESS_COMPONENT,
+                portletEntityAccessComponent);
+        request.setAttribute(
+                PALAdminConstants.PORTLET_WINDOW_ACCESSOR_COMPONENT,
+                portletWindowAccessor);
 
         chain.processActionFilter(request, response);
     }
@@ -128,6 +157,11 @@
                 portletRegistry);
         request.setAttribute(PALAdminConstants.PERMISSION_MANAGER_COMPONENT,
                 permissionManager);
+        request.setAttribute(PALAdminConstants.PORTLET_ENTITY_ACCESS_COMPONENT,
+                portletEntityAccessComponent);
+        request.setAttribute(
+                PALAdminConstants.PORTLET_WINDOW_ACCESSOR_COMPONENT,
+                portletWindowAccessor);
 
         chain.renderFilter(request, response);
 

Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/logic/SiteEditorLogic.java
===================================================================
--- pal-admin/trunk/src/main/java/jp/sf/pal/admin/logic/SiteEditorLogic.java	2007-07-23 13:40:52 UTC (rev 357)
+++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/logic/SiteEditorLogic.java	2007-07-23 13:42:36 UTC (rev 358)
@@ -32,10 +32,13 @@
 
 import org.apache.jetspeed.JetspeedActions;
 import org.apache.jetspeed.PortalReservedParameters;
+import org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent;
+import org.apache.jetspeed.components.portletentity.PortletEntityNotStoredException;
 import org.apache.jetspeed.components.portletregistry.PortletRegistry;
+import org.apache.jetspeed.container.window.FailedToRetrievePortletWindow;
+import org.apache.jetspeed.container.window.PortletWindowAccessor;
 import org.apache.jetspeed.decoration.DecorationFactory;
 import org.apache.jetspeed.decoration.LayoutInfo;
-import org.apache.jetspeed.om.common.SecuredResource;
 import org.apache.jetspeed.om.common.SecurityConstraint;
 import org.apache.jetspeed.om.common.SecurityConstraints;
 import org.apache.jetspeed.om.common.portlet.MutablePortletApplication;
@@ -43,6 +46,8 @@
 import org.apache.jetspeed.om.folder.Folder;
 import org.apache.jetspeed.om.folder.FolderNotFoundException;
 import org.apache.jetspeed.om.folder.InvalidFolderException;
+import org.apache.jetspeed.om.page.ContentFragment;
+import org.apache.jetspeed.om.page.ContentPage;
 import org.apache.jetspeed.om.page.Fragment;
 import org.apache.jetspeed.om.page.Page;
 import org.apache.jetspeed.om.page.SecurityConstraintsDef;
@@ -58,6 +63,7 @@
 import org.apache.jetspeed.profiler.Profiler;
 import org.apache.jetspeed.request.RequestContext;
 import org.apache.jetspeed.security.PermissionManager;
+import org.apache.pluto.om.window.PortletWindow;
 import org.seasar.framework.log.Logger;
 
 public class SiteEditorLogic implements Serializable {
@@ -82,6 +88,10 @@
 
     private transient PermissionManager permissionManager = null;
 
+    private transient PortletWindowAccessor portletWindowAccessor = null;
+
+    private transient PortletEntityAccessComponent portletEntityAccessComponent = null;
+
     private transient RequestContext requestContext = null;
 
     /**
@@ -170,6 +180,44 @@
     }
 
     /**
+     * @return the permissionManager
+     */
+    public PortletWindowAccessor getPortletWindowAccessor() {
+        if (portletWindowAccessor == null) {
+            portletWindowAccessor = PortalComponentUtil
+                    .getPortletWindowAccessor();
+        }
+        return portletWindowAccessor;
+    }
+
+    /**
+     * @param portletWindowAccessor the portletWindowAccessor to set
+     */
+    public void setPortletWindowAccessor(
+            PortletWindowAccessor portletWindowAccessor) {
+        this.portletWindowAccessor = portletWindowAccessor;
+    }
+
+    /**
+     * @return the permissionManager
+     */
+    public PortletEntityAccessComponent getPortletEntityAccessComponent() {
+        if (portletEntityAccessComponent == null) {
+            portletEntityAccessComponent = PortalComponentUtil
+                    .getPortletEntityAccessComponent();
+        }
+        return portletEntityAccessComponent;
+    }
+
+    /**
+     * @param portletEntityAccessComponent the portletEntityAccessComponent to set
+     */
+    public void setPortletEntityAccessComponent(
+            PortletEntityAccessComponent portletEntityAccessComponent) {
+        this.portletEntityAccessComponent = portletEntityAccessComponent;
+    }
+
+    /**
      * @return the profiler
      */
     public RequestContext getRequestContext() {
@@ -1009,6 +1057,41 @@
             throw new CommonException("could.not.update.layout",
                     "Could not update a layout: " + path, e);
         }
+
+        try {
+            ContentPage cpage = getPageManager().getContentPage(page.getPath());
+            ContentFragment cfragment = cpage.getContentFragmentById(fid);
+            PortletWindow portletWindow = getPortletWindowAccessor()
+                    .getPortletWindow(cfragment);
+            getPortletEntityAccessComponent().updatePortletEntity(
+                    portletWindow.getPortletEntity(), cfragment);
+            getPortletEntityAccessComponent().storePortletEntity(
+                    portletWindow.getPortletEntity());
+
+            getPortletWindowAccessor().createPortletWindow(
+                    portletWindow.getPortletEntity(), cfragment.getId());
+        } catch (PageNotFoundException e) {
+            throw new CommonException(
+                    "updated.layout.but.could.not.update.cache",
+                    "Update a layout configuration, but could not update a cache.: "
+                            + path, e);
+        } catch (NodeException e) {
+            throw new CommonException(
+                    "updated.layout.but.could.not.update.cache",
+                    "Update a layout configuration, but could not update a cache.: "
+                            + path, e);
+        } catch (FailedToRetrievePortletWindow e) {
+            throw new CommonException(
+                    "updated.layout.but.could.not.update.cache",
+                    "Update a layout configuration, but could not update a cache.: "
+                            + path, e);
+        } catch (PortletEntityNotStoredException e) {
+            throw new CommonException(
+                    "updated.layout.but.could.not.update.cache",
+                    "Update a layout configuration, but could not update a cache.: "
+                            + path, e);
+        }
+
     }
 
     public String deleteLayout(String path) throws CommonException {
@@ -1088,6 +1171,41 @@
             throw new CommonException("could.not.update.portlet",
                     "Could not update a page: " + path, e);
         }
+
+        try {
+            ContentPage cpage = getPageManager().getContentPage(page.getPath());
+            ContentFragment cfragment = cpage.getContentFragmentById(fid);
+            PortletWindow portletWindow = getPortletWindowAccessor()
+                    .getPortletWindow(cfragment);
+            getPortletEntityAccessComponent().updatePortletEntity(
+                    portletWindow.getPortletEntity(), cfragment);
+            getPortletEntityAccessComponent().storePortletEntity(
+                    portletWindow.getPortletEntity());
+
+            getPortletWindowAccessor().createPortletWindow(
+                    portletWindow.getPortletEntity(), cfragment.getId());
+        } catch (PageNotFoundException e) {
+            throw new CommonException(
+                    "updated.portlet.but.could.not.update.cache",
+                    "Update a portlet configuration, but could not update a cache.: "
+                            + path, e);
+        } catch (NodeException e) {
+            throw new CommonException(
+                    "updated.portlet.but.could.not.update.cache",
+                    "Update a portlet configuration, but could not update a cache.: "
+                            + path, e);
+        } catch (FailedToRetrievePortletWindow e) {
+            throw new CommonException(
+                    "updated.portlet.but.could.not.update.cache",
+                    "Update a portlet configuration, but could not update a cache.: "
+                            + path, e);
+        } catch (PortletEntityNotStoredException e) {
+            throw new CommonException(
+                    "updated.portlet.but.could.not.update.cache",
+                    "Update a portlet configuration, but could not update a cache.: "
+                            + path, e);
+        }
+
     }
 
     public String deletePortlet(String path) throws CommonException {

Modified: pal-admin/trunk/src/main/java/jp/sf/pal/admin/util/PortalComponentUtil.java
===================================================================
--- pal-admin/trunk/src/main/java/jp/sf/pal/admin/util/PortalComponentUtil.java	2007-07-23 13:40:52 UTC (rev 357)
+++ pal-admin/trunk/src/main/java/jp/sf/pal/admin/util/PortalComponentUtil.java	2007-07-23 13:42:36 UTC (rev 358)
@@ -20,7 +20,9 @@
 import jp.sf.pal.admin.PALAdminConstants;
 
 import org.apache.jetspeed.administration.PortalAdministration;
+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.decoration.DecorationFactory;
 import org.apache.jetspeed.deployment.DeploymentManager;
 import org.apache.jetspeed.factory.PortletFactory;
@@ -114,4 +116,16 @@
                         PALAdminConstants.PERMISSION_MANAGER_COMPONENT);
     }
 
+    public static PortletEntityAccessComponent getPortletEntityAccessComponent() {
+        return (PortletEntityAccessComponent) getFacesContext()
+                .getExternalContext().getRequestMap().get(
+                        PALAdminConstants.PORTLET_ENTITY_ACCESS_COMPONENT);
+    }
+
+    public static PortletWindowAccessor getPortletWindowAccessor() {
+        return (PortletWindowAccessor) getFacesContext().getExternalContext()
+                .getRequestMap().get(
+                        PALAdminConstants.PORTLET_WINDOW_ACCESSOR_COMPONENT);
+    }
+
 }

Modified: pal-admin/trunk/src/main/resources/appMessages.properties
===================================================================
--- pal-admin/trunk/src/main/resources/appMessages.properties	2007-07-23 13:40:52 UTC (rev 357)
+++ pal-admin/trunk/src/main/resources/appMessages.properties	2007-07-23 13:42:36 UTC (rev 358)
@@ -167,3 +167,6 @@
 
 invalid.path=Invalid path. Please try again. If you see this error message again, please contact a site administrator.
 could.not.access.path=Could not access the path.
+
+updated.layout.but.could.not.update.cache=Updated layout configuration, but could not update a cache. If you see this error message again, please contact a site administrator.
+updated.portlet.but.could.not.update.cache=Updated portlet configuration, but could not update a cache. If you see this error message again, please contact a site administrator.

Modified: pal-admin/trunk/src/main/webapp/WEB-INF/jetspeed-portlet.xml
===================================================================
--- pal-admin/trunk/src/main/webapp/WEB-INF/jetspeed-portlet.xml	2007-07-23 13:40:52 UTC (rev 357)
+++ pal-admin/trunk/src/main/webapp/WEB-INF/jetspeed-portlet.xml	2007-07-23 13:42:36 UTC (rev 358)
@@ -62,6 +62,7 @@
     <js:service name="ApplicationServerManager"/>
     <js:service name="DeploymentManager"/>
     <js:service name="EntityAccessor"/>
+    <js:service name="WindowAccessor"/>
     <js:service name="PageManager"/>
     <js:service name="PermissionManager"/>
     <js:service name="PortalAdministration"/>


pal-cvs メーリングリストの案内
Back to archive index