mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V2.1-A to HEAD
7983: NodeRef + child path relative URLs support for WebScript download content API git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8839 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -26,6 +26,7 @@ package org.alfresco.repo.web.scripts.bean;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.SocketException;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -45,6 +46,7 @@ import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.util.URLEncoder;
|
||||
import org.alfresco.web.scripts.AbstractWebScript;
|
||||
import org.alfresco.web.scripts.Cache;
|
||||
import org.alfresco.web.scripts.WebScriptException;
|
||||
@@ -68,6 +70,8 @@ public class ContentGet extends AbstractWebScript
|
||||
// Logger
|
||||
private static final Log logger = LogFactory.getLog(ContentGet.class);
|
||||
|
||||
private static final String NODE_URL = "/api/node/content/{0}/{1}/{2}/{3}";
|
||||
|
||||
// Component dependencies
|
||||
private Repository repository;
|
||||
private NamespaceService namespaceService;
|
||||
@@ -258,4 +262,22 @@ public class ContentGet extends AbstractWebScript
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to generate a URL to a content node for downloading content from the server.
|
||||
* The content is supplied directly in the reponse. This generally means a browser will
|
||||
* attempt to open the content directly if possible, else it will prompt to save the file.
|
||||
*
|
||||
* @param ref NodeRef of the content node to generate URL for (cannot be null)
|
||||
* @param name File name end element to return on the url (used by the browser on Save)
|
||||
*
|
||||
* @return URL to download the content from the specified node
|
||||
*/
|
||||
public final static String generateNodeURL(NodeRef ref, String name)
|
||||
{
|
||||
return MessageFormat.format(NODE_URL, new Object[] {
|
||||
ref.getStoreRef().getProtocol(),
|
||||
ref.getStoreRef().getIdentifier(),
|
||||
ref.getId(),
|
||||
URLEncoder.encode(name) } );
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user