taylor 01/12/05 22:26:54
Modified: src/java/org/apache/jetspeed/modules/actions/controllers
RowColumnControllerAction.java
src/java/org/apache/jetspeed/modules/actions/controls
Customize.java
src/java/org/apache/jetspeed/modules/actions/portlets
CustomizeSetAction.java
src/java/org/apache/jetspeed/services/profiler
JetspeedProfilerService.java
src/java/org/apache/jetspeed/services/rundata
DefaultJetspeedRunData.java
Added: src/java/org/apache/jetspeed/util AutoProfile.java
Log:
From Andreas:
New class AutoProfile.java:
(org.apache.jetspeed.util)
- Load a wml or html profile depending on:
- forced call
- already set customization mediatype in the user session
- if used mediatype is different than the customization mediatype
- Create a list of all used portlets inside a pane
Changes for DefaultJetspeedRundata.java:
(org.apache.jetspeed.services.rundata)
- Store the name of the currently edited pane in the session object
- Store only new Portlets on the stack (different to last entry)
Changes for JetspeedProfilerService.java:
(org.apache.jetspeed.services.profiler)
- New createProfile methode : creates a wml and html profile from a 'parentAccount'
(using turbine if null)
NOTE: Ensure that your parentAccount contains a wml/index.psml file!
(Also every existing account!)
Changes for CustomizeSetAction.java:
(org.apache.jetspeed.modules.actions.portlets)
- Reload mediatype profile if necessary (see AutoProfile.java)
- Mediatype for current profile available for velocity (mtype)
- List of used portlets available for velocity (runs)
- Name of the currently edited pane available for velocity (panename)
- Create Controller list depends on mediatype
- Create Portlet list depends on mediatype
- For wml profiles : add ClearPortletControl to each entry
- Add only Portlets if they are not already used in a pane : else we would have
problems (removing)
- Save changes on wml profile immediately
Changes for RowColumnControllerAction.java:
(org.apache.jetspeed.modules.actions.controllers)
- A list of already used portlets is available for velocity templates thru the runs
variable
- Reload mediatype profile if necessary (see AutoProfile.java)
- Add a control to each entry in a wml psml file
- Save modified wml profiles immediately
Changes for Customize.java:
(org.apache.jetspeed.modules.actions.controler)
- Fixed the stack error while a click on customization created a new stack entry :
this is done by adding there parameter 'reset' to the url which deletes all stack
objects so customization starts with the first portlet
- For the customization link I added the 'mtype' parameter : the desired mediatype
profile is loaded (if not already used) by the autoprofile class (see autoprofile.java)
- If mediatype is wml we always start with the first portlet because the zero
portlet is the container : I changed the wml/index.psml format (had problems with
WMLCardPortlet)
Revision Changes Path
1.6 +89 -11
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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- RowColumnControllerAction.java 2001/07/29 13:21:42 1.5
+++ RowColumnControllerAction.java 2001/12/06 06:26:54 1.6
@@ -55,6 +55,7 @@
package org.apache.jetspeed.modules.actions.controllers;
import org.apache.jetspeed.portal.PortletSet;
+import org.apache.jetspeed.portal.Portlet;
import org.apache.jetspeed.portal.PortletController;
import org.apache.jetspeed.portal.PortletControllerConfig;
import org.apache.jetspeed.portal.PanedPortletController;
@@ -67,6 +68,8 @@
import org.apache.jetspeed.xml.api.portletmarkup.Metainfo;
import org.apache.jetspeed.xml.api.portletmarkup.Layout;
+import org.apache.jetspeed.util.AutoProfile;
+
// Turbine stuff
import org.apache.turbine.util.Log;
import org.apache.turbine.util.RunData;
@@ -258,14 +261,26 @@
}
}
+
context.put("portlets",plist);
context.put("titles",titles);
+
+ /**
+ * Make a list of all used portlets available thru the 'runs' reference
+ *
--------------------------------------------------------------------------
+ * last modified: 10/31/01
+ * Andreas Kempf, Siemens ICM S CP PE, Munich
+ * mailto: [EMAIL PROTECTED]
+ */
+ context.put("runs", AutoProfile.getPortletList(rundata));
+ //
--------------------------------------------------------------------------
}
public void doCancel(RunData data, Context context)
{
((JetspeedRunData)data).setCustomized(null);
- if (((JetspeedRunData)data).getCustomized()==null)
+
+ if (((JetspeedRunData)data).getCustomized() ==null)
{
data.setScreenTemplate("Home");
}
@@ -296,12 +311,26 @@
* - paneid: the id a the pane to modify within the current profile
* - position: the position of the component to delete
*/
- public void doDelete(RunData data, Context context)
+ public void doDelete(RunData data, Context context) throws Exception
{
- JetspeedRunData jdata = (JetspeedRunData)data;
- PortletSet customizedSet = (PortletSet)jdata.getCustomized();
- int position = data.getParameters().getInt("position",-1);
- Profile profile = jdata.getProfile();
+ /**
+ * Reload profile for customization (if necessary)
+ * --------------------------------------------------------------------------
+ * last modified: 10/31/01
+ * Andreas Kempf, Siemens ICM S CP PE, Munich
+ * mailto: [EMAIL PROTECTED]
+ */
+ AutoProfile.doIt (data, true);
+ // --------------------------------------------------------------------------
+
+ JetspeedRunData jdata = (JetspeedRunData)data;
+ PortletSet customizedSet = (PortletSet)jdata.getCustomized();
+ int position = data.getParameters().getInt("position",-1);
+ Profile profile = jdata.getProfile();
+
+ // ADDED for WML
+ boolean isWML = (profile.getMediaType().equalsIgnoreCase("wml"));
+
if (customizedSet == null) return;
@@ -316,12 +345,25 @@
{
Portlets p = set.getPortlets(i);
Layout layout = p.getLayout();
- if (layout!=null)
+//
+// if (layout == null)
+// {
+// Layout nl = new Layout ();
+// nl.setPosition (String.valueOf(i));
+//
+// }
+ if ((layout!=null) && (layout.getPosition() != null))
{
+
int lpos = Integer.parseInt(layout.getPosition());
if (lpos==position)
{
set.removePortlets(i);
+
+ // MODIFIED: Save changes for wml profiles
+ if (isWML)
+ doSave(data, null);
+
return;
}
}
@@ -332,13 +374,18 @@
{
Entry p = set.getEntry(i);
Layout layout = p.getLayout();
- if (layout!=null)
+
+ if ((layout!=null) && (layout.getPosition() != null))
{
int lpos = Integer.parseInt(layout.getPosition());
if (lpos==position)
{
set.removeEntry(i);
+
+ // MODIFIED: Save changes for wml profiles
+ if (isWML)
+ doSave(data, null);
return;
}
}
@@ -348,16 +395,26 @@
if (position < set.getPortletsCount())
{
set.removePortlets(position);
+
+ // MODIFIED: Save changes for wml profiles
+ if (isWML)
+ doSave(data, null);
return;
}
if (position < set.getEntryCount())
{
set.removeEntry(position);
+
+ // MODIFIED: Save changes for wml profiles
+ if (isWML)
+ doSave(data, null);
return;
}
}
}
+
+
}
/** Move a component up within the pane
@@ -365,7 +422,7 @@
* - paneid: the id a the pane to modify within the current profile
* - position: move the component which occupies this position
*/
- public void doUp(RunData data, Context context)
+ public void doUp(RunData data, Context context) throws Exception
{
doMove(data,context,true);
}
@@ -375,7 +432,7 @@
* - paneid: the id a the pane to modify within the current profile
* - position: move the component which occupies this position
*/
- public void doDown(RunData data, Context context)
+ public void doDown(RunData data, Context context) throws Exception
{
doMove(data,context,false);
}
@@ -386,13 +443,29 @@
* - position: move the component which occupies this position
* The moveUp boolean determines the direction of the move
*/
- public void doMove(RunData data, Context context, boolean moveUp)
+ public void doMove(RunData data, Context context, boolean moveUp) throws
Exception
{
+ /**
+ * Reload profile for customization (if necessary)
+ * --------------------------------------------------------------------------
+ * last modified: 10/31/01
+ * Andreas Kempf, Siemens ICM S CP PE, Munich
+ * mailto: [EMAIL PROTECTED]
+ */
+
+ AutoProfile.doIt (data, true);
+ // --------------------------------------------------------------------------
+
+
JetspeedRunData jdata = (JetspeedRunData)data;
PortletSet customizedSet = (PortletSet)jdata.getCustomized();
int position = data.getParameters().getInt("position",-1);
Profile profile = jdata.getProfile();
+ // ADDED for WML
+ boolean isWML = (profile.getMediaType().equalsIgnoreCase("wml"));
+
+
if (customizedSet == null) return;
if (position > -1)
@@ -520,5 +593,10 @@
targetLayout.setPosition(String.valueOf(position));
}
}
+
+
+ // MODIFIED: Save changes for wml profiles
+ if (isWML)
+ doSave(data, null);
}
}
1.6 +49 -1
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.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- Customize.java 2001/10/08 16:06:17 1.5
+++ Customize.java 2001/12/06 06:26:54 1.6
@@ -65,8 +65,11 @@
import org.apache.jetspeed.portal.PortletControl;
import org.apache.jetspeed.services.rundata.JetspeedRunData;
+import org.apache.jetspeed.util.AutoProfile;
+
import java.util.Enumeration;
import java.util.Stack;
+import javax.servlet.http.*;
/**
* Handle Customization requests for the current portlet
@@ -75,6 +78,9 @@
*/
public class Customize extends Action
{
+
+
+
public void doPerform( RunData rundata ) throws Exception
{
JetspeedRunData jdata = (JetspeedRunData)rundata;
@@ -84,13 +90,55 @@
return;
}
+
+ // Load the profile for customization (if not already loaded!)
+ // Andreas Kempf, Siemens ICM S CP PE, Munich
+ // ---------------------------------------------------------------------
+
+ String editMediaType = rundata.getParameters().getString ("mtype");
+ String resetStack = rundata.getParameters().getString ("reset");
+
+ // RESET (remove) all Stackentries - used on first customization!!!
+ if ((resetStack != null) && ((resetStack.equalsIgnoreCase("on")) ||
(resetStack.equalsIgnoreCase("1"))))
+ {
+ Portlet p = jdata.getCustomized();
+ while (p != null)
+ {
+ jdata.setCustomized(null);
+ p = jdata.getCustomized();
+ }
+ }
+
+ if (editMediaType != null)
+ {
+ AutoProfile.loadProfile (rundata, editMediaType);
+ }
+ else
+ {
+ rundata.getSession().putValue ("customizeType",
((JetspeedRunData)rundata).getProfile().getMediaType ());
+ }
+ // ---------------------------------------------------------------------
+
+
String name = jdata.getPortlet();
if ( name == null )
{
//if no portlet specified, customized the default pane
//of the profile
- name="0";
+
+ // set Portlet #1 for wml
+ // Andreas Kempf, ICM S CP PE, Munich
+ // ---------------------------------------------------------------------
+ if ((editMediaType != null) && (editMediaType.equalsIgnoreCase("wml")))
+ {
+ name="1";
+ }
+ else
+ name="0";
+ // ---------------------------------------------------------------------
+
+
jdata.setPortlet(name);
}
1.10 +180 -47
jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/CustomizeSetAction.java
Index: CustomizeSetAction.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/CustomizeSetAction.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- CustomizeSetAction.java 2001/09/05 05:53:19 1.9
+++ CustomizeSetAction.java 2001/12/06 06:26:54 1.10
@@ -75,7 +75,11 @@
import org.apache.jetspeed.xml.api.portletmarkup.Controller;
import org.apache.jetspeed.xml.api.portletmarkup.Control;
import org.apache.jetspeed.services.JetspeedSecurity;
+import org.apache.jetspeed.xml.api.portletmarkup.Layout;
+import org.apache.jetspeed.util.AutoProfile;
+
+
// Turbine stuff
import org.apache.turbine.util.Log;
import org.apache.turbine.util.RunData;
@@ -90,7 +94,9 @@
import java.util.Iterator;
import java.util.Collections;
import java.util.Comparator;
+import java.util.Enumeration;
+
/**
* This action implements the default portletset behavior customizer
*
@@ -101,16 +107,41 @@
*/
public class CustomizeSetAction extends VelocityPortletAction
{
+
+
/**
* Subclasses must override this method to provide default behavior
* for the portlet action
*/
protected void buildNormalContext( VelocityPortlet portlet,
Context context,
- RunData rundata )
+ RunData rundata ) throws Exception
{
+
+ /**
+ * Reload profile for customization (if necessary)
+ * --------------------------------------------------------------------------
+ * last modified: 10/31/01
+ * Andreas Kempf, Siemens ICM S CP PE, Munich
+ * mailto: [EMAIL PROTECTED]
+ */
+ AutoProfile.doIt (rundata, true);
+
+ JetspeedRunData jdata = (JetspeedRunData)rundata;
+ Profile profile = jdata.getProfile();
+ String mediaType = jdata.getProfile().getMediaType ();
+
+ // set velocity variable of mediatype (displayed in the customizer menu)
+ context.put("mtype", profile.getMediaType());
+
+
+ // make the list of already used panes/portlets available through the
'runs' reference
+ context.put("runs", AutoProfile.getPortletList(rundata));
+ // ---------------------------------------------------------------------
+
+
// we should first retrieve the portlet to customize
- PortletSet set = (PortletSet)((JetspeedRunData)rundata).getCustomized();
+ PortletSet set = (PortletSet)(jdata).getCustomized();
//identify the portlet submode and build the appropriate subt-template path
String mode = rundata.getParameters().getString("mode");
@@ -142,27 +173,57 @@
if (set==null) return;
+
+
// generic context stuff
+ context.put("panename", (String) jdata.getSession().getAttribute
("customizedPaneName"));
context.put("skin", set.getPortletConfig().getPortletSkin());
context.put("set", set);
context.put("action","portlets.CustomizeSetAction");
- context.put("controllers", buildInfoList(rundata,
Registry.PORTLET_CONTROLLER));
+ context.put("controllers", buildInfoList(rundata,
Registry.PORTLET_CONTROLLER, mediaType));
context.put("skins", buildList(rundata, Registry.SKIN));
- context.put("currentController", set.getController().getConfig().getName());
- context.put("currentSkin",
set.getPortletConfig().getPortletSkin().getName());
+
+ String CtrlName = set.getController().getConfig().getName();
+ context.put("currentController", CtrlName);
+
- if (set.getController() instanceof PortletSetController)
+ /**
+ * Special handling for wml profiles
+ * no skins, no properties menuentry, no panes
+ * --------------------------------------------------------------------------
+ * last modified: 10/31/01
+ * Andreas Kempf, Siemens ICM S CP PE, Munich
+ * mailto: [EMAIL PROTECTED]
+ */
+
+ if (mediaType.equalsIgnoreCase("wml"))
{
+ context.put("currentSkin","Not for wml!");
+ context.put("allowproperties", "false");
+ }
+ else
+ {
+ context.put("currentSkin",
set.getPortletConfig().getPortletSkin().getName());
+ context.put("allowproperties", "true");
+ }
+
+
+ // do not allow panes for wml profiles
+ if ((!mediaType.equalsIgnoreCase("wml")) && (set.getController() instanceof
PortletSetController))
+ {
context.put("allowpane","true");
}
else
{
context.put("allowportlet", "true");
}
+ //
--------------------------------------------------------------------------
+
+
if ("add".equals(mode)) // build context for add mode
{
- List portlets = buildPortletList(rundata,set);
+ List portlets = buildPortletList(rundata,set,mediaType);
int start = rundata.getParameters().getInt("start",0);
int size = 15;
@@ -258,28 +319,88 @@
}
/** Add new portlets in the customized set */
- public void doAdd(RunData rundata, Context context)
+ public void doAdd(RunData rundata, Context context) throws Exception
{
+ /**
+ * Special handling for wml profiles
+ * no skins, no properties menuentry, no panes
+ *
--------------------------------------------------------------------------
+ * last modified: 10/31/01
+ * Andreas Kempf, Siemens ICM S CP PE, Munich
+ * mailto: [EMAIL PROTECTED]
+ */
+ boolean isWML = AutoProfile.doIt (rundata,
true).getMediaType().equalsIgnoreCase("wml");
+
PortletSet set = (PortletSet)((JetspeedRunData)rundata).getCustomized();
String[] pnames = rundata.getParameters().getStrings("pname");
+
+ // Create a ClearPortletControl
+ Control ctrl = new Control();
+ ctrl.setName ("ClearPortletControl");
+
if ( (pnames!=null) && (set!=null) )
{
Portlets portlets = ((JetspeedRunData)rundata).getProfile()
.getDocument()
.getPortlets(set.getName());
+
+ List usedPortlets = AutoProfile.getPortletList(rundata);
+ boolean addIt;
+ int cc;
+ Entry usedEntry;
+
for(int i=0;i < pnames.length; i++)
{
PortletEntry entry =
(PortletEntry)Registry.getEntry(Registry.PORTLET, pnames[i]);
+
+ // add only new portlets!
if ((entry!=null) && (portlets != null))
{
- Entry p = new Entry();
- p.setParent(pnames[i]);
- portlets.addEntry(p);
+
+ addIt = true;
+ for (cc=0; cc<usedPortlets.size(); cc++)
+ {
+ usedEntry = (Entry) usedPortlets.get(cc);
+ if (entry.getName().equals(usedEntry.getParent()))
+ {
+ addIt = false;
+ break;
+ }
+
+ }
+
+ if (addIt)
+ {
+ Entry p = new Entry();
+ // add the ClearPortletControl to wml entries
+ if (isWML)
+ p.setControl (ctrl);
+
+ p.setParent(pnames[i]);
+ portlets.addEntry(p);
+ }
}
}
}
+ //
--------------------------------------------------------------------------
+
+
rundata.getUser().setTemp("mode","layout");
+
+ /**
+ * Save changed wml profile
+ *
--------------------------------------------------------------------------
+ * last modified: 10/31/01
+ * Andreas Kempf, Siemens ICM S CP PE, Munich
+ * mailto: [EMAIL PROTECTED]
+ */
+ if (isWML)
+ {
+ ((JetspeedRunData)rundata).getProfile().store();
+ //rundata.save();
+ }
+
}
/** Sets the metainfo for this entry */
@@ -401,7 +522,9 @@
}
}
- public static List buildPortletList(RunData data, PortletSet set)
+
+ // Create a list of all available portlets
+ public static List buildPortletList(RunData data, PortletSet set, String
mediaType)
{
List list = new ArrayList();
@@ -410,22 +533,21 @@
.toString();
Iterator m = Registry.get(Registry.MEDIA_TYPE).listEntryNames();
- String mediaName = "html";
-
- while(m.hasNext())
- {
- MediaTypeEntry me = (MediaTypeEntry)
- Registry.getEntry(Registry.MEDIA_TYPE,(String)m.next());
-
- if (me!=null)
- {
- if (mime.equals(me.getMimeType()))
- {
- mediaName = me.getName();
- break;
- }
- }
- }
+//
+// while(m.hasNext())
+// {
+// MediaTypeEntry me = (MediaTypeEntry)
+// Registry.getEntry(Registry.MEDIA_TYPE,(String)m.next());
+//
+// if (me!=null)
+// {
+// if (mime.equals(me.getMimeType()))
+// {
+// mediaName = me.getName();
+// break;
+// }
+// }
+// }
Iterator i = Registry.get(Registry.PORTLET).listEntryNames();
@@ -434,11 +556,21 @@
PortletEntry entry = (PortletEntry)Registry.getEntry(Registry.PORTLET,
(String)i.next());
+ Iterator medias;
+
+ // MODIFIED: Selection now takes care of the specified mediatype!
if (JetspeedSecurity.checkPermission(data,
JetspeedSecurity.PERMISSION_CUSTOMIZE, entry) &&
((!entry.isHidden())
&& (!entry.getType().equals(PortletEntry.TYPE_ABSTRACT))
- && entry.hasMediaType(mediaName)))
+ && entry.hasMediaType(mediaType)))
{
+ medias = entry.listMediaTypes();
+// Logme.now ("MediaTypes for entry: "+entry.getName()+" type =
"+entry.getType());
+// while (medias.hasNext())
+// {
+// Logme.now ((String)medias.next());
+// }
+//
list.add(entry);
}
}
@@ -461,7 +593,7 @@
return list;
}
- public static List buildInfoList(RunData data, String regName)
+ public static List buildInfoList(RunData data, String regName, String mediaType)
{
List list = new ArrayList();
@@ -470,22 +602,22 @@
.toString();
Iterator m = Registry.get(Registry.MEDIA_TYPE).listEntryNames();
- String mediaName = "html";
-
- while(m.hasNext())
- {
- MediaTypeEntry me = (MediaTypeEntry)
- Registry.getEntry(Registry.MEDIA_TYPE,(String)m.next());
-
- if (me!=null)
- {
- if (mime.equals(me.getMimeType()))
- {
- mediaName = me.getName();
- break;
- }
- }
- }
+// String mediaName = "html";
+//
+// while(m.hasNext())
+// {
+// MediaTypeEntry me = (MediaTypeEntry)
+// Registry.getEntry(Registry.MEDIA_TYPE,(String)m.next());
+//
+// if (me!=null)
+// {
+// if (mime.equals(me.getMimeType()))
+// {
+// mediaName = me.getName();
+// break;
+// }
+// }
+// }
Iterator i = Registry.get(regName).listEntryNames();
@@ -494,9 +626,10 @@
PortletInfoEntry entry = (PortletInfoEntry)Registry.getEntry(regName,
(String)i.next());
+ // MODIFIED: Selection now takes care of the specified mediatype!
if (JetspeedSecurity.checkPermission(data,
JetspeedSecurity.PERMISSION_CUSTOMIZE, entry) &&
((!entry.isHidden())
- && entry.hasMediaType(mediaName)))
+ && entry.hasMediaType(mediaType)))
{
list.add(entry);
}
1.17 +54 -6
jakarta-jetspeed/src/java/org/apache/jetspeed/services/profiler/JetspeedProfilerService.java
Index: JetspeedProfilerService.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/profiler/JetspeedProfilerService.java,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- JetspeedProfilerService.java 2001/12/03 05:22:30 1.16
+++ JetspeedProfilerService.java 2001/12/06 06:26:54 1.17
@@ -131,7 +131,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">David Sean Taylor</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Santiago Gala</a>
- * @version $Id: JetspeedProfilerService.java,v 1.16 2001/12/03 05:22:30 taylor Exp
$
+ * @version $Id: JetspeedProfilerService.java,v 1.17 2001/12/06 06:26:54 taylor Exp
$
*/
public class JetspeedProfilerService extends TurbineBaseService
@@ -161,6 +161,9 @@
String resourceDefault; // the default name for a resource
String resourceExt; // the default extension for a resource
+ // MODIFIED: A. Kempf
+ String parentAccount = null; // the parent account which is used to create
profiles
+
boolean useSecurity = false; // use security features
boolean useLanguage = true; // use extended language mapping features
@@ -168,6 +171,31 @@
private Map mediaMap = null;
/**
+ * This methode creates a wml profile and a html profile
+ * for a new user
+ * --------------------------------------------------------------------------
+ * last modified: 10/31/01
+ * Andreas Kempf, Siemens ICM S CP PE, Munich
+ * mailto: [EMAIL PROTECTED]
+ */
+ public Profile createProfile(RunData data, Profile profile)
+ throws ProfileException
+ {
+ Profile dummy = null;
+
+
+ if (parentAccount == null)
+ parentAccount = new String ("turbine");
+
+ createProfile (data, profile, "wml", parentAccount);
+ dummy = createProfile (data, profile, "html", parentAccount);
+
+
+ return dummy;
+ }
+ // --------------------------------------------------------------------------
+
+ /**
* This is the early initialization method called by the
* Turbine <code>Service</code> framework
* @param conf The <code>ServletConfig</code>
@@ -628,16 +656,28 @@
}
/**
- * Create a new profile. The profile parameter's document will be cloned.
+ * Create a new profile.
+ * The profile parameter's document will be cloned.
*
* @param rundata The rundata object for the current request.
* @param profile The description of the new profile to be created.
+ * @param contentType create a profile for the specific contentType
+ * @param from create a profile by cloning the profile from the specific user
(if null - turbine is used)
* @return The newly created profile.
+ * -----------------------------------------------------------
+ * Andreas Kempf, Siemens ICM S CP PE, Munich
*/
- public Profile createProfile( RunData data, Profile profile )
+ public Profile createProfile( RunData data, Profile profile, String
contentType, String from )
throws ProfileException
{
- if (null == profile.getDocument())
+ if ((contentType == null) || (contentType.length() < 2))
+ contentType = "html";
+
+ if ((from == null) || (from.length() < 2))
+ from = "turbine";
+
+
+ if ((null == profile.getDocument()) ||
(!profile.getMediaType().equalsIgnoreCase (contentType)))
{
// locate the default resource
@@ -646,23 +686,31 @@
try
{
ProfileLocator locator = new BaseProfileLocator();
- locator.setUser( JetspeedSecurity.getUser("turbine") );
- locator.setMediaType("html");
+ locator.setUser( JetspeedSecurity.getUser(from) );
+
+ locator.setMediaType(contentType);
PSMLDocument doc = fallback(locator, data);
+
if (doc != null)
profile.setDocument(doc);
+
profile.setName( resourceDefault + resourceExt );
+
}
catch (Exception e)
{
throw new ProfileException(e.toString());
}
}
+
try
{
+ profile.setMediaType(contentType);
+
PSMLDocument doc = PsmlManager.createDocument(profile);
Profile newProfile = (Profile)profile.clone();
newProfile.setDocument(doc);
+
return newProfile;
}
catch (CloneNotSupportedException e)
1.5 +38 -1
jakarta-jetspeed/src/java/org/apache/jetspeed/services/rundata/DefaultJetspeedRunData.java
Index: DefaultJetspeedRunData.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/services/rundata/DefaultJetspeedRunData.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DefaultJetspeedRunData.java 2001/09/04 12:09:30 1.4
+++ DefaultJetspeedRunData.java 2001/12/06 06:26:54 1.5
@@ -73,7 +73,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Rapha�l Luta</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Santiago Gala</a>
- * @version $Id: DefaultJetspeedRunData.java,v 1.4 2001/09/04 12:09:30 sgala Exp $
+ * @version $Id: DefaultJetspeedRunData.java,v 1.5 2001/12/06 06:26:54 taylor Exp $
*/
public class DefaultJetspeedRunData extends DefaultTurbineRunData
implements JetspeedRunData
@@ -120,6 +120,17 @@
p = (Portlet)stack.peek();
}
+ /**
+ * Save the title of this currently selected portlet
+ *
--------------------------------------------------------------------------
+ * last modified: 11/06/01
+ * Andreas Kempf, Siemens ICM S CP PE, Munich
+ */
+ if ((p != null) && (stack.size() > 1))
+ getSession().setAttribute ("customizedPaneName", (String)p.getTitle());
+ else
+ getSession().setAttribute ("customizedPaneName", "*");
+
return (Portlet)p;
}
@@ -135,15 +146,41 @@
{
stack = new Stack();
getSession().setAttribute("customize",stack);
+
}
if (p==null)
{
if (!stack.empty()) stack.pop();
+
+ getSession().setAttribute ("customizedPaneName", "*");
}
else
{
+ if (stack.size () > 0)
+ {
+ Portlet last = (Portlet)stack.peek();
+
+
+ if ((last!=null) && (p.getName().equals(last.getName())) &&
(p.getTitle().equals(last.getTitle())))
+ {
+ System.out.println ("Portlet already used!!!");
+ }
+ else
+ stack.push(p);
+ }
+ else
stack.push(p);
+
+
+ /**
+ * Save the title of this currently selected portlet
+ *
--------------------------------------------------------------------------
+ * last modified: 11/06/01
+ * Andreas Kempf, Siemens ICM S CP PE, Munich
+ */
+
+ getSession().setAttribute ("customizedPaneName", (String)p.getTitle());
}
}
1.1
jakarta-jetspeed/src/java/org/apache/jetspeed/util/AutoProfile.java
Index: AutoProfile.java
===================================================================
package org.apache.jetspeed.util;
import org.apache.jetspeed.xml.api.portletmarkup.Portlets;
import org.apache.jetspeed.xml.api.portletmarkup.Entry;
import org.apache.jetspeed.om.profile.Profile;
import org.apache.jetspeed.services.Profiler;
import org.apache.jetspeed.util.MimeType;
import org.apache.jetspeed.services.rundata.JetspeedRunData;
import org.apache.jetspeed.portal.PortletSet;
import org.apache.turbine.util.RunData;
import javax.servlet.http.*;
import java.util.*;
/**
* This class is used to handle different mediatype profile
*
* @author <a href="mailto:[EMAIL PROTECTED]">Andreas Kempf</a>
* @version $Id: AutoProfile.java,v1.0 2001/10/31
*/
public class AutoProfile
{
/**
* Load a mediaType specific profile
* --------------------------------------------------------------------------
* last modified: 10/31/01
* Andreas Kempf, Siemens ICM S CP PE, Munich
*/
public static Profile loadProfile (RunData rundata, String mediaType) throws
Exception
{
Profiler myProfiler = new Profiler ();
if ((mediaType != null) && (mediaType.equalsIgnoreCase("wml")))
{
((JetspeedRunData)rundata).getProfile().store();
Profile myPro = myProfiler.getProfile (rundata, MimeType.WML);
((JetspeedRunData)rundata).setProfile (myPro);
// It is essential that a session object exists!
rundata.getSession().setAttribute ("customizeType", "wml");
}
else
{
((JetspeedRunData)rundata).getProfile().store();
Profile myPro = myProfiler.getProfile (rundata, MimeType.HTML);
((JetspeedRunData)rundata).setProfile (myPro);
// It is essential that a session object exists!
rundata.getSession().setAttribute ("customizeType", "html");
}
return ((JetspeedRunData)rundata).getProfile();
}
/**
* Load a profile - the mediatype is depending on rundata settings
* The profile will load if the rundata.profile.mediatype differs from
customtype (Session Param)
* if the param notForce is false, the profile will be loaded wether is already
used or not
* --------------------------------------------------------------------------
* last modified: 10/31/01
* Andreas Kempf, Siemens ICM S CP PE, Munich
*/
public static Profile doIt (RunData rundata, boolean notForce) throws Exception
{
// retrieve current customization mediatype (stored in the user session object)
HttpSession ses = rundata.getSession ();
String mediaType = (String) ses.getAttribute ("customizeType");
if ((mediaType != null) && (mediaType.equalsIgnoreCase ("wml")))
{
// WML Profil nicht laden, wenn bereits vorhanden!
if (notForce)
{
if (!((JetspeedRunData)rundata).getProfile().getMediaType
().equalsIgnoreCase("wml"))
{
return loadProfile (rundata, "wml");
}
}
// WML auf jeden Fall neu laden!
else
return loadProfile (rundata, "wml");
}
else
if ((mediaType != null) && (mediaType.equalsIgnoreCase ("html")))
{
// HTML Profil nicht laden, wenn bereits vorhanden!
if (notForce)
{
if (!((JetspeedRunData)rundata).getProfile().getMediaType
().equalsIgnoreCase("html"))
{
return loadProfile (rundata, "html");
}
}
// HTML auf jeden Fall neu laden!
else
return loadProfile (rundata, "html");
}
return ((JetspeedRunData)rundata).getProfile();
}
// Create a list of all used portlets!
// last modified: 10/31/01
// Andreas Kempf, Siemens ICM S CP PE, Munich
// ---------------------------------------------------------------------
public static List getPortletList (RunData rundata)
{
Profile profile = ((JetspeedRunData)rundata).getProfile();
Portlets allPortlets =
profile.getDocument().getPortlets(((PortletSet)((JetspeedRunData)rundata).getCustomized()).getName());
List installed = new ArrayList ();
Entry iPortlet;
if (allPortlets != null)
{
for (int ii = 0; ii < allPortlets.getEntryCount(); ii++)
{
iPortlet = (Entry) allPortlets.getEntry (ii);
installed.add (iPortlet);
}
}
return installed;
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>