portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From morci...@apache.org
Subject cvs commit: jakarta-jetspeed/xdocs portlet_config_WebClippingPortlet.xml catalog.xml
Date Fri, 05 Sep 2003 16:41:17 GMT
morciuch    2003/09/05 09:41:17

  Modified:    .        README
               docs/site catalog.html
               docs/site/images logo.gif
               src/java/org/apache/jetspeed/util/rewriter HTMLRewriter.java
                        ProxyRewriter.java Rewriter.java
                        SwingParserAdaptor.java
               webapp/WEB-INF/conf JetspeedResources.properties
                        demo-portlets.xreg portlets.xreg
               xdocs    catalog.xml
  Added:       src/java/org/apache/jetspeed/portal/portlets
                        WebClippingPortlet.java
               src/java/org/apache/jetspeed/services/transformer
                        JetspeedTransformerService.java
                        TransformerService.java
               src/java/org/apache/jetspeed/util/rewriter
                        ClipperRewriter.java
               webapp/WEB-INF/psml/user/turbine/html web-clipping.psml
               webapp/examples local-content.html nested.html
                        organized.html startTagNumber.html
               xdocs    portlet_config_WebClippingPortlet.xml
  Log:
  Integrated a WebClippingPortlet contributed by Marco Mari (see Bugzilla issue# 22947).
  
  Revision  Changes    Path
  1.23      +9 -0      jakarta-jetspeed/README
  
  Index: README
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/README,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- README	8 Aug 2003 15:21:47 -0000	1.22
  +++ README	5 Sep 2003 16:41:16 -0000	1.23
  @@ -295,6 +295,15 @@
   These were tested with Eclipse 2.1.1 and JDK 1.3.
   
   ==============================================
  +Jetspeed 1.4 was released on ??? ??, 2003.
  +==============================================
  +
  +* New Features *
  +
  +	- Logging converted from Turbine to Commons. Contributed by Harald Ommang
  +	- WebClippingPortlet contributed by Marco Mari.
  +
  +==============================================
   Jetspeed 1.4b4 was released on April 25, 2003.
   ==============================================
   
  
  
  
  1.23      +5 -4      jakarta-jetspeed/docs/site/catalog.html
  
  Index: catalog.html
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/docs/site/catalog.html,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- catalog.html	25 Aug 2003 06:18:39 -0000	1.22
  +++ catalog.html	5 Sep 2003 16:41:16 -0000	1.23
  @@ -5,7 +5,6 @@
           
   <!-- start the processing -->
       <!-- ====================================================================== -->
  -    <!-- GENERATED FILE, DO NOT EDIT, EDIT THE XML FILE IN xdocs INSTEAD! -->
       <!-- Main Page Section -->
       <!-- ====================================================================== -->
       <html>
  @@ -15,7 +14,6 @@
                           
              
                                       
  -                        
               <title>Jetspeed - Jetspeed Portlet Catalog</title>
           </head>
   
  @@ -155,9 +153,12 @@
           <li>
             <a href="portlet_config_DBBrowser.html">Database Browser Portlet</a> 
   	</li>
  -        <li>
  +    <li>
             <a href="portlet_config_LogfileViewer.html">Logfile Viewer Portlet</a> 
   	</li>	
  +    <li>
  +          <a href="portlet_config_WebClippingPortlet.html">Web Clipping Portlet</a> 
  +	</li>	
           </ul>
                                                   <a href="portlet_config_common.html">Configuration common to many standard portlets</a>
                               </blockquote>
  @@ -174,7 +175,7 @@
                   </td></tr>
                   <tr><td colspan="2">
                       <div align="center"><font color="#525D76" size="-1"><em>
  -                    Copyright &#169; 1999-2003, Apache Software Foundation
  +                    Copyright &#169; 1999-2002, Apache Software Foundation
                       </em></font></div>
                   </td></tr>
               </table>
  
  
  
  1.3       +35 -29    jakarta-jetspeed/docs/site/images/logo.gif
  
  	<<Binary file>>
  
  
  1.1                  jakarta-jetspeed/src/java/org/apache/jetspeed/portal/portlets/WebClippingPortlet.java
  
  Index: WebClippingPortlet.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 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.portal.portlets;
  
  //Element Construction Set
  import java.io.IOException;
  import java.io.InputStreamReader;
  import java.io.Reader;
  import java.net.URL;
  import java.net.URLConnection;
  import java.util.Enumeration;
  import java.util.Hashtable;
  import java.util.Iterator;
  
  import org.apache.ecs.ConcreteElement;
  import org.apache.jetspeed.portal.PortletConfig;
  import org.apache.jetspeed.portal.PortletException;
  import org.apache.jetspeed.services.Transformer;
  import org.apache.jetspeed.util.Base64;
  import org.apache.jetspeed.util.JetspeedClearElement;
  import org.apache.turbine.services.servlet.TurbineServlet;
  import org.apache.turbine.util.RunData;
  
  import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
  import org.apache.jetspeed.services.logging.JetspeedLogger;
  
  /**
   * A class that clips parts of one or more web pages.
   *
   * @author <a href="mailto:mmari@ce.unipr.it">Marco Mari</a>
   * @version $Id: WebClippingPortlet.java,v 1.1 2003/09/05 16:41:16 morciuch Exp $ 
   */
  
  public class WebClippingPortlet extends AbstractInstancePortlet
  {
  
  	/**
  	 * Static initialization of the logger for this class
  	 */
  	private static final JetspeedLogger logger =
  		JetspeedLogFactoryService.getLogger(WebClippingPortlet.class.getName());
  
  	// Define parameter name for the first tag to clip
  	public static final String START = "startTag";
  	// Define parameter name for the last tag to clip
  	public static final String STOP = "stopTag";
  	// Define parameter name for a single tag to clip
  	public static final String TAG = "Tag";
  	// Define parameter name for the number of the tag to clip
  	public static final String TAGNUM = "startTagNumber";
  	// Define parameter name for the URL of the page
  	public static final String URL = "url";
  	// Error message for startTag without stopTag
  	private String BAD_PARAM = "<br>Error: startTag without stopTag<br>";
  	// Error message for wrong startTagNumber parameter
  	private String BAD_NUMBER = "<br>Error: bad integer parameter<br>";
  
  	protected boolean initDone = false;
  	protected boolean contentStale = true;
  	protected boolean cacheContent = false;
  	protected String username = null;
  	protected String password = null;
  
  	private Hashtable patterns = null;
  
  	/**
  	 * Initialize this portlet
  	 * @throws PortletException Initialization failed
  	 */
  	public void init()
  	{
  		if (initDone)
  			return;
  
  		patterns = new Hashtable();
  
  		try
  		{
  			loadParams();
  		}
  		catch (Exception e)
  		{
  			logger.info("Exception occurred:" + e.toString());
  			e.printStackTrace();
  		}
  
  		contentStale = true;
  		initDone = true;
  	}
  
  	/**
  	 * took this from FileServerPortlet as it was private 
  	 *
  	*/
  
  	// FIXME: Currently only the expiration the HTTP Response header is honored. 
  	//        Expiration information in <meta> tags are not honored 
  
  	protected Reader getReader(String url) throws IOException
  	{
  		URL pageUrl = new URL(url);
  
  		URLConnection pageConn = pageUrl.openConnection();
  		try
  		{
  			// set HTTP Basic Authetication header if username and password are set
  			if (username != null && password != null)
  			{
  				pageConn.setRequestProperty(
  					"Authorization",
  					"Basic "
  						+ Base64.encodeAsString(username + ":" + password));
  			}
  
  		}
  		catch (Exception e)
  		{
  			logger.info("Exception occurred:" + e.toString());
  			e.printStackTrace();
  		}
  
  		long pageExpiration = pageConn.getExpiration();
  		String encoding = pageConn.getContentEncoding();
  		String tempString = null;
  		String noCache = "no-cache";
  
  		if (encoding == null)
  		{
  			// Standard HTTP encoding
  			encoding = "iso-8859-1";
  		}
  
  		/*
  		 * Determing if content should be cached.
  		 */
  		cacheContent = true; // Assume content is cached
  		if (pageExpiration == 0)
  		{
  			cacheContent = false;
  		}
  		// Check header field CacheControl
  		tempString = pageConn.getHeaderField("Cache-Control");
  		if (tempString != null)
  		{
  			if (tempString.toLowerCase().indexOf(noCache) >= 0)
  			{
  				cacheContent = false;
  			}
  		}
  		// Check header field Pragma
  		tempString = pageConn.getHeaderField("Pragma");
  		if (tempString != null)
  		{
  			if (tempString.toLowerCase().indexOf(noCache) >= 0)
  			{
  				cacheContent = false;
  			}
  		}
  
  		// Assign a reader
  		Reader rdr = new InputStreamReader(pageConn.getInputStream(), encoding);
  
  		// Only set the page expiration it the page has not expired
  		if (pageExpiration > System.currentTimeMillis()
  			&& (cacheContent == true))
  		{
  			contentStale = false;
  			logger.debug(
  				"WebPagePortlet caching URL: "
  					+ url
  					+ " Expiration: "
  					+ pageExpiration
  					+ ", "
  					+ (pageExpiration - System.currentTimeMillis())
  					+ " milliseconds into the future");
  			setExpirationMillis(pageExpiration);
  		}
  		else
  		{
  			contentStale = true;
  		}
  
  		return rdr;
  	}
  
  	/**
  	This methods outputs the content of the portlet for a given 
  	request.
  	
  	@param data the RunData object for the request
  	@return the content to be displayed to the user-agent
  	*/
  	public ConcreteElement getContent(RunData data)
  	{
  		PortletConfig config = this.getPortletConfig();
  
  		if (contentStale == true)
  			return getWebClippedContent(data, config);
  
  		if (null == getExpirationMillis())
  			return getContent(data, null, true);
  
  		if (getExpirationMillis().longValue() <= System.currentTimeMillis())
  			return getWebClippedContent(data, config);
  
  		return getContent(data, null, true);
  	}
  
  	/*
  	 * This method returns the clipped part of the Web page
  	 */
  	private ConcreteElement getWebClippedContent(
  		RunData data,
  		PortletConfig config)
  	{
  		String clippedString = ""; // HTML to visualize
  		JetspeedClearElement element = null;
  		int patternNumber = 1;
  		int tagNumber = 0;
  		Reader htmlReader;
  		String defaultUrl = selectUrl(data, config);
  
  		try
  		{
  			// Re-load parameters to see immediately the effect of changes
  			loadParams();
  			Enumeration en = patterns.keys();
  
  			while (en.hasMoreElements())
  			{
  				String name = (String) en.nextElement();
  
  				// Search for parameters in the right order
  				if (name.equals(START + String.valueOf(patternNumber))
  					|| name.equals(TAG + String.valueOf(patternNumber)))
  				{
  					String start =
  						(String) patterns.get(
  							START + String.valueOf(patternNumber));
  					String simpleTag =
  						(String) patterns.get(
  							TAG + String.valueOf(patternNumber));
  					String stop =
  						(String) patterns.get(
  							STOP + String.valueOf(patternNumber));
  					String tagNum =
  						(String) patterns.get(
  							TAGNUM + String.valueOf(patternNumber));
  					// A group of params can have a specific url
  					String url =
  						(String) patterns.get(
  							URL + String.valueOf(patternNumber));
  					url = controlUrl(url, defaultUrl);
  					htmlReader = getReader(url);
  
  					if ((start != null) && (stop == null))
  					{
  						element = new JetspeedClearElement(BAD_PARAM);
  						return element;
  					}
  
  					if (tagNum != null)
  					{
  						try
  						{
  							tagNumber = Integer.parseInt(tagNum);
  						}
  						catch (NumberFormatException e)
  						{
  							logger.info("Exception occurred:" + e.toString());
  							e.printStackTrace();
  							element = new JetspeedClearElement(BAD_NUMBER);
  							return element;
  						}
  					}
  
  					if ((simpleTag != null) && (tagNum == null))
  						clippedString =
  							clippedString
  								+ Transformer.findElement(
  									htmlReader,
  									url,
  									simpleTag);
  					else if ((simpleTag != null) && (tagNum != null))
  						clippedString =
  							clippedString
  								+ Transformer.findElementNumber(
  									htmlReader,
  									url,
  									simpleTag,
  									tagNumber);
  					else if (tagNum == null)
  						clippedString =
  							clippedString
  								+ Transformer.clipElements(
  									htmlReader,
  									url,
  									start,
  									stop);
  					else if (tagNum != null)
  						clippedString =
  							clippedString
  								+ Transformer.clipElementsNumber(
  									htmlReader,
  									url,
  									start,
  									stop,
  									tagNumber);
  
  					patternNumber = patternNumber + 1;
  					//Restart Enumeration, because params could not be in the right order
  					en = patterns.keys();
  					htmlReader.close();
  				}
  			}
  
  			element = new JetspeedClearElement(clippedString);
  
  			//FIXME: We should do a clearContent() for the media type, not ALL media types
  			this.clearContent();
  			// doing this because setContent() is not overwriting current content.
  			this.setContent(element);
  
  		}
  		catch (Exception e)
  		{
  			logger.info("Exception occurred:" + e.toString());
  			e.printStackTrace();
  		}
  
  		return element;
  	}
  
  	/**
  	 * Usually called by caching system when portlet is marked as expired, but
  	 * has not be idle longer then TimeToLive.
  	 *
  	 * Any cached content that is expired need to be refreshed.
  	 */
  	public void refresh()
  	{
  		if (cacheContent == true)
  		{
  			getWebClippedContent(null, this.getPortletConfig());
  		}
  	}
  
  	/**
  	 * Select the URL to use for this portlet.
  	 * @return The URL to use for this portlet
  	 */
  	protected String selectUrl(RunData data, PortletConfig config)
  	{
  		String url = config.getURL();
  		return url;
  	}
  
  	/*
  	 * Choose between a specific url and the default url
  	 */
  	private String controlUrl(String url, String defaultUrl)
  	{
  		if (url == null)
  		{
  			return defaultUrl;
  		}
  
  		//if the given URL doesn not include a protocol... ie http:// or ftp://
  		//then resolve it relative to the current URL context
  		if (url.indexOf("://") < 0)
  		{
  			url = TurbineServlet.getResource(url).toString();
  		}
  
  		return url;
  	}
  
  	/*
  	 * Load portlet parameters
  	 */
  	private void loadParams() throws PortletException
  	{
  		Iterator en = this.getPortletConfig().getInitParameterNames();
  
  		try
  		{
  			while (en.hasNext())
  			{
  				String name = (String) en.next();
  
  				if (name.equals("username"))
  					username =
  						this.getPortletConfig().getInitParameter("username");
  				else if (name.equals("password"))
  					password =
  						this.getPortletConfig().getInitParameter("password");
  				else
  					patterns.put(
  						name,
  						this.getPortletConfig().getInitParameter(name));
  
  			}
  		}
  		catch (Exception e)
  		{
  			logger.info("Exception occurred:" + e.toString());
  			e.printStackTrace();
  			throw new PortletException(e.toString());
  		}
  	}
  
  }
  
  
  
  1.1                  jakarta-jetspeed/src/java/org/apache/jetspeed/services/transformer/JetspeedTransformerService.java
  
  Index: JetspeedTransformerService.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 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.services.transformer;
  
  // turbine stuff
  import java.io.Reader;
  
  import javax.servlet.ServletConfig;
  
  import org.apache.jetspeed.util.rewriter.ClipperRewriter;
  import org.apache.turbine.services.TurbineBaseService;
  import org.apache.turbine.util.Log;
  
  /**
   * Simple implementation of the TransformerService.
   * @author <a href="mailto:mmari@ce.unipr.it">Marco Mari</a>
   * @version $Id: JetspeedTransformerService.java,v 1.1 2003/09/05 16:41:17 morciuch Exp $* 
   */
  public class JetspeedTransformerService
  	extends TurbineBaseService
  	implements TransformerService
  {
  	protected ClipperRewriter rewriter = null;
  	String convertedString;
  
  	/**
  	 * This is the early initialization method called by the 
  	 * Turbine <code>Service</code> framework
  	 * @param conf The <code>ServletConfig</code>
  	 */
  	public void init(ServletConfig conf)
  	{
  		// controls if already initialized
  		if (getInit())
  		{
  			return;
  		}
  
  		rewriter = new ClipperRewriter();
  		setInit(true);
  	}
  
  	/**
  	 * Late init. Don't return control until early init says we're done.
  	 */
  	public void init()
  	{
  		while (!getInit())
  		{
  			try
  			{
  				Thread.sleep(500);
  				Log.info("JetspeedTransformerService: Waiting for init()...");
  			}
  			catch (InterruptedException ie)
  			{
  				Log.error(ie);
  			}
  		}
  	}
  
  	/**
  	 * Finds an element in a web page
  	 * 
  	 * @param htmlReader Reader for the html rewriter
  	 * @param url        page address
  	 * @param element    a part of the element to search
  	 */
  	public String findElement(Reader htmlReader, String url, String element)
  	{
  		// If not indicated, assume to find the first element
  		return clipElementsNumber(htmlReader, url, element, null, 1);
  	}
  
  	/**
  	 * Clips the part of a web page between startElement and stopElement
  	 * 
  	 * @param htmlReader    Reader for the html rewriter
  	 * @param url           page address
  	 * @param startElement  the first element to clip
  	 * @param lastElement   the last element to clip
  	 */
  	public String clipElements(
  		Reader htmlReader,
  		String url,
  		String startElement,
  		String stopElement)
  	{
  		// If not indicated, assume to find the first startElement
  		return clipElementsNumber(
  			htmlReader,
  			url,
  			startElement,
  			stopElement,
  			1);
  	}
  
  	/**
  	 * Finds in an HTML page the "tagNumber" tag of type "element"
  	 * Example: element = "p", tagNumber = "3"
  	 * Page content:
  	 * <p>..</p>
  	 * <p>..</p>
  	 * <p>..   <---Finds this    
  	 * 
  	 * @param htmlReader Reader for the html rewriter
  	 * @param url        page address
  	 * @param element    the element to search
  	 * @param tagNumber  the number of the element to search
  	 */
  	public String findElementNumber(
  		Reader htmlReader,
  		String url,
  		String element,
  		int tagNumber)
  	{
  		return clipElementsNumber(htmlReader, url, element, null, tagNumber);
  	}
  
  	/**
  	 * Clips a part of a web page, starting from the "tagNumber" "startElement"
  	 * Example: startElement = "p", tagNumber = "3", stopElement = "img"
  	 * Page content:
  	 * <p>..</p>
  	 * <p>..</p>
  	 * <p>..   <---Starts here
  	 * ........<img>  <---Stops here
  	 * 
  	 * @param htmlReader    Reader for the html rewriter
  	 * @param url           page address
  	 * @param startElement  the first element to clip
  	 * @param stopElement   the last element to clip
  	 * @param tagNumber     the number of the first element to clip
  	 */
  	public String clipElementsNumber(
  		Reader htmlReader,
  		String url,
  		String startElement,
  		String stopElement,
  		int tagNumber)
  	{
  		rewriter.setStartElement(startElement);
  		rewriter.setStopElement(stopElement);
  		rewriter.setStartElementNumber(tagNumber);
  
  		try
  		{
  			convertedString = rewriter.rewrite(htmlReader, url);
  		}
  		catch (Exception e)
  		{
  			Log.info("Exception occurred:" + e.toString());
  			e.printStackTrace();
  		}
  
  		return convertedString;
  	}
  
  }
  
  
  
  1.1                  jakarta-jetspeed/src/java/org/apache/jetspeed/services/transformer/TransformerService.java
  
  Index: TransformerService.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 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.services.transformer;
  
  //standard java stuff
  import java.io.Reader;
  
  // turbine stuff
  import org.apache.turbine.services.Service;
  
  /**
   * This service is responsible for locate and transform HTML content
   * 
   * @author <a href="mailto:mmari@ce.unipr.it">Marco Mari</a>
   * @version $Id: TransformerService.java,v 1.1 2003/09/05 16:41:17 morciuch Exp $ 
   */
  public interface TransformerService extends Service
  {
  
  	/** The name of this service */
  	public String SERVICE_NAME = "Transformer";
  
  	/**
  	 * Finds an element in a web page
  	 * 
  	 * @param htmlReader Reader for the html rewriter
  	 * @param url        page address
  	 * @param element    the element to search
  	 */
  	public String findElement(Reader htmlReader, String url, String element);
  
  	/**
  	 * Clips the part of a web page between startElement and stopElement
  	 * 
  	 * @param htmlReader    Reader for the html rewriter
  	 * @param url           page address
  	 * @param startElement  the first element to clip
  	 * @param stopElement   the last element to clip
  	 */
  	public String clipElements(
  		Reader htmlReader,
  		String url,
  		String startElement,
  		String stopElement);
  
  	/**
  	 * Finds in an HTML page the "tagNumber" tag of type "element"
  	 * Example: element = "p", tagNumber = "3"
  	 * Page content:
  	 * <p>..</p>
  	 * <p>..</p>
  	 * <p>..   <---Finds this    
  	 * 
  	 * @param htmlReader Reader for the html rewriter
  	 * @param url        page address
  	 * @param element    the element to search
  	 * @param tagNumber  the number of the element to search
  	 */
  	public String findElementNumber(
  		Reader htmlReader,
  		String url,
  		String element,
  		int tagNumber);
  
  	/**
  	 * Clips a part of a web page, starting from the "tagNumber" "startElement"
  	 * Example: startElement = "p", tagNumber = "3", stopElement = "img"
  	 * Page content:
  	 * <p>..</p>
  	 * <p>..</p>
  	 * <p>..   <---Starts here
  	 * ........<img>  <---Stops here
  	 * 
  	 * @param htmlReader    Reader for the html rewriter
  	 * @param url           page address
  	 * @param startElement  the first element to clip
  	 * @param stopElement   the last element to clip
  	 * @param tagNumber     the number of the first element to clip
  	 */
  	public String clipElementsNumber(
  		Reader htmlReader,
  		String url,
  		String startElement,
  		String stopElement,
  		int tagNumber);
  }
  
  
  
  1.5       +9 -2      jakarta-jetspeed/src/java/org/apache/jetspeed/util/rewriter/HTMLRewriter.java
  
  Index: HTMLRewriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/util/rewriter/HTMLRewriter.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- HTMLRewriter.java	4 Mar 2003 00:05:16 -0000	1.4
  +++ HTMLRewriter.java	5 Sep 2003 16:41:17 -0000	1.5
  @@ -1,7 +1,7 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -180,6 +180,13 @@
           return null;
       }
   
  +    /*
  +     * Text Event
  +     */
  +    public boolean enterText(char[] values, int param)
  +    {
  +        return true;
  +    }
   
       /*
        * Convert Tag Events
  
  
  
  1.2       +6 -2      jakarta-jetspeed/src/java/org/apache/jetspeed/util/rewriter/ProxyRewriter.java
  
  Index: ProxyRewriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/util/rewriter/ProxyRewriter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ProxyRewriter.java	29 Oct 2002 18:38:06 -0000	1.1
  +++ ProxyRewriter.java	5 Sep 2003 16:41:17 -0000	1.2
  @@ -1,7 +1,7 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -349,6 +349,10 @@
       {
       }
   
  +	public boolean enterText(char[] values, int param)
  +	{
  +		return false;
  +	}
   }
   
   
  
  
  
  1.5       +4 -2      jakarta-jetspeed/src/java/org/apache/jetspeed/util/rewriter/Rewriter.java
  
  Index: Rewriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/util/rewriter/Rewriter.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Rewriter.java	4 Mar 2003 00:05:16 -0000	1.4
  +++ Rewriter.java	5 Sep 2003 16:41:17 -0000	1.5
  @@ -1,7 +1,7 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -123,6 +123,8 @@
   
       boolean enterEndTagEvent(HTML.Tag tag);
       String exitEndTagEvent(HTML.Tag tag);
  +
  +    boolean enterText(char[] values, int param);
   
       void convertTagEvent(HTML.Tag tag, MutableAttributeSet attrs);
   }
  
  
  
  1.5       +9 -3      jakarta-jetspeed/src/java/org/apache/jetspeed/util/rewriter/SwingParserAdaptor.java
  
  Index: SwingParserAdaptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/src/java/org/apache/jetspeed/util/rewriter/SwingParserAdaptor.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- SwingParserAdaptor.java	4 Mar 2003 00:05:16 -0000	1.4
  +++ SwingParserAdaptor.java	5 Sep 2003 16:41:17 -0000	1.5
  @@ -1,7 +1,7 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2000-2001 The Apache Software Foundation.  All rights
  + * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
    * reserved.
    *
    * Redistribution and use in source and binary forms, with or without
  @@ -66,6 +66,8 @@
   
   // java.net
   import java.net.*;
  +import org.apache.turbine.util.Log;//AAAtogli!
  +
   
   /*
    * HTML Parser Adaptor for the Swing 'HotJava' parser.
  @@ -117,6 +119,8 @@
           } catch (Exception e)
           {
               e.printStackTrace();
  +      //Log.info("Exception occurred:" + e.toString());AAAtogli!!!
  +      //Log.info("Exception occurred:" + e.printStackTrace());
               throw new MalformedURLException(e.toString());
           }
           return res;
  @@ -172,7 +176,9 @@
                if (false == emit)                               
                    return;                                      
                if (values[0] == '>')                            
  -                 return;                                      
  +                 return;     
  +             if (false == rewriter.enterText(values, param))
  +                return;                    
   
               addToResult(values);
           }
  
  
  
  1.1                  jakarta-jetspeed/src/java/org/apache/jetspeed/util/rewriter/ClipperRewriter.java
  
  Index: ClipperRewriter.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 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.rewriter;
  
  // java.io
  import java.io.Reader;
  import java.net.MalformedURLException;
  import java.util.Enumeration;
  import java.util.StringTokenizer;
  
  import javax.swing.text.MutableAttributeSet;
  import javax.swing.text.html.HTML;
  
  import org.apache.turbine.util.Log;
  
  /**
   *
   * HTML Rewriter for transformer service
   *
   * @author <a href="mailto:mmari@ce.unipr.it">Marco Mari</a>
   * @version $Id: ClipperRewriter.java,v 1.1 2003/09/05 16:41:17 morciuch Exp $ 
   */
  
  public class ClipperRewriter extends HTMLRewriter
  {
  	private String startElement;
  	private String stopElement;
  	private boolean foundStart = false;
  	private boolean foundStop = false;
  	private boolean nested = false;
  	private int nestedNumber = 0;
  	private int startElementNumber;
  	private int foundElementNumber = 0;
  	private String NOT_FOUND = "<br>Element not found, returning null<br>";
  	private String INVALID_START = "<br>Error: received null start element<br>";
  	private String INVALID_NUMBER =
  		"<br>Error: received tagNumber negative or null<br>";
  
  	/*
  	 * Construct the Clipper Rewriter
  	 *
  	 */
  	public ClipperRewriter()
  	{
  	}
  
  	/*
  	 * Rewriting HTML content between startElement and stopElement
  	 *
  	 * @param input    the HTML input stream.
  	 * @param baseURL  the base URL of the target host.
  	 * @return         the rewritten HTML output stream.
  	 *
  	 * @exception      MalformedURLException a servlet exception.
  	 */
  
  	public String rewrite(Reader input, String baseURL)
  		throws MalformedURLException
  	{
  		this.baseURL = baseURL;
  		String rewrittenHTML = "";
  		foundStart = false;
  		foundStop = false;
  		nestedNumber = 0;
  		foundElementNumber = 0;
  
  		// Null startElement is invalid
  		if (startElement == null)
  		{
  			return INVALID_START;
  		}
  
  		// StartElementNumber must be positive
  		if (startElementNumber <= 0)
  		{
  			return INVALID_NUMBER;
  		}
  
  		nested = controlCoupled(startElement, stopElement);
  		HTMLParserAdaptor parser = new SwingParserAdaptor(this);
  		rewrittenHTML = parser.run(input);
  
  		if (Log.getLogger().isDebugEnabled())
  		{
  			Log.debug("Clipper rewriter: start element:" + startElement);
  			Log.debug("Clipper rewriter: stop element:" + stopElement);
  			Log.debug("Clipper rewriter: foundStart:" + foundStart);
  			Log.debug("Clipper rewriter: foundStop:" + foundStop);
  			Log.debug("Clipper rewriter: nested:" + nested);
  			Log.debug(
  				"Clipper rewriter: foundElementNumber:" + foundElementNumber);
  			Log.debug("Clipper rewriter: rewrittenHTML:" + rewrittenHTML);
  		}
  
  		if ((foundStart == false)
  			|| ((foundStop == false) && (stopElement != null)))
  			return NOT_FOUND;
  		else
  			return rewrittenHTML;
  	}
  
  	/*
  	 * Returns true if all rewritten URLs should be sent back to the proxy server.
  	 *
  	 * @return true if all URLs are rewritten back to proxy server.
  	 */
  	public boolean proxyAllTags()
  	{
  		return true;
  	}
  
  	/*
  	 * Simple Tag Events
  	 */
  	public boolean enterSimpleTagEvent(HTML.Tag tag, MutableAttributeSet attrs)
  	{
  		String attributes = attrsToString(attrs);
  		String tagString = tag.toString();
  		return checkTag(tagString, attributes, "simple");
  	}
  
  	/*
  	 * Start Tag Events
  	 */
  	public boolean enterStartTagEvent(HTML.Tag tag, MutableAttributeSet attrs)
  	{
  		String attributes = attrsToString(attrs);
  		String tagString = tag.toString();
  		return checkTag(tagString, attributes, "start");
  	}
  
  	/*
  	 * Exit Tag Events
  	 */
  	public boolean enterEndTagEvent(HTML.Tag tag)
  	{
  		String tagString = tag.toString();
  		return checkTag(tagString, null, "end");
  	}
  
  	/*
  	 * Text Event
  	 */
  	public boolean enterText(char[] values, int param)
  	{
  		if ((foundStart == true)
  			&& (foundStop == false)
  			&& (stopElement != null))
  			return true;
  		else
  			return false;
  	}
  
  	/**
  	 * Set the start element
  	 *
  	 * @param startElement    the new start element
  	 */
  	public void setStartElement(String startElement)
  	{
  		this.startElement = startElement;
  	}
  
  	/**
  	 * Set the stop element
  	 *
  	 * @param stopElement    the new stop element
  	 */
  	public void setStopElement(String stopElement)
  	{
  		this.stopElement = stopElement;
  	}
  
  	/**
  	 * Set the start element number
  	 *
  	 * @param startElementNumber    the new start element number
  	 */
  	public void setStartElementNumber(int startElementNumber)
  	{
  		this.startElementNumber = startElementNumber;
  	}
  
  	/*
  	 * Control if searched tags are coupled.
  	 * If searched tags are coupled, we must consider nested tags, example:
  	 * Searched: <table>   and   </table>
  	 * in the page there is:
  	 * <table>...
  	 *     <table>...
  	 *     </table>
  	 * </table>
  	 * We are searching for the first and fourth tag!
  	 */
  	private boolean controlCoupled(String start, String stop)
  	{
  		StringTokenizer startTok = new StringTokenizer(start);
  		boolean foundCoupled = false;
  		String token;
  
  		if (stop == null)
  			return false;
  
  		while (startTok.hasMoreTokens())
  		{
  			token = startTok.nextToken();
  
  			if (token.equals(stop) == true)
  				return true;
  		}
  
  		return false;
  	}
  
  	/*
  	 * Convert the attributes set to a string
  	 */
  	private String attrsToString(MutableAttributeSet attrs)
  	{
  		String element = "";
  
  		if (attrs != null)
  		{
  			Enumeration en = attrs.getAttributeNames();
  
  			while (en.hasMoreElements())
  			{
  				Object attr = en.nextElement();
  				element =
  					element
  						+ " "
  						+ attr.toString()
  						+ "="
  						+ attrs.getAttribute(attr).toString();
  			}
  
  			return element;
  		}
  
  		return null;
  	}
  
  	/*
  	 * Control to include or exclude the tag
  	 */
  	private boolean checkTag(String tag, String attrs, String position)
  	{
  		if (foundStart == false)
  		{
  			// Searching for start element
  			if ((compareTag(tag, attrs, startElement) == true)
  				&& ((position.equals("end") == false) || (stopElement == null)))
  			{
  				foundElementNumber = foundElementNumber + 1;
  
  				if (foundElementNumber == startElementNumber)
  				{
  					foundStart = true;
  
  					if (nested == true)
  						nestedNumber = nestedNumber + 1;
  
  					return true;
  				}
  				else
  					return false;
  			}
  			else
  			{
  				// It's not start element
  				return false;
  			}
  			// Searching for stop element
  		}
  		else if ((foundStop == false) && (stopElement != null))
  		{
  			if (compareTag(tag, attrs, stopElement))
  			{
  				if (nested == true)
  					if (position.equals("start"))
  						nestedNumber = nestedNumber + 1;
  					else if (position.equals("end"))
  						nestedNumber = nestedNumber - 1;
  
  				if ((nestedNumber == 0) && (position.equals("start") == false))
  					foundStop = true;
  
  				return true;
  			}
  			else
  			{
  				// It's not stop element
  				return true;
  			}
  		}
  		else
  			// Stop already found, don't include this tag
  			return false;
  	}
  
  	/*
  	 * Control if the current tag is the searched tag with the right attributes
  	 */
  	private boolean compareTag(String tag, String attrs, String base)
  	{
  		StringTokenizer baseTok = new StringTokenizer(base);
  		String token;
  		boolean foundTag = false;
  
  		while (baseTok.hasMoreTokens())
  		{
  			token = baseTok.nextToken();
  
  			// Exact match for the tag, for the attrs it's simpler to control the index
  			if (token.equals(tag))
  				foundTag = true;
  			else if (attrs == null)
  				return false;
  			else if (attrs.indexOf(token) == -1)
  				return false;
  		}
  
  		if (foundTag == false)
  			return false;
  		else
  		{
  			if (Log.getLogger().isDebugEnabled())
  				Log.debug(
  					"Clipper rewriter: match between tag "
  						+ tag
  						+ ", attrs "
  						+ attrs
  						+ ", and searched: "
  						+ base);
  
  			return true;
  		}
  
  	}
  
  }
  
  
  
  1.108     +6 -1      jakarta-jetspeed/webapp/WEB-INF/conf/JetspeedResources.properties
  
  Index: JetspeedResources.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/conf/JetspeedResources.properties,v
  retrieving revision 1.107
  retrieving revision 1.108
  diff -u -r1.107 -r1.108
  --- JetspeedResources.properties	23 Jul 2003 23:53:01 -0000	1.107
  +++ JetspeedResources.properties	5 Sep 2003 16:41:17 -0000	1.108
  @@ -655,3 +655,8 @@
   log4j.configureAndWatch=true
   # Number of ms between each property file check
   log4j.watchInterval=60000
  +
  +#########################################
  +# Transformer Service                   #
  +#########################################
  +services.Transformer.classname = org.apache.jetspeed.services.transformer.JetspeedTransformerService
  
  
  
  1.42      +122 -1    jakarta-jetspeed/webapp/WEB-INF/conf/demo-portlets.xreg
  
  Index: demo-portlets.xreg
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/conf/demo-portlets.xreg,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- demo-portlets.xreg	21 Aug 2003 04:05:45 -0000	1.41
  +++ demo-portlets.xreg	5 Sep 2003 16:41:17 -0000	1.42
  @@ -608,5 +608,126 @@
           <media-type ref="html"/>
           <category>search</category>
       </portlet-entry>
  - 
  +    <portlet-entry name="Nested example" hidden="false" type="ref" parent="WebClippingPortlet" application="false">
  +        <meta-info>
  +            <title>Nested example</title>
  +            <description>Example of nested tags</description>
  +        </meta-info>
  +        <parameter name="startTag1" value="table" hidden="false"/>
  +	<parameter name="stopTag1" value="table" hidden="false"/>
  +        <parameter name="startTagNumber1" value="1" hidden="false"/>
  +        <url>/examples/nested.html</url>
  +        <category>sites</category>
  +    </portlet-entry>
  +    <portlet-entry name="StartTagNumber example" hidden="false" type="ref" parent="WebClippingPortlet" application="false">
  +        <meta-info>
  +            <title>StartTagNumber example</title>
  +            <description>Example of startTagNumber parameter</description>
  +        </meta-info>
  +        <parameter name="startTag1" value="p align" hidden="false"/>
  +	<parameter name="stopTag1" value="p" hidden="false"/>
  +        <parameter name="startTagNumber1" value="2" hidden="false"/>
  +        <url>/examples/startTagNumber.html</url>
  +        <category>sites</category>
  +    </portlet-entry>
  +    <portlet-entry name="JetspeedClipped" hidden="false" type="ref" parent="WebClippingPortlet" application="false">
  +        <meta-info>
  +            <title>Jetspeed Clipped</title>
  +            <description>Jetspeed homepage clipped</description>
  +        </meta-info>
  +        <parameter name="startTag1" value="ul" hidden="false"/>
  +	<parameter name="stopTag1" value="ul" hidden="false"/>
  +        <parameter name="startTag2" value="table cellpadding=2" hidden="false"/>
  +	<parameter name="stopTag2" value="table" hidden="false"/>       
  +        <url>http://jakarta.apache.org/jetspeed/</url>
  +        <category>sites</category>
  +    </portlet-entry>
  +    <portlet-entry name="Java.Sun Clipped" hidden="false" type="ref" parent="WebClippingPortlet" application="false">
  +        <meta-info>
  +            <title>Java.Sun Clipped</title>
  +            <description>Java homepage clipped</description>
  +        </meta-info>
  +	<parameter name="startTag1" value="table" hidden="false"/>
  +	<parameter name="stopTag1" value="table" hidden="false"/>
  +        <parameter name="startTag2" value="center" hidden="false"/>
  +	<parameter name="stopTag2" value="center" hidden="false"/>
  +        <parameter name="startTag3" value="table" hidden="false"/>
  +	<parameter name="stopTag3" value="table" hidden="false"/>
  +        <parameter name="startTagNumber3" value="18" hidden="false"/>
  +        <url>http://java.sun.com/</url>
  +        <category>sites</category>
  +    </portlet-entry>
  +    <portlet-entry name="Mozilla Clipped" hidden="false" type="ref" parent="WebClippingPortlet" application="false">
  +        <meta-info>
  +            <title>Mozilla Clipped</title>
  +            <description>Mozilla homepage clipped</description>
  +        </meta-info>
  +	<parameter name="Tag1" value="img" hidden="false"/>
  +	<parameter name="startTag1" value="td" hidden="false"/>
  +	<parameter name="stopTag1" value="td" hidden="false"/>
  +        <parameter name="startTag2" value="div id=foundationBox" hidden="false"/>
  +	<parameter name="stopTag2" value="div" hidden="false"/>
  +        <parameter name="startTag3" value="td id=mozillaQuoteCell" hidden="false"/>
  +	<parameter name="stopTag3" value="td" hidden="false"/>
  +        <parameter name="startTagNumber3" value="4" hidden="false"/>
  +        <url>http://www.mozilla.org/</url>
  +        <category>sites</category>
  +    </portlet-entry>
  +    <portlet-entry name="Search example" hidden="false" type="ref" parent="WebClippingPortlet" application="false">
  +        <meta-info>
  +            <title>Search example</title>
  +            <description>Searching and showing results from Yahoo</description>
  +        </meta-info>
  +        <parameter name="startTag1" value="ol" hidden="false"/>
  +	<parameter name="stopTag1" value="ol" hidden="false"/>
  +        <url>http://search.yahoo.com/search?p=jetspeed&amp;n=10</url>
  +        <category>sites</category>
  +    </portlet-entry>
  +    <portlet-entry name="Different URLs example" hidden="false" type="ref" parent="WebClippingPortlet" application="false">
  +        <meta-info>
  +            <title>Different URLs example</title>
  +            <description>Example of clipping from different URLs</description>
  +        </meta-info>
  +        <parameter name="startTag1" value="p" hidden="false"/>
  +        <parameter name="stopTag1" value="p" hidden="false"/>
  +        <parameter name="Tag2" value="img" hidden="false"/>
  +        <parameter name="url2" value="http://jakarta.apache.org/" hidden="false"/>
  +        <parameter name="startTag3" value="p" hidden="false"/>
  +        <parameter name="stopTag3" value="p" hidden="false"/>
  +        <parameter name="startTagNumber3" value="2" hidden="false"/>
  +        <parameter name="startTag4" value="table" hidden="false"/>
  +        <parameter name="stopTag4" value="table" hidden="false"/>
  +        <parameter name="startTagNumber4" value="3" hidden="false"/>
  +        <parameter name="url4" value="http://jakarta.apache.org/tomcat/" hidden="false"/>
  +        <url>/examples/local-content.html</url>
  +        <category>sites</category>
  +    </portlet-entry>
  +    <portlet-entry name="Organized content example" hidden="false" type="ref" parent="WebClippingPortlet" application="false">
  +        <meta-info>
  +            <title>Organized content example</title>
  +            <description>Example of organizing clipped contents</description>
  +        </meta-info>
  +        <parameter name="startTag1" value="p" hidden="false"/>
  +        <parameter name="stopTag1" value="p" hidden="false"/>
  +        <parameter name="Tag2" value="table" hidden="false"/>
  +        <parameter name="Tag3" value="tr" hidden="false"/>
  +        <parameter name="Tag4" value="td" hidden="false"/>
  +        <parameter name="Tag5" value="img" hidden="false"/>
  +        <parameter name="url5" value="http://www.altavista.com" hidden="false"/>
  +        <parameter name="Tag6" value="td" hidden="false"/>
  +        <parameter name="startTagNumber6" value="2" hidden="false"/>
  +        <parameter name="Tag7" value="td" hidden="false"/>
  +        <parameter name="startTagNumber7" value="3" hidden="false"/>
  +        <parameter name="startTag8" value="table bgcolor=#93B2DD" hidden="false"/>
  +        <parameter name="stopTag8" value="table" hidden="false"/>
  +        <parameter name="url8" value="http://www.altavista.com" hidden="false"/>
  +        <parameter name="Tag9" value="td" hidden="false"/>
  +        <parameter name="startTagNumber9" value="4" hidden="false"/>
  +        <parameter name="Tag10" value="tr" hidden="false"/>
  +        <parameter name="startTagNumber10" value="2" hidden="false"/>
  +        <parameter name="Tag11" value="table" hidden="false"/>
  +        <parameter name="startTagNumber11" value="2" hidden="false"/>
  +        <url>/examples/organized.html</url>
  +        <category>sites</category>
  +    </portlet-entry>
   </registry>
  
  
  
  1.41      +8 -0      jakarta-jetspeed/webapp/WEB-INF/conf/portlets.xreg
  
  Index: portlets.xreg
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/webapp/WEB-INF/conf/portlets.xreg,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- portlets.xreg	2 Jul 2003 22:34:45 -0000	1.40
  +++ portlets.xreg	5 Sep 2003 16:41:17 -0000	1.41
  @@ -291,4 +291,12 @@
           <classname>org.apache.jetspeed.portal.portlets.GenericMVCPortlet</classname>
       </portlet-entry>
   
  +     <portlet-entry name="WebClippingPortlet" hidden="false" type="abstract" application="false">
  +        <security-ref parent="default"/>
  +        <classname>org.apache.jetspeed.portal.portlets.WebClippingPortlet</classname>
  +        <media-type ref="html"/>
  +        <category>web</category>
  +        <category>proxy</category>
  +    </portlet-entry>
  +
   </registry>
  
  
  
  1.1                  jakarta-jetspeed/webapp/WEB-INF/psml/user/turbine/html/web-clipping.psml
  
  Index: web-clipping.psml
  ===================================================================
  <?xml version="1.0" encoding="iso-8859-1"?>
  <portlets id="P-f77281171a-10003">
      <metainfo>
          <title>Web clipping examples</title>
      </metainfo>
      <skin name="orange-red-Bordered"/>
      <control name="TabControl"/>
      <controller name="TabController"/>
      <portlets id="P-f77281baee-10004">
          <metainfo>
              <title>Nested</title>
          </metainfo>
          <security-ref parent="owner-only"/>
          <layout position="0" size="-1"/>
          <entry id="P-f77281fb84-10005" parent="Nested example">
              <layout position="-1" size="-1">
                  <property name="column" value="0"/>
                  <property name="row" value="0"/>
              </layout>
          </entry>
      </portlets>
      <portlets id="P-f77282e3f6-10006">
          <metainfo>
              <title>StartTagNumber</title>
          </metainfo>
          <security-ref parent="owner-only"/>
          <layout position="1" size="-1"/>
          <entry id="P-f77282f9d4-10007" parent="StartTagNumber example">
              <layout position="-1" size="-1">
                  <property name="column" value="0"/>
                  <property name="row" value="0"/>
              </layout>
          </entry>
      </portlets>
      <portlets id="P-f77283bd62-1000a">
          <metainfo>
              <title>Jetspeed</title>
          </metainfo>
          <security-ref parent="owner-only"/>
          <layout position="2" size="-1"/>
          <entry id="P-f772844efb-1000b" parent="JetspeedClipped">
              <layout position="-1" size="-1">
                  <property name="column" value="0"/>
                  <property name="row" value="0"/>
              </layout>
          </entry>
      </portlets>
      <portlets id="P-f772846ea1-1000c">
          <metainfo>
              <title>Java.Sun</title>
          </metainfo>
          <security-ref parent="owner-only"/>
          <layout position="3" size="-1"/>
          <entry id="P-f772848b9e-1000d" parent="Java.Sun Clipped">
              <layout position="-1" size="-1">
                  <property name="column" value="0"/>
                  <property name="row" value="0"/>
              </layout>
          </entry>
      </portlets>
      <portlets id="P-f77284cebe-1000e">
          <metainfo>
              <title>Mozilla</title>
          </metainfo>
          <security-ref parent="owner-only"/>
          <layout position="4" size="-1"/>
          <entry id="P-f77284e9d0-1000f" parent="Mozilla Clipped">
              <layout position="-1" size="-1">
                  <property name="column" value="0"/>
                  <property name="row" value="0"/>
              </layout>
          </entry>
      </portlets>
      <portlets id="P-f772851ca1-10010">
          <metainfo>
              <title>Search</title>
          </metainfo>
          <security-ref parent="owner-only"/>
          <layout position="5" size="-1"/>
          <entry id="P-f772853911-10011" parent="Search example">
              <layout position="-1" size="-1">
                  <property name="column" value="0"/>
                  <property name="row" value="0"/>
              </layout>
          </entry>
      </portlets>
      <portlets id="P-f772858849-10012">
          <metainfo>
              <title>Different URLs</title>
          </metainfo>
          <security-ref parent="owner-only"/>
          <layout position="6" size="-1"/>
          <entry id="P-f77285a1fc-10013" parent="Different URLs example">
              <layout position="-1" size="-1">
                  <property name="column" value="0"/>
                  <property name="row" value="0"/>
              </layout>
          </entry>
      </portlets>
      <portlets id="P-f77285d346-10014">
          <metainfo>
              <title>Organized Content</title>
          </metainfo>
          <security-ref parent="owner-only"/>
          <layout position="7" size="-1"/>
          <entry id="P-f77285ebeb-10015" parent="Organized content example">
              <layout position="-1" size="-1">
                  <property name="column" value="0"/>
                  <property name="row" value="0"/>
              </layout>
          </entry>
      </portlets>
  </portlets>
  
  
  
  1.1                  jakarta-jetspeed/webapp/examples/local-content.html
  
  Index: local-content.html
  ===================================================================
  <p align="center">
  <big>
  You can insert content from a local HTML file, add images:
  </big>
  </p>
  <p align="center">
  <big>
  or any other component from different URLs:
  </big>
  </p>
  
  
  
  1.1                  jakarta-jetspeed/webapp/examples/nested.html
  
  Index: nested.html
  ===================================================================
  <table>
  <tr>
  <td>aaa</td>
  <td><table>
      <tr>
      <td>bbb</td>
      </tr>
      <tr>
      <td>bbb</td>
      </tr>
      </table>
  </td>
  <td>ccc</td>
  </tr>
  <tr>
  <td>ddd</td>
  <td>eee</td>
  <td>fff</td>
  </tr>
  </table>
  
  
  
  
  1.1                  jakarta-jetspeed/webapp/examples/organized.html
  
  Index: organized.html
  ===================================================================
  <p><big>You can organize clipped elements:</big></p>
  <table border = "3">
  <tr>
  <td></td>
  <td></td>
  </tr>
  </table>
  
  
  
  
  1.1                  jakarta-jetspeed/webapp/examples/startTagNumber.html
  
  Index: startTagNumber.html
  ===================================================================
  <p align="left">
  First paragraph
  </p>
  <p align="left">
  Second paragraph
  </p>
  <p align="left">
  Third paragraph
  </p>
  
  
  
  
  1.5       +4 -1      jakarta-jetspeed/xdocs/catalog.xml
  
  Index: catalog.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed/xdocs/catalog.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- catalog.xml	25 Aug 2003 06:18:42 -0000	1.4
  +++ catalog.xml	5 Sep 2003 16:41:17 -0000	1.5
  @@ -33,8 +33,11 @@
           <li>
             <a href="portlet_config_DBBrowser.html">Database Browser Portlet</a> 
   	</li>
  -        <li>
  +    <li>
             <a href="portlet_config_LogfileViewer.html">Logfile Viewer Portlet</a> 
  +	</li>	
  +    <li>
  +          <a href="portlet_config_WebClippingPortlet.html">Web Clipping Portlet</a> 
   	</li>	
           </ul>
        <a href="portlet_config_common.html">Configuration common to many standard portlets</a>
  
  
  
  1.1                  jakarta-jetspeed/xdocs/portlet_config_WebClippingPortlet.xml
  
  Index: portlet_config_WebClippingPortlet.xml
  ===================================================================
  <?xml version="1.0"?>
  <document> 
    <properties>  
      <title>Portlet Configuration How To</title>
      <subtitle>WebClippingPortlet</subtitle>
      <authors>   
        <person name="Marco Mari" email="mmari@ce.unipr.it"></person>
      </authors>
    </properties>
    <body>
      <section name="">  
        <p>    
          <font face="arial,helvetica,sanserif" size="+3">      
            <center><strong>WebClippingPortlet</strong></center>
          </font>
          <br/>
          <font face="arial,helvetica,sanserif">      
            <center>
              <strong>Class Name : org.apache.jetspeed.portal.portlets.WebClippingPortlet</strong>
            </center>
          </font>
          <br/>
        </p>
      </section>
      <section name="Description">  
        <p>
         Present one ore more clipped parts of one or more web pages in a portlet.
         The clipped part is a section of a web page between a start tag and a stop tag.
         This portlet supports nested tags:<br/>
            &lt;table&gt;
                ...
               &lt;table&gt;
                ...
               &lt;/table&gt;
                ...
            &lt;/table&gt;<br/>
          In this case you can clip the complete table, or only the inner table.  
        </p>
        <p>
         Example of how to find a tag:<br/>
         Find:  &lt;img src="http://www.apache.org/images/asf_logo_wide.png" width="537" 
                     height="51" alt="Apache Software Foundation"/&gt;<br/>
         If it's the first image (or there's only one image) in the page, you can clip it with:<br/>
         Tag...="img"<br/>
         But you can also find the image with:<br/>
         Tag...="img src=http://www.apache.org/images/asf_logo_wide.png width=537 
                     height=51 alt=Apache Software Foundation"<br/>
         Tag...="img src=http://www.apache.org/images/asf_logo_wide.png" <br/>
         Or (simpler!):<br/>
         Tag...="img asf_logo_wide.png" <br/>
         Tag...="img 537 Apache"<br/>
         The match is between the tags (img) and any portion of its attributes (width=537, 537, asf_logo_wide.png, ...)
        </p>
  
        <subsection name="Supported Media Types">    
          <p>
            <a href="portlet_config_common.html&#35;Supported Media Types">Description of Media Types.</a>
            <ul>
              <li>html</li>      
            </ul>
          </p>
        </subsection>
      </section>
  
      <section name="Element: parameter">  
        <p>
          Parameters that control what parts of the web pages are converted into a portlet.
          All these parameters are followed by a number: startTag1, startTag2, ...
        </p>
        <p>
          This element is <strong>required</strong>
        </p>
        <p>    
          <a href="portlet_config_common.html&#35;Element: parameter">Parameters common to many portlets.</a>
        </p>
        <table>
          <tr>
            <th>Parameter Name</th>
            <th>Description</th>
          </tr>     
          <tr>
            <td>startTag...</td>
            <td>First tag to include in the portlet</td>
          </tr>
          <tr>
            <td>stopTag...</td>
            <td>Last tag to include in the portlet</td>
          </tr>
          <tr>
            <td>Tag...</td>
            <td>Single tag to include in the portlet, ie useful to include images. You must indicate or a couple startTag..
                -stopTag.., or only a Tag.. parameter</td>
          </tr>
          <tr>
            <td>startTagNumber...</td>
            <td>If the page contains some identical tags, you can select one of them using startTag (or Tag) and startTagNumber.<br/>
                Example: in the page there are four paragraphs, you can select the second with startTag..="p" and startTagNumber..="2"</td>
          </tr>
          <tr>
            <td>url...</td>
            <td>It's possible to specify a different URL for each element to clip. If it's not specified, the default URL is used. 
                It's also possible to use a local URL, ie:<br/>
                /examples/local-page.html</td>
          </tr>
        </table>
      </section>
  
      <section name="Element: url">  
        <p>
          Contains the default URL of the web page to be displayed. It's possible to use a local URL.
        </p>
        <p>
          This element is <strong>required</strong>
        </p>
        <p>
          <a href="portlet_config_common.html&#35;Element: url">General information about of URL.</a>
        </p>
        <p>
          <strong>Good URLs:</strong>
        </p>
        <dl>
          <dt>
            <tt>&lt;url&gt;http://jakata.apache.org/jetspeed&lt;/url&gt;</tt>
          </dt>
          <dd>Basic URL</dd>
          <dt>
            <tt>&lt;url&gt;/examples/local-page.html&lt;/url&gt;</tt>
          </dt>
          <dd>Local URL</dd>
          <dt>
            <tt>&lt;url&gt;http://search.yahoo.com/bin/search?p=jetspeed&lt;/url&gt;</tt>
          </dt>
          <dd>1 Parameter passed</dd>
          <dt>
            <tt>&lt;url&gt;http://search.yahoo.com/search?p=jetspeed&amp;amp;n=100&lt;/url&gt;</tt>
          </dt>
          <dd>2 Parameter passed</dd>
        </dl>
        <p>
          <strong>Bad URLs:</strong>
        </p>
        <dl>    
          <dt>
            <tt>&lt;url&gt;http://search.yahoo.com/search?p=jetspeed&amp;n=100&lt;/url&gt;</tt>
          </dt>
          <dd>Contains &amp; instead of &amp;amp;.</dd>
        </dl>
      </section>
  
      <section name="Example of Registry Entry">  
        <p>
          The example will show local content, an image from Jakarta, and a clipped part of Tomcat home page
        </p>
        <p>
          From &lt;jetspeed_home&gt;/WEB-INF/conf/WebClipping.xreg
        </p>
        <source test=""><![CDATA[
        <portlet-entry name="Different URLs example" hidden="false" type="ref" parent="WebClippingPortlet" application="false">
          <meta-info>
              <title>Different URLs example</title>
              <description>Example of clipping from different URLs</description>
          </meta-info>
          <parameter name="startTag1" value="p" hidden="false"/>
          <parameter name="stopTag1" value="p" hidden="false"/>
          <parameter name="Tag2" value="img" hidden="false"/>
          <parameter name="url2" value="http://jakarta.apache.org/" hidden="false"/>
          <parameter name="startTag3" value="p" hidden="false"/>
          <parameter name="stopTag3" value="p" hidden="false"/>
          <parameter name="startTagNumber3" value="2" hidden="false"/>
          <parameter name="startTag4" value="table" hidden="false"/>
          <parameter name="stopTag4" value="table" hidden="false"/>
          <parameter name="startTagNumber4" value="3" hidden="false"/>
          <parameter name="url4" value="http://jakarta.apache.org/tomcat/" hidden="false"/>
          <url>/examples/local-content.html</url>
          <category>sites</category>
        </portlet-entry>]]></source>
      </section>
  
      <section name="Known problems (version 1.4b4)">  
        <p>    
          <ul> 
            <li>No known problems, but more testing needed</li>
          </ul>
        </p>
      </section>
  
    </body>
  </document>
  
  
  

Mime
View raw message