mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD (5.2) to 5.2.N (5.2.1)
126543 jkaabimofrad: Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2) 123868 jkaabimofrad: RA-856: Added support for REST APIs “/content” endpoints to optionally set their own cache. (Currently, only the Renditions API is setting its own cache) - Removed the http attachment header setting from the AbstractResourceWebScript, as the ContentStreamer already has this feature - Reformatted ContentStreamer according to Alfresco code standards git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@126888 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -27,14 +27,21 @@ package org.alfresco.rest.framework.resource.content;
|
||||
public class AbstractBinaryResource implements BinaryResource
|
||||
{
|
||||
final String attachFileName;
|
||||
final CacheDirective cacheDirective;
|
||||
|
||||
public AbstractBinaryResource(String attachFileName)
|
||||
public AbstractBinaryResource(String attachFileName, CacheDirective cacheDirective)
|
||||
{
|
||||
this.attachFileName = attachFileName;
|
||||
this.cacheDirective = cacheDirective;
|
||||
}
|
||||
|
||||
public String getAttachFileName()
|
||||
{
|
||||
return attachFileName;
|
||||
}
|
||||
|
||||
public CacheDirective getCacheDirective()
|
||||
{
|
||||
return cacheDirective;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2016 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
* Alfresco is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Alfresco is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.alfresco.rest.framework.resource.content;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* An immutable builder for setting the HTTP cache.
|
||||
*
|
||||
* @author Jamal Kaabi-Mofrad
|
||||
*/
|
||||
public class CacheDirective
|
||||
{
|
||||
private final boolean neverCache;
|
||||
private final boolean isPublic;
|
||||
private final boolean mustRevalidate;
|
||||
private final Date lastModified;
|
||||
private final String eTag;
|
||||
private final Long maxAge;
|
||||
|
||||
private CacheDirective(Builder builder)
|
||||
{
|
||||
this.neverCache = builder.neverCache;
|
||||
this.isPublic = builder.isPublic;
|
||||
this.mustRevalidate = builder.mustRevalidate;
|
||||
this.lastModified = builder.lastModified == null ? null : new Date(builder.lastModified.getTime());
|
||||
this.eTag = builder.eTag;
|
||||
this.maxAge = builder.maxAge;
|
||||
}
|
||||
|
||||
public boolean isNeverCache()
|
||||
{
|
||||
return neverCache;
|
||||
}
|
||||
|
||||
public boolean isPublic()
|
||||
{
|
||||
return isPublic;
|
||||
}
|
||||
|
||||
public boolean isMustRevalidate()
|
||||
{
|
||||
return mustRevalidate;
|
||||
}
|
||||
|
||||
public Date getLastModified()
|
||||
{
|
||||
if (lastModified != null)
|
||||
{
|
||||
return new Date(lastModified.getTime());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getETag()
|
||||
{
|
||||
return eTag;
|
||||
}
|
||||
|
||||
public Long getMaxAge()
|
||||
{
|
||||
return maxAge;
|
||||
}
|
||||
|
||||
public static class Builder
|
||||
{
|
||||
// The default values are the same as the org.springframework.extensions.webscripts.Cache
|
||||
private boolean neverCache = true;
|
||||
private boolean isPublic = false;
|
||||
private boolean mustRevalidate = true;
|
||||
private Date lastModified = null;
|
||||
private String eTag = null;
|
||||
private Long maxAge = null;
|
||||
|
||||
public Builder setNeverCache(boolean neverCache)
|
||||
{
|
||||
this.neverCache = neverCache;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setPublic(boolean aPublic)
|
||||
{
|
||||
isPublic = aPublic;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setMustRevalidate(boolean mustRevalidate)
|
||||
{
|
||||
this.mustRevalidate = mustRevalidate;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setLastModified(Date lastModified)
|
||||
{
|
||||
this.lastModified = lastModified;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setETag(String eTag)
|
||||
{
|
||||
this.eTag = eTag;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setMaxAge(Long maxAge)
|
||||
{
|
||||
this.maxAge = maxAge;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CacheDirective build()
|
||||
{
|
||||
return new CacheDirective(this);
|
||||
}
|
||||
}
|
||||
}
|
@@ -44,7 +44,7 @@ public class FileBinaryResource extends AbstractBinaryResource
|
||||
|
||||
public FileBinaryResource(File file, String attachFileName)
|
||||
{
|
||||
super(attachFileName);
|
||||
super(attachFileName, null);
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
|
@@ -42,7 +42,12 @@ public class NodeBinaryResource extends AbstractBinaryResource
|
||||
|
||||
public NodeBinaryResource(NodeRef nodeRef, QName propertyQName, ContentInfo contentInfo, String attachFileName)
|
||||
{
|
||||
super(attachFileName);
|
||||
this(nodeRef, propertyQName, contentInfo, attachFileName, null);
|
||||
}
|
||||
|
||||
public NodeBinaryResource(NodeRef nodeRef, QName propertyQName, ContentInfo contentInfo, String attachFileName, CacheDirective cacheDirective)
|
||||
{
|
||||
super(attachFileName, cacheDirective);
|
||||
this.nodeRef = nodeRef;
|
||||
this.propertyQName = propertyQName;
|
||||
this.contentInfo = contentInfo;
|
||||
|
Reference in New Issue
Block a user