1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
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 }