001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.kernel.poller;
016    
017    import com.liferay.portal.kernel.util.StringBundler;
018    import com.liferay.portal.kernel.util.Validator;
019    
020    import java.util.Map;
021    
022    /**
023     * @author Brian Wing Shun Chan
024     */
025    public class PollerRequest {
026    
027            public PollerRequest(
028                    PollerHeader pollerHeader, String portletId,
029                    Map<String, String> parameterMap, String chunkId,
030                    boolean receiveRequest) {
031    
032                    _pollerHeader = pollerHeader;
033                    _portletId = portletId;
034                    _parameterMap = parameterMap;
035                    _chunkId = chunkId;
036                    _receiveRequest = receiveRequest;
037            }
038    
039            public boolean equals(Object obj) {
040                    if (this == obj) {
041                            return true;
042                    }
043    
044                    if (!(obj instanceof PollerRequest)) {
045                            return false;
046                    }
047    
048                    PollerRequest portletRequest = (PollerRequest)obj;
049    
050                    if (Validator.equals(_portletId, portletRequest._portletId)) {
051                            return true;
052                    }
053    
054                    return false;
055            }
056    
057            public long getBrowserKey() {
058                    return _pollerHeader.getBrowserKey();
059            }
060    
061            public String getChunkId() {
062                    return _chunkId;
063            }
064    
065            public long getCompanyId() {
066                    return _pollerHeader.getCompanyId();
067            }
068    
069            public Map<String, String> getParameterMap() {
070                    return _parameterMap;
071            }
072    
073            public PollerHeader getPollerHeader() {
074                    return _pollerHeader;
075            }
076    
077            public String getPortletId() {
078                    return _portletId;
079            }
080    
081            public String[] getPortletIds() {
082                    return _pollerHeader.getPortletIds();
083            }
084    
085            public long getTimestamp() {
086                    return _pollerHeader.getTimestamp();
087            }
088    
089            public long getUserId() {
090                    return _pollerHeader.getUserId();
091            }
092    
093            public int hashCode() {
094                    if (_portletId != null) {
095                            return _portletId.hashCode();
096                    }
097                    else {
098                            return 0;
099                    }
100            }
101    
102            public boolean isInitialRequest() {
103                    return _pollerHeader.isInitialRequest();
104            }
105    
106            public boolean isReceiveRequest() {
107                    return _receiveRequest;
108            }
109    
110            public boolean isStartPolling() {
111                    return _pollerHeader.isStartPolling();
112            }
113    
114            public String toString() {
115                    StringBundler sb = new StringBundler(11);
116    
117                    sb.append("{chunkId=");
118                    sb.append(_chunkId);
119                    sb.append(", parameterMap=");
120                    sb.append(_parameterMap);
121                    sb.append(", pollerHeader=");
122                    sb.append(_pollerHeader);
123                    sb.append(", portletId=");
124                    sb.append(_portletId);
125                    sb.append(", receiveRequest=");
126                    sb.append(_receiveRequest);
127                    sb.append("}");
128    
129                    return sb.toString();
130            }
131    
132            private String _chunkId;
133            private Map<String, String> _parameterMap;
134            private PollerHeader _pollerHeader;
135            private String _portletId;
136            private boolean _receiveRequest;
137    
138    }