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  package com.fatwire.gst.foundation.taglib;
17  
18  import java.io.IOException;
19  import javax.servlet.jsp.JspException;
20  
21  import COM.FutureTense.Interfaces.ICS;
22  
23  import com.fatwire.gst.foundation.properties.AssetApiPropertyDao;
24  import com.fatwire.gst.foundation.properties.Property;
25  import com.fatwire.gst.foundation.properties.PropertyDao;
26  
27  import org.apache.commons.logging.Log;
28  import org.apache.commons.logging.LogFactory;
29  
30  /**
31   * extract the asset id from the asset property value
32   * 
33   * @author Tony Field
34   * @since 11-09-02
35   */
36  public final class GetPropertyAssetIdTag extends GsfSimpleTag {
37      private static final Log LOG = LogFactory.getLog("com.fatwire.gst.foundation.properties");
38      private String name;
39      private String property;
40  
41      /*
42       * (non-Javadoc)
43       * 
44       * @see javax.servlet.jsp.tagext.SimpleTagSupport#doTag()
45       */
46      @Override
47      public void doTag() throws JspException, IOException {
48          final ICS ics = getICS();
49          PropertyDao propertyDao = AssetApiPropertyDao.getInstance(ics);
50          Property p = propertyDao.getProperty(property);
51          if (p != null) {
52              getJspContext().setAttribute(name, p.asAssetId());
53          } else {
54              LOG.info("Cannot find property: " + property + "'.");
55          }
56          super.doTag();
57      }
58  
59      /**
60       * @param name the name to set
61       */
62      public void setName(final String name) {
63          this.name = name;
64      }
65  
66      /**
67       * @param property the property to set
68       */
69      public void setProperty(final String property) {
70          this.property = property;
71      }
72  }