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;
18
19 import com.fatwire.gst.foundation.facade.runtag.render.LogDep;
20
21 import static COM.FutureTense.Interfaces.Utilities.goodString;
22
23 import COM.FutureTense.Cache.CacheManager;
24 import COM.FutureTense.Interfaces.ICS;
25 import COM.FutureTense.Util.ftMessage;
26
27 public final class RenderUtils {
28
29 private RenderUtils() {
30 }
31
32 /**
33 * Checks if the pagelet should be cached. Takes into consideration if
34 * current pagelet is rendered for Satellite Server.
35 *
36 * @param ics
37 * @param pname the pagename
38 * @return true if this pagename is cacheable for the current render context (Satellite or ContentServer).
39 */
40 public static boolean isCacheable(final ICS ics, final String pname) {
41 return CacheManager.clientIsSS(ics) ? ics.getPageData(pname).getSSCacheInfo().shouldCache() : ics.getPageData(
42 pname).getCSCacheInfo().shouldCache();
43 }
44
45 /**
46 * Records the compositions dependencies for SiteEntry,CSElement and
47 * Template.
48 *
49 * @param ics
50 */
51 public static void recordBaseCompositionalDependencies(final ICS ics) {
52
53 if (isCacheable(ics, ics.GetVar(ftMessage.PageName))) {
54 if (goodString(ics.GetVar("seid"))) {
55 LogDep.logDep(ics, "SiteEntry", ics.GetVar("seid"));
56 }
57 if (goodString(ics.GetVar("eid"))) {
58 LogDep.logDep(ics, "CSElement", ics.GetVar("eid"));
59 }
60 if (goodString(ics.GetVar("tid"))) {
61 LogDep.logDep(ics, "Template", ics.GetVar("tid"));
62 }
63
64 }
65 }
66
67 }