1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portlet;
16  
17  import javax.portlet.CacheControl;
18  import javax.portlet.MimeResponse;
19  
20  /**
21   * <a href="CacheControlImpl.java.html"><b><i>View Source</i></b></a>
22   *
23   * @author Brian Wing Shun Chan
24   * @author Deepak Gothe
25   */
26  public class CacheControlImpl implements CacheControl {
27  
28      public CacheControlImpl(
29          String eTag, int expirationTime, boolean publicScope,
30          boolean useCachedContent, MimeResponseImpl mimeResponseImpl) {
31  
32          _eTag = eTag;
33          _expirationTime = expirationTime;
34          _publicScope = publicScope;
35          _useCachedContent = useCachedContent;
36          _mimeResponseImpl = mimeResponseImpl;
37      }
38  
39      public String getETag() {
40          return _eTag;
41      }
42  
43      public boolean isPublicScope() {
44          return _publicScope;
45      }
46  
47      public int getExpirationTime() {
48          return _expirationTime;
49      }
50  
51      public void setETag(String eTag) {
52          _eTag = eTag;
53  
54          _mimeResponseImpl.setProperty(MimeResponse.ETAG, eTag);
55      }
56  
57      public void setExpirationTime(int expirationTime) {
58          _expirationTime = expirationTime;
59  
60          _mimeResponseImpl.setProperty(
61              MimeResponse.EXPIRATION_CACHE, String.valueOf(expirationTime));
62      }
63  
64      public void setPublicScope(boolean publicScope) {
65          _publicScope = publicScope;
66  
67          _mimeResponseImpl.setProperty(
68              MimeResponse.PUBLIC_SCOPE, String.valueOf(publicScope));
69      }
70  
71      public void setUseCachedContent(boolean useCachedContent) {
72          _useCachedContent = useCachedContent;
73  
74          _mimeResponseImpl.setProperty(
75              MimeResponse.USE_CACHED_CONTENT, String.valueOf(useCachedContent));
76      }
77  
78      public boolean useCachedContent() {
79          return _useCachedContent;
80      }
81  
82      private String _eTag;
83      private int _expirationTime;
84      private MimeResponseImpl _mimeResponseImpl;
85      private boolean _publicScope;
86      private boolean _useCachedContent;
87  
88  }