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)
126382 jkaabimofrad: Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2) 120441 jvonka: RA-727: REST fwk - fix GET node binary resource (setting of content info response headers) - including encoding (Content-Type charset) & locale (Content-Language) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@126728 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1161,8 +1161,14 @@ public class NodesImpl implements Nodes
|
|||||||
throw new InvalidArgumentException("NodeId of content is expected: "+nodeRef);
|
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
|
// TODO attachment header - update (or extend ?) REST fwk
|
||||||
return new NodeBinaryResource(nodeRef, ContentModel.PROP_CONTENT);
|
return new NodeBinaryResource(nodeRef, ContentModel.PROP_CONTENT, ci);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@@ -38,12 +38,14 @@ public class NodeBinaryResource implements BinaryResource
|
|||||||
|
|
||||||
final NodeRef nodeRef;
|
final NodeRef nodeRef;
|
||||||
final QName propertyQName;
|
final QName propertyQName;
|
||||||
|
final ContentInfo contentInfo;
|
||||||
|
|
||||||
public NodeBinaryResource(NodeRef nodeRef, QName propertyQName)
|
public NodeBinaryResource(NodeRef nodeRef, QName propertyQName, ContentInfo contentInfo)
|
||||||
{
|
{
|
||||||
super();
|
super();
|
||||||
this.nodeRef = nodeRef;
|
this.nodeRef = nodeRef;
|
||||||
this.propertyQName = propertyQName;
|
this.propertyQName = propertyQName;
|
||||||
|
this.contentInfo = contentInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public NodeRef getNodeRef()
|
public NodeRef getNodeRef()
|
||||||
@@ -55,4 +57,8 @@ public class NodeBinaryResource implements BinaryResource
|
|||||||
{
|
{
|
||||||
return this.propertyQName;
|
return this.propertyQName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ContentInfo getContentInfo() {
|
||||||
|
return this.contentInfo;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,28 +1,28 @@
|
|||||||
/*
|
/*
|
||||||
* #%L
|
* #%L
|
||||||
* Alfresco Remote API
|
* Alfresco Remote API
|
||||||
* %%
|
* %%
|
||||||
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
* Copyright (C) 2005 - 2016 Alfresco Software Limited
|
||||||
* %%
|
* %%
|
||||||
* This file is part of the Alfresco software.
|
* This file is part of the Alfresco software.
|
||||||
* If the software was purchased under a paid Alfresco license, the terms of
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
* the paid license agreement will prevail. Otherwise, the software is
|
* the paid license agreement will prevail. Otherwise, the software is
|
||||||
* provided under the following open source license terms:
|
* provided under the following open source license terms:
|
||||||
*
|
*
|
||||||
* Alfresco is free software: you can redistribute it and/or modify
|
* 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
|
* 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
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* Alfresco is distributed in the hope that it will be useful,
|
* Alfresco is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU Lesser General Public License for more details.
|
* GNU Lesser General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||||
* #L%
|
* #L%
|
||||||
*/
|
*/
|
||||||
package org.alfresco.rest.framework.webscripts;
|
package org.alfresco.rest.framework.webscripts;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -53,6 +53,7 @@ import org.springframework.extensions.webscripts.Description.RequiredCache;
|
|||||||
import org.springframework.extensions.webscripts.Format;
|
import org.springframework.extensions.webscripts.Format;
|
||||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||||
import org.springframework.extensions.webscripts.WebScriptResponse;
|
import org.springframework.extensions.webscripts.WebScriptResponse;
|
||||||
|
import org.springframework.extensions.webscripts.WrappingWebScriptResponse;
|
||||||
import org.springframework.extensions.webscripts.servlet.WebScriptServletResponse;
|
import org.springframework.extensions.webscripts.servlet.WebScriptServletResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -244,15 +245,22 @@ public abstract class ApiWebScript extends AbstractWebScript
|
|||||||
//Set content info on the response
|
//Set content info on the response
|
||||||
res.setContentType(contentInfo.getMimeType());
|
res.setContentType(contentInfo.getMimeType());
|
||||||
res.setContentEncoding(contentInfo.getEncoding());
|
res.setContentEncoding(contentInfo.getEncoding());
|
||||||
|
|
||||||
|
if (res instanceof WrappingWebScriptResponse)
|
||||||
|
{
|
||||||
|
WrappingWebScriptResponse wrappedRes = ((WrappingWebScriptResponse) res);
|
||||||
|
res = wrappedRes.getNext();
|
||||||
|
}
|
||||||
|
|
||||||
if (res instanceof WebScriptServletResponse)
|
if (res instanceof WebScriptServletResponse)
|
||||||
{
|
{
|
||||||
WebScriptServletResponse servletResponse = (WebScriptServletResponse) res;
|
WebScriptServletResponse servletResponse = (WebScriptServletResponse) res;
|
||||||
if (contentInfo.getLength() > 0)
|
if (contentInfo.getLength() > 0)
|
||||||
{
|
{
|
||||||
if (contentInfo.getLength()>0 && contentInfo.getLength() < Integer.MAX_VALUE)
|
if (contentInfo.getLength() > 0 && contentInfo.getLength() < Integer.MAX_VALUE)
|
||||||
{
|
{
|
||||||
servletResponse.getHttpServletResponse().setContentLength((int)contentInfo.getLength());
|
servletResponse.getHttpServletResponse().setContentLength((int) contentInfo.getLength());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (contentInfo.getLocale() != null)
|
if (contentInfo.getLocale() != null)
|
||||||
{
|
{
|
||||||
@@ -260,7 +268,6 @@ public abstract class ApiWebScript extends AbstractWebScript
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setResolver(ExceptionResolver<Exception> resolver)
|
public void setResolver(ExceptionResolver<Exception> resolver)
|
||||||
|
@@ -38,6 +38,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.EntityResourceAction.ReadById;
|
||||||
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
import org.alfresco.rest.framework.resource.actions.interfaces.RelationshipResourceAction;
|
||||||
import org.alfresco.rest.framework.resource.content.BinaryResource;
|
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.CollectionWithPagingInfo;
|
||||||
import org.alfresco.rest.framework.resource.parameters.Params;
|
import org.alfresco.rest.framework.resource.parameters.Params;
|
||||||
import org.alfresco.rest.framework.resource.parameters.Params.RecognizedParams;
|
import org.alfresco.rest.framework.resource.parameters.Params.RecognizedParams;
|
||||||
@@ -220,7 +222,11 @@ public class ResourceWebScriptGet extends AbstractResourceWebScript implements P
|
|||||||
Object result = executeInternal(resource, params);
|
Object result = executeInternal(resource, params);
|
||||||
if (result instanceof BinaryResource)
|
if (result instanceof BinaryResource)
|
||||||
{
|
{
|
||||||
executionCallback.onSuccess(result, null);
|
ContentInfo ci = null;
|
||||||
|
if (result instanceof NodeBinaryResource) {
|
||||||
|
ci = ((NodeBinaryResource)result).getContentInfo();
|
||||||
|
}
|
||||||
|
executionCallback.onSuccess(result, ci);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user