use of org.alfresco.rest.framework.resource.content.ContentInfo in project alfresco-remote-api by Alfresco.
the class AbstractResourceWebScript method streamResponse.
protected void streamResponse(final WebScriptRequest req, final WebScriptResponse res, BinaryResource resource) throws IOException {
if (resource instanceof FileBinaryResource) {
FileBinaryResource fileResource = (FileBinaryResource) resource;
// if requested, set attachment
boolean attach = StringUtils.isNotEmpty(fileResource.getAttachFileName());
Map<String, Object> model = getModelForCacheDirective(fileResource.getCacheDirective());
streamer.streamContent(req, res, fileResource.getFile(), null, attach, fileResource.getAttachFileName(), model);
} else if (resource instanceof NodeBinaryResource) {
NodeBinaryResource nodeResource = (NodeBinaryResource) resource;
ContentInfo contentInfo = nodeResource.getContentInfo();
setContentInfoOnResponse(res, contentInfo);
// if requested, set attachment
boolean attach = StringUtils.isNotEmpty(nodeResource.getAttachFileName());
Map<String, Object> model = getModelForCacheDirective(nodeResource.getCacheDirective());
streamer.streamContent(req, res, nodeResource.getNodeRef(), nodeResource.getPropertyQName(), attach, nodeResource.getAttachFileName(), model);
}
}
use of org.alfresco.rest.framework.resource.content.ContentInfo in project alfresco-remote-api by Alfresco.
the class WithResponseTest method testSetters.
@Test
public void testSetters() throws Exception {
WithResponse callBack = new WithResponse(Status.STATUS_OK, ResponseWriter.DEFAULT_JSON_CONTENT, ResponseWriter.CACHE_NEVER);
callBack.setStatus(Status.STATUS_GONE);
Cache myCache = new Cache(new Description.RequiredCache() {
@Override
public boolean getNeverCache() {
return false;
}
@Override
public boolean getIsPublic() {
return true;
}
@Override
public boolean getMustRevalidate() {
return true;
}
});
callBack.setCache(myCache);
ContentInfo myContent = new ContentInfoImpl(Format.HTML.mimetype(), "UTF-16", 12, Locale.FRENCH);
callBack.setContentInfo(myContent);
assertEquals(Status.STATUS_GONE, callBack.getStatus());
assertEquals(myCache, callBack.getCache());
assertEquals(myContent, callBack.getContentInfo());
}
Aggregations