1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.springframework.extensions.surf.support;
20
21 import javax.servlet.ServletRequest;
22
23 import org.apache.commons.logging.Log;
24 import org.apache.commons.logging.LogFactory;
25 import org.springframework.extensions.surf.PageMapper;
26 import org.springframework.extensions.surf.RequestContext;
27 import org.springframework.extensions.surf.WebFrameworkServiceRegistry;
28 import org.springframework.extensions.surf.exception.PageMapperException;
29 import org.springframework.extensions.surf.types.Page;
30
31
32
33
34
35
36
37
38 public abstract class AbstractPageMapper extends BaseFactoryBean implements PageMapper
39 {
40 public static Log logger = LogFactory.getLog(AbstractPageMapper.class);
41
42 public AbstractPageMapper(WebFrameworkServiceRegistry serviceRegistry)
43 {
44 super(serviceRegistry);
45 }
46
47
48
49
50 public void execute(RequestContext context, ServletRequest request)
51 throws PageMapperException
52 {
53 executeMapper(context, request);
54
55
56 postExecute(context, request);
57 }
58
59
60
61
62
63
64
65
66
67 public abstract void executeMapper(RequestContext context,
68 ServletRequest request) throws PageMapperException;
69
70
71
72
73
74
75
76
77
78 public void postExecute(RequestContext context, ServletRequest request)
79 throws PageMapperException
80 {
81 if (context.getSiteConfiguration() == null)
82 {
83 if (logger.isDebugEnabled())
84 debug(context, "No site configuration - performing reset");
85
86 context.setPage(null);
87 context.setCurrentObject(null);
88 }
89
90
91
92 if (context.getPage() == null && context.getCurrentObjectId() == null)
93 {
94
95 if (context.getSiteConfiguration() != null)
96 {
97
98 Page rootPage = context.getRootPage();
99 if (rootPage != null)
100 {
101 if (logger.isDebugEnabled())
102 debug(context, "Set root page as current page");
103
104 context.setPage(rootPage);
105 }
106 }
107 }
108 }
109
110
111
112
113 protected void debug(RequestContext context, String value)
114 {
115 logger.debug("PageMapper [" + context.getId() + "] " + value);
116 }
117 }