View Javadoc

1   /*
2    * Copyright 2008 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.facade.runtag.asset;
18  
19  import COM.FutureTense.Interfaces.ICS;
20  
21  import com.fatwire.assetapi.data.AssetId;
22  import com.fatwire.gst.foundation.facade.runtag.AbstractTagRunner;
23  import com.openmarket.xcelerate.asset.AssetIdImpl;
24  
25  /**
26   * <ASSET.GETSUBTYPE [NAME="loaded asset]" [TYPE="assettype]"
27   * [OBJECTID="asset id]" [OUTPUT="variable name"] />
28   * 
29   * @author Tony Field
30   * @since Oct 7, 2008
31   */
32  public class GetSubtype extends AbstractTagRunner {
33      public GetSubtype() {
34          super("ASSET.GETSUBTYPE");
35      }
36  
37      public void setAssetId(AssetId id) {
38          setType(id.getType());
39          setObjectid(id.getId());
40      }
41  
42      public void setName(String s) {
43          this.set("NAME", s);
44      }
45  
46      public void setType(String s) {
47          this.set("TYPE", s);
48      }
49  
50      public void setObjectid(long id) {
51          this.set("OBJECTID", Long.toString(id));
52      }
53  
54      public void setOutput(String s) {
55          this.set("OUTPUT", s);
56      }
57  
58      /**
59       * Get the subtype of the specified asset. The asset does not need to be
60       * loaded.
61       * 
62       * @param ics ICS context
63       * @param id the Id of the asset to return the subtype for.
64       * @return subtype on success
65       */
66      public static String getSubtype(ICS ics, AssetId id) {
67          ics.PushVars();
68          GetSubtype gs = new GetSubtype();
69          gs.setAssetId(id);
70          gs.setOutput("st");
71          gs.execute(ics);
72          String ret = ics.GetVar("st");
73          ics.PopVars();
74          return ret;
75      }
76  
77      /**
78       * Get the subtype of the specified asset. The asset does not need to be
79       * loaded.
80       * 
81       * @param ics ICS context
82       * @param c the type of the asset to return the subtype for.
83       * @param cid the id of the asset to return the subtype for.
84       * @return subtype on success
85       */
86      public static String getSubtype(ICS ics, String c, String cid) {
87          return getSubtype(ics, new AssetIdImpl(c, Long.valueOf(cid)));
88      }
89  
90      /**
91       * Get the subtype for the specified loaded asset.
92       * 
93       * @param ics ICS context
94       * @param loadedAssetName object pool handle for the asset
95       * @return the subtype on success
96       */
97      public static String getSubtype(ICS ics, String loadedAssetName) {
98          ics.PushVars();
99          GetSubtype gs = new GetSubtype();
100         gs.setName(loadedAssetName);
101         gs.setOutput("st");
102         gs.execute(ics);
103         String ret = ics.GetVar("st");
104         ics.PopVars();
105         return ret;
106     }
107 }