mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)
75556: Merged EOL to HEAD-BUG-FIX (5.0/Cloud) 74583: ACE-2010 EOL Legacey CMIS Inputs (2) in 5.0 << Broken >> - With Kevin - try and bring back ContentGet/ContentInfo so need ReferenceFactory 75109: ACE-2010 - EOL Legacey CMIS Inputs (2) in 5.0. Restored ContentGet and ContentInfo functionality without CMIS related infection. 75110: ACE-2010 - EOL Legacey CMIS Inputs (2) in 5.0. Move content scripts out of cmis folder so it can be safely removed. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@77490 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,51 +0,0 @@
|
||||
<webscript kind="org.alfresco.cmiskind">
|
||||
<shortname>Delete Content (deleteContent)</shortname>
|
||||
<description>
|
||||
<![CDATA[
|
||||
Deletes the content stream for the specified Document object.
|
||||
]]>
|
||||
</description>
|
||||
|
||||
<!-- by object id -->
|
||||
<url>/cmis/i/{id}/content{property}</url>
|
||||
<url>/cmis/s/{store}/i/{id}/content{property}</url>
|
||||
<!-- by path -->
|
||||
<url>/cmis/p{path}/content{property}</url>
|
||||
<url>/cmis/s/{store}/p{path}/content{property}</url>
|
||||
|
||||
<url>/api/node/content{property}/{store_type}/{store_id}/{id}</url>
|
||||
<url>/api/path/content{property}/{store_type}/{store_id}/{nodepath}</url>
|
||||
<url>/api/avmpath/content{property}/{store_id}/{id}</url>
|
||||
<url>/api/node/{store_type}/{store_id}/{id}/content{property}</url>
|
||||
<url>/api/path/{store_type}/{store_id}/{nodepath}/content{property}</url>
|
||||
|
||||
<args>
|
||||
<arg>
|
||||
<shortname>store</shortname>
|
||||
<description>the store name</description>
|
||||
</arg>
|
||||
<arg>
|
||||
<shortname>id</shortname>
|
||||
<description>the node id of the object</description>
|
||||
</arg>
|
||||
<arg>
|
||||
<shortname>path</shortname>
|
||||
<description>the path of the object (relative to CMIS root, typically "Company Home")</description>
|
||||
</arg>
|
||||
<arg>
|
||||
<shortname>nodepath</shortname>
|
||||
<description>the path of the object (relative to root of Alfresco store)</description>
|
||||
</arg>
|
||||
<arg>
|
||||
<shortname>property</shortname>
|
||||
<description>the name of the content property to retrieve content from</description>
|
||||
<default>cm:content</default>
|
||||
</arg>
|
||||
</args>
|
||||
|
||||
<format default="atomentry">argument</format>
|
||||
|
||||
<authentication>guest</authentication>
|
||||
<family>CMIS</family>
|
||||
<lifecycle>deprecated</lifecycle>
|
||||
</webscript>
|
@@ -1,56 +0,0 @@
|
||||
<webscript>
|
||||
<shortname>Write Content (setContent)</shortname>
|
||||
<description>
|
||||
<![CDATA[
|
||||
Sets the content stream for the specified Document object.
|
||||
]]>
|
||||
</description>
|
||||
|
||||
<!-- by object id -->
|
||||
<url>/cmis/i/{id}/content{property}?overwriteFlag={overwriteFlag?}</url>
|
||||
<url>/cmis/s/{store}/i/{id}/content{property}?overwriteFlag={overwriteFlag?}</url>
|
||||
<!-- by path -->
|
||||
<url>/cmis/p{path}/content{property}?overwriteFlag={overwriteFlag?}</url>
|
||||
<url>/cmis/s/{store}/p{path}/content{property}?overwriteFlag={overwriteFlag?}</url>
|
||||
<!-- alfresco style -->
|
||||
<url>/api/node/content{property}/{store_type}/{store_id}/{id}?overwriteFlag={overwriteFlag?}</url>
|
||||
<url>/api/path/content{property}/{store_type}/{store_id}/{nodepath}?overwriteFlag={overwriteFlag?}</url>
|
||||
<url>/api/avmpath/content{property}/{store_id}/{id}?overwriteFlag={overwriteFlag?}</url>
|
||||
<url>/api/node/{store_type}/{store_id}/{id}/content{property}?overwriteFlag={overwriteFlag?}</url>
|
||||
<url>/api/path/{store_type}/{store_id}/{nodepath}/content{property}?overwriteFlag={overwriteFlag?}</url>
|
||||
|
||||
<args>
|
||||
<arg>
|
||||
<shortname>store</shortname>
|
||||
<description>the store name</description>
|
||||
</arg>
|
||||
<arg>
|
||||
<shortname>id</shortname>
|
||||
<description>the node id of the object</description>
|
||||
</arg>
|
||||
<arg>
|
||||
<shortname>path</shortname>
|
||||
<description>the path of the object (relative to CMIS root, typically "Company Home")</description>
|
||||
</arg>
|
||||
<arg>
|
||||
<shortname>nodepath</shortname>
|
||||
<description>the path of the object (relative to root of Alfresco store)</description>
|
||||
</arg>
|
||||
<arg>
|
||||
<shortname>property</shortname>
|
||||
<description>the name of the content property to retrieve content from</description>
|
||||
<default>cm:content</default>
|
||||
</arg>
|
||||
<arg>
|
||||
<shortname>overwriteFlag</shortname>
|
||||
<description>if true, force download of content as attachment</description>
|
||||
<default>true</default>
|
||||
</arg>
|
||||
</args>
|
||||
|
||||
<format default="text">argument</format>
|
||||
|
||||
<authentication>guest</authentication>
|
||||
<family>CMIS</family>
|
||||
<lifecycle>deprecated</lifecycle>
|
||||
</webscript>
|
@@ -2,23 +2,14 @@
|
||||
<shortname>Get Content (getContent)</shortname>
|
||||
<description>
|
||||
<![CDATA[
|
||||
Gets the content stream for the specified document, or gets a rendition stream for a specified rendition of a document.
|
||||
Gets the content stream for the specified document.
|
||||
]]>
|
||||
</description>
|
||||
|
||||
<!-- by object id -->
|
||||
<url>/cmis/i/{id}/content{property}?a={attach?}&streamId={streamId?}</url>
|
||||
<url>/cmis/s/{store}/i/{id}/content{property}?a={attach?}&streamId={streamId?}</url>
|
||||
<!-- by path -->
|
||||
<url>/cmis/p{path}/content{property}?a={attach?}&streamId={streamId?}</url>
|
||||
<url>/cmis/s/{store}/p{path}/content{property}?a={attach?}&streamId={streamId?}</url>
|
||||
|
||||
<!-- alfresco style -->
|
||||
<url>/api/node/content{property}/{store_type}/{store_id}/{id}?a={attach?}&streamId={streamId?}</url>
|
||||
<url>/api/path/content{property}/{store_type}/{store_id}/{nodepath}?a={attach?}&streamId={streamId?}</url>
|
||||
<url>/api/avmpath/content{property}/{store_id}/{avmpath}?a={attach?}&streamId={streamId?}</url>
|
||||
<url>/api/node/{store_type}/{store_id}/{id}/content{property}?a={attach?}&streamId={streamId?}</url>
|
||||
<url>/api/path/{store_type}/{store_id}/{nodepath}/content{property}?a={attach?}&streamId={streamId?}</url>
|
||||
<url>/api/node/content{property}/{store_type}/{store_id}/{id}?a={attach?}</url>
|
||||
<url>/api/path/content{property}/{store_type}/{store_id}/{nodepath}?a={attach?}</url>
|
||||
<url>/api/node/{store_type}/{store_id}/{id}/content{property}?a={attach?}</url>
|
||||
<url>/api/path/{store_type}/{store_id}/{nodepath}/content{property}?a={attach?}</url>
|
||||
|
||||
<args>
|
||||
<arg>
|
||||
@@ -29,10 +20,6 @@
|
||||
<shortname>id</shortname>
|
||||
<description>the node id of the object</description>
|
||||
</arg>
|
||||
<arg>
|
||||
<shortname>path</shortname>
|
||||
<description>the path of the object (relative to CMIS root, typically "Company Home")</description>
|
||||
</arg>
|
||||
<arg>
|
||||
<shortname>nodepath</shortname>
|
||||
<description>the path of the object (relative to root of Alfresco store)</description>
|
||||
@@ -47,16 +34,11 @@
|
||||
<description>if true, force download of content as attachment</description>
|
||||
<default>false</default>
|
||||
</arg>
|
||||
<arg>
|
||||
<shortname>streamId</shortname>
|
||||
<description>if provided, download the rendition of the content as identified by the stream id</description>
|
||||
</arg>
|
||||
</args>
|
||||
|
||||
<format default="">argument</format>
|
||||
|
||||
<authentication>guest</authentication>
|
||||
<transaction allow="readonly"/>
|
||||
<family>CMIS</family>
|
||||
<lifecycle>deprecated</lifecycle>
|
||||
<lifecycle>internal</lifecycle>
|
||||
</webscript>
|
@@ -1,10 +1,10 @@
|
||||
<webscript>
|
||||
<shortname>Head Content</shortname>
|
||||
<description> Head method for the specified document.</description>
|
||||
<description>HEAD method for the specified document.</description>
|
||||
|
||||
<!-- alfresco style -->
|
||||
<!-- maybe need to add many paths, like in content.get.desc.xml -->
|
||||
<url>/api/node/content{property}/{store_type}/{store_id}/{id}?a={attach?}&streamId={streamId?}</url>
|
||||
<url>/api/node/content{property}/{store_type}/{store_id}/{id}?a={attach?}</url>
|
||||
|
||||
<args>
|
||||
<arg>
|
||||
@@ -21,13 +21,10 @@
|
||||
<description>if true, force download of content as attachment</description>
|
||||
<default>false</default>
|
||||
</arg>
|
||||
<arg>
|
||||
<shortname>streamId</shortname>
|
||||
<description>if provided, download the rendition of the content as identified by the stream id</description>
|
||||
</arg>
|
||||
</args>
|
||||
|
||||
<format default="">argument</format>
|
||||
<authentication>guest</authentication>
|
||||
<transaction allow="readonly"/>
|
||||
<lifecycle>internal</lifecycle>
|
||||
</webscript>
|
@@ -282,6 +282,27 @@
|
||||
<!-- CMIS Test Runner Web Script -->
|
||||
<bean id="webscript.org.alfresco.cmis.test.post" class="org.alfresco.repo.cmis.rest.test.CMISTestRunnerWebScript" parent="webscript" />
|
||||
|
||||
<!-- Content Retrieval -->
|
||||
<bean id="webscript.org.alfresco.content.content.get" class="org.alfresco.repo.web.scripts.content.ContentGet" parent="webscript">
|
||||
<property name="namespaceService" ref="NamespaceService" />
|
||||
<property name="permissionService" ref="PermissionService" />
|
||||
<property name="nodeService" ref="NodeService" />
|
||||
<property name="dictionaryService" ref="DictionaryService" />
|
||||
<property name="mimetypeService" ref="MimetypeService" />
|
||||
<property name="delegate" ref="webscript.content.streamer" />
|
||||
<property name="contentService" ref="contentService" />
|
||||
<property name="repository" ref="repositoryHelper" />
|
||||
</bean>
|
||||
|
||||
<!-- Content Info -->
|
||||
<bean id="webscript.org.alfresco.content.content.head" class="org.alfresco.repo.web.scripts.content.ContentInfo" parent="webscript">
|
||||
<property name="permissionService" ref="PermissionService" />
|
||||
<property name="nodeService" ref="NodeService" />
|
||||
<property name="mimetypeService" ref="MimetypeService" />
|
||||
<property name="delegate" ref="webscript.content.streamer" />
|
||||
<property name="repository" ref="repositoryHelper" />
|
||||
</bean>
|
||||
|
||||
<!-- -->
|
||||
<!-- CMIS Client -->
|
||||
<!-- -->
|
||||
|
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2012 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.content;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
import org.springframework.extensions.webscripts.WebScriptResponse;
|
||||
import org.springframework.web.context.ServletContextAware;
|
||||
|
||||
|
||||
/**
|
||||
* Content Retrieval Service
|
||||
*
|
||||
* Stream content from the Repository.
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public class ContentGet extends StreamContent implements ServletContextAware
|
||||
{
|
||||
// Logger
|
||||
@SuppressWarnings("unused")
|
||||
private static final Log logger = LogFactory.getLog(ContentGet.class);
|
||||
|
||||
// Component dependencies
|
||||
private ServletContext servletContext;
|
||||
private DictionaryService dictionaryService;
|
||||
private NamespaceService namespaceService;
|
||||
private ContentService contentService;
|
||||
|
||||
/**
|
||||
* @param
|
||||
*/
|
||||
public void setServletContext(ServletContext servletContext)
|
||||
{
|
||||
this.servletContext = servletContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dictionaryService
|
||||
*/
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param namespaceService
|
||||
*/
|
||||
public void setNamespaceService(NamespaceService namespaceService)
|
||||
{
|
||||
this.namespaceService = namespaceService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param contentService
|
||||
*/
|
||||
public void setContentService(ContentService contentService)
|
||||
{
|
||||
this.contentService = contentService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.scripts.WebScript#execute(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.WebScriptResponse)
|
||||
*/
|
||||
public void execute(WebScriptRequest req, WebScriptResponse res)
|
||||
throws IOException
|
||||
{
|
||||
// create map of args
|
||||
String[] names = req.getParameterNames();
|
||||
Map<String, String> args = new HashMap<String, String>(names.length, 1.0f);
|
||||
for (String name : names)
|
||||
{
|
||||
args.put(name, req.getParameter(name));
|
||||
}
|
||||
|
||||
// create map of template vars
|
||||
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
|
||||
|
||||
// create object reference from url
|
||||
ObjectReference reference = createObjectReferenceFromUrl(args, templateVars);
|
||||
NodeRef nodeRef = reference.getNodeRef();
|
||||
if (nodeRef == null)
|
||||
{
|
||||
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find " + reference.toString());
|
||||
}
|
||||
|
||||
// determine attachment
|
||||
boolean attach = Boolean.valueOf(req.getParameter("a"));
|
||||
|
||||
// render content
|
||||
QName propertyQName = ContentModel.PROP_CONTENT;
|
||||
String contentPart = templateVars.get("property");
|
||||
if (contentPart.length() > 0 && contentPart.charAt(0) == ';')
|
||||
{
|
||||
if (contentPart.length() < 2)
|
||||
{
|
||||
throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Content property malformed");
|
||||
}
|
||||
String propertyName = contentPart.substring(1);
|
||||
if (propertyName.length() > 0)
|
||||
{
|
||||
propertyQName = QName.createQName(propertyName, namespaceService);
|
||||
}
|
||||
}
|
||||
|
||||
// Stream the content
|
||||
streamContentLocal(req, res, nodeRef, attach, propertyQName);
|
||||
}
|
||||
|
||||
private void streamContentLocal(WebScriptRequest req, WebScriptResponse res, NodeRef nodeRef, boolean attach, QName propertyQName) throws IOException
|
||||
{
|
||||
String userAgent = req.getHeader("User-Agent");
|
||||
|
||||
boolean rfc5987Supported = (null != userAgent) && (userAgent.contains("MSIE") || userAgent.contains(" Chrome/") || userAgent.contains(" FireFox/"));
|
||||
|
||||
if (attach && rfc5987Supported)
|
||||
{
|
||||
String name = (String) nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
|
||||
|
||||
//IE use file extension to get mimetype
|
||||
//So we set correct extension. see MNT-11246
|
||||
if(userAgent.contains("MSIE"))
|
||||
{
|
||||
String mimeType = contentService.getReader(nodeRef, propertyQName).getMimetype();
|
||||
if (!mimetypeService.getMimetypes(FilenameUtils.getExtension(name)).contains(mimeType))
|
||||
{
|
||||
name = FilenameUtils.removeExtension(name) + FilenameUtils.EXTENSION_SEPARATOR_STR + mimetypeService.getExtension(mimeType);
|
||||
}
|
||||
}
|
||||
|
||||
streamContent(req, res, nodeRef, propertyQName, attach, name, null);
|
||||
}
|
||||
else
|
||||
{
|
||||
streamContent(req, res, nodeRef, propertyQName, attach, null, null);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2013 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.alfresco.repo.web.scripts.content;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.springframework.extensions.webscripts.Cache;
|
||||
import org.springframework.extensions.webscripts.WebScriptException;
|
||||
import org.springframework.extensions.webscripts.WebScriptRequest;
|
||||
import org.springframework.extensions.webscripts.WebScriptResponse;
|
||||
|
||||
/**
|
||||
* Content Info Service Get info about content from the Repository.
|
||||
*
|
||||
* @author alex.malinovsky
|
||||
*/
|
||||
public class ContentInfo extends StreamContent
|
||||
{
|
||||
@Override
|
||||
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException
|
||||
{
|
||||
// create empty map of args
|
||||
Map<String, String> args = new HashMap<String, String>(0, 1.0f);
|
||||
// create map of template vars
|
||||
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
|
||||
// create object reference from url
|
||||
ObjectReference reference = createObjectReferenceFromUrl(args, templateVars);
|
||||
NodeRef nodeRef = reference.getNodeRef();
|
||||
if (nodeRef == null)
|
||||
{
|
||||
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find " + reference.toString());
|
||||
}
|
||||
|
||||
// render content
|
||||
QName propertyQName = ContentModel.PROP_CONTENT;
|
||||
|
||||
// Stream the content
|
||||
streamContent(req, res, nodeRef, propertyQName, false, null, null);
|
||||
}
|
||||
|
||||
protected void streamContentImpl(WebScriptRequest req, WebScriptResponse res,
|
||||
ContentReader reader, NodeRef nodeRef, QName propertyQName,
|
||||
boolean attach, Date modified, String eTag, String attachFileName)
|
||||
throws IOException
|
||||
{
|
||||
delegate.setAttachment(req, res, attach, attachFileName);
|
||||
|
||||
// establish mimetype
|
||||
String mimetype = reader.getMimetype();
|
||||
String extensionPath = req.getExtensionPath();
|
||||
if (mimetype == null || mimetype.length() == 0)
|
||||
{
|
||||
mimetype = MimetypeMap.MIMETYPE_BINARY;
|
||||
int extIndex = extensionPath.lastIndexOf('.');
|
||||
if (extIndex != -1)
|
||||
{
|
||||
String ext = extensionPath.substring(extIndex + 1);
|
||||
mimetype = mimetypeService.getMimetype(ext);
|
||||
}
|
||||
}
|
||||
|
||||
// set mimetype for the content and the character encoding + length for the stream
|
||||
res.setContentType(mimetype);
|
||||
res.setContentEncoding(reader.getEncoding());
|
||||
res.setHeader("Content-Length", Long.toString(reader.getSize()));
|
||||
|
||||
// set caching
|
||||
Cache cache = new Cache();
|
||||
cache.setNeverCache(false);
|
||||
cache.setMustRevalidate(true);
|
||||
cache.setMaxAge(0L);
|
||||
cache.setLastModified(modified);
|
||||
cache.setETag(eTag);
|
||||
res.setCache(cache);
|
||||
}
|
||||
}
|
@@ -26,10 +26,12 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.model.Repository;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.service.cmr.repository.StoreRef;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.apache.commons.logging.Log;
|
||||
@@ -61,6 +63,7 @@ public class StreamContent extends AbstractWebScript
|
||||
protected NodeService nodeService;
|
||||
protected MimetypeService mimetypeService;
|
||||
protected ContentStreamer delegate;
|
||||
protected Repository repository;
|
||||
|
||||
/**
|
||||
* @param mimetypeService
|
||||
@@ -93,6 +96,14 @@ public class StreamContent extends AbstractWebScript
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param repository
|
||||
*/
|
||||
public void setRepository(Repository repository)
|
||||
{
|
||||
this.repository = repository;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.scripts.WebScript#execute(org.alfresco.web.scripts.WebScriptRequest, org.alfresco.web.scripts.WebScriptResponse)
|
||||
*/
|
||||
@@ -366,4 +377,78 @@ public class StreamContent extends AbstractWebScript
|
||||
renderTemplate(templatePath, model, writer);
|
||||
}
|
||||
|
||||
protected ObjectReference createObjectReferenceFromUrl(Map<String, String> args, Map<String, String> templateArgs)
|
||||
{
|
||||
String objectId = args.get("noderef");
|
||||
if (objectId != null)
|
||||
{
|
||||
return new ObjectReference(objectId);
|
||||
}
|
||||
|
||||
StoreRef storeRef = null;
|
||||
String store_type = templateArgs.get("store_type");
|
||||
String store_id = templateArgs.get("store_id");
|
||||
if (store_type != null && store_id != null)
|
||||
{
|
||||
storeRef = new StoreRef(store_type, store_id);
|
||||
}
|
||||
|
||||
String id = templateArgs.get("id");
|
||||
if (storeRef != null && id != null)
|
||||
{
|
||||
return new ObjectReference(storeRef, id);
|
||||
}
|
||||
|
||||
String nodepath = templateArgs.get("nodepath");
|
||||
if (nodepath == null)
|
||||
{
|
||||
nodepath = args.get("nodepath");
|
||||
}
|
||||
if (storeRef != null && nodepath != null)
|
||||
{
|
||||
return new ObjectReference(storeRef, nodepath.split("/"));
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
class ObjectReference
|
||||
{
|
||||
private NodeRef ref;
|
||||
|
||||
ObjectReference(String nodeRef)
|
||||
{
|
||||
this.ref = new NodeRef(nodeRef);
|
||||
}
|
||||
|
||||
ObjectReference(StoreRef ref, String id)
|
||||
{
|
||||
if (id.indexOf('/') != -1)
|
||||
{
|
||||
id = id.substring(0, id.indexOf('/'));
|
||||
}
|
||||
this.ref = new NodeRef(ref, id);
|
||||
}
|
||||
|
||||
ObjectReference(StoreRef ref, String[] path)
|
||||
{
|
||||
String[] reference = new String[path.length + 2];
|
||||
reference[0] = ref.getProtocol();
|
||||
reference[1] = ref.getIdentifier();
|
||||
System.arraycopy(path, 0, reference, 2, path.length);
|
||||
this.ref = repository.findNodeRef("path", reference);
|
||||
}
|
||||
|
||||
public NodeRef getNodeRef()
|
||||
{
|
||||
return this.ref;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return ref != null ? ref.toString() : super.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user