portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wea...@apache.org
Subject cvs commit: jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/velocity RemoteContentTool.java
Date Sun, 01 Aug 2004 15:49:46 GMT
weaver      2004/08/01 08:49:46

  Added:       portal/src/java/org/apache/jetspeed/velocity
                        RemoteContentTool.java
  Log:
  SImple tool for obtaining content from a URL.
  
  Revision  Changes    Path
  1.1                  jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/velocity/RemoteContentTool.java
  
  Index: RemoteContentTool.java
  ===================================================================
  /*
   * Created on Jul 28, 2004
   *
   * TODO To change the template for this generated file go to
   * Window - Preferences - Java - Code Generation - Code and Comments
   */
  package org.apache.jetspeed.velocity;
  
  import org.apache.commons.httpclient.HttpClient;
  import org.apache.commons.httpclient.methods.GetMethod;
  import org.apache.velocity.tools.view.tools.ViewTool;
  
  /**
   * <p>
   * ContentTool
   * </p>
   * <p>
   *
   * </p>
   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
   * @version $Id: RemoteContentTool.java,v 1.1 2004/08/01 15:49:46 weaver Exp $
   *
   */
  public class RemoteContentTool implements ViewTool
  {
  
      /**
       * <p>
       * init
       * </p>
       *
       * @see org.apache.velocity.tools.view.tools.ViewTool#init(java.lang.Object)
       * @param arg0
       */
      public void init( Object arg0 )
      {
          
          
      }
      
      public String include(String remoteContentUrl)
      {
          GetMethod remoteContentGet = null;
          
          try
          {
              HttpClient client = new HttpClient();
              remoteContentGet = new GetMethod(remoteContentUrl);
              client.executeMethod(remoteContentGet);
              return remoteContentGet.getResponseBodyAsString();
          }
          catch (Exception e)
          {
              return e.toString()+" message:"+ e.getMessage();
          }
          finally
          {
              if(remoteContentGet != null)
              {
                  remoteContentGet.releaseConnection();
              }
          }
      }
  
   
  
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org


Mime
View raw message