001    /**
002     * Copyright (c) 2000-2010 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.portlet;
016    
017    import javax.portlet.CacheControl;
018    import javax.portlet.MimeResponse;
019    
020    /**
021     * @author Brian Wing Shun Chan
022     * @author Deepak Gothe
023     */
024    public class CacheControlImpl implements CacheControl {
025    
026            public CacheControlImpl(
027                    String eTag, int expirationTime, boolean publicScope,
028                    boolean useCachedContent, MimeResponseImpl mimeResponseImpl) {
029    
030                    _eTag = eTag;
031                    _expirationTime = expirationTime;
032                    _publicScope = publicScope;
033                    _useCachedContent = useCachedContent;
034                    _mimeResponseImpl = mimeResponseImpl;
035            }
036    
037            public String getETag() {
038                    return _eTag;
039            }
040    
041            public boolean isPublicScope() {
042                    return _publicScope;
043            }
044    
045            public int getExpirationTime() {
046                    return _expirationTime;
047            }
048    
049            public void setETag(String eTag) {
050                    _eTag = eTag;
051    
052                    _mimeResponseImpl.setProperty(MimeResponse.ETAG, eTag);
053            }
054    
055            public void setExpirationTime(int expirationTime) {
056                    _expirationTime = expirationTime;
057    
058                    _mimeResponseImpl.setProperty(
059                            MimeResponse.EXPIRATION_CACHE, String.valueOf(expirationTime));
060            }
061    
062            public void setPublicScope(boolean publicScope) {
063                    _publicScope = publicScope;
064    
065                    _mimeResponseImpl.setProperty(
066                            MimeResponse.PUBLIC_SCOPE, String.valueOf(publicScope));
067            }
068    
069            public void setUseCachedContent(boolean useCachedContent) {
070                    _useCachedContent = useCachedContent;
071    
072                    _mimeResponseImpl.setProperty(
073                            MimeResponse.USE_CACHED_CONTENT, String.valueOf(useCachedContent));
074            }
075    
076            public boolean useCachedContent() {
077                    return _useCachedContent;
078            }
079    
080            private String _eTag;
081            private int _expirationTime;
082            private MimeResponseImpl _mimeResponseImpl;
083            private boolean _publicScope;
084            private boolean _useCachedContent;
085    
086    }