View Javadoc

1   /*
2    * Copyright 2010 FatWire Corporation. All Rights Reserved.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not 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.
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  import com.openmarket.xcelerate.asset.AssetIdImpl;
28  
29  import org.apache.commons.lang.StringUtils;
30  
31  /**
32   * @author Dolf Dijkstra
33   * @since Mar, 2011
34   */
35  public class AssetChildrenTag extends GsfSimpleTag {
36  
37      private String attributes;
38      private String list;
39      private String assoc;
40      private String c;
41      private long cid;
42  
43      /*
44       * (non-Javadoc)
45       * 
46       * @see javax.servlet.jsp.tagext.SimpleTagSupport#doTag()
47       */
48      @Override
49      public void doTag() throws JspException, IOException {
50  
51          final ICS ics = getICS();
52          final ScatteredAssetAccessTemplate t = new ScatteredAssetAccessTemplate(ics);
53          final AssetId id = (StringUtils.isBlank(c) || cid == 0) ? t.currentId() : new AssetIdImpl(c, cid);
54  
55          if (StringUtils.isBlank(attributes)) {
56              getJspContext().setAttribute(list, t.readAssociatedAssetIds(id, assoc));
57          } else if ("*".equals(attributes.trim())) {
58              getJspContext().setAttribute(list, t.readAssociatedAssets(id, assoc));
59          } else {
60              getJspContext().setAttribute(list, t.readAssociatedAssets(id, assoc, attributes.split(",")));
61          }
62  
63          super.doTag();
64      }
65  
66      /**
67       * @param attributes the attributes to set
68       */
69      public void setAttributes(final String attributes) {
70          this.attributes = attributes;
71      }
72  
73      /**
74       * @param list the list to set
75       */
76      public void setList(final String list) {
77          this.list = list;
78      }
79  
80      /**
81       * @param assoc the assoc to set
82       */
83      public void setAssoc(final String assoc) {
84          this.assoc = assoc;
85      }
86  
87      /**
88       * @param c the c to set
89       */
90      public void setC(final String c) {
91          this.c = c;
92      }
93  
94      /**
95       * @param cid the cid to set
96       */
97      public void setCid(final long cid) {
98          this.cid = cid;
99      }
100 
101 }