001    /**
002     * Copyright (c) 2000-present 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            public BaseCometRequest(HttpServletRequest request) {
028                    _request = request;
029    
030                    setRequest(request);
031            }
032    
033            @Override
034            public long getCompanyId() {
035                    return _companyId;
036            }
037    
038            @Override
039            public String getPathInfo() {
040                    return _pathInfo;
041            }
042    
043            @Override
044            public HttpServletRequest getRequest() {
045                    return _request;
046            }
047    
048            @Override
049            public long getTimestamp() {
050                    return _timestamp;
051            }
052    
053            @Override
054            public long getUserId() {
055                    return _userId;
056            }
057    
058            @Override
059            public void setCompanyId(long companyId) {
060                    _companyId = companyId;
061            }
062    
063            @Override
064            public void setPathInfo(String pathInfo) {
065                    _pathInfo = pathInfo;
066            }
067    
068            public void setRequest(HttpServletRequest request) {
069                    setCompanyId(PortalUtil.getCompanyId(request));
070                    setPathInfo(request.getPathInfo());
071                    setUserId(PortalUtil.getUserId(request));
072            }
073    
074            @Override
075            public void setTimestamp(long timestamp) {
076                    _timestamp = timestamp;
077            }
078    
079            @Override
080            public void setUserId(long userId) {
081                    _userId = userId;
082            }
083    
084            private long _companyId;
085            private String _pathInfo;
086            private final HttpServletRequest _request;
087            private long _timestamp = System.currentTimeMillis();
088            private long _userId;
089    
090    }