raphael 2002/11/08 15:13:44
Modified: src/java/org/apache/jetspeed/modules/actions/controllers
MultiColumnControllerAction.java
RowColumnControllerAction.java
src/java/org/apache/jetspeed/modules/actions/controls
Customize.java
src/java/org/apache/jetspeed/modules/actions/portlets
CustomizeAction.java
Added: src/java/org/apache/jetspeed/modules/actions/controls
EndCustomize.java
Log:
Replace a static method in Customize to a new action so that it can be
overriden by standard Turbine modules mechanism
Revision Changes Path
1.23 +36 -15
jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controllers/MultiColumnControllerAction.java
Index: MultiColumnControllerAction.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controllers/MultiColumnControllerAction.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- MultiColumnControllerAction.java 21 Oct 2002 22:31:14 -0000 1.22
+++ MultiColumnControllerAction.java 8 Nov 2002 23:13:44 -0000 1.23
@@ -71,9 +71,9 @@
import org.apache.jetspeed.services.rundata.JetspeedRunData;
import org.apache.jetspeed.services.Registry;
import org.apache.jetspeed.services.statemanager.SessionState;
-import org.apache.jetspeed.modules.actions.controls.Customize;
// Turbine stuff
+import org.apache.turbine.modules.ActionLoader;
import org.apache.turbine.services.localization.Localization;
import org.apache.turbine.util.Log;
import org.apache.turbine.util.RunData;
@@ -193,7 +193,7 @@
if ((constraints != null)
&& (constraints.getColumn() != null)
- && (constraints.getRow() != null)
+ && (constraints.getRow() != null)
&& (constraints.getColumn().intValue() < colNum))
{
row = constraints.getRow().intValue();
@@ -237,7 +237,7 @@
{
dumpColumns(table);
}
-
+
context.put("portlets", table);
}
catch (Exception e)
@@ -340,11 +340,11 @@
titles.put(entry.getId(), pentry.getTitle());
continue;
}
-
+
titles.put(entry.getId(), entry.getParent());
continue;
}
-
+
if (identityElement instanceof Reference)
{
titles.put(identityElement.getId(),
Localization.getString("CUSTOMIZER_REF_DEFAULTTITLE"));
@@ -372,7 +372,14 @@
// if we are all done customization
if (((JetspeedRunData) data).getCustomized() == null)
{
- Customize.exit(data);
+ try
+ {
+ ActionLoader.getInstance().exec( data, "controls.EndCustomize" );
+ }
+ catch (Exception e)
+ {
+ Log.error("Unable to load action controls.EndCustomize ",e);
+ }
}
}
@@ -398,9 +405,23 @@
if (((JetspeedRunData) data).getCustomized() == null)
{
// save the edit profile and make it current
- Customize.save(data);
+ try
+ {
+ ((JetspeedRunData) data).getCustomizedProfile().store();
+ }
+ catch (Exception e)
+ {
+ Log.error("Unable to save profile ",e);
+ }
- Customize.exit(data);
+ try
+ {
+ ActionLoader.getInstance().exec( data, "controls.EndCustomize" );
+ }
+ catch (Exception e)
+ {
+ Log.error("Unable to load action controls.EndCustomize ",e);
+ }
}
}
@@ -427,11 +448,11 @@
{
IdentityElement identityElement = (IdentityElement)
columns[col].get(row);
columns[col].remove(row);
-
+
Portlets portlets = jdata.getCustomizedProfile()
.getDocument()
.getPortletsById(customizedSet.getID());
-
+
if (portlets != null)
{
if (identityElement instanceof Entry)
@@ -591,7 +612,7 @@
protected static void move(List[] cols, int oCol, int oRow, int nCol, int nRow)
{
Object obj = null;
-
+
if ((oCol < cols.length) && (oRow < cols[oCol].size()))
{
obj = cols[oCol].get(oRow);
@@ -768,7 +789,7 @@
}
/**
- * Add an element to the "table" or "work" objects. If the element is
+ * Add an element to the "table" or "work" objects. If the element is
* unconstrained, and the position is within the number of columns, then
* the element is added to "table". Othewise the element is added to "work"
*
@@ -776,7 +797,7 @@
* @param table of positioned elements
* @param work list of un-positioned elements
* @param columnCount Number of colum
- */
+ */
protected static void addElement(IdentityElement element, List[] table, List
work, int columnCount)
{
Layout layout = element.getLayout();
@@ -817,7 +838,7 @@
if (layout != null)
{
// We got here because the column, as defined in the layout,
- // is greater then the numner of columns. This usually
+ // is greater then the numner of columns. This usually
// happens when the number of column has been decreased.
// Delete the offending layout. It may be recreated with
// the correct values.
@@ -826,7 +847,7 @@
}
work.add(element);
}
-
+
}
protected void dumpColumns(List[] cols)
1.16 +26 -5
jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controllers/RowColumnControllerAction.java
Index: RowColumnControllerAction.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controllers/RowColumnControllerAction.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- RowColumnControllerAction.java 27 Sep 2002 17:02:08 -0000 1.15
+++ RowColumnControllerAction.java 8 Nov 2002 23:13:44 -0000 1.16
@@ -74,7 +74,6 @@
import org.apache.jetspeed.util.template.JetspeedLink;
import org.apache.jetspeed.util.template.JetspeedLinkFactory;
import org.apache.jetspeed.services.Profiler;
-import org.apache.jetspeed.modules.actions.controls.Customize;
// Turbine stuff
//import org.apache.turbine.util.DynamicURI;
@@ -82,6 +81,7 @@
import org.apache.turbine.util.RunData;
import org.apache.turbine.util.StringUtils;
import org.apache.turbine.services.template.TurbineTemplate;
+import org.apache.turbine.modules.ActionLoader;
// Velocity Stuff
import org.apache.velocity.context.Context;
@@ -297,7 +297,14 @@
if (((JetspeedRunData)data).getCustomized() == null)
{
- Customize.exit(data);
+ try
+ {
+ ActionLoader.getInstance().exec( data, "controls.EndCustomize" );
+ }
+ catch (Exception e)
+ {
+ Log.error("Unable to load action controls.EndCustomize ",e);
+ }
}
}
@@ -315,9 +322,23 @@
if (((JetspeedRunData) data).getCustomized() == null)
{
// save the edit profile and make it current
- Customize.save(data);
+ try
+ {
+ ((JetspeedRunData) data).getCustomizedProfile().store();
+ }
+ catch (Exception e)
+ {
+ Log.error("Unable to save profile ",e);
+ }
- Customize.exit(data);
+ try
+ {
+ ActionLoader.getInstance().exec( data, "controls.EndCustomize" );
+ }
+ catch (Exception e)
+ {
+ Log.error("Unable to load action controls.EndCustomize ",e);
+ }
}
}
@@ -418,7 +439,7 @@
}
}
}
-
+
}
1.14 +21 -27
jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controls/Customize.java
Index: Customize.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controls/Customize.java,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- Customize.java 27 Sep 2002 17:02:16 -0000 1.13
+++ Customize.java 8 Nov 2002 23:13:44 -0000 1.14
@@ -51,7 +51,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-
+
package org.apache.jetspeed.modules.actions.controls;
// Turbine stuff
@@ -64,8 +64,8 @@
import org.apache.jetspeed.portal.PortletSet;
import org.apache.jetspeed.portal.PortletControl;
import org.apache.jetspeed.services.rundata.JetspeedRunData;
-import org.apache.jetspeed.util.MimeType;
import org.apache.jetspeed.om.profile.Profile;
+import org.apache.jetspeed.om.profile.ProfileLocator;
import org.apache.jetspeed.services.Profiler;
import org.apache.jetspeed.services.statemanager.SessionState;
import org.apache.jetspeed.util.template.JetspeedLink;
@@ -76,7 +76,7 @@
/**
* Handle Customization requests for the current portal page
- *
+ *
* @author <a href="mailto:raphael@;apache.org">Rapha�l Luta</a>
* @author <a href="mailto:paulsp@;apache.org">Paul Spencer</a>
* @author <a href="mailto:ggolden@;apache.org">Glenn R. Golden</a>
@@ -85,7 +85,7 @@
{
/**
* @param rundata The RunData object for the current request
- */
+ */
public void doPerform( RunData rundata ) throws Exception
{
JetspeedRunData jdata = (JetspeedRunData)rundata;
@@ -105,7 +105,7 @@
// this will be the profile we are editing
Profile profile = null;
-
+
// the "reset" parameter's presence signals the start of customization
if ( (resetStack != null)
&& ((resetStack.equalsIgnoreCase("on")) ||
(resetStack.equalsIgnoreCase("1"))))
@@ -113,22 +113,19 @@
// clear out any prior customization state
jdata.cleanupFromCustomization();
}
-
+
// if we have not yet setup for customization, do so now
if (jdata.getCustomizedProfile() == null)
{
- // if not specified, use the current profile's type
- if (editMediaType == null) editMediaType =
jdata.getProfile().getMediaType();
+ ProfileLocator locator = (ProfileLocator)jdata.getProfile().clone();
- // set the type of this customization in state
- //customizationState.setAttribute("customize-type", editMediaType);
-
- MimeType mType = MimeType.HTML;
- if (editMediaType.equalsIgnoreCase("xml")) mType = MimeType.XML;
- else if(editMediaType.equalsIgnoreCase("xml")) mType = MimeType.WML;
+ if (editMediaType != null)
+ {
+ locator.setMediaType(editMediaType);
+ }
// get a profile to edit
- profile = (Profile) Profiler.getProfile(rundata, mType).clone();
+ profile = (Profile) Profiler.getProfile(locator).clone();
jdata.setCustomizedProfile(profile);
}
@@ -156,7 +153,7 @@
while ((found==null) && (sets.size() > 0))
{
PortletSet set = (PortletSet)sets.pop();
-
+
if (set.getID().equals(peid))
{
found = set;
@@ -167,14 +164,14 @@
while((found==null) && en.hasMoreElements())
{
Portlet p = (Portlet)en.nextElement();
-
+
// unstack the controls to find the real PortletSets
Portlet real = p;
while (real instanceof PortletControl)
{
real = ((PortletControl)p).getPortlet();
}
-
+
if (real instanceof PortletSet)
{
if (real.getID().equals(peid))
@@ -188,35 +185,31 @@
}
}
else if (p.getID().equals(peid))
- {
+ {
found = p;
}
}
}
}
-
+
if (found!=null)
{
jdata.setCustomized(found);
jdata.setScreenTemplate("Customize");
}
-
+
}
/**
* Save the current customization
* Used by any other customizer to get this done right!
+ *
+ * @deprecated. The customizers should handle the save themselves
*/
public static void save(RunData data)
{
try
{
-/* String mtype = data.getParameters().getString("mtype");
- if (mtype != null)
- {
- profile.setMediaType(mtype);
- }
-*/
Profile profile = ((JetspeedRunData) data).getCustomizedProfile();
profile.store();
}
@@ -229,6 +222,7 @@
/**
* Exit the customizer.
+ * @deprecated. Exec the controls.EndCustomize action instead
*/
public static void exit(RunData data)
{
1.1
jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controls/EndCustomize.java
Index: EndCustomize.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2000-2001 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Jetspeed" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache" or
* "Apache Jetspeed", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
package org.apache.jetspeed.modules.actions.controls;
// Turbine stuff
import org.apache.turbine.modules.Action;
import org.apache.turbine.util.RunData;
import org.apache.turbine.util.Log;
// Jetspeed stuff
import org.apache.jetspeed.services.rundata.JetspeedRunData;
import org.apache.jetspeed.util.template.JetspeedLink;
import org.apache.jetspeed.util.template.JetspeedLinkFactory;
/**
* This action must be invoked to clean up the customization
* state and redirect the user to his portal hompage
*
* @author <a href="mailto:raphael@;apache.org">Rapha�l Luta</a>
* @author <a href="mailto:paulsp@;apache.org">Paul Spencer</a>
* @author <a href="mailto:ggolden@;apache.org">Glenn R. Golden</a>
*/
public class EndCustomize extends Action
{
/**
* @param rundata The RunData object for the current request
*/
public void doPerform( RunData data ) throws Exception
{
JetspeedLink jsLink = null;
((JetspeedRunData) data).cleanupFromCustomization();
// bring logged on user to homepage via HTTP redirect
try
{
jsLink = JetspeedLinkFactory.getInstance(data);
String mtype = data.getParameters().getString("mtype");
if (mtype != null)
{
jsLink.setMediaType(mtype);
jsLink.addQueryData("mtype", mtype);
}
}
catch (Exception e)
{
Log.error(e);
}
data.setRedirectURI(jsLink.toString());
JetspeedLinkFactory.putInstance(jsLink);
jsLink = null;
}
}
1.17 +40 -29
jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/CustomizeAction.java
Index: CustomizeAction.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/CustomizeAction.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- CustomizeAction.java 24 Oct 2002 16:17:20 -0000 1.16
+++ CustomizeAction.java 8 Nov 2002 23:13:44 -0000 1.17
@@ -51,7 +51,7 @@
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
-
+
package org.apache.jetspeed.modules.actions.portlets;
// Jetspeed Stuff
@@ -79,12 +79,12 @@
import org.apache.jetspeed.portal.PortletInstance;
import org.apache.jetspeed.util.MetaData;
import org.apache.jetspeed.services.statemanager.SessionState;
-import org.apache.jetspeed.modules.actions.controls.Customize;
// Turbine stuff
import org.apache.turbine.util.Log;
import org.apache.turbine.util.RunData;
import org.apache.turbine.services.template.TurbineTemplate;
+import org.apache.turbine.modules.ActionLoader;
// Velocity Stuff
import org.apache.velocity.context.Context;
@@ -94,20 +94,20 @@
import java.util.Iterator;
/**
- * This action implements the default portlet behavior customizer
- *
+ * This action implements the default portlet behavior customizer
+ *
* <p>Don't call it from the URL, the Portlet and the Action are automatically
* associated through the registry PortletName
- *
+ *
* @author <a href="mailto:raphael@;apache.org">Rapha�l Luta</a>
*/
public class CustomizeAction extends VelocityPortletAction
{
- /**
- * Subclasses must override this method to provide default behavior
+ /**
+ * Subclasses must override this method to provide default behavior
* for the portlet action
- *
+ *
* <table>
* <tr><th>Context </th><th> Description</th></tr>
* <!-- --------- ------------------------- -->
@@ -120,7 +120,7 @@
* <tr><td>security_ref </td><td> Current securityRef for this portlet
INSTANCE</td></tr>
* </table>
*/
- protected void buildNormalContext( VelocityPortlet portlet,
+ protected void buildNormalContext( VelocityPortlet portlet,
Context context,
RunData rundata )
{
@@ -131,11 +131,11 @@
// we should first retrieve the portlet to customize
Portlet p = ((JetspeedRunData)rundata).getCustomized();
-
+
context.put("action", "portlets.CustomizeAction");
-
+
if (p==null) return;
-
+
// retrieve the portlet parameters
PortletEntry entry =
(PortletEntry)Registry.getEntry(Registry.PORTLET,p.getName());
// save the entry in the session
@@ -146,7 +146,7 @@
{
String name = (String)i.next();
Parameter param = entry.getParameter(name);
-
+
// filter some "system" and hidden parameters
if ( (!param.isHidden()) && (name.charAt(0)!='_') )
{
@@ -157,7 +157,7 @@
}
}
}
-
+
// get the customization state for this page
SessionState customizationState =
((JetspeedRunData)rundata).getPageSessionState();
customizationState.setAttribute("customize-parameters", params);
@@ -166,7 +166,7 @@
context.put("parameters", params);
context.put("portlet", p);
context.put("customizer", portlet);
-
+
if (p.getPortletConfig().getSecurityRef() != null)
context.put("security_ref",
p.getPortletConfig().getSecurityRef().getParent());
if (p.getPortletConfig().getSkin() != null)
@@ -174,11 +174,11 @@
Profile profile = ((JetspeedRunData)rundata).getCustomizedProfile();
String currentTitle =
profile.getDocument().getEntryById(p.getID()).getTitle();
- if (currentTitle == null && p.getPortletConfig().getMetainfo() != null)
+ if (currentTitle == null && p.getPortletConfig().getMetainfo() != null)
{
currentTitle = p.getPortletConfig().getMetainfo().getTitle();
}
- context.put("current_title", currentTitle);
+ context.put("current_title", currentTitle);
}
@@ -188,7 +188,14 @@
((JetspeedRunData)rundata).setCustomized(null);
if (((JetspeedRunData)rundata).getCustomized()==null)
{
- Customize.exit(rundata);
+ try
+ {
+ ActionLoader.getInstance().exec( rundata, "controls.EndCustomize" );
+ }
+ catch (Exception e)
+ {
+ Log.error("Unable to load action controls.EndCustomize ",e);
+ }
}
}
@@ -255,7 +262,7 @@
{
boolean skinChanged = false;
String currentSkinName = null;
-
+
if (pc.getSkin() != null)
currentSkinName = pc.getPortletSkin().getName();
@@ -281,7 +288,7 @@
// have a different idea of skin - and the caching of
Portlets does
// NOT include skin -ggolden.
pc.setPortletSkin(skin);
-
+
Skin psmlSkin = entry.getSkin();
if (psmlSkin == null)
{
@@ -312,7 +319,7 @@
{
boolean titleChanged = false;
String currentTitle = entry.getTitle();
-
+
MetaData md = pc.getMetainfo();
if (currentTitle == null && md != null && md.getTitle() != null)
currentTitle = md.getTitle();
@@ -350,15 +357,15 @@
try
{
PortletInstance instance = PersistenceManager.getInstance(p, rundata);
-
+
Iterator i = params.iterator();
while(i.hasNext())
{
- Parameter param = (Parameter)i.next();
+ Parameter param = (Parameter)i.next();
String name = param.getName();
String newValue = rundata.getParameters().getString(name);
-
+
// we treat null and empty string in the same way, we should
// probably find a better system as they may have different semantic
if ((newValue==null)||(newValue.equals("")))
@@ -391,10 +398,14 @@
// save all the changes
if ((madePsChange == true) || (madePcChange == true))
{
- // Note: no need to use the PersistenceManager's store(instance),
which
- // ends up writing the modified PSMLDocument to the service:
Customize.size()
- // takes care of this for us. -ggolden
- Customize.save(rundata);
+ try
+ {
+ ((JetspeedRunData) rundata).getCustomizedProfile().store();
+ }
+ catch (Exception e)
+ {
+ Log.error("Unable to save profile ",e);
+ }
}
//FIXME: this hack is due to the corrupted lifecycle of the portlet in
the
//current API when caching is activated
@@ -415,6 +426,6 @@
catch (Exception e)
{
Log.error(e);
- }
+ }
}
}
--
To unsubscribe, e-mail: <mailto:jetspeed-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:jetspeed-dev-help@;jakarta.apache.org>