1   /**
2    * Copyright (c) 2000-2009 Liferay, Inc. All rights reserved.
3    *
4    *
5    *
6    *
7    * The contents of this file are subject to the terms of the Liferay Enterprise
8    * Subscription License ("License"). You may not use this file except in
9    * compliance with the License. You can obtain a copy of the License by
10   * contacting Liferay, Inc. See the License for the specific language governing
11   * permissions and limitations under the License, including but not limited to
12   * distribution rights of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portal.sharepoint;
24  
25  import com.liferay.portal.kernel.util.GetterUtil;
26  import com.liferay.portal.kernel.util.StringPool;
27  import com.liferay.portal.model.User;
28  
29  import java.util.HashMap;
30  import java.util.Map;
31  
32  import javax.servlet.http.HttpServletRequest;
33  import javax.servlet.http.HttpServletResponse;
34  
35  /**
36   * <a href="SharepointRequest.java.html"><b><i>View Source</i></b></a>
37   *
38   * @author Bruno Farache
39   */
40  public class SharepointRequest {
41  
42      public SharepointRequest(String rootPath) {
43          _rootPath = rootPath;
44      }
45  
46      public SharepointRequest(
47          HttpServletRequest request, HttpServletResponse response, User user) {
48  
49          _request = request;
50          _response = response;
51          _user = user;
52  
53          _params.putAll(request.getParameterMap());
54      }
55  
56      public void addParam(String key, String value) {
57          _params.put(key, new String[] {value});
58      }
59  
60      public byte[] getBytes() {
61          return _bytes;
62      }
63  
64      public long getCompanyId() {
65          return _user.getCompanyId();
66      }
67  
68      public HttpServletRequest getHttpServletRequest() {
69          return _request;
70      }
71  
72      public HttpServletResponse getHttpServletResponse() {
73          return _response;
74      }
75  
76      public String getParameterValue(String name) {
77          String[] values = _params.get(name);
78  
79          if ((values != null) && (values.length > 0)) {
80              return GetterUtil.getString(_params.get(name)[0]);
81          }
82          else {
83              return StringPool.BLANK;
84          }
85      }
86  
87      public String getRootPath() {
88          return _rootPath;
89      }
90  
91      public SharepointStorage getSharepointStorage() {
92          return _storage;
93      }
94  
95      public User getUser() {
96          return _user;
97      }
98  
99      public long getUserId() {
100         return _user.getUserId();
101     }
102 
103     public void setBytes(byte[] bytes) {
104         _bytes = bytes;
105     }
106 
107     public void setRootPath(String rootPath) {
108         _rootPath = SharepointUtil.replaceBackSlashes(rootPath);
109     }
110 
111     public void setSharepointStorage(SharepointStorage storage) {
112         _storage = storage;
113     }
114 
115     private SharepointStorage _storage;
116     private HttpServletRequest _request;
117     private HttpServletResponse _response;
118     private String _rootPath = StringPool.BLANK;
119     private User _user;
120     private byte[] _bytes;
121     private Map<String, String[]> _params = new HashMap<String, String[]>();
122 
123 }