001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.kernel.poller.comet;
016    
017    import com.liferay.portal.util.PortalUtil;
018    
019    import javax.servlet.http.HttpServletRequest;
020    
021    /**
022     * @author Edward Han
023     * @author Brian Wing Shun Chan
024     */
025    public abstract class BaseCometRequest implements CometRequest {
026    
027            @Override
028            public long getCompanyId() {
029                    return _companyId;
030            }
031    
032            @Override
033            public String getPathInfo() {
034                    return _pathInfo;
035            }
036    
037            @Override
038            public HttpServletRequest getRequest() {
039                    return _request;
040            }
041    
042            @Override
043            public long getTimestamp() {
044                    return _timestamp;
045            }
046    
047            @Override
048            public long getUserId() {
049                    return _userId;
050            }
051    
052            @Override
053            public void setCompanyId(long companyId) {
054                    _companyId = companyId;
055            }
056    
057            @Override
058            public void setPathInfo(String pathInfo) {
059                    _pathInfo = pathInfo;
060            }
061    
062            public void setRequest(HttpServletRequest request) {
063                    setCompanyId(PortalUtil.getCompanyId(request));
064                    setPathInfo(request.getPathInfo());
065                    setUserId(PortalUtil.getUserId(request));
066            }
067    
068            @Override
069            public void setTimestamp(long timestamp) {
070                    _timestamp = timestamp;
071            }
072    
073            @Override
074            public void setUserId(long userId) {
075                    _userId = userId;
076            }
077    
078            private long _companyId;
079            private String _pathInfo;
080            private HttpServletRequest _request;
081            private long _timestamp = System.currentTimeMillis();
082            private long _userId;
083    
084    }