Update of 
/var/cvs/contributions/CMSContainer/cmsc/portlets/src/java/com/finalist/cmsc/portlets
In directory 
james.mmbase.org:/tmp/cvs-serv31022/cmsc/portlets/src/java/com/finalist/cmsc/portlets

Modified Files:
        CmscPortlet.java AbstractContentPortlet.java 
        IFramePortlet.java JspPortlet.java 
Log Message:
CMSC-961 - Added code to save and load arbitrary portlet/portletnode parameters 
to the CmscPortlet, and pointed some other portlets to super.


See also: 
http://cvs.mmbase.org/viewcvs/contributions/CMSContainer/cmsc/portlets/src/java/com/finalist/cmsc/portlets
See also: http://www.mmbase.org/jira/browse/CMSC-961


Index: CmscPortlet.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer/cmsc/portlets/src/java/com/finalist/cmsc/portlets/CmscPortlet.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- CmscPortlet.java    2 Jun 2008 21:56:34 -0000       1.22
+++ CmscPortlet.java    21 Jun 2008 15:52:35 -0000      1.23
@@ -2,16 +2,33 @@
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.*;
-
-import javax.portlet.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Properties;
+import java.util.ResourceBundle;
+import java.util.Set;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.GenericPortlet;
+import javax.portlet.PortletException;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletPreferences;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletRequestDispatcher;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.WindowState;
 import javax.servlet.ServletRequest;
 import javax.servlet.http.HttpServletRequestWrapper;
 import javax.servlet.jsp.jstl.core.Config;
 import javax.servlet.jsp.jstl.fmt.LocalizationContext;
 
-import net.sf.mmapps.commons.bridge.CloudUtil;
-
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -28,15 +45,24 @@
 import com.finalist.cmsc.services.sitemanagement.SiteManagementAdmin;
 import com.finalist.cmsc.util.bundles.CombinedResourceBundle;
 import com.finalist.pluto.portalImpl.aggregation.PortletFragment;
