Update of 
/var/cvs/contributions/CMSContainer/cmsc/portal/src/java/com/finalist/pluto/portalImpl/aggregation
In directory 
james.mmbase.org:/tmp/cvs-serv1180/cmsc/portal/src/java/com/finalist/pluto/portalImpl/aggregation

Modified Files:
        PortletFragment.java layoutrouting.properties 
        AbstractFragment.java ScreenFragment.java 
Log Message:
CMSC-749 Newsletter: PDA version of the newsletter


See also: 
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer/cmsc/portal/src/java/com/finalist/pluto/portalImpl/aggregation
See also: http://www.mmbase.org/jira/browse/CMSC-749


Index: PortletFragment.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer/cmsc/portal/src/java/com/finalist/pluto/portalImpl/aggregation/PortletFragment.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- PortletFragment.java        21 Apr 2008 10:11:51 -0000      1.11
+++ PortletFragment.java        9 May 2008 10:06:55 -0000       1.12
@@ -25,6 +25,7 @@
 import org.apache.pluto.PortletContainerException;
 import org.apache.pluto.om.ControllerObjectAccess;
 import org.apache.pluto.om.entity.PortletEntity;
+import org.apache.pluto.om.portlet.PortletApplicationDefinition;
 import org.apache.pluto.om.portlet.PortletDefinition;
 import org.apache.pluto.om.servlet.ServletDefinition;
 import org.apache.pluto.om.servlet.ServletDefinitionCtrl;
@@ -37,6 +38,7 @@
 import com.finalist.pluto.portalImpl.core.*;
 import com.finalist.pluto.portalImpl.om.common.impl.PreferenceSetImpl;
 import com.finalist.pluto.portalImpl.om.entity.impl.PortletEntityImpl;
+import 
com.finalist.pluto.portalImpl.om.servlet.impl.WebApplicationDefinitionImpl;
 import com.finalist.pluto.portalImpl.om.window.impl.PortletWindowImpl;
 import com.finalist.pluto.portalImpl.servlet.ServletObjectAccess;
 import com.finalist.pluto.portalImpl.servlet.ServletResponseImpl;
@@ -163,7 +165,18 @@
       String errorMsg = null;
       try {
          log.debug("|| portletLoad:'" + portletWindow.getId() + "'");
+          
          
PortletContainerFactory.getPortletContainer().portletLoad(portletWindow, 
wrappedRequest, response);
+
+         PortletDefinition def = 
portletWindow.getPortletEntity().getPortletDefinition();
+         if (def == null) {
+            throw new PortletException("PortletDefinition not found for window 
" + portletWindow.getId());
+         }
+
+         // store the context path in the webapp.
+         PortletApplicationDefinition app = 
def.getPortletApplicationDefinition();
+         WebApplicationDefinitionImpl wa = (WebApplicationDefinitionImpl) 
app.getWebApplicationDefinition();
+         wa.setContextRoot(request.getContextPath());
       }
       catch (PortletContainerException e) {
          log.error("PortletContainerException-Error in Portlet", e);
@@ -285,7 +298,7 @@
          // output the header JSP page
 
          // request.setAttribute("portletInfo", portletInfo);
-         RequestDispatcher rd = getMainRequestDispatcher(portletHeaderJsp);
+         RequestDispatcher rd = getMainRequestDispatcher(portletHeaderJsp, 
response.getContentType());
          rd.include(request, response);
          try {
             // output the Portlet
@@ -301,7 +314,7 @@
          finally {
             // output the footer JSP page
             String portletFooterJsp = 
getServletContextParameterValue("portlet.footer.jsp", 
"PortletFragmentFooter.jsp");
-            RequestDispatcher rdFooter = 
getMainRequestDispatcher(portletFooterJsp);
+            RequestDispatcher rdFooter = 
getMainRequestDispatcher(portletFooterJsp, response.getContentType());
             rdFooter.include(request, response);
 
             request.removeAttribute(PortalConstants.FRAGMENT);
@@ -320,6 +333,10 @@
       }
    }
 
+   public PortletMode getPortletMode(PortalEnvironment env, PortletWindow 
portletWindow) {
+       return env.getPortalControlParameter().getMode(portletWindow);
+   }
+
 
    public PortletWindow getPortletWindow() {
       return portletWindow;


Index: layoutrouting.properties
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer/cmsc/portal/src/java/com/finalist/pluto/portalImpl/aggregation/layoutrouting.properties,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- layoutrouting.properties    8 May 2008 06:29:47 -0000       1.1
+++ layoutrouting.properties    9 May 2008 10:06:55 -0000       1.2
@@ -1 +1,4 @@
+text/html=/WEB-INF/templates/layout/
+application/xhtml+xml=/WEB-INF/templates/layout/
 text/plain=/WEB-INF/templates/layout_plain/ 
\ No newline at end of file
+application/vnd.wap.xhtml+xml=/WEB-INF/templates/layout_mobile/
\ No newline at end of file


Index: AbstractFragment.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer/cmsc/portal/src/java/com/finalist/pluto/portalImpl/aggregation/AbstractFragment.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- AbstractFragment.java       8 May 2008 09:13:21 -0000       1.9
+++ AbstractFragment.java       9 May 2008 10:06:55 -0000       1.10
@@ -19,7 +19,6 @@
 
 package com.finalist.pluto.portalImpl.aggregation;
 
-import com.finalist.cmsc.portalImpl.ControllerFilter;
 import com.finalist.cmsc.services.Parameters;
 import org.mmbase.util.logging.Logger;
 import org.mmbase.util.logging.Logging;
@@ -58,6 +57,7 @@
       }
 
       this.config = config;
+      initRoutingRules();
    }
 
 
@@ -86,22 +86,26 @@
    }
 
 
-   public RequestDispatcher getMainRequestDispatcher(String resourceName) {
-
-      String location = "/WEB-INF/templates/layout/";
-
-      String contentType = ControllerFilter.getContentType();
-      initRoutingRules(contentType);
-
-      if (null != contentType && null != routings.getProperty(contentType)) {
-         location = routings.getProperty(contentType);
+   public RequestDispatcher getMainRequestDispatcher(String resourceName, 
String contentType) {
+       contentType = removeCharsetFromContentType(contentType);
+       if (null != contentType && !routings.containsKey(contentType)) {
+           throw new IllegalArgumentException("invalid contenttype: " + 
contentType);
       }
 
+      String location = routings.getProperty(contentType);
       log.debug(String.format("Get RequestDispatcher of %s from %s", 
resourceName, location));
 
       return getRequestDispatcher("cmsc.portal.layout.base.dir", 
location.trim(), resourceName.trim());
    }
 
+    private String removeCharsetFromContentType(String contentType) {
+        int indexOf = contentType.indexOf(";");
+        if (indexOf > -1) {
+            contentType = contentType.substring(0, indexOf);
+        }
+        return contentType;
+    }
+
    public RequestDispatcher getRequestDispatcher(String contentName, String 
defaultValue, String resourceName) {
       String root = getServletContextParameterValue(contentName, defaultValue);
       return getServletConfig().getServletContext().getRequestDispatcher(root 
+ resourceName);
@@ -112,8 +116,8 @@
       return initParameters.getString(name);
    }
 
-   private void initRoutingRules(String contentType) {
-      if (null != contentType && null == routings) {
+   private void initRoutingRules() {
+     if (routings == null) {
          InputStream inputStream = 
this.getClass().getResourceAsStream("layoutrouting.properties");
          routings = new Properties();
          try {


Index: ScreenFragment.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer/cmsc/portal/src/java/com/finalist/pluto/portalImpl/aggregation/ScreenFragment.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- ScreenFragment.java 21 Apr 2008 10:11:51 -0000      1.11
+++ ScreenFragment.java 9 May 2008 10:06:55 -0000       1.12
@@ -49,7 +49,7 @@
 
       Iterator<PortletFragment> portlets = this.getChildFragments().iterator();
       while (portlets.hasNext()) {
-         Fragment portlet = portlets.next();
+          PortletFragment portlet = portlets.next();
          // let the Portlet do it's thing
          portlet.service(request, response);
       }
@@ -59,7 +59,7 @@
             log.debug("using layout:'" + layout.getResource() + "' for page:'" 
+ page.getTitle() + "'");
 
             request.setAttribute(PortalConstants.FRAGMENT, this);
-            RequestDispatcher rd = 
getMainRequestDispatcher(layout.getResource());
+            RequestDispatcher rd = 
getMainRequestDispatcher(layout.getResource(), response.getContentType());
             rd.include(request, response);
             request.removeAttribute(PortalConstants.FRAGMENT);
          }
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to