1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.springframework.extensions.webscripts.portlet;
20
21 import java.util.Map;
22
23 import javax.portlet.PortletRequest;
24
25 import org.springframework.extensions.surf.util.Content;
26 import org.springframework.extensions.webscripts.Match;
27 import org.springframework.extensions.webscripts.Runtime;
28 import org.springframework.extensions.webscripts.WebScriptRequestURLImpl;
29
30
31
32
33
34
35
36 public class WebScriptPortletRequest extends WebScriptRequestURLImpl
37 {
38 public static final String ALFPORTLETUSERNAME = "alfportletusername";
39
40
41 private PortletRequest req;
42
43
44
45
46
47
48
49
50
51 public WebScriptPortletRequest(Runtime container, PortletRequest req, String scriptUrl, Match serviceMatch)
52 {
53 this(container, req, splitURL(scriptUrl), serviceMatch);
54 }
55
56
57
58
59
60
61
62
63 public WebScriptPortletRequest(Runtime container, PortletRequest req, String[] scriptUrlParts, Match serviceMatch)
64 {
65 super(container, scriptUrlParts, serviceMatch);
66 this.req = req;
67 if (req != null)
68 {
69
70 Map userInfo = (Map)req.getAttribute(PortletRequest.USER_INFO);
71 if (userInfo != null)
72 {
73
74 String liferayUsername = (String)userInfo.get("user.home-info.online.email");
75 if (liferayUsername != null)
76 {
77
78 if (liferayUsername.indexOf('@') != -1)
79 {
80 liferayUsername = liferayUsername.substring(0, liferayUsername.indexOf('@'));
81 }
82
83 this.req.getPortletSession().setAttribute(ALFPORTLETUSERNAME, liferayUsername);
84 }
85 }
86 }
87 }
88
89
90
91
92
93
94 public PortletRequest getPortletRequest()
95 {
96 return req;
97 }
98
99
100
101
102 public String getServerPath()
103 {
104 return req.getScheme() + "://" + req.getServerName() + ":" + req.getServerPort();
105 }
106
107
108
109
110 public String getAgent()
111 {
112
113 return null;
114 }
115
116
117
118
119 public String[] getHeaderNames()
120 {
121 return new String[] {};
122 }
123
124
125
126
127 public String getHeader(String name)
128 {
129 return null;
130 }
131
132
133
134
135 public String[] getHeaderValues(String name)
136 {
137 return null;
138 }
139
140
141
142
143 public Content getContent()
144 {
145 return null;
146 }
147
148 }