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