-import com.finalist.pluto.portalImpl.core.*;
+import com.finalist.pluto.portalImpl.core.CmscPortletMode;
+import com.finalist.pluto.portalImpl.core.PortalEnvironment;
+import com.finalist.pluto.portalImpl.core.PortalURL;
+
+import net.sf.mmapps.commons.bridge.CloudUtil;
 
 @SuppressWarnings("unused")
 public class CmscPortlet extends GenericPortlet {
 
    private static final String CONTENT_TYPE_DEFAULT = "text/html";
+
+   private static final String NODEPARAM_PREFIX = "nodeparam_";
+
+   private static final String PARAM_PREFIX = "param_";
+
    private static Properties routings;
-   private Log log;
 
+   private Log log;
 
    protected Log getLogger() {
       if (log == null) {
@@ -56,7 +82,8 @@
     *      javax.portlet.ActionResponse)
     */
    @Override
-   public void processAction(ActionRequest req, ActionResponse res) throws 
PortletException, IOException {
+   public void processAction(ActionRequest req, ActionResponse res) throws 
PortletException,
+         IOException {
       if (getLogger().isDebugEnabled()) {
          getLogger().debug("===> process " + getPortletName() + " mode = " + 
req.getPortletMode());
       }
@@ -65,25 +92,32 @@
       if (mode.equals(PortletMode.VIEW)) {
          processView(req, res);
       }
-      else if (mode.equals(CmscPortletMode.ABOUT)) {
+      else
+         if (mode.equals(CmscPortletMode.ABOUT)) {
          processAbout(req, res);
       }
-      else if (mode.equals(CmscPortletMode.CONFIG)) {
+         else
+            if (mode.equals(CmscPortletMode.CONFIG)) {
          processConfig(req, res);
       }
-      else if (mode.equals(PortletMode.EDIT)) {
+            else
+               if (mode.equals(PortletMode.EDIT)) {
          processEdit(req, res);
       }
-      else if (mode.equals(CmscPortletMode.EDIT_DEFAULTS)) {
+               else
+                  if (mode.equals(CmscPortletMode.EDIT_DEFAULTS)) {
          processEditDefaults(req, res);
       }
-      else if (mode.equals(PortletMode.HELP)) {
+                  else
+                     if (mode.equals(PortletMode.HELP)) {
          processHelp(req, res);
       }
-      else if (mode.equals(CmscPortletMode.PREVIEW)) {
+                     else
+                        if (mode.equals(CmscPortletMode.PREVIEW)) {
          processPreview(req, res);
       }
-      else if (mode.equals(CmscPortletMode.PRINT)) {
+                        else
+                           if (mode.equals(CmscPortletMode.PRINT)) {
          processPrint(req, res);
       }
       else {
@@ -91,36 +125,42 @@
       }
    }
 
-
-   public void processPrint(ActionRequest req, ActionResponse res) throws 
PortletException, IOException {
+   public void processPrint(ActionRequest req, ActionResponse res) throws 
PortletException,
+         IOException {
       // convenience method
    }
 
-
-   public void processPreview(ActionRequest req, ActionResponse res) throws 
PortletException, IOException {
+   public void processPreview(ActionRequest req, ActionResponse res) throws 
PortletException,
+         IOException {
       // convenience method
    }
 
-
-   public void processHelp(ActionRequest req, ActionResponse res) throws 
PortletException, IOException {
+   public void processHelp(ActionRequest req, ActionResponse res) throws 
PortletException,
+         IOException {
       // convenience method
    }
 
-
-   public void processEditDefaults(ActionRequest request, ActionResponse 
response) throws PortletException, IOException {
+   public void processEditDefaults(ActionRequest request, ActionResponse 
response)
+         throws PortletException, IOException {
       PortletPreferences preferences = request.getPreferences();
       String portletId = 
preferences.getValue(PortalConstants.CMSC_OM_PORTLET_ID, null);
       if (portletId != null) {
-         for (Enumeration<String> iterator = request.getParameterNames(); 
iterator.hasMoreElements();) {
-            String name = iterator.nextElement();
-            String[] values = request.getParameterValues(name);
-            if (name.startsWith("node.")) {
-               setPortletNodeParameter(portletId, 
name.substring("node.".length()), values);
-            }
-            else {
-               setPortletParameter(portletId, name, values);
+         for (Enumeration<String> iterator = request.getParameterNames(); 
iterator
+               .hasMoreElements();) {
+            String parameterName = iterator.nextElement();
+
+            if (parameterName.toLowerCase().startsWith(PARAM_PREFIX)) {
+               String[] parameterValues = 
request.getParameterValues(parameterName);
+               setPortletParameter(portletId, 
parameterName.substring(PARAM_PREFIX.length()),
+                     parameterValues);
+            }
+            if (parameterName.toLowerCase().startsWith(NODEPARAM_PREFIX)) {
+               String[] parameterValues = 
request.getParameterValues(parameterName);
+               setPortletParameter(portletId, 
parameterName.substring(NODEPARAM_PREFIX.length()),
+                     parameterValues);
             }
          }
+         saveParameters(request, portletId);
       }
       else {
          getLogger().error("No portletId");
@@ -129,37 +169,42 @@
       response.setPortletMode(PortletMode.VIEW);
    }
 
-
-   public void processEdit(ActionRequest req, ActionResponse res) throws 
PortletException, IOException {
+   protected void saveParameters(ActionRequest request, String portletId) {
       // convenience method
    }
 
-
-   public void processConfig(ActionRequest req, ActionResponse res) throws 
PortletException, IOException {
+   public void processEdit(ActionRequest req, ActionResponse res) throws 
PortletException,
+         IOException {
       // convenience method
    }
 
-
-   public void processAbout(ActionRequest req, ActionResponse res) throws 
PortletException, IOException {
+   public void processConfig(ActionRequest req, ActionResponse res) throws 
PortletException,
+         IOException {
       // convenience method
    }
 
-
-   public void processView(ActionRequest req, ActionResponse res) throws 
PortletException, IOException {
+   public void processAbout(ActionRequest req, ActionResponse res) throws 
PortletException,
+         IOException {
       // convenience method
    }
 
+   public void processView(ActionRequest req, ActionResponse res) throws 
PortletException,
+         IOException {
+      // convenience method
+   }
 
    /**
     * @see javax.portlet.GenericPortlet#doDispatch(javax.portlet.RenderRequest,
     *      javax.portlet.RenderResponse)
     */
    @Override
-   protected void doDispatch(RenderRequest req, RenderResponse res) throws 
IOException, PortletException {
+   protected void doDispatch(RenderRequest req, RenderResponse res) throws 
IOException,
+         PortletException {
 
       if (getLogger().isDebugEnabled()) {
          getLogger().debug(
-               "===> " + getPortletName() + " mode = " + req.getPortletMode() 
+ " window = " + req.getWindowState());
+               "===> " + getPortletName() + " mode = " + req.getPortletMode() 
+ " window = "
+                     + req.getWindowState());
       }
 
       WindowState state = req.getWindowState();
@@ -170,25 +215,32 @@
          if (mode.equals(PortletMode.VIEW)) {
             doView(req, res);
          }
-         else if (mode.equals(CmscPortletMode.ABOUT)) {
+         else
+            if (mode.equals(CmscPortletMode.ABOUT)) {
             doAbout(req, res);
          }
-         else if (mode.equals(CmscPortletMode.CONFIG)) {
+            else
+               if (mode.equals(CmscPortletMode.CONFIG)) {
             doConfig(req, res);
          }
-         else if (mode.equals(PortletMode.EDIT)) {
+               else
+                  if (mode.equals(PortletMode.EDIT)) {
             doEdit(req, res);
          }
-         else if (mode.equals(CmscPortletMode.EDIT_DEFAULTS)) {
+                  else
+                     if (mode.equals(CmscPortletMode.EDIT_DEFAULTS)) {
             doEditDefaults(req, res);
          }
-         else if (mode.equals(PortletMode.HELP)) {
+                     else
+                        if (mode.equals(PortletMode.HELP)) {
             doHelp(req, res);
          }
-         else if (mode.equals(CmscPortletMode.PREVIEW)) {
+                        else
+                           if (mode.equals(CmscPortletMode.PREVIEW)) {
             doPreview(req, res);
          }
-         else if (mode.equals(CmscPortletMode.PRINT)) {
+                           else
+                              if (mode.equals(CmscPortletMode.PRINT)) {
             doPrint(req, res);
          }
          else {
@@ -197,7 +249,6 @@
       }
    }
 
-
    protected List<Locale> getLocales(RenderRequest request) {
       PortletMode mode = request.getPortletMode();
 
@@ -220,7 +271,6 @@
       return locales;
    }
 
-
    protected Locale getEditorLocale(RenderRequest request, Locale 
defaultLocale) {
       Locale editorsLocale = (Locale) request.getAttribute("editorsLocale");
       if (editorsLocale == null) {
@@ -244,7 +294,6 @@
       return editorsLocale;
    }
 
-
    private Locale getUserLocale(Cloud cloud) {
       Locale userLocale = null;
       String username = cloud.getUser().getIdentifier();
@@ -260,10 +309,9 @@
       return userLocale;
    }
 
-
    /**
-    * This will set both the primary and the secondary resource bundle (which 
is
-    * used when in edit modus)
+    * This will set both the primary and the secondary resource bundle (which 
is used when in edit
+    * modus)
     *
     * @param req
     * @param template
@@ -337,52 +385,68 @@
       }
    }
 
-
    @Override
-   protected void doView(RenderRequest req, RenderResponse res) throws 
PortletException, java.io.IOException {
+   protected void doView(RenderRequest req, RenderResponse res) throws 
PortletException,
+         java.io.IOException {
       PortletPreferences preferences = req.getPreferences();
       String template = 
preferences.getValue(PortalConstants.CMSC_PORTLET_VIEW_TEMPLATE, null);
 
       String contentType = req.getResponseContentType();
       String location = routings.getProperty(contentType);
 
-      log.debug(String.format("Use %s as view from %s",template,location));
+      log.debug(String.format("Use %s as view from %s", template, location));
       doInclude(location.trim(), template, req, res);
    }
 
-
    @Override
-   protected void doEdit(RenderRequest req, RenderResponse res) throws 
IOException, PortletException {
+   protected void doEdit(RenderRequest req, RenderResponse res) throws 
IOException,
+         PortletException {
       PortletPreferences preferences = req.getPreferences();
       String template = 
preferences.getValue(PortalConstants.CMSC_PORTLET_VIEW_TEMPLATE, null);
       doInclude("edit", template, req, res);
    }
 
-
    @Override
-   protected void doHelp(RenderRequest req, RenderResponse res) throws 
PortletException, IOException {
+   protected void doHelp(RenderRequest req, RenderResponse res) throws 
PortletException,
+         IOException {
       doInclude("help", null, req, res);
    }
 
-
-   protected void doAbout(RenderRequest req, RenderResponse res) throws 
IOException, PortletException {
+   protected void doAbout(RenderRequest req, RenderResponse res) throws 
IOException,
+         PortletException {
       doInclude("about", null, req, res);
    }
 
-
-   protected void doConfig(RenderRequest req, RenderResponse res) throws 
IOException, PortletException {
+   protected void doConfig(RenderRequest req, RenderResponse res) throws 
IOException,
+         PortletException {
       doInclude("config", null, req, res);
    }
 
-
-   protected void doEditDefaults(RenderRequest req, RenderResponse res) throws 
IOException, PortletException {
+   protected void doEditDefaults(RenderRequest req, RenderResponse res) throws 
IOException,
+         PortletException {
+      PortletPreferences preferences = req.getPreferences();
+      for (Enumeration<String> iterator = preferences.getNames(); 
iterator.hasMoreElements();) {
+         String parameterName = iterator.nextElement();
+         if (req.getAttribute(parameterName) == null) {
+            String[] parameterValues = preferences.getValues(parameterName, 
null);
+            if (parameterValues != null && parameterValues.length != 0) {
+               if (parameterValues.length > 1) {
+                  List<String> values = Arrays.asList(parameterValues);
+                  setAttribute(req, parameterName, values);
+               }
+               else {
+                  setAttribute(req, parameterName, parameterValues[0]);
+               }
+            }
+         }
+      }
       doInclude("edit_defaults", null, req, res);
    }
 
-
    protected void addViewInfo(RenderRequest req) {
       PortletPreferences preferences = req.getPreferences();
-      String definitionId = 
preferences.getValue(PortalConstants.CMSC_OM_PORTLET_DEFINITIONID, null);
+      String definitionId = preferences
+            .getValue(PortalConstants.CMSC_OM_PORTLET_DEFINITIONID, null);
 
       List<View> views = SiteManagement.getViews(definitionId);
       setAttribute(req, "views", views);
@@ -393,19 +457,18 @@
       }
    }
 
-
-   protected void doPreview(RenderRequest req, RenderResponse res) throws 
IOException, PortletException {
+   protected void doPreview(RenderRequest req, RenderResponse res) throws 
IOException,
+         PortletException {
       doInclude("preview", null, req, res);
    }
 
-
-   protected void doPrint(RenderRequest req, RenderResponse res) throws 
IOException, PortletException {
+   protected void doPrint(RenderRequest req, RenderResponse res) throws 
IOException,
+         PortletException {
       doInclude("print", null, req, res);
    }
 
-
-   protected void doInclude(String type, String template, RenderRequest 
request, RenderResponse response)
-         throws PortletException, IOException {
+   protected void doInclude(String type, String template, RenderRequest 
request,
+         RenderResponse response) throws PortletException, IOException {
       setResourceBundle(request, template);
 
       String contentType = request.getResponseContentType();
@@ -417,7 +480,6 @@
       rd.include(request, response);
    }
 
-
    protected PortletRequestDispatcher getRequestDispatcher(String type, String 
template) {
       String resourceExtension = "jsp";
       String fullTemplate = getTemplate(type, template, resourceExtension);
@@ -436,16 +498,15 @@
 
    private boolean templateExists(String fullTemplate) {
       Set<String> webInfResources = 
getPortletContext().getResourcePaths(fullTemplate);
-      /* @see javax.servlet.ServletContext#getResourcePaths(String)
-       * getResourcePaths returns a Set containing the directory listing, or 
null
-       * if there are no resources in the web application whose path begins 
with the supplied path.
-       * we are using a full path instead of a partial path. 
webInfResources.isEmpty() is true when
-       * the resource exists
+      /*
+       * @see javax.servlet.ServletContext#getResourcePaths(String) 
getResourcePaths returns a Set
+       *      containing the directory listing, or null if there are no 
resources in the web
+       *      application whose path begins with the supplied path. we are 
using a full path instead
+       *      of a partial path. webInfResources.isEmpty() is true when the 
resource exists
        */
       return webInfResources != null;
    }
 
-
    protected String getTemplate(String type, String template, String 
resourceExtension) {
       String baseDir = getPortletContext().getInitParameter("cmsc.portal." + 
type + ".base.dir");
       if (StringUtils.isEmpty(baseDir)) {
@@ -465,14 +526,14 @@
    }
 
    private String getAggregationDir() {
-      String aggregationDir = 
getPortletContext().getInitParameter("cmsc.portal.aggregation.base.dir");
+      String aggregationDir = getPortletContext().getInitParameter(
+            "cmsc.portal.aggregation.base.dir");
       if (StringUtils.isEmpty(aggregationDir)) {
          aggregationDir = "/WEB-INF/templates/";
       }
       return aggregationDir;
    }
 
-
    protected void setAttribute(RenderRequest request, String var, Object 
value) {
       if (StringUtils.isNotEmpty(var)) {
          // put in variable
@@ -485,7 +546,6 @@
       }
    }
 
-
    protected void setPortletNodeParameter(String portletId, String key, String 
value) {
       PortletParameter param = new PortletParameter();
       param.setKey(key);
@@ -493,7 +553,6 @@
       SiteManagementAdmin.setPortletNodeParameter(portletId, param);
    }
 
-
    protected void setPortletParameter(String portletId, String key, String 
value) {
       PortletParameter param = new PortletParameter();
       param.setKey(key);
@@ -501,7 +560,6 @@
       SiteManagementAdmin.setPortletParameter(portletId, param);
    }
 
-
    protected void setPortletNodeParameter(String portletId, String key, 
String[] values) {
       PortletParameter param = new PortletParameter();
       param.setKey(key);
@@ -509,7 +567,6 @@
       SiteManagementAdmin.setPortletNodeParameter(portletId, param);
    }
 
-
    protected void setPortletParameter(String portletId, String key, String[] 
values) {
       PortletParameter param = new PortletParameter();
       param.setKey(key);
@@ -517,21 +574,18 @@
       SiteManagementAdmin.setPortletParameter(portletId, param);
    }
 
-
    protected void setPortletView(String portletId, String viewId) {
       if (viewId != null) {
          SiteManagementAdmin.setPortletView(portletId, viewId);
       }
    }
 
-
    public String getUrlPath(RenderRequest request) {
       PortalEnvironment env = PortalEnvironment.getPortalEnvironment(request);
       PortalURL currentURL = env.getRequestedPortalURL();
       return currentURL.getGlobalNavigationAsString();
    }
 
-
    protected void logInitParameters() {
       if (getLogger().isDebugEnabled()) {
          Enumeration<String> enumeration = getInitParameterNames();
@@ -542,7 +596,6 @@
       }
    }
 
-
    protected void logParameters(ActionRequest request) {
       if (getLogger().isDebugEnabled()) {
          Map<String, ?> map = request.getParameterMap();
@@ -550,7 +603,6 @@
       }
    }
 
-
    protected void logPreference(ActionRequest req) {
       if (getLogger().isDebugEnabled()) {
          PortletPreferences preferences = req.getPreferences();
@@ -559,7 +611,6 @@
       }
    }
 
-
    protected void logPreference(RenderRequest req) {
       if (getLogger().isDebugEnabled()) {
          PortletPreferences preferences = req.getPreferences();
@@ -568,14 +619,14 @@
       }
    }
 
-
    protected void logMap(Map<String, ?> map) {
       for (Map.Entry<String, ?> entry : map.entrySet()) {
          String key = entry.getKey();
          Object value = entry.getValue();
          if (key != null && value != null) {
             if (value instanceof List) {
-               for (Iterator<String> iterator = ((List<String>) 
value).iterator(); iterator.hasNext();) {
+               for (Iterator<String> iterator = ((List<String>) 
value).iterator(); iterator
+                     .hasNext();) {
                   String val = iterator.next();
                   if (val != null) {
                      getLogger().debug("key: " + key + " value: " + val);
@@ -606,7 +657,8 @@
 
    protected PortletFragment getPortletFragment(PortletRequest request) {
       InternalPortletRequest internalPortletRequest = 
CoreUtils.getInternalRequest(request);
-      ServletRequest servletRequest = ((HttpServletRequestWrapper) 
internalPortletRequest).getRequest();
+      ServletRequest servletRequest = ((HttpServletRequestWrapper) 
internalPortletRequest)
+            .getRequest();
       return (PortletFragment) 
servletRequest.getAttribute(PortalConstants.FRAGMENT);
    }
 
@@ -616,7 +668,8 @@
          routings = new Properties();
          try {
             routings.load(inputStream);
-         } catch (IOException e) {
+         }
+         catch (IOException e) {
             log.error(e);
          }
      }


Index: AbstractContentPortlet.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer/cmsc/portlets/src/java/com/finalist/cmsc/portlets/AbstractContentPortlet.java,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- AbstractContentPortlet.java 10 May 2008 16:31:23 -0000      1.11
+++ AbstractContentPortlet.java 21 Jun 2008 15:52:35 -0000      1.12
@@ -12,105 +12,118 @@
 import java.io.IOException;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
-import java.util.*;
-
-import javax.portlet.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletMode;
+import javax.portlet.PortletModeException;
+import javax.portlet.PortletPreferences;
+import javax.portlet.PortletSession;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
 
 import org.apache.commons.lang.StringUtils;
-import net.sf.mmapps.commons.bridge.CloudUtil;
 import org.mmbase.bridge.Cloud;
 import org.mmbase.bridge.Node;
+
 import com.finalist.cmsc.beans.om.ContentElement;
 import com.finalist.cmsc.portalImpl.PortalConstants;
 import com.finalist.cmsc.portalImpl.headerresource.MetaHeaderResource;
+import com.finalist.cmsc.repository.ContentElementUtil;
 import com.finalist.cmsc.services.contentrepository.ContentRepository;
 import com.finalist.cmsc.services.sitemanagement.SiteManagement;
-import com.finalist.pluto.portalImpl.aggregation.PortletFragment;
 import com.finalist.cmsc.services.versioning.Versioning;
 import com.finalist.cmsc.services.versioning.VersioningException;
 import com.finalist.cmsc.services.workflow.Workflow;
-import com.finalist.cmsc.repository.ContentElementUtil;
+import com.finalist.pluto.portalImpl.aggregation.PortletFragment;
 import com.finalist.pluto.portalImpl.core.CmscPortletMode;
 
+import net.sf.mmapps.commons.bridge.CloudUtil;
+
 public abstract class AbstractContentPortlet extends CmscPortlet {
 
    protected static final String CONTENTELEMENT = "contentelement";
+
    protected static final String USE_LIFECYCLE = "useLifecycle";
 
    protected static final String ACTION_PARAM = "action";
+
    protected static final String CONTENT_PARAM = "content_";
 
    protected static final String ELEMENT_ID = "elementId";
+
    protected static final String VIEW = "view";
 
    protected static final String WINDOW = "window";
+
    protected static final String PAGE = "page";
 
    /** name of the map on the request that contains error messages */
    protected static final String ERROR_MESSSAGES = "errormessages";
+
    /**
-    * name of the map on the request that contains the original values of the
-    * form
+    * name of the map on the request that contains the original values of the 
form
     */
    protected static final String ORIGINAL_VALUES = "originalValues";
+
    /** name of the parameter that defines the mode the view is displayed in */
    protected static final String MODE = "mode";
 
-   private DateFormat metaDateFormat = new SimpleDateFormat("dd/MM/yyyy");
-
+   private final DateFormat metaDateFormat = new 
SimpleDateFormat("dd/MM/yyyy");
 
    /**
     * @see 
net.sf.mmapps.commons.portlets.CmscPortlet#processEditDefaults(javax.portlet.ActionRequest,
     *      javax.portlet.ActionResponse)
     */
    @Override
-   public void processEditDefaults(ActionRequest request, ActionResponse 
response) throws PortletException, IOException {
+   public void processEditDefaults(ActionRequest request, ActionResponse 
response)
+         throws PortletException, IOException {
       String action = request.getParameter(ACTION_PARAM);
       if (action == null) {
          response.setPortletMode(CmscPortletMode.EDIT_DEFAULTS);
       }
-      else if (action.equals("edit")) {
+      else
+         if (action.equals("edit")) {
          PortletPreferences preferences = request.getPreferences();
          String portletId = 
preferences.getValue(PortalConstants.CMSC_OM_PORTLET_ID, null);
          if (portletId != null) {
             // get the values submitted with the form
-            saveParameters(request, portletId);
-
             setPortletView(portletId, request.getParameter(VIEW));
-
             setPortletNodeParameter(portletId, PAGE, 
request.getParameter(PAGE));
             setPortletParameter(portletId, WINDOW, 
request.getParameter(WINDOW));
          }
          else {
             getLogger().error("No portletId");
          }
-         // switch to View mode
-         response.setPortletMode(PortletMode.VIEW);
       }
       else {
          getLogger().error("Unknown action: '" + action + "'");
       }
+      super.processEditDefaults(request, response);
    }
 
-
-   @SuppressWarnings("unused")
-   protected void saveParameters(ActionRequest request, String portletId) {
-      // convenience method
-   }
-
-
    /**
     * @see 
net.sf.mmapps.commons.portlets.CmscPortlet#processEdit(javax.portlet.ActionRequest,
     *      javax.portlet.ActionResponse)
     */
    @Override
-   public void processEdit(ActionRequest request, ActionResponse response) 
throws PortletException, IOException {
+   public void processEdit(ActionRequest request, ActionResponse response) 
throws PortletException,
+         IOException {
       getLogger().debug("===>ContentChannelPortlet.EDIT mode");
       String action = request.getParameter(ACTION_PARAM);
       if (action == null) {
          response.setPortletMode(PortletMode.EDIT);
       }
-      else if (action.equals("edit")) {
+      else
+         if (action.equals("edit")) {
          PortletPreferences preferences = request.getPreferences();
          String portletId = 
preferences.getValue(PortalConstants.CMSC_OM_PORTLET_ID, null);
 
@@ -156,7 +169,8 @@
                         Versioning.addVersion(node);
                      }
                      catch (VersioningException e) {
-                        getLogger().error("Problem while adding version for 
node : " + node.getNumber(), e);
+                           getLogger().error(
+                                 "Problem while adding version for node : " + 
node.getNumber(), e);
                      }
                   }
                   node.commit();
@@ -178,22 +192,20 @@
       }
    }
 
-
     protected Cloud getCloud() {
         Cloud cloud = CloudUtil.getCloudFromThread();
         return cloud;
     }
 
-
    @SuppressWarnings("unused")
-   protected void setEditResponse(ActionRequest request, ActionResponse 
response, Map<String, Node> nodesMap)
-         throws PortletModeException {
+   protected void setEditResponse(ActionRequest request, ActionResponse 
response,
+         Map<String, Node> nodesMap) throws PortletModeException {
       response.setPortletMode(PortletMode.VIEW);
    }
 
-
    @Override
-   protected void doEditDefaults(RenderRequest req, RenderResponse res) throws 
IOException, PortletException {
+   protected void doEditDefaults(RenderRequest req, RenderResponse res) throws 
IOException,
+         PortletException {
       addViewInfo(req);
 
       PortletPreferences preferences = req.getPreferences();
@@ -214,8 +226,8 @@
       super.doEditDefaults(req, res);
    }
 
-
-   protected void doEdit(RenderRequest req, RenderResponse res, String 
elementId) throws IOException, PortletException {
+   protected void doEdit(RenderRequest req, RenderResponse res, String 
elementId)
+         throws IOException, PortletException {
       if (ContentRepository.mayEdit(elementId)) {
          super.doEdit(req, res);
       }
@@ -225,15 +237,17 @@
       }
    }
 
-
    protected void setMetaData(RenderRequest req, String elementId) {
       try {
          ContentElement element = 
ContentRepository.getContentElement(elementId);
 
          PortletFragment portletFragment = getPortletFragment(req);
-         portletFragment.addHeaderResource(new MetaHeaderResource(true, 
"title", element.getTitle()));
-         portletFragment.addHeaderResource(new MetaHeaderResource(true, 
"subject", element.getKeywords()));
-         portletFragment.addHeaderResource(new MetaHeaderResource(true, 
"date", formatDate(element.getCreationdate())));
+         portletFragment
+               .addHeaderResource(new MetaHeaderResource(true, "title", 
element.getTitle()));
+         portletFragment.addHeaderResource(new MetaHeaderResource(true, 
"subject", element
+               .getKeywords()));
+         portletFragment.addHeaderResource(new MetaHeaderResource(true, 
"date", formatDate(element
+               .getCreationdate())));
          portletFragment.addHeaderResource(new MetaHeaderResource(true, 
"identifier", elementId));
          portletFragment.addHeaderResource(new MetaHeaderResource(true, 
"coverage",
                formatDate(element.getPublishdate()) + " - " + 
formatDate(element.getExpirydate())));
@@ -248,7 +262,6 @@
       }
    }
 
-
    private String formatDate(Date date) {
       if (date == null) {
          return "";
@@ -258,20 +271,19 @@
       }
    }
 
-
    @Override
-   public void processView(ActionRequest request, ActionResponse response) 
throws PortletException, IOException {
+   public void processView(ActionRequest request, ActionResponse response) 
throws PortletException,
+         IOException {
       /*
-       * Freek: I moved all the reaction stuff to the tags in the reaciton
-       * module. (see there) I am not entirely sure if the line below is still
-       * required... but think so.
+       * Freek: I moved all the reaction stuff to the tags in the reaciton 
module. (see there) I am
+       * not entirely sure if the line below is still required... but think so.
        */
       response.setPortletMode(CmscPortletMode.EDIT_DEFAULTS);
    }
 
-
    @Override
-   protected void doView(RenderRequest req, RenderResponse res) throws 
PortletException, IOException {
+   protected void doView(RenderRequest req, RenderResponse res) throws 
PortletException,
+         IOException {
       PortletSession session = req.getPortletSession();
       Object errormessages = session.getAttribute(ERROR_MESSSAGES);
       if (errormessages != null) {


Index: IFramePortlet.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer/cmsc/portlets/src/java/com/finalist/cmsc/portlets/IFramePortlet.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- IFramePortlet.java  2 Jun 2008 08:31:41 -0000       1.6
+++ IFramePortlet.java  21 Jun 2008 15:52:35 -0000      1.7
@@ -11,7 +11,12 @@
 
 import java.io.IOException;
 
-import javax.portlet.*;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletPreferences;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
 
 import com.finalist.cmsc.portalImpl.PortalConstants;
 
@@ -19,38 +24,58 @@
  * IFramePortlet
  */
 public class IFramePortlet extends CmscPortlet {
+
    /**
     * Configuration constants.
     */
    public static final String ALIGN_ATTR_PARAM = "align";
+
    public static final String CLASS_ATTR_PARAM = "class";
+
    public static final String FRAME_BORDER_ATTR_PARAM = "frameBorder";
+
    public static final String HEIGHT_ATTR_PARAM = "height";
+
    public static final String ID_ATTR_PARAM = "id";
+
    public static final String MARGIN_HEIGHT_ATTR_PARAM = "marginHeight";
+
    public static final String MARGIN_WIDTH_ATTR_PARAM = "marginWidth";
+
    public static final String NAME_ATTR_PARAM = "name";
+
    public static final String SCROLLING_ATTR_PARAM = "scrolling";
+
    public static final String SOURCE_ATTR_PARAM = "source";
+
    public static final String SOURCE_REQ_PARAM = "source";
+
    public static final String STYLE_ATTR_PARAM = "style";
+
    public static final String WIDTH_ATTR_PARAM = "width";
 
    /**
     * Configuration default constants.
     */
    public static final String ALIGN_ATTR_DEFAULT = "bottom";
+
    public static final String FRAME_BORDER_ATTR_DEFAULT = "0";
+
    public static final String HEIGHT_ATTR_DEFAULT = null;
+
    public static final String MARGIN_HEIGHT_ATTR_DEFAULT = "0";
+
    public static final String MARGIN_WIDTH_ATTR_DEFAULT = "0";
+
    public static final String SCROLLING_ATTR_DEFAULT = "no";
+
    public static final String SOURCE_ATTR_DEFAULT = "about:blank";
-   public static final String WIDTH_ATTR_DEFAULT = "100%";
 
+   public static final String WIDTH_ATTR_DEFAULT = "100%";
 
    @Override
-   public void processEditDefaults(ActionRequest request, ActionResponse 
response) throws PortletException, IOException {
+   public void processEditDefaults(ActionRequest request, ActionResponse 
response)
+         throws PortletException, IOException {
       PortletPreferences preferences = request.getPreferences();
       String portletId = 
preferences.getValue(PortalConstants.CMSC_OM_PORTLET_ID, null);
       if (portletId != null) {
@@ -58,13 +83,17 @@
          setPortletParameter(portletId, ALIGN_ATTR_PARAM, 
request.getParameter(ALIGN_ATTR_PARAM));
 
          setPortletParameter(portletId, CLASS_ATTR_PARAM, 
request.getParameter(CLASS_ATTR_PARAM));
-         setPortletParameter(portletId, FRAME_BORDER_ATTR_PARAM, 
request.getParameter(FRAME_BORDER_ATTR_PARAM));
+         setPortletParameter(portletId, FRAME_BORDER_ATTR_PARAM, request
+               .getParameter(FRAME_BORDER_ATTR_PARAM));
          setPortletParameter(portletId, HEIGHT_ATTR_PARAM, 
request.getParameter(HEIGHT_ATTR_PARAM));
          setPortletParameter(portletId, ID_ATTR_PARAM, 
request.getParameter(ID_ATTR_PARAM));
-         setPortletParameter(portletId, MARGIN_HEIGHT_ATTR_PARAM, 
request.getParameter(MARGIN_HEIGHT_ATTR_PARAM));
-         setPortletParameter(portletId, MARGIN_WIDTH_ATTR_PARAM, 
request.getParameter(MARGIN_WIDTH_ATTR_PARAM));
+         setPortletParameter(portletId, MARGIN_HEIGHT_ATTR_PARAM, request
+               .getParameter(MARGIN_HEIGHT_ATTR_PARAM));
+         setPortletParameter(portletId, MARGIN_WIDTH_ATTR_PARAM, request
+               .getParameter(MARGIN_WIDTH_ATTR_PARAM));
          setPortletParameter(portletId, NAME_ATTR_PARAM, 
request.getParameter(NAME_ATTR_PARAM));
-         setPortletParameter(portletId, SCROLLING_ATTR_PARAM, 
request.getParameter(SCROLLING_ATTR_PARAM));
+         setPortletParameter(portletId, SCROLLING_ATTR_PARAM, request
+               .getParameter(SCROLLING_ATTR_PARAM));
          setPortletParameter(portletId, SOURCE_ATTR_PARAM, 
request.getParameter(SOURCE_ATTR_PARAM));
          setPortletParameter(portletId, STYLE_ATTR_PARAM, 
request.getParameter(STYLE_ATTR_PARAM));
          setPortletParameter(portletId, WIDTH_ATTR_PARAM, 
request.getParameter(WIDTH_ATTR_PARAM));
@@ -74,39 +103,44 @@
          getLogger().error("No portletId");
       }
       // switch to View mode
-      response.setPortletMode(PortletMode.VIEW);
+      super.processEditDefaults(request, response);
    }
 
-
    @Override
-   protected void doEditDefaults(RenderRequest req, RenderResponse res) throws 
IOException, PortletException {
+   protected void doEditDefaults(RenderRequest req, RenderResponse res) throws 
IOException,
+         PortletException {
       // TODO Auto-generated method stub
       super.doEditDefaults(req, res);
    }
 
-
    /**
     * Generate IFRAME with view source.
     */
    @Override
-   public void doView(RenderRequest request, RenderResponse response) throws 
PortletException, IOException {
+   public void doView(RenderRequest request, RenderResponse response) throws 
PortletException,
+         IOException {
       PortletPreferences preferences = request.getPreferences();
 
       // get IFRAME source
       String source = getPreference(preferences, SOURCE_ATTR_PARAM, 
SOURCE_ATTR_DEFAULT);
       // allow for source suggested from other portlet
-      if(request.getParameter(SOURCE_REQ_PARAM) != null) source = 
request.getParameter(SOURCE_REQ_PARAM);
+      if (request.getParameter(SOURCE_REQ_PARAM) != null)
+         source = request.getParameter(SOURCE_REQ_PARAM);
 
       // IFRAME attribute members.
       String alignAttr = getPreference(preferences, ALIGN_ATTR_PARAM, 
ALIGN_ATTR_DEFAULT);
       String classAttr = getPreference(preferences, CLASS_ATTR_PARAM, null);
-      String frameBorderAttr = getPreference(preferences, 
FRAME_BORDER_ATTR_PARAM, FRAME_BORDER_ATTR_DEFAULT);
+      String frameBorderAttr = getPreference(preferences, 
FRAME_BORDER_ATTR_PARAM,
+            FRAME_BORDER_ATTR_DEFAULT);
       String heightAttr = getPreference(preferences, HEIGHT_ATTR_PARAM, 
HEIGHT_ATTR_DEFAULT);
       String idAttr = getPreference(preferences, ID_ATTR_PARAM, null);
-      String marginHeightAttr = getPreference(preferences, 
MARGIN_HEIGHT_ATTR_PARAM, MARGIN_HEIGHT_ATTR_DEFAULT);
-      String marginWidthAttr = getPreference(preferences, 
MARGIN_WIDTH_ATTR_PARAM, MARGIN_WIDTH_ATTR_DEFAULT);
+      String marginHeightAttr = getPreference(preferences, 
MARGIN_HEIGHT_ATTR_PARAM,
+            MARGIN_HEIGHT_ATTR_DEFAULT);
+      String marginWidthAttr = getPreference(preferences, 
MARGIN_WIDTH_ATTR_PARAM,
+            MARGIN_WIDTH_ATTR_DEFAULT);
       String nameAttr = getPreference(preferences, NAME_ATTR_PARAM, null);
-      String scrollingAttr = getPreference(preferences, SCROLLING_ATTR_PARAM, 
SCROLLING_ATTR_DEFAULT);
+      String scrollingAttr = getPreference(preferences, SCROLLING_ATTR_PARAM,
+            SCROLLING_ATTR_DEFAULT);
       String styleAttr = getPreference(preferences, STYLE_ATTR_PARAM, null);
       String widthAttr = getPreference(preferences, WIDTH_ATTR_PARAM, 
WIDTH_ATTR_DEFAULT);
 
@@ -118,31 +152,24 @@
 
       content.append("<iframe");
       content.append(" src=\"").append(source).append("\"");
-      if (alignAttr != null)
-         content.append(" align=\"").append(alignAttr).append("\"");
-      if (classAttr != null)
-         content.append(" class=\"").append(classAttr).append("\"");
+      if (alignAttr != null) content.append(" 
align=\"").append(alignAttr).append("\"");
+      if (classAttr != null) content.append(" 
class=\"").append(classAttr).append("\"");
       if (frameBorderAttr != null)
          content.append(" 
frameborder=\"").append(frameBorderAttr).append("\"");
-      if (idAttr != null)
-         content.append(" id=\"").append(idAttr).append("\"");
+      if (idAttr != null) content.append(" id=\"").append(idAttr).append("\"");
       if (marginHeightAttr != null)
          content.append(" 
marginheight=\"").append(marginHeightAttr).append("\"");
       if (marginWidthAttr != null)
          content.append(" 
marginwidth=\"").append(marginWidthAttr).append("\"");
-      if (nameAttr != null)
-         content.append(" name=\"").append(nameAttr).append("\"");
-      if (heightAttr != null)
-         content.append(" height=\"").append(heightAttr).append("\"");
+      if (nameAttr != null) content.append(" 
name=\"").append(nameAttr).append("\"");
+      if (heightAttr != null) content.append(" 
height=\"").append(heightAttr).append("\"");
       if (scrollingAttr != null)
          content.append(" scrolling=\"").append(scrollingAttr).append("\"");
-      if (styleAttr != null)
-         content.append(" style=\"").append(styleAttr).append("\"");
-      if (widthAttr != null)
-         content.append(" width=\"").append(widthAttr).append("\"");
+      if (styleAttr != null) content.append(" 
style=\"").append(styleAttr).append("\"");
+      if (widthAttr != null) content.append(" 
width=\"").append(widthAttr).append("\"");
       content.append(">");
-      content.append("<p style=\"text-align:center\"><a 
href=\"").append(source).append("\">").append(source).append(
-            "</a></p>");
+      content.append("<p style=\"text-align:center\"><a 
href=\"").append(source).append("\">")
+            .append(source).append("</a></p>");
       content.append("</iframe>");
 
       content.append("</td></tr></table>");
@@ -152,7 +179,6 @@
       response.getWriter().print(content.toString());
    }
 
-
    /**
     * Get IFRAME preference.
     */


Index: JspPortlet.java
===================================================================
RCS file: 
/var/cvs/contributions/CMSContainer/cmsc/portlets/src/java/com/finalist/cmsc/portlets/JspPortlet.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- JspPortlet.java     26 Nov 2007 11:43:40 -0000      1.4
+++ JspPortlet.java     21 Jun 2008 15:52:35 -0000      1.5
@@ -11,7 +11,12 @@
 
 import java.io.IOException;
 
-import javax.portlet.*;
+import javax.portlet.ActionRequest;
+import javax.portlet.ActionResponse;
+import javax.portlet.PortletException;
+import javax.portlet.PortletPreferences;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
 
 import com.finalist.cmsc.portalImpl.PortalConstants;
 import com.finalist.pluto.portalImpl.core.CmscPortletMode;
@@ -23,13 +28,13 @@
 
    private static final String VIEW = "view";
 
-
    /**
     * @see 
net.sf.mmapps.commons.portlets.CmscPortlet#processEditDefaults(javax.portlet.ActionRequest,
     *      javax.portlet.ActionResponse)
     */
    @Override
-   public void processEditDefaults(ActionRequest request, ActionResponse 
response) throws PortletException, IOException {
+   public void processEditDefaults(ActionRequest request, ActionResponse 
response)
+         throws PortletException, IOException {
       getLogger().debug("===>MenuPortlet.EDIT mode");
       PortletPreferences preferences = request.getPreferences();
       String portletId = 
preferences.getValue(PortalConstants.CMSC_OM_PORTLET_ID, null);
@@ -38,7 +43,8 @@
       if (action == null) {
          response.setPortletMode(CmscPortletMode.EDIT_DEFAULTS);
       }
-      else if (action.equals("edit")) {
+      else
+         if (action.equals("edit")) {
          if (portletId != null) {
             // get the values submitted with the form
             setPortletView(portletId, request.getParameter(VIEW));
@@ -46,17 +52,16 @@
          else {
             getLogger().error("No portletId");
          }
-         // switch to View mode
-         response.setPortletMode(PortletMode.VIEW);
       }
       else {
          getLogger().error("Unknown action: '" + action + "'");
       }
+      super.processEditDefaults(request, response);
    }
 
-
    @Override
-   protected void doEditDefaults(RenderRequest req, RenderResponse res) throws 
IOException, PortletException {
+   protected void doEditDefaults(RenderRequest req, RenderResponse res) throws 
IOException,
+         PortletException {
       addViewInfo(req);
       super.doEditDefaults(req, res);
    }
_______________________________________________
Cvs mailing list
[email protected]
http://lists.mmbase.org/mailman/listinfo/cvs

Reply via email to