1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.fatwire.gst.foundation.taglib;
18
19 import javax.servlet.jsp.JspException;
20 import javax.servlet.jsp.PageContext;
21 import javax.servlet.jsp.tagext.BodyTagSupport;
22 import javax.servlet.jsp.tagext.Tag;
23
24 import COM.FutureTense.Interfaces.ICS;
25
26 import com.fatwire.gst.foundation.facade.assetapi.asset.ScatteredAssetAccessTemplate;
27 import com.fatwire.gst.foundation.facade.runtag.render.LogDep;
28
29 import org.apache.commons.logging.Log;
30 import org.apache.commons.logging.LogFactory;
31
32 public class GsfRootTag extends BodyTagSupport {
33 public static final String ICS_VARIABLE_NAME = "ics";
34 public static final String VARIABLE_SCOPE_NAME = "cs";
35 public static final String ASSET_DAO = "assetDao";
36
37
38
39 private static final long serialVersionUID = -5369419132504852400L;
40
41 private static final Log LOG = LogFactory.getLog(GsfRootTag.class.getPackage().getName());
42
43
44
45
46
47
48 @Override
49 public int doStartTag() throws JspException {
50 super.doStartTag();
51
52 final ICS ics = getICS();
53
54 if (ics != null) {
55 pageContext.setAttribute(VARIABLE_SCOPE_NAME, new ICSAsMap(ics), PageContext.PAGE_SCOPE);
56 final ScatteredAssetAccessTemplate assetTemplate = new ScatteredAssetAccessTemplate(ics);
57 pageContext.setAttribute(ASSET_DAO, assetTemplate, PageContext.PAGE_SCOPE);
58 if (ics.GetVar("tid") != null) {
59 LogDep.logDep(ics, "Template", ics.GetVar("tid"));
60 }
61 if (ics.GetVar("seid") != null) {
62 LogDep.logDep(ics, "SiteEntry", ics.GetVar("seid"));
63 }
64 if (ics.GetVar("eid") != null) {
65 LogDep.logDep(ics, "CSElement", ics.GetVar("eid"));
66 }
67 } else {
68 throw new JspException("ics is not found on the page context. This tags needs to be nested in the <cs:ftcs> tag.");
69 }
70 return EVAL_BODY_INCLUDE;
71 }
72
73 protected ICS getICS() {
74 final Object o = pageContext.getAttribute(ICS_VARIABLE_NAME, PageContext.PAGE_SCOPE);
75 if (o instanceof ICS) {
76 return (ICS) o;
77 }
78 return null;
79 }
80
81
82
83
84
85
86 @Override
87 public int doEndTag() throws JspException {
88 pageContext.removeAttribute(VARIABLE_SCOPE_NAME, PageContext.PAGE_SCOPE);
89 pageContext.removeAttribute(ASSET_DAO, PageContext.PAGE_SCOPE);
90 return Tag.EVAL_PAGE;
91 }
92
93 }