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 pa...@apache.org on 2002/04/04 05:49:23 UTC
cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/util/template JetspeedLink.java
paulsp 02/04/03 19:49:23
Added: src/java/org/apache/jetspeed/util/template JetspeedLink.java
Log:
Part of the PEID implementation. This will replace JetspeedTemplateLink.java
Revision Changes Path
1.1 jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/JetspeedLink.java
Index: JetspeedLink.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 apache@apache.org.
*
* 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.util.template;
// Jetspeed
import org.apache.jetspeed.om.profile.Profile;
import org.apache.jetspeed.om.profile.ProfileException;
import org.apache.jetspeed.om.profile.ProfileLocator;
import org.apache.jetspeed.portal.Portlet;
import org.apache.jetspeed.portal.PortletSet;
import org.apache.jetspeed.portal.PortletController;
import org.apache.jetspeed.portal.PanedPortletController;
import org.apache.jetspeed.services.Profiler;
import org.apache.jetspeed.services.resources.JetspeedResources;
import org.apache.jetspeed.services.rundata.JetspeedRunData;
// Turbine
import org.apache.turbine.util.RunData;
import org.apache.turbine.util.Log;
import org.apache.turbine.util.DynamicURI;
import org.apache.turbine.util.template.TemplateLink;
import org.apache.turbine.services.pull.ApplicationTool;
/**
* <p>A customized version of the TemplateLink which can handle portlet
* references.</p>
*
* <p>It is inserted into the template context by Turbine, via request tools.</p>
*
* <p>Each portlet must call setPortlet(this) on it before entering the template
* rendering code. This is done currently in VelocityPortlet.</p>
*
* @author <a href="mailto:paulsp@apache.org">Paul Spencer</a>
* @version $Id: JetspeedLink.java,v 1.1 2002/04/04 03:49:23 paulsp Exp $
*/
public class JetspeedLink implements ApplicationTool
{
// parameter names for the Jetspeed framework elements
// public static final String PANEID_KEY = "js_pane";
// public static final String PORTLETID_KEY = "js_peid";
/**
*<p>Request to which we refer.</p>
*/
private JetspeedRunData rundata = null;
/**
* Profile locator from <code>rundata</code>. This is here
* for performance reasons.
*/
private ProfileLocator locator = null;
/**
* @deprecated Use JetspeedResources.PATH_PANEL_KEY. This is a from JetspeedTemplateLink
*/
public static final String PANEL_KEY = "select-panel";
/**
* @deprecated JetspeedResources.PATH_PORTLET_KEY. This is a from JetspeedTemplateLink
*/
public static final String PORTLET_KEY = "portlet";
/**
*<p>The portlet that will be used to build the reference.</p>
* @deprecated This is a from JetspeedTemplateLink
*/
protected Portlet activePortlet = null;
/**
* Empty constructor.for introspection
*/
public JetspeedLink()
{
}
/**
* Constructor required by ApplicationTool interface
*
* @param data A Jetspeed RunData object.
*/
public JetspeedLink(RunData data)
{
init(data);
}
/**
* Return an link to a specific portlet using the portet's id
*
* @param peid of the portlet
* @throws ProfileException if the profile detects an error
* @return DynamicURI to spedific portlet
*/
public DynamicURI forPortletById(String peid) throws ProfileException
{
DynamicURI uri = Profiler.makeDynamicURI(rundata, locator);
return uri.addPathInfo( JetspeedResources.PATH_PORTLETID_KEY, peid);
}
/**
* Return a link to a specific pane using the pane's id
*
* @param paneId of the Pane
* @throws ProfileException if the profile detects an error
* @return URI to specific portlet
*/
public DynamicURI forPaneById(String paneId) throws ProfileException
{
DynamicURI uri = Profiler.makeDynamicURI(rundata, locator);
return uri.addPathInfo(JetspeedResources.PATH_PANEID_KEY, paneId);
}
/**
* Return a link to the root portlet or pane
* @throws ProfileException if the profile detects an error
* @return URI to the root portlet/pane
*/
public DynamicURI getRoot() throws ProfileException
{
return Profiler.makeDynamicURI(rundata, locator);
}
/**
* Return a URL, as a string, the the root page or pane.
*
* @return a URL, as a string, the the root page or pane.
*/
public String toString()
{
try
{
return Profiler.makeDynamicURI(rundata, locator).toString();
} catch (ProfileException e)
{
return new DynamicURI(rundata).toString();
}
}
/**
* Depracated methods from JetspeedTemplateLink.
*/
/**
* <p> Set the portlet giving context to this Link object.</p>
*
* This method is from JetspeeTemplateLink and is only here
* for backward compatibility. This it should not be used for
* any new development. Also any problems with this method will
* not be fixed
*
* @param portlet the name of the active portlet
* @deprecated the name is confusing. Use @see(#forPaneById()) instead.
*/
public void setPortlet(Portlet portlet)
{
this.activePortlet=portlet;
}
/**
* Add a portlet reference in the link.
*
* This method is from JetspeeTemplateLink and is only here
* for backward compatibility. This it should not be used for
* any new development. Also any problems with this method will
* not be fixed
*
* @param portlet the name of the portlet to link to
* @deprecated the name is confusing. Use @see(#forPortletById()) instead.
* @return a DynamicURI referencing the named portlet for easy link construction in template
*/
public DynamicURI setPortlet(String portlet)
{
return this.forPortlet( portlet );
}
/**
* Add a portlet reference in the link.
*
* This method is from JetspeeTemplateLink and is only here
* for backward compatibility. This it should not be used for
* any new development. Also any problems with this method will
* not be fixed
*
* @param portlet the name of the portlet to link to
* @deprecated Use @see(#forPortletById()) instead.
* @return a DynamicURI referencing the named portlet for easy link construction in template
*/
public DynamicURI forPortlet(String portlet)
{
try
{
DynamicURI uri = Profiler.makeDynamicURI(rundata, locator);
return uri.addPathInfo(JetspeedResources.PATH_PORTLET_KEY, portlet);
} catch ( ProfileException e)
{
return null;
}
}
/**
* Add a select-panel reference in the link
*
* This method is from JetspeeTemplateLink and is only here
* for backward compatibility. This it should not be used for
* any new development. Also any problems with this method will
* not be fixed
*
* @param portlet the name of the portlet to link to
* @deprecated Use @see(#forPaneById()) instead.
* @return a self reference for easy link construction in template
*/
public DynamicURI setPanel(String panel)
{
PortletController controller = activePortlet.getPortletConfig().getPortletSet().getController();
String id = null;
if (controller instanceof PanedPortletController)
{
PortletSet set = controller.getPortlets();
Portlet portlet = null;
if (null != set)
{
portlet = set.getPortletByName(panel);
}
if (portlet != null)
id = portlet.getID();
}
try
{
DynamicURI uri = Profiler.makeDynamicURI(rundata, locator);
return uri.addPathInfo(JetspeedResources.PATH_PANEID_KEY, id);
} catch ( ProfileException e)
{
return null;
}
}
/**
* <p>Use the activePortlet to get the current Panel name (key).</p>
*
* This method is from JetspeeTemplateLink and is only here
* for backward compatibility. This it should not be used for
* any new development. Also any problems with this method will
* not be fixed
*
* @deprecated Use @see(#forPaneById()) instead.
* @return the panel parameter name
*/
public String getPanelKey()
{
String panelName = PANEL_KEY;
try
{
PortletController controller = activePortlet.getPortletConfig()
.getPortletSet()
.getController();
if (controller instanceof PanedPortletController)
{
panelName=((PanedPortletController)controller).getParameterName();
}
}
catch (Exception e)
{
panelName = PANEL_KEY;
}
return panelName;
}
/**
* Methods required by ApplictionTool interface
*
*/
/**
* This will initialise a JetspeedTool object that was
* constructed with the default constructor (ApplicationTool
* method).
*
* @param data assumed to be a RunData object
*/
public void init(Object data)
{
this.rundata = (JetspeedRunData)data;
Profile profile = null;
try
{
profile = Profiler.getProfile(rundata);
}
catch (Exception e)
{
locator = null;
return;
}
// Get ProfileLocator for path info.
if ((profile instanceof ProfileLocator) == false)
{
locator = null;
return;
}
locator = (ProfileLocator) profile;
return;
}
/**
* Refresh method - does nothing
*/
public void refresh()
{
// empty
}
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/util/template JetspeedLink.java
Posted by Paul Spencer <pa...@apache.org>.
Santiago,
Santiago Gala wrote:
> paulsp@apache.org wrote:
>
>> paulsp 02/04/03 19:49:23
>>
>> Added: src/java/org/apache/jetspeed/util/template
>> JetspeedLink.java
>> Log:
>> Part of the PEID implementation. This will replace
>> JetspeedTemplateLink.java
>>
>>
> I imagine you have not finished with changes, but just to make sure you
> know, this breaks build because of missing configuration keys.
>
I have checked in the missing registry keys, sorry about the incomplete
commit.
> Also, I have a fairly extensive set of changes pending to commit for the
> correct pooling of JetspeedTemplateLink objects, and also to make them
> work with groups and pages. So, please don't remove JetspeedTemplateLink
> from CVS until we can merge these two change sets.
I will deprecate the class, but I will NOT remove it from the cvs. As I
"upgrade" a class from JetspeedTemplateLink to JetspeedLink, the class
may no longer work with JetspeedTemplateLink.
>
> I know that my intermitent activity is annoying (it is also for me ;) ),
> but I think most of the changes I have here are worth integration.
>
Paul Spencer
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: Groups, pages, anonymous user...
Posted by David Sean Taylor <da...@bluesunrise.com>.
> I have isolated changes required for this. As you know, I
> have a trend
> to mix patches, so at the end I have a heavily modified
> repository (bad
> for separation of concerns).
IMO features should take maybe one week to write, and don't let it sit
otherwise it becomes dated as others commit in overlapping areas.
>
> I have problems getting groups and pages working for anonymous user,
> since my changes made the assumption that we had always a user
> ("anonymous", with role "guest") for security checks.
>
> We need to always have a user around for most of the group
> stuff (how do
> we know group permissions, etc.).
>
> So: I want to change Jetspeed so that getAnonymousUser() and
> getUser()
> return the same kind of user, one with ACL and roles. isAnonymous()
> would work so that settings for the "anonymous" user are not saved to
> the DB (this is important). The only overhead incurred would
> be due to
> recovering User, Group, Role, and Permission records, and calculating
> ACLs (needed in any case for security). A lot of code would be
> simplified, as there would be no more
> if(data.getUser().hasLoggedIn())
> {} tests.
>
If I understand, you are proposing the anonymous page will require a
'logon'.
What about an incremental solution: for now, anon users are not allowed
access to any other resources.
Get your commits in for logged on users, and then implement the
anonymous user/logon feature as a separate feature.
Wrt JetspeedLink, it seems that both you and Paul are working on the
same feature.
You need to sort out who is doing what.
Please review Pauls commit on JetspeedLink and see if it conflicts with
your work.
Paul's commits aren't complete, he still has some work to check in.
David
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Groups, pages, anonymous user...
Posted by Santiago Gala <sg...@hisitech.com>.
David Sean Taylor wrote:
>Santiago,
>
>I just checked out clean and no problems.
>
>>Also, I have a fairly extensive set of changes pending to
>>commit for the
>>correct pooling of JetspeedTemplateLink objects, and also to
>>make them
>>work with groups and pages. So, please don't remove
>>JetspeedTemplateLink
>>from CVS until we can merge these two change sets.
>>
>
>Im looking forward to links working with group/role pages.
>If there's anything I can do to help, finish up any loose ends you don't
>have time for, whatever, I'd be glad to help out,
>
I have isolated changes required for this. As you know, I have a trend
to mix patches, so at the end I have a heavily modified repository (bad
for separation of concerns).
I have problems getting groups and pages working for anonymous user,
since my changes made the assumption that we had always a user
("anonymous", with role "guest") for security checks.
We need to always have a user around for most of the group stuff (how do
we know group permissions, etc.).
So: I want to change Jetspeed so that getAnonymousUser() and getUser()
return the same kind of user, one with ACL and roles. isAnonymous()
would work so that settings for the "anonymous" user are not saved to
the DB (this is important). The only overhead incurred would be due to
recovering User, Group, Role, and Permission records, and calculating
ACLs (needed in any case for security). A lot of code would be
simplified, as there would be no more if(data.getUser().hasLoggedIn())
{} tests.
If nobody objects to this change, I'll start by changing this part of
the code.
I'm still searching for a solution which don't involve changes to the
way user login is handled.
>.
>Regards,
>
>David
>
>
>
>--
>To unsubscribe, e-mail: <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
RE: cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/util/template JetspeedLink.java
Posted by David Sean Taylor <da...@bluesunrise.com>.
Santiago,
I just checked out clean and no problems.
> Also, I have a fairly extensive set of changes pending to
> commit for the
> correct pooling of JetspeedTemplateLink objects, and also to
> make them
> work with groups and pages. So, please don't remove
> JetspeedTemplateLink
> from CVS until we can merge these two change sets.
Im looking forward to links working with group/role pages.
If there's anything I can do to help, finish up any loose ends you don't
have time for, whatever, I'd be glad to help out,
Regards,
David
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: cvs commit: jakarta-jetspeed/src/java/org/apache/jetspeed/util/template
JetspeedLink.java
Posted by Santiago Gala <sg...@hisitech.com>.
paulsp@apache.org wrote:
>paulsp 02/04/03 19:49:23
>
> Added: src/java/org/apache/jetspeed/util/template JetspeedLink.java
> Log:
> Part of the PEID implementation. This will replace JetspeedTemplateLink.java
>
>
I imagine you have not finished with changes, but just to make sure you
know, this breaks build because of missing configuration keys.
Also, I have a fairly extensive set of changes pending to commit for the
correct pooling of JetspeedTemplateLink objects, and also to make them
work with groups and pages. So, please don't remove JetspeedTemplateLink
from CVS until we can merge these two change sets.
I know that my intermitent activity is annoying (it is also for me ;) ),
but I think most of the changes I have here are worth integration.
compile:
[javac] Compiling 370 source files to
/home/sgala/jakarta/pristine/jakarta-jetspeed/bin/classes
[javac]
/home/sgala/jakarta/pristine/jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/JetspeedLink.java:148:
cannot resolve symbol
[javac] symbol : variable PATH_PORTLETID_KEY
[javac] location: class
org.apache.jetspeed.services.resources.JetspeedResources
[javac] return uri.addPathInfo(
JetspeedResources.PATH_PORTLETID_KEY, peid);
[javac] ^
[javac]
/home/sgala/jakarta/pristine/jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/JetspeedLink.java:161:
cannot resolve symbol
[javac] symbol : variable PATH_PANEID_KEY
[javac] location: class
org.apache.jetspeed.services.resources.JetspeedResources
[javac] return
uri.addPathInfo(JetspeedResources.PATH_PANEID_KEY, paneId);
[javac] ^
[javac]
/home/sgala/jakarta/pristine/jakarta-jetspeed/src/java/org/apache/jetspeed/util/template/JetspeedLink.java:285:
cannot resolve symbol
[javac] symbol : variable PATH_PANEID_KEY
[javac] location: class
org.apache.jetspeed.services.resources.JetspeedResources
[javac] return
uri.addPathInfo(JetspeedResources.PATH_PANEID_KEY, id);
[javac] ^
[javac] Note: Some input files use or override a deprecated API.
[javac] Note: Recompile with -deprecation for details.
[javac] 3 errors
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>