1packageorg.apache.jetspeed.services.jsp.tags;
23/*4 * Copyright 2000-2004 The Apache Software Foundation.5 * 6 * Licensed under the Apache License, Version 2.0 (the "License");7 * you may not use this file except in compliance with the License.8 * You may obtain a copy of the License at9 * 10 * http://www.apache.org/licenses/LICENSE-2.011 * 12 * Unless required by applicable law or agreed to in writing, software13 * distributed under the License is distributed on an "AS IS" BASIS,14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15 * See the License for the specific language governing permissions and16 * limitations under the License.17 */1819import javax.servlet.jsp.JspException;
20import javax.servlet.jsp.PageContext;
21import javax.servlet.jsp.tagext.TagSupport;
2223// Turbine Classes 24import org.apache.turbine.util.ContentURI;
25import org.apache.turbine.util.RunData;
26import org.apache.turbine.services.jsp.JspService;
2728// Jetspeed classes29import org.apache.jetspeed.services.logging.JetspeedLogFactoryService;
30import org.apache.jetspeed.services.logging.JetspeedLogger;
3132/***33 * Supporting class for the contentURI tag.34 * Returns the URL for the given webapp relative URI35 *36 * @author <a href="mailto:raphael@apache.org">Raphaël Luta</a>37 * @version $Id: ContentURITag.java,v 1.7 2004/02/23 03:59:40 jford Exp $38 */39publicclassContentURITagextends TagSupport
40 {
41/***42 * Static initialization of the logger for this class43 */44privatestaticfinalJetspeedLogger logger = JetspeedLogFactoryService.getLogger(ContentURITag.class.getName());
4546/***47 * type parameter defines type of URI that is requested48 */49private String href;
5051/*** 52 * The setter for type parameter53 */54publicvoid setHref(String href)
55 {
56this.href = href;
57 }
5859publicint doStartTag() throws JspException
60 {
61 RunData data = (RunData)pageContext.getAttribute(JspService.RUNDATA, PageContext.REQUEST_SCOPE);
6263 String result = new ContentURI(data).getURI(this.href);
6465try66 {
67if (result != null) {
68 pageContext.getOut().print(result);
69 }
70 }
71catch (Exception e)
72 {
73 String message = "Error processing contentUri-tag, parameter: "+ href;
74 logger.error(message, e);
75try76 {
77 data.getOut().print( message );
78 }
79catch(java.io.IOException ioe) {}
80 }
8182return EVAL_BODY_INCLUDE;
83 }
8485 }