1 package org.apache.turbine.util.template;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26 import org.apache.turbine.modules.NavigationLoader;
27 import org.apache.turbine.services.template.TurbineTemplate;
28 import org.apache.turbine.util.RunData;
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44 public class TemplateNavigation
45 {
46
47 private static Log log = LogFactory.getLog(TemplateNavigation.class);
48
49
50 private RunData data;
51
52
53 private String template = null;
54
55
56
57
58
59
60 public TemplateNavigation(RunData data)
61 {
62 this.data = data;
63 }
64
65
66
67
68
69
70
71
72 public TemplateNavigation setTemplate(String template)
73 {
74 log.debug("setTemplate(" + template + ")");
75 this.template = template;
76 return this;
77 }
78
79
80
81
82
83
84 @Override
85 public String toString()
86 {
87 String module = null;
88 String returnValue = null;
89
90 try
91 {
92 if (template == null)
93 {
94 returnValue = "Navigation Template is null (Might be unset)";
95 throw new Exception(returnValue);
96 }
97
98 data.getTemplateInfo().setNavigationTemplate(template);
99 module = TurbineTemplate.getNavigationName(template);
100
101 if (module == null)
102 {
103 returnValue = "Template Service returned null for Navigation Template " + template;
104 throw new Exception(returnValue);
105 }
106
107 returnValue = NavigationLoader.getInstance().eval(data, module);
108 }
109 catch (Exception e)
110 {
111 if (returnValue == null)
112 {
113 returnValue = "Error processing navigation template: "
114 + template + ", using module: " + module;
115 }
116 log.error(returnValue, e);
117 }
118
119 return returnValue;
120 }
121 }