KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > roller > ui > authoring > tags > ShowEntrySummaryTag


1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. The ASF licenses this file to You
4 * under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License. For additional information regarding
15 * copyright in this work, please see the NOTICE file in the top level
16 * directory of this distribution.
17 */

18 /* Created on April 14, 2006 */
19 package org.apache.roller.ui.authoring.tags;
20
21 import java.util.HashMap JavaDoc;
22 import javax.servlet.jsp.JspException JavaDoc;
23 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
24 import java.util.Map JavaDoc;
25 import org.apache.commons.lang.StringUtils;
26
27 import org.apache.commons.logging.Log;
28 import org.apache.commons.logging.LogFactory;
29 import org.apache.struts.util.RequestUtils;
30
31 import org.apache.roller.model.Roller;
32 import org.apache.roller.model.PluginManager;
33 import org.apache.roller.model.RollerFactory;
34 import org.apache.roller.pojos.WeblogEntryData;
35 import org.apache.roller.ui.core.RollerContext;
36
37 /**
38  * Shows entry summary with plugins applied.
39  * @jsp.tag name="ShowEntrySummary"
40  */

41 public class ShowEntrySummaryTag extends TagSupport JavaDoc {
42     static final long serialVersionUID = 3166731504235428544L;
43     private static Log mLogger =
44             LogFactory.getFactory().getInstance(ShowEntrySummaryTag.class);
45     
46     private String JavaDoc name = null;
47     private String JavaDoc property = null;
48     private String JavaDoc scope = "request";
49     private boolean singleEntry = false;
50     
51     /**
52      * @see javax.servlet.jsp.tagext.Tag#doStartTag()
53      */

54     public int doStartTag() throws JspException JavaDoc {
55         Roller roller = RollerFactory.getRoller();
56         WeblogEntryData entry = (WeblogEntryData)
57             RequestUtils.lookup(pageContext, name, property, scope);
58         if (StringUtils.isNotEmpty(entry.getSummary())) {
59             String JavaDoc xformed = entry.getSummary();
60             try {
61                 if (entry.getPlugins() != null) {
62                     RollerContext rctx =
63                         RollerContext.getRollerContext();
64                     PluginManager ppmgr = roller.getPagePluginManager();
65                     Map JavaDoc plugins = ppmgr.getWeblogEntryPlugins(
66                         entry.getWebsite());
67                     xformed = ppmgr.applyWeblogEntryPlugins(
68                         plugins, entry, entry.getSummary());
69                 }
70                 pageContext.getOut().println(xformed);
71             } catch (Throwable JavaDoc e) {
72                 throw new JspException JavaDoc("ERROR applying plugin to entry", e);
73             }
74         }
75         return TagSupport.SKIP_BODY;
76     }
77         
78     /**
79      * @return Returns the name.
80      */

81     public String JavaDoc getName() {
82         return name;
83     }
84     
85     /**
86      * @jsp.attribute required="true"
87      */

88     public void setName(String JavaDoc name) {
89         this.name = name;
90     }
91     
92     /**
93      * @return Returns the property.
94      */

95     public String JavaDoc getProperty() {
96         return property;
97     }
98     /**
99      * @jsp.attribute required="false"
100      */

101     public void setProperty(String JavaDoc property) {
102         this.property = property;
103     }
104     
105     /**
106      * @jsp.attribute required="false"
107      */

108     public String JavaDoc getScope() {
109         return scope;
110     }
111     /**
112      * @param scope The scope to set.
113      */

114     public void setScope(String JavaDoc scope) {
115         this.scope = scope;
116     }
117 }
118
Popular Tags