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