1 |
| |
2 |
| |
3 |
| |
4 |
| |
5 |
| |
6 |
| |
7 |
| |
8 |
| |
9 |
| |
10 |
| |
11 |
| |
12 |
| |
13 |
| |
14 |
| |
15 |
| package org.apache.tapestry.portlet; |
16 |
| |
17 |
| import java.net.MalformedURLException; |
18 |
| import java.net.URL; |
19 |
| import java.util.List; |
20 |
| |
21 |
| import javax.portlet.PortletContext; |
22 |
| |
23 |
| import org.apache.commons.logging.Log; |
24 |
| import org.apache.commons.logging.LogFactory; |
25 |
| import org.apache.hivemind.util.Defense; |
26 |
| import org.apache.tapestry.describe.DescriptionReceiver; |
27 |
| import org.apache.tapestry.web.WebContext; |
28 |
| import org.apache.tapestry.web.WebUtils; |
29 |
| |
30 |
| |
31 |
| |
32 |
| |
33 |
| |
34 |
| |
35 |
| |
36 |
| public class PortletWebContext implements WebContext |
37 |
| { |
38 |
| private static final Log LOG = LogFactory.getLog(PortletWebContext.class); |
39 |
| |
40 |
| private final PortletContext _portletContext; |
41 |
| |
42 |
10
| public PortletWebContext(PortletContext portletContext)
|
43 |
| { |
44 |
10
| Defense.notNull(portletContext, "portletContext");
|
45 |
| |
46 |
10
| _portletContext = portletContext;
|
47 |
| } |
48 |
| |
49 |
8
| public URL getResource(String path)
|
50 |
| { |
51 |
8
| try
|
52 |
| { |
53 |
8
| return _portletContext.getResource(path);
|
54 |
| } |
55 |
| catch (MalformedURLException ex) |
56 |
| { |
57 |
1
| LOG.error(PortletMessages.errorGettingResource(path, ex), ex);
|
58 |
| |
59 |
1
| return null;
|
60 |
| } |
61 |
| } |
62 |
| |
63 |
1
| public List getAttributeNames()
|
64 |
| { |
65 |
1
| return WebUtils.toSortedList(_portletContext.getAttributeNames());
|
66 |
| } |
67 |
| |
68 |
1
| public Object getAttribute(String name)
|
69 |
| { |
70 |
1
| return _portletContext.getAttribute(name);
|
71 |
| } |
72 |
| |
73 |
2
| public void setAttribute(String name, Object attribute)
|
74 |
| { |
75 |
2
| if (attribute == null)
|
76 |
1
| _portletContext.removeAttribute(name);
|
77 |
| else |
78 |
1
| _portletContext.setAttribute(name, attribute);
|
79 |
| } |
80 |
| |
81 |
1
| public List getInitParameterNames()
|
82 |
| { |
83 |
1
| return WebUtils.toSortedList(_portletContext.getInitParameterNames());
|
84 |
| } |
85 |
| |
86 |
1
| public String getInitParameterValue(String name)
|
87 |
| { |
88 |
1
| return _portletContext.getInitParameter(name);
|
89 |
| } |
90 |
| |
91 |
0
| public String getMimeType(String resourcePath)
|
92 |
| { |
93 |
0
| return _portletContext.getMimeType(resourcePath);
|
94 |
| } |
95 |
| |
96 |
0
| public void describeTo(DescriptionReceiver receiver)
|
97 |
| { |
98 |
0
| receiver.describeAlternate(_portletContext);
|
99 |
| } |
100 |
| } |