raphael 01/05/31 10:11:21
Modified: src/java/org/apache/jetspeed/om/newregistry Parameter.java
src/java/org/apache/jetspeed/om/newregistry/base
BaseParameter.java
src/java/org/apache/jetspeed/portal BasePortletSet.java
PortalState.java
src/java/org/apache/jetspeed/portal/controls
VelocityPortletControl.java
src/java/org/apache/jetspeed/portal/portlets
AbstractPortlet.java FileServerPortlet.java
NewRSSPortlet.java VelocityPortlet.java
src/java/org/apache/jetspeed/portal/service
JetspeedPersistenceService.java
src/java/org/apache/jetspeed/util PSMLManager.java
Added: src/java/org/apache/jetspeed/modules/actions/portlets
CustomizeAction.java
src/java/org/apache/jetspeed/portal PortletCustomizer.java
Log:
add a generic PortletCustomizer that can customize any portlet properties
based on the regsitry parameter descriptions.
- extend the registry parameter syntax to allow meta-info and security
extensions
- update partially the admin and portet regsitries
- fix a maximization bug that prevented correct maximization of portlets
in nested portlet sets.
Revision Changes Path
1.1
jakarta-jetspeed/src/java/org/apache/jetspeed/modules/actions/portlets/CustomizeAction.java
Index: CustomizeAction.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.portlets;
import org.apache.jetspeed.portal.Portlet;
import org.apache.jetspeed.portal.PortalState;
import org.apache.jetspeed.portal.PortletException;
import org.apache.jetspeed.portal.portlets.VelocityPortlet;
import org.apache.jetspeed.portal.service.PersistenceService;
import org.apache.jetspeed.portal.service.ServiceFactory;
import org.apache.jetspeed.portal.service.ServiceException;
import org.apache.jetspeed.services.Registry;
import org.apache.jetspeed.om.newregistry.PortletEntry;
import org.apache.jetspeed.om.newregistry.Parameter;
// Turbine stuff
import org.apache.turbine.util.Log;
import org.apache.turbine.util.RunData;
// Velocity Stuff
import org.apache.velocity.context.Context;
import java.util.Vector;
import java.util.List;
import java.util.Iterator;
/**
* 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:[EMAIL PROTECTED]">Rapha�l Luta</a>
*/
public class CustomizeAction extends VelocityPortletAction
{
/**
* Subclasses must override this method to provide default behavior
* for the portlet action
*/
protected void buildNormalContext( VelocityPortlet portlet,
Context context,
RunData rundata )
{
// we should first retrieve the portlet to customize
Portlet p = (Portlet)rundata.getSession().getAttribute("customize");
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
Vector params = new Vector();
Iterator i = entry.getParameterNames();
while(i.hasNext())
{
String name = (String)i.next();
Parameter param = entry.getParameter(name);
// filter some "system" and hidden parameters
if ( (!param.isHidden()) && (name.charAt(0)!='_') )
{
// check the user role
String role =
(param.getSecurity()!=null)?param.getSecurity().getRole():null;
if ((role==null)||(rundata.getACL().hasRole(role)))
{
params.add(entry.getParameter(name));
}
}
}
rundata.getSession().setAttribute("parameters", params);
// populate the customizer context
context.put("parameters", params);
context.put("portlet", p);
}
/** Clean up the customization state */
public void doCancel(RunData rundata, Context context)
{
rundata.getSession().removeAttribute("customize");
rundata.getSession().removeAttribute("parameters");
PortalState.reset(rundata);
}
/** Updates the customized portlet entry */
public void doUpdate(RunData rundata, Context context)
{
// we should first retrieve the portlet to customize and its parameters
// definition
Portlet p = (Portlet)rundata.getSession().getAttribute("customize");
List params = (List)rundata.getSession().getAttribute("parameters");
if ((p==null)||(params==null))
{
//default to build normal
buildNormalContext(null,context,rundata);
return;
}
try
{
Object[] obj = { p };
PersistenceService ps = (PersistenceService)ServiceFactory
.getService( PersistenceService.class,
rundata, obj);
PersistenceService.Page page = ps.getPage();
Iterator i = params.iterator();
while(i.hasNext())
{
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("")))
{
// this will fail if the parameter is currently set in the
registry
// but not in the PSML entry. This is a good thing !
page.removeAttribute(name);
}
else
{
// only update if the value changed
if
(!newValue.equals(p.getPortletConfig().getInitParameter(name)))
{
Log.note("Changing attribute "+name+" to "+newValue);
page.setAttribute(name,newValue);
p.getPortletConfig().setInitParameter(name,newValue);
}
}
}
// save all the changes
ps.store();
//FIXME: this hack is due to the corrupted lifecycle of the portlet in
the
//current API when caching is activated
try
{
p.init();
}
catch (PortletException e)
{
Log.error("Customizer failed to reinitialize the portlet
"+p.getName(), e);
}
// we're done, make sure clean up the
// session
rundata.getSession().removeAttribute("customize");
rundata.getSession().removeAttribute("parameters");
PortalState.reset(rundata);
}
catch (ServiceException e)
{
Log.error(e);
}
}
}
1.3 +2 -11
jakarta-jetspeed/src/java/org/apache/jetspeed/om/newregistry/Parameter.java
Index: Parameter.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/newregistry/Parameter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Parameter.java 2001/05/02 14:16:59 1.2
+++ Parameter.java 2001/05/31 17:10:41 1.3
@@ -58,19 +58,10 @@
* Interface describing a parameter for a registry entry.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Rapha�l Luta</a>
- * @version $Id: Parameter.java,v 1.2 2001/05/02 14:16:59 raphael Exp $
+ * @version $Id: Parameter.java,v 1.3 2001/05/31 17:10:41 raphael Exp $
*/
-public interface Parameter
+public interface Parameter extends RegistryEntry
{
-
- /** @return the name of this parameter */
- public String getName();
-
- /** Sets the name of this parameter.
- *
- * @param name the new parameter name
- */
- public void setName(String name);
/** @return the value for this parameter */
public String getValue();
1.3 +4 -19
jakarta-jetspeed/src/java/org/apache/jetspeed/om/newregistry/base/BaseParameter.java
Index: BaseParameter.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/om/newregistry/base/BaseParameter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- BaseParameter.java 2001/05/02 14:17:09 1.2
+++ BaseParameter.java 2001/05/31 17:10:47 1.3
@@ -65,30 +65,15 @@
*
* @see org.apache.jetspeed.om.newregistry.Parameter
* @author <a href="mailto:[EMAIL PROTECTED]">Rapha�l Luta</a>
- * @version $Id: BaseParameter.java,v 1.2 2001/05/02 14:17:09 raphael Exp $
+ * @version $Id: BaseParameter.java,v 1.3 2001/05/31 17:10:47 raphael Exp $
*/
-public class BaseParameter implements Parameter, java.io.Serializable
+public class BaseParameter extends BaseRegistryEntry
+ implements Parameter, java.io.Serializable
{
- private String name = null;
private String value = null;
private String type = null;
- /** @return the name of this parameter */
- public String getName()
- {
- return this.name;
- }
-
- /** Sets the name of this parameter.
- *
- * @param name the new parameter name
- */
- public void setName(String name)
- {
- this.name = name;
- }
-
/** @return the value for this parameter */
public String getValue()
{
@@ -117,5 +102,5 @@
public void setType(String type)
{
this.type = type;
- }
+ }
}
1.5 +21 -34
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/BasePortletSet.java
Index: BasePortletSet.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/BasePortletSet.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- BasePortletSet.java 2001/05/29 23:06:24 1.4
+++ BasePortletSet.java 2001/05/31 17:10:51 1.5
@@ -82,7 +82,7 @@
*
* @author <a href="mailto:[EMAIL PROTECTED]">Rapha�l Luta</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Kevin A. Burton</a>
- * @version $Id: BasePortletSet.java,v 1.4 2001/05/29 23:06:24 raphael Exp $
+ * @version $Id: BasePortletSet.java,v 1.5 2001/05/31 17:10:51 raphael Exp $
*/
public class BasePortletSet implements PortletSet, Portlet, PortletState
{
@@ -118,16 +118,6 @@
private long creationTime;
/**
- The name of the portlet being customized
- */
- private String customize;
-
- /**
- The name of the portlet being maximized
- */
- private String maximize;
-
- /**
The name of the portlet displaying info
*/
private String info;
@@ -284,44 +274,41 @@
public ConcreteElement getContent(RunData rundata)
{
- ConcreteElement content = null;
-
if (PortalState.hasCustomized(rundata))
{
//handle the customize special case
- content = PortalState.getCustomizeContent( this, rundata );
+ return PortalState.getCustomizeContent( this, rundata );
}
else if (PortalState.hasMaximized(rundata))
{
//handle the maximize special case
- content = PortalState.getMaximizeContent( this, rundata );
+ return PortalState.getMaximizeContent( this, rundata );
}
- if (content == null)
- {
- //process the normal rendering flow
+ ConcreteElement content = null;
+
+ //process the normal rendering flow
- CapabilityMap map = CapabilityMapFactory.getCapabilityMap( rundata );
- PortletController controller = getController();
+ CapabilityMap map = CapabilityMapFactory.getCapabilityMap( rundata );
+ PortletController controller = getController();
- if ( controller == null )
+ if ( controller == null )
+ {
+ Portlet p = getPortletAt(0);
+
+ if (p!=null)
{
- Portlet p = getPortletAt(0);
-
- if (p!=null)
- {
- return p.getContent( rundata );
- }
+ return p.getContent( rundata );
}
- else
+ }
+ else
+ {
+ if ( ! controller.supportsType( map.getPreferredType() ) )
{
- if ( ! controller.supportsType( map.getPreferredType() ) )
- {
- setController( ControllerFactory.getPortletController("") );
- }
-
- return controller.getContent( rundata );
+ setController( ControllerFactory.getPortletController("") );
}
+
+ return controller.getContent( rundata );
}
return content;
1.2 +18 -2
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/PortalState.java
Index: PortalState.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/PortalState.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PortalState.java 2001/05/29 22:57:41 1.1
+++ PortalState.java 2001/05/31 17:10:54 1.2
@@ -55,6 +55,7 @@
package org.apache.jetspeed.portal;
import org.apache.turbine.util.RunData;
+import org.apache.turbine.util.Log;
import org.apache.ecs.ConcreteElement;
import java.util.Enumeration;
@@ -108,6 +109,7 @@
*/
public static void setMaximized( String portlet, RunData rundata )
{
+ Log.note("Maximized: "+portlet);
rundata.getSession().setAttribute(MAXIMIZED, portlet);
}
@@ -137,7 +139,12 @@
if ( (real instanceof PortletSet) || (p.getName().equals(name)) )
{
- return p.getContent(data);
+ ConcreteElement result = p.getContent(data);
+ // if result is not null, we have found our portlet
+ if (result!=null)
+ {
+ return result;
+ }
}
}
}
@@ -152,6 +159,7 @@
*/
public static void clearMaximized( RunData rundata )
{
+ Log.note("Maximized cleared");
rundata.getSession().removeAttribute(MAXIMIZED);
}
@@ -183,6 +191,7 @@
*/
public static void setCustomized( String portlet, RunData rundata )
{
+ Log.note("Customized: "+portlet);
rundata.getSession().setAttribute(CUSTOMIZED, portlet);
}
@@ -199,6 +208,7 @@
{
String name = getCustomized( data );
+
if (set.getName().equals(name))
{
// FIXME: we can't call getContent() because that would create
@@ -217,7 +227,12 @@
if ( (real instanceof PortletSet) || (p.getName().equals(name)) )
{
- return p.getContent(data);
+ ConcreteElement result = p.getContent(data);
+ // if result is not null, we have found our portlet
+ if (result!=null)
+ {
+ return result;
+ }
}
}
}
@@ -232,6 +247,7 @@
*/
public static void clearCustomized( RunData rundata )
{
+ Log.note("Customized cleared");
rundata.getSession().removeAttribute(CUSTOMIZED);
}
1.1
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/PortletCustomizer.java
Index: PortletCustomizer.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.portal;
/**
* This interface is used as a marker for identifying the portlet
* classes that can be used as their own customizer
*
* This marker is detected by the PortalState class when rendering
* the customizer for a given portlet
*
* @author <a href="mailto:[EMAIL PROTECTED]">Rapha�l Luta</a>
*/
public interface PortletCustomizer
{
// empty interface
}
1.3 +67 -5
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/controls/VelocityPortletControl.java
Index: VelocityPortletControl.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/controls/VelocityPortletControl.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- VelocityPortletControl.java 2001/05/29 22:54:35 1.2
+++ VelocityPortletControl.java 2001/05/31 17:10:58 1.3
@@ -62,9 +62,15 @@
// Jetspeed stuff
import org.apache.jetspeed.portal.Portlet;
+import org.apache.jetspeed.portal.PortletSet;
import org.apache.jetspeed.portal.PortletControl;
import org.apache.jetspeed.portal.PortletState;
+import org.apache.jetspeed.portal.PortletCustomizer;
import org.apache.jetspeed.portal.PortalState;
+import org.apache.jetspeed.portal.factory.PortletFactory;
+import org.apache.jetspeed.services.Registry;
+import org.apache.jetspeed.services.resources.JetspeedResources;
+import org.apache.jetspeed.om.newregistry.PortletEntry;
import org.apache.jetspeed.util.MimeType;
// Ecs stuff
@@ -122,8 +128,18 @@
context.put("actions", buildActionList( rundata, portlet ) );
context.put("config", getConfig() );
context.put("skin", portlet.getPortletConfig().getPortletSkin() );
- context.put("portlet", portlet );
+ if ( portlet.getName().equals(PortalState.getCustomized(rundata))
+ && (! (portlet instanceof PortletCustomizer) ) )
+ {
+ Log.note("Portlet "+portlet.getName()+" customized, using default
customizer");
+ context.put("portlet",getCustomizer(portlet, rundata));
+ }
+ else
+ {
+ context.put("portlet", portlet );
+ }
+
// allow subclasses to add elements to the context
buildContext( rundata, context );
@@ -144,6 +160,48 @@
return new StringElement( s );
}
+ /** This method retrieves the appropriate customizer portlet for the
+ * current portlet
+ *
+ * @param p the portlet to customize
+ * @param data the RunData for this request
+ * @return the portlet object of the appropriate customizer
+ */
+ public Portlet getCustomizer(Portlet p, RunData data)
+ {
+ Portlet customizer = p;
+
+ // if the portlet cannot customize itself...
+ if (! (p instanceof PortletCustomizer) )
+ {
+
+ //look for the customizer name in the portlet
+ //config (from Registry definition)
+
+ String name = p.getPortletConfig().getInitParameter("_customizer");
+
+ if (name == null)
+ {
+ String key = (p instanceof PortletSet)?"PortletSet":"Portlet";
+
+ name =
JetspeedResources.getString("customizer."+key,key+"Customizer");
+ }
+
+ try
+ {
+ PortletEntry entry =
(PortletEntry)Registry.getEntry(Registry.PORTLET,name);
+ customizer = PortletFactory.getPortlet(entry);
+ data.getSession().setAttribute("customize", p);
+ }
+ catch (Exception e)
+ {
+ Log.error(e);
+ }
+ }
+
+ return customizer;
+ }
+
/**
* This method allows subclasses of the VelocityPortletControl
* to populate the context of this control before rendering by
@@ -175,10 +233,15 @@
{
// the portlet is state aware
PortletState state = (PortletState)portlet;
+ boolean maximized =
portlet.getName().equals(PortalState.getMaximized(rundata));
+ boolean customized =
portlet.getName().equals(PortalState.getCustomized(rundata));
if ( state.allowCustomize( rundata ) )
{
- actions.add( new PortletAction("customize") );
+ if (! customized )
+ {
+ actions.add( new PortletAction("customize") );
+ }
}
else
{
@@ -188,13 +251,12 @@
}
}
- if ( state.allowClose( rundata ) )
+ if ( (!customized) && (!maximized) && state.allowClose( rundata ) )
{
actions.add( new PortletAction("close") );
}
- if ( ( state.isMinimized( rundata ) )
- || (portlet.getName().equals(PortalState.getMaximized(rundata))) )
+ if ( state.isMinimized( rundata ) || maximized )
{
actions.add( new PortletAction("restore") );
}
1.40 +12 -4
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/AbstractPortlet.java
Index: AbstractPortlet.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/AbstractPortlet.java,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- AbstractPortlet.java 2001/05/29 23:07:04 1.39
+++ AbstractPortlet.java 2001/05/31 17:11:02 1.40
@@ -93,7 +93,7 @@
@author <A HREF="mailto:[EMAIL PROTECTED]">Kevin A. Burton</A>
@author <A HREF="mailto:[EMAIL PROTECTED]">Rapha�l Luta</A>
-@version $Id: AbstractPortlet.java,v 1.39 2001/05/29 23:07:04 raphael Exp $
+@version $Id: AbstractPortlet.java,v 1.40 2001/05/31 17:11:02 raphael Exp $
*/
public abstract class AbstractPortlet implements Portlet, PortletState, Cacheable
{
@@ -248,6 +248,12 @@
/**
*/
+ protected void clearContent() {
+ this.content.clear();
+ }
+
+ /**
+ */
protected void setContent( ConcreteElement content ) {
this.setContent( content, null );
}
@@ -369,9 +375,11 @@
/**
By default don't provide any initialization
*/
- public void init( ) throws PortletException {}
-
-
+ public void init( ) throws PortletException
+ {
+ // make sure to clean all content
+ clearContent();
+ }
/**
@see Portlet#getCreationTime
1.24 +4 -1
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/FileServerPortlet.java
Index: FileServerPortlet.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/FileServerPortlet.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- FileServerPortlet.java 2001/04/09 23:31:01 1.23
+++ FileServerPortlet.java 2001/05/31 17:11:04 1.24
@@ -83,7 +83,7 @@
*
@author <a href="mailto:[EMAIL PROTECTED]">Kevin A. Burton</a>
@author <a href="mailto:[EMAIL PROTECTED]">Santiago Gala</a>
- @version $Id: FileServerPortlet.java,v 1.23 2001/04/09 23:31:01 sgala Exp $
+ @version $Id: FileServerPortlet.java,v 1.24 2001/05/31 17:11:04 raphael Exp $
*/
public class FileServerPortlet extends FileWatchPortlet {
@@ -91,6 +91,9 @@
*/
public void init() throws PortletException {
+ // first make sure we propagate init
+ super.init();
+
PortletConfig config = this.getPortletConfig();
//fetch the URL as a String...
1.9 +4 -1
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/NewRSSPortlet.java
Index: NewRSSPortlet.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/NewRSSPortlet.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- NewRSSPortlet.java 2001/05/08 10:00:21 1.8
+++ NewRSSPortlet.java 2001/05/31 17:11:06 1.9
@@ -99,7 +99,7 @@
is only used for this mime-type</dd>
</dl>
@author <A HREF="mailto:[EMAIL PROTECTED]">Rapha�l Luta</A>
-@version $Id: NewRSSPortlet.java,v 1.8 2001/05/08 10:00:21 raphael Exp $
+@version $Id: NewRSSPortlet.java,v 1.9 2001/05/31 17:11:06 raphael Exp $
*/
public class NewRSSPortlet extends FileWatchPortlet {
@@ -114,6 +114,9 @@
parse the document tied to this portlet
*/
public void init( ) throws PortletException {
+
+ // first make sure we propagate init
+ super.init();
DocumentBuilder parser = null;
String url = null;
1.2 +1 -0
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/VelocityPortlet.java
Index: VelocityPortlet.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/VelocityPortlet.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- VelocityPortlet.java 2001/05/29 22:57:48 1.1
+++ VelocityPortlet.java 2001/05/31 17:11:07 1.2
@@ -80,6 +80,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Rapha�l Luta</a>
*/
public class VelocityPortlet extends AbstractPortlet
+
{
/**
By default the data is non cacheable
1.6 +2 -2
jakarta-jetspeed/src/java/org/apache/jetspeed/portal/service/JetspeedPersistenceService.java
Index: JetspeedPersistenceService.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/portal/service/JetspeedPersistenceService.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- JetspeedPersistenceService.java 2001/05/28 15:07:41 1.5
+++ JetspeedPersistenceService.java 2001/05/31 17:11:14 1.6
@@ -422,8 +422,8 @@
}
}
- // now save it -- again, the page name does not match the file name
- if (! PSMLManager.setPSMLContent (aRunData, iName.equals ("HTML") ?
MimeType.HTML : MimeType.WML, iPortlets))
+ // now save it -- again, the page name == the file name is assumed
+ if (! PSMLManager.setPSMLContent (aRunData, iName, iPortlets))
reset ();
}
1.8 +59 -0
jakarta-jetspeed/src/java/org/apache/jetspeed/util/PSMLManager.java
Index: PSMLManager.java
===================================================================
RCS file:
/home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/util/PSMLManager.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- PSMLManager.java 2001/05/08 19:20:50 1.7
+++ PSMLManager.java 2001/05/31 17:11:19 1.8
@@ -78,14 +78,28 @@
import java.io.*;
import java.util.*;
+import org.xml.sax.InputSource;
+import org.apache.xml.serialize.Serializer;
+import org.apache.xml.serialize.XMLSerializer;
+import org.apache.xml.serialize.OutputFormat;
+
public class PSMLManager
{
// The UserProfiler that handles conversions by MimeTypes
private static MultiDeviceUserProfiler profiler = null;
+ /** the output format for pretty printing when saving PSML */
+ private static OutputFormat format = null;
+
static
{
profiler = new MultiDeviceUserProfiler();
+
+ // create the serializer output format
+ format = new OutputFormat();
+ format.setIndenting(true);
+ format.setIndent(4);
+
}
/**
* Reads a userconfiguration and builds an Portlets tree
@@ -175,6 +189,7 @@
{
return profiler.getSupportedMimeTypes();
}
+
/**
* Insert the method's description here.
* @return boolean true if successfull, else false
@@ -252,6 +267,50 @@
psf.refresh();
+ return true;
+ }
+ catch (Exception e)
+ {
+ Log.error("PSMLManager: Error writing PSML", e);
+ }
+
+ return false;
+ }
+
+ /**
+ * Insert the method's description here.
+ * @return boolean true if successfull, else false
+ * @param url java.lang.String the url handle for this PSML content
+ * @param portlets org.apache.jetspeed.xml.api.portletmarkup.Portlets The
Portlets-tree representing the PSML
+ */
+ public static boolean setPSMLContent(RunData data, String url, Portlets
portlets)
+ {
+
+ String username = data.getUser().getUserName();
+
+ // Verify the username is specified
+ if ((username == null) || (portlets == null))
+ {
+ Log.error("PSMLManager: Must specify a username and a Portlets
object!");
+ return false;
+ }
+
+ Log.note("PSMLManager: Writing "+username+"'s PSML for to '"+url+"'");
+
+ try
+ {
+ DiskCacheEntry pde = JetspeedDiskCache.getInstance().getEntry( url );
+ java.io.Writer out = pde.getWriter();
+
+ Serializer serializer = new XMLSerializer(out, format);
+ portlets.marshal(serializer.asDocumentHandler());
+ out.flush();
+ out.close();
+
+ PortletSetFactory psf = PortletSetFactory.getInstance( url );
+
+ psf.refresh();
+
return true;
}
catch (Exception e)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]