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 java.io.IOException;
20
21 import javax.servlet.jsp.JspException;
22
23 import COM.FutureTense.Interfaces.ICS;
24
25 import com.fatwire.assetapi.data.AssetId;
26 import com.fatwire.gst.foundation.facade.assetapi.asset.ScatteredAssetAccessTemplate;
27
28 import org.apache.commons.lang.StringUtils;
29
30 public class AssetLoadTag extends GsfSimpleTag {
31
32 private String c;
33 private long cid;
34 private String attributes;
35 private String name;
36
37
38
39
40
41
42 @Override
43 public void doTag() throws JspException, IOException {
44
45 final ICS ics = getICS();
46 final ScatteredAssetAccessTemplate t = new ScatteredAssetAccessTemplate(ics);
47
48
49 if (StringUtils.isBlank(c) || cid == 0) {
50 if (StringUtils.isBlank(attributes)) {
51 getJspContext().setAttribute(name, t.readCurrent());
52 } else {
53 getJspContext().setAttribute(name, t.readCurrent(attributes.split(",")));
54 }
55
56 } else {
57 final AssetId id = t.createAssetId(c, cid);
58 if (StringUtils.isBlank(attributes)) {
59 getJspContext().setAttribute(name, t.read(id));
60 } else {
61 getJspContext().setAttribute(name, t.read(id, attributes.split(",")));
62 }
63
64 }
65
66 super.doTag();
67 }
68
69
70
71
72 public void setC(String c) {
73 this.c = c;
74 }
75
76
77
78
79 public void setCid(final long cid) {
80 this.cid = cid;
81 }
82
83
84
85
86 public void setAttributes(final String attributes) {
87 this.attributes = attributes;
88 }
89
90
91
92
93 public void setName(final String name) {
94 this.name = name;
95 }
96
97 }