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:
Ancuta Morarasu
2016-05-11 12:06:18 +00:00
parent 7925bca309
commit ae11fef3de
9 changed files with 378 additions and 189 deletions

View File

@@ -37,6 +37,7 @@ import org.alfresco.rest.framework.core.exceptions.DisabledServiceException;
import org.alfresco.rest.framework.core.exceptions.InvalidArgumentException;
import org.alfresco.rest.framework.core.exceptions.NotFoundException;
import org.alfresco.rest.framework.resource.content.BinaryResource;
import org.alfresco.rest.framework.resource.content.CacheDirective;
import org.alfresco.rest.framework.resource.content.ContentInfoImpl;
import org.alfresco.rest.framework.resource.content.FileBinaryResource;
import org.alfresco.rest.framework.resource.content.NodeBinaryResource;
@@ -70,6 +71,7 @@ import java.io.File;
import java.io.InputStream;
import java.io.Serializable;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -348,14 +350,23 @@ public class RenditionsImpl implements Renditions, ResourceLoaderAware
Map<QName, Serializable> nodeProps = nodeService.getProperties(renditionNodeRef);
ContentData contentData = (ContentData) nodeProps.get(ContentModel.PROP_CONTENT);
Date modified = (Date) nodeProps.get(ContentModel.PROP_MODIFIED);
org.alfresco.rest.framework.resource.content.ContentInfo contentInfo = null;
if (contentData != null)
{
contentInfo = new ContentInfoImpl(contentData.getMimetype(), contentData.getEncoding(), contentData.getSize(), contentData.getLocale());
}
// add cache settings
CacheDirective cacheDirective = new CacheDirective.Builder()
.setNeverCache(false)
.setMustRevalidate(false)
.setLastModified(modified)
.setETag(modified != null ? Long.toString(modified.getTime()) : null)
.setMaxAge(Long.valueOf(31536000))// one year (in seconds)
.build();
return new NodeBinaryResource(renditionNodeRef, ContentModel.PROP_CONTENT, contentInfo, attachFileName);
return new NodeBinaryResource(renditionNodeRef, ContentModel.PROP_CONTENT, contentInfo, attachFileName, cacheDirective);
}
protected NodeRef getRenditionByName(NodeRef nodeRef, String renditionId, Parameters parameters)