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.kernel.poller;
16  
17  import com.liferay.portal.kernel.util.StringBundler;
18  import com.liferay.portal.kernel.util.Validator;
19  
20  import java.util.Map;
21  
22  /**
23   * <a href="PollerRequest.java.html"><b><i>View Source</i></b></a>
24   *
25   * @author Brian Wing Shun Chan
26   */
27  public class PollerRequest {
28  
29      public PollerRequest(
30          PollerHeader pollerHeader, String portletId,
31          Map<String, String> parameterMap, String chunkId,
32          boolean receiveRequest) {
33  
34          _pollerHeader = pollerHeader;
35          _portletId = portletId;
36          _parameterMap = parameterMap;
37          _chunkId = chunkId;
38          _receiveRequest = receiveRequest;
39      }
40  
41      public boolean equals(Object obj) {
42          if (this == obj) {
43              return true;
44          }
45  
46          if (!(obj instanceof PollerRequest)) {
47              return false;
48          }
49  
50          PollerRequest portletRequest = (PollerRequest)obj;
51  
52          if (Validator.equals(_portletId, portletRequest._portletId)) {
53              return true;
54          }
55  
56          return false;
57      }
58  
59      public long getBrowserKey() {
60          return _pollerHeader.getBrowserKey();
61      }
62  
63      public String getChunkId() {
64          return _chunkId;
65      }
66  
67      public long getCompanyId() {
68          return _pollerHeader.getCompanyId();
69      }
70  
71      public Map<String, String> getParameterMap() {
72          return _parameterMap;
73      }
74  
75      public PollerHeader getPollerHeader() {
76          return _pollerHeader;
77      }
78  
79      public String getPortletId() {
80          return _portletId;
81      }
82  
83      public String[] getPortletIds() {
84          return _pollerHeader.getPortletIds();
85      }
86  
87      public long getTimestamp() {
88          return _pollerHeader.getTimestamp();
89      }
90  
91      public long getUserId() {
92          return _pollerHeader.getUserId();
93      }
94  
95      public int hashCode() {
96          if (_portletId != null) {
97              return _portletId.hashCode();
98          }
99          else {
100             return 0;
101         }
102     }
103 
104     public boolean isInitialRequest() {
105         return _pollerHeader.isInitialRequest();
106     }
107 
108     public boolean isReceiveRequest() {
109         return _receiveRequest;
110     }
111 
112     public boolean isStartPolling() {
113         return _pollerHeader.isStartPolling();
114     }
115 
116     public String toString() {
117         StringBundler sb = new StringBundler(11);
118 
119         sb.append("{chunkId=");
120         sb.append(_chunkId);
121         sb.append(", parameterMap=");
122         sb.append(_parameterMap);
123         sb.append(", pollerHeader=");
124         sb.append(_pollerHeader);
125         sb.append(", portletId=");
126         sb.append(_portletId);
127         sb.append(", receiveRequest=");
128         sb.append(_receiveRequest);
129         sb.append("}");
130 
131         return sb.toString();
132     }
133 
134     private String _chunkId;
135     private Map<String, String> _parameterMap;
136     private PollerHeader _pollerHeader;
137     private String _portletId;
138     private boolean _receiveRequest;
139 
140 }