You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by gg...@apache.org on 2002/09/27 19:02:16 UTC
cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/controls Customize.java
ggolden 2002/09/27 10:02:16
Modified: src/java/org/apache/jetspeed/modules/actions/controls
Customize.java
Log:
The customizers, including the Portlet customizer, now work on a clone of the
current Profile / PSMLDocument rather than on the current ones. This is to
assure that if, due to new account creation and caching, there are two different
Profiles that use the same PSMLDocument, only the one being edited will be
modified. Also, as someone is modifying a Profile, other users won't see the
results until the modification is saved. If the modification is cancled, nothing
changes.
Some support was added to the JetspeedRunData and the Customize.java for this.
The JetspeedPortletInstance was changed to be aware of the clone used in customization, and to make a clone if needed before modifying the current psml.
Revision Changes Path
1.13 +103 -30 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.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- Customize.java 23 Jul 2002 04:54:36 -0000 1.12
+++ Customize.java 27 Sep 2002 17:02:16 -0000 1.13
@@ -64,18 +64,22 @@
import org.apache.jetspeed.portal.PortletSet;
import org.apache.jetspeed.portal.PortletControl;
import org.apache.jetspeed.services.rundata.JetspeedRunData;
-
-import org.apache.jetspeed.util.AutoProfile;
+import org.apache.jetspeed.util.MimeType;
+import org.apache.jetspeed.om.profile.Profile;
+import org.apache.jetspeed.services.Profiler;
+import org.apache.jetspeed.services.statemanager.SessionState;
+import org.apache.jetspeed.util.template.JetspeedLink;
+import org.apache.jetspeed.util.template.JetspeedLinkFactory;
import java.util.Enumeration;
import java.util.Stack;
-import javax.servlet.http.*;
/**
- * Handle Customization requests for the current portlet
+ * 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>
*/
public class Customize extends Action
{
@@ -84,57 +88,71 @@
*/
public void doPerform( RunData rundata ) throws Exception
{
- if( rundata.getUser() == null)
+ JetspeedRunData jdata = (JetspeedRunData)rundata;
+
+ if (jdata.getUser() == null)
{
return;
}
- JetspeedRunData jdata = (JetspeedRunData)rundata;
+ // read some parameters
+ String editMediaType = jdata.getParameters().getString ("mtype");
+ String resetStack = jdata.getParameters().getString ("reset");
+ String peid = jdata.getParameters().getString("js_peid");
- // Load the profile for customization (if not already loaded!)
- // Andreas Kempf, Siemens ICM S CP PE, Munich
- // ---------------------------------------------------------------------
+ // get the customization state for this page
+ SessionState customizationState = jdata.getPageSessionState();
- String editMediaType = rundata.getParameters().getString ("mtype");
- String resetStack = rundata.getParameters().getString ("reset");
+ // this will be the profile we are editing
+ Profile profile = null;
- // RESET (remove) all Stackentries - used on first customization!!!
- if ((resetStack != null) && ((resetStack.equalsIgnoreCase("on")) || (resetStack.equalsIgnoreCase("1"))))
+ // the "reset" parameter's presence signals the start of customization
+ if ( (resetStack != null)
+ && ((resetStack.equalsIgnoreCase("on")) || (resetStack.equalsIgnoreCase("1"))))
{
- Portlet p = jdata.getCustomized();
- while (p != null)
- {
- jdata.setCustomized(null);
- p = jdata.getCustomized();
- }
- jdata.setCustomized(null);
+ // clear out any prior customization state
+ jdata.cleanupFromCustomization();
}
-
- if (editMediaType != null)
+ // if we have not yet setup for customization, do so now
+ if (jdata.getCustomizedProfile() == null)
{
- AutoProfile.loadProfile (rundata, editMediaType);
+ // if not specified, use the current profile's type
+ if (editMediaType == null) editMediaType = jdata.getProfile().getMediaType();
+
+ // 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;
+
+ // get a profile to edit
+ profile = (Profile) Profiler.getProfile(rundata, mType).clone();
+ jdata.setCustomizedProfile(profile);
}
+
+ // we are continuing an on-going customization
else
{
- rundata.getSession().putValue ("customizeType", ((JetspeedRunData)rundata).getProfile().getMediaType ());
+ // get the profile we are working on
+ profile = jdata.getCustomizedProfile();
}
- // ---------------------------------------------------------------------
-
+
// Get js_peid parmameter.
// If it does not exist, we will customize the root of the profile
- String peid = rundata.getParameters().getString("js_peid");
if ( peid == null )
{
// use the id of the root set of the profile
- peid = jdata.getProfile().getRootSet().getID();
+ peid = profile.getRootSet().getID();
jdata.setJs_peid(peid);
}
+ // find the portlet within the profile with this peid %%% isn't there a better way to do this? -ggolden
Portlet found = null;
Stack sets = new Stack();
- sets.push(jdata.getProfile().getRootSet());
-
+ sets.push(profile.getRootSet());
+
while ((found==null) && (sets.size() > 0))
{
PortletSet set = (PortletSet)sets.pop();
@@ -184,4 +202,59 @@
}
}
+
+ /**
+ * Save the current customization
+ * Used by any other customizer to get this done right!
+ */
+ 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();
+ }
+ catch (Exception e)
+ {
+ Log.error("Error while saving profile", e);
+ }
+
+ } // save
+
+ /**
+ * Exit the customizer.
+ */
+ public static void exit(RunData data)
+ {
+ 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;
+
+ } // exit
}
+
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>