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.render;
18  
19  import org.apache.commons.lang.StringUtils;
20  
21  import COM.FutureTense.Cache.CacheManager;
22  import COM.FutureTense.Interfaces.ICS;
23  
24  import com.fatwire.assetapi.data.AssetId;
25  import com.fatwire.gst.foundation.facade.runtag.AbstractTagRunner;
26  import com.openmarket.xcelerate.publish.PubConstants;
27  
28  /**
29   * Wraps the <RENDER.LOGDEP> xml tag.
30   * 
31   * @author Tony Field
32   * @since 10-Jun-2008
33   */
34  public final class LogDep extends AbstractTagRunner {
35      public LogDep() {
36          super("RENDER.LOGDEP");
37      }
38  
39      public static enum DependencyType {
40          exact, exists, greater, none
41      }
42  
43      public void setAsset(String s) {
44          set("ASSET", s);
45      }
46  
47      public void setDeptype(DependencyType deptype) {
48          switch (deptype) {
49              case exact:
50                  set("DEPTYPE", "exact");
51                  break;
52              case exists:
53                  set("DEPTYPE", "exists");
54                  break;
55              case greater:
56                  set("DEPTYPE", "greater");
57                  break;
58              case none:
59                  set("DEPTYPE", "none");
60                  break;
61          }
62      }
63  
64      public void setC(String s) {
65          set("c", s);
66      }
67  
68      public void setCid(String s) {
69          set("cid", s);
70      }
71  
72      public static void logDep(ICS ics, String c, String cid) {
73  
74          String rm = StringUtils.defaultString(ics.GetVar(PubConstants.RENDERMODE), PubConstants.LIVE);
75          if (rm.startsWith(PubConstants.DEPS) || rm.startsWith(PubConstants.EXPORT)) {
76              LogDep ld = new LogDep();
77              ld.setC(c);
78              ld.setCid(cid);
79              ld.execute(ics);
80          } else {
81              CacheManager.RecordItem(ics, PubConstants.CACHE_PREFIX + cid + PubConstants.SEPARATOR + c);
82          }
83      }
84  
85      public static void logDep(ICS ics, AssetId id) {
86          if (ics == null)
87              throw new IllegalArgumentException("ics must not be null");
88          if (id == null)
89              throw new IllegalArgumentException("id must not be null");
90          logDep(ics, id.getType(), Long.toString(id.getId()));
91      }
92  }