1/*2* Licensed to the Apache Software Foundation (ASF) under one or more3* contributor license agreements. See the NOTICE file distributed with4* this work for additional information regarding copyright ownership.5* The ASF licenses this file to You under the Apache License, Version 2.06* (the "License"); you may not use this file except in compliance with7* the License. You may obtain a copy of the License at8*9* http://www.apache.org/licenses/LICENSE-2.010*11* Unless required by applicable law or agreed to in writing, software12* distributed under the License is distributed on an "AS IS" BASIS,13* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.14* See the License for the specific language governing permissions and15* limitations under the License.16*/17/*18 * Created on Jul 28, 200419 *20 * TODO To change the template for this generated file go to21 * Window - Preferences - Java - Code Generation - Code and Comments22 */23packageorg.apache.jetspeed.velocity;
2425import org.apache.commons.httpclient.HttpClient;
26import org.apache.commons.httpclient.methods.GetMethod;
27import org.apache.velocity.tools.view.tools.ViewTool;
2829/***30 * <p>31 * ContentTool32 * </p>33 * <p>34 *35 * </p>36 * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>37 * @version $Id: RemoteContentTool.java 516881 2007-03-11 10:34:21Z ate $38 *39 */40publicclassRemoteContentTool implements ViewTool
41 {
4243/***44 * <p>45 * init46 * </p>47 *48 * @see org.apache.velocity.tools.view.tools.ViewTool#init(java.lang.Object)49 * @param arg050 */51publicvoid init( Object arg0 )
52 {
535455 }
5657public String include(String remoteContentUrl)
58 {
59 GetMethod remoteContentGet = null;
6061try62 {
63 HttpClient client = new HttpClient();
64 remoteContentGet = new GetMethod(remoteContentUrl);
65 client.executeMethod(remoteContentGet);
66return remoteContentGet.getResponseBodyAsString();
67 }
68catch (Exception e)
69 {
70return e.toString()+" message:"+ e.getMessage();
71 }
72finally73 {
74if(remoteContentGet != null)
75 {
76 remoteContentGet.releaseConnection();
77 }
78 }
79 }
80818283 }