001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. The ASF licenses this file to You
004: * under the Apache License, Version 2.0 (the "License"); you may not
005: * use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License. For additional information regarding
015: * copyright in this work, please see the NOTICE file in the top level
016: * directory of this distribution.
017: */
018: /* Created on April 14, 2006 */
019: package org.apache.roller.ui.authoring.tags;
020:
021: import java.util.HashMap;
022: import javax.servlet.jsp.JspException;
023: import javax.servlet.jsp.tagext.TagSupport;
024: import java.util.Map;
025: import org.apache.commons.lang.StringUtils;
026:
027: import org.apache.commons.logging.Log;
028: import org.apache.commons.logging.LogFactory;
029: import org.apache.struts.util.RequestUtils;
030:
031: import org.apache.roller.business.Roller;
032: import org.apache.roller.business.PluginManager;
033: import org.apache.roller.business.RollerFactory;
034: import org.apache.roller.pojos.WeblogEntryData;
035: import org.apache.roller.ui.core.RollerContext;
036:
037: /**
038: * Shows entry summary with plugins applied.
039: * @jsp.tag name="ShowEntrySummary"
040: */
041: public class ShowEntrySummaryTag extends TagSupport {
042: static final long serialVersionUID = 3166731504235428544L;
043: private static Log mLogger = LogFactory.getFactory().getInstance(
044: ShowEntrySummaryTag.class);
045:
046: private String name = null;
047: private String property = null;
048: private String scope = "request";
049: private boolean singleEntry = false;
050:
051: /**
052: * @see javax.servlet.jsp.tagext.Tag#doStartTag()
053: */
054: public int doStartTag() throws JspException {
055: Roller roller = RollerFactory.getRoller();
056: WeblogEntryData entry = (WeblogEntryData) RequestUtils.lookup(
057: pageContext, name, property, scope);
058: if (StringUtils.isNotEmpty(entry.getSummary())) {
059: String xformed = entry.getSummary();
060: try {
061: if (entry.getPlugins() != null) {
062: RollerContext rctx = RollerContext
063: .getRollerContext();
064: PluginManager ppmgr = roller.getPagePluginManager();
065: Map plugins = ppmgr.getWeblogEntryPlugins(entry
066: .getWebsite());
067: xformed = ppmgr.applyWeblogEntryPlugins(plugins,
068: entry, entry.getSummary());
069: }
070: pageContext.getOut().println(xformed);
071: } catch (Throwable e) {
072: throw new JspException(
073: "ERROR applying plugin to entry", e);
074: }
075: }
076: return TagSupport.SKIP_BODY;
077: }
078:
079: /**
080: * @return Returns the name.
081: */
082: public String getName() {
083: return name;
084: }
085:
086: /**
087: * @jsp.attribute required="true"
088: */
089: public void setName(String name) {
090: this .name = name;
091: }
092:
093: /**
094: * @return Returns the property.
095: */
096: public String getProperty() {
097: return property;
098: }
099:
100: /**
101: * @jsp.attribute required="false"
102: */
103: public void setProperty(String property) {
104: this .property = property;
105: }
106:
107: /**
108: * @jsp.attribute required="false"
109: */
110: public String getScope() {
111: return scope;
112: }
113:
114: /**
115: * @param scope The scope to set.
116: */
117: public void setScope(String scope) {
118: this.scope = scope;
119: }
120: }
|