diff --git a/source/java/org/alfresco/rest/api/impl/NodesImpl.java b/source/java/org/alfresco/rest/api/impl/NodesImpl.java
index 0433ee80e8..37e7ef4611 100644
--- a/source/java/org/alfresco/rest/api/impl/NodesImpl.java
+++ b/source/java/org/alfresco/rest/api/impl/NodesImpl.java
@@ -1154,8 +1154,14 @@ public class NodesImpl implements Nodes
throw new InvalidArgumentException("NodeId of content is expected: "+nodeRef);
}
+ ContentData cd = (ContentData)nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT);
+ org.alfresco.rest.framework.resource.content.ContentInfo ci = null;
+ if (cd != null) {
+ ci = new org.alfresco.rest.framework.resource.content.ContentInfoImpl(cd.getMimetype(), cd.getEncoding(), cd.getSize(), cd.getLocale());
+ }
+
// TODO attachment header - update (or extend ?) REST fwk
- return new NodeBinaryResource(nodeRef, ContentModel.PROP_CONTENT);
+ return new NodeBinaryResource(nodeRef, ContentModel.PROP_CONTENT, ci);
}
@Override
diff --git a/source/java/org/alfresco/rest/framework/resource/content/NodeBinaryResource.java b/source/java/org/alfresco/rest/framework/resource/content/NodeBinaryResource.java
index 8e955fe771..15730e8aef 100755
--- a/source/java/org/alfresco/rest/framework/resource/content/NodeBinaryResource.java
+++ b/source/java/org/alfresco/rest/framework/resource/content/NodeBinaryResource.java
@@ -1,3 +1,21 @@
+/*
+ * Copyright (C) 2005-2015 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 .
+ */
package org.alfresco.rest.framework.resource.content;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -13,12 +31,14 @@ public class NodeBinaryResource implements BinaryResource
final NodeRef nodeRef;
final QName propertyQName;
+ final ContentInfo contentInfo;
- public NodeBinaryResource(NodeRef nodeRef, QName propertyQName)
+ public NodeBinaryResource(NodeRef nodeRef, QName propertyQName, ContentInfo contentInfo)
{
super();
this.nodeRef = nodeRef;
this.propertyQName = propertyQName;
+ this.contentInfo = contentInfo;
}
public NodeRef getNodeRef()
@@ -30,4 +50,8 @@ public class NodeBinaryResource implements BinaryResource
{
return this.propertyQName;
}
+
+ public ContentInfo getContentInfo() {
+ return this.contentInfo;
+ }
}
diff --git a/source/java/org/alfresco/rest/framework/webscripts/ApiWebScript.java b/source/java/org/alfresco/rest/framework/webscripts/ApiWebScript.java
index 4dd8bbbd88..4770402305 100644
--- a/source/java/org/alfresco/rest/framework/webscripts/ApiWebScript.java
+++ b/source/java/org/alfresco/rest/framework/webscripts/ApiWebScript.java
@@ -1,3 +1,21 @@
+/*
+ * Copyright (C) 2005-2015 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 .
+ */
package org.alfresco.rest.framework.webscripts;
import java.io.File;
@@ -28,6 +46,7 @@ import org.springframework.extensions.webscripts.Description.RequiredCache;
import org.springframework.extensions.webscripts.Format;
import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.extensions.webscripts.WebScriptResponse;
+import org.springframework.extensions.webscripts.WrappingWebScriptResponse;
import org.springframework.extensions.webscripts.servlet.WebScriptServletResponse;
/**
@@ -219,15 +238,22 @@ public abstract class ApiWebScript extends AbstractWebScript
//Set content info on the response
res.setContentType(contentInfo.getMimeType());
res.setContentEncoding(contentInfo.getEncoding());
+
+ if (res instanceof WrappingWebScriptResponse)
+ {
+ WrappingWebScriptResponse wrappedRes = ((WrappingWebScriptResponse) res);
+ res = wrappedRes.getNext();
+ }
+
if (res instanceof WebScriptServletResponse)
{
WebScriptServletResponse servletResponse = (WebScriptServletResponse) res;
if (contentInfo.getLength() > 0)
{
- if (contentInfo.getLength()>0 && contentInfo.getLength() < Integer.MAX_VALUE)
- {
- servletResponse.getHttpServletResponse().setContentLength((int)contentInfo.getLength());
- }
+ if (contentInfo.getLength() > 0 && contentInfo.getLength() < Integer.MAX_VALUE)
+ {
+ servletResponse.getHttpServletResponse().setContentLength((int) contentInfo.getLength());
+ }
}
if (contentInfo.getLocale() != null)
{
@@ -235,7 +261,6 @@ public abstract class ApiWebScript extends AbstractWebScript
}
}
}
-
}
public void setResolver(ExceptionResolver resolver)
diff --git a/source/java/org/alfresco/rest/framework/webscripts/ResourceWebScriptGet.java b/source/java/org/alfresco/rest/framework/webscripts/ResourceWebScriptGet.java
index a97e38039b..5024b86e18 100644
--- a/source/java/org/alfresco/rest/framework/webscripts/ResourceWebScriptGet.java
+++ b/source/java/org/alfresco/rest/framework/webscripts/ResourceWebScriptGet.java
@@ -13,6 +13,8 @@ import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAct
import org.alfresco.rest.framework.resource.actions.interfaces.EntityResourceAction.ReadById;
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
import org.alfresco.rest.framework.resource.content.BinaryResource;
+import org.alfresco.rest.framework.resource.content.ContentInfo;
+import org.alfresco.rest.framework.resource.content.NodeBinaryResource;
import org.alfresco.rest.framework.resource.parameters.CollectionWithPagingInfo;
import org.alfresco.rest.framework.resource.parameters.Params;
import org.alfresco.rest.framework.resource.parameters.Params.RecognizedParams;
@@ -195,7 +197,11 @@ public class ResourceWebScriptGet extends AbstractResourceWebScript implements P
Object result = executeInternal(resource, params);
if (result instanceof BinaryResource)
{
- executionCallback.onSuccess(result, null);
+ ContentInfo ci = null;
+ if (result instanceof NodeBinaryResource) {
+ ci = ((NodeBinaryResource)result).getContentInfo();
+ }
+ executionCallback.onSuccess(result, ci);
}
else
{