mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
Merged V4.1-BUG-FIX to HEAD
39838: Minor fixes to yellowTheme rendering and title background 39871: ALF-610: Merged V3.4-BUG-FIX (3.4.11) to V4.1-BUG-FIX (4.1.1) 39842: ALF-15294 CLONE Jodconvertor - no office manager available - Wire up 'startListener' logic better, so that it does not need to go in OpenOfficeContentTransformerWorker but in the SocketOpenOfficeConnection, which also avoids a test on start up. 39841: ALF-15294 CLONE Jodconvertor - no office manager available Changing the OOoDirect subsystem so that: - It will not start an OpenOffice process if the OOoJodconverter subsystem is also starting an process on the same port (8100 is still the default in both cases). An ERROR is logged on startup if there is a clash of ports. - It no longer tries to establishes a connection to an OpenOffice process if ooo.enabled is false, or there is a clash of port numbers with the OOoJodconverter subsystem. Both these checks are new. - ooo.enabled must now be true before it tries to connect to an OpenOffice process on a remote host (ooo.host must not be localhost). - It will no longer schedule a job to establish and test the connection if it is not being used. 39923: ALF-610: Merged V3.4-BUG-FIX (3.4.11) to V4.1-BUG-FIX (4.1.1) 39922: ALF-15294 CLONE Jodconvertor - no office manager available - Start up problems with community version when the OOoJodconverter sub system is not there, because of the access to a Jod bean - Allow a default bean to be specified when the sub system bean could not be accessed. 39962: ALF-15158: Downloading Office 97 files with .doc extension result in file with .dot extension when using Google Chrome - Added more complete and intelligent content disposition header with the aim of supporting RFC 5987 39975: Merged BRANCHES/DEV/V3.4-BUG-FIX to BRANCHES/DEV/V4.1-BUG-FIX (Record Only) 39974: Merged BRANCHES/DEV/V4.1-BUG-FIX to BRANCHES/DEV/V3.4-BUG-FIX 39953: Refactored "Content I'm Editing" dashlet from synchronous (slowing down user dashboard initial display) to asynchronous client-side rendering. (ALF-13404) 39978: Merged BRANCHES/DEV/BELARUS/V4.1-BUG-FIX-2012_07_09 to BRANCHES/DEV/V4.1-BUG-FIX 39921: ALF-13473: IE9: can't login to awe. Upgrade YUI library to 2.9.0 for awe application. 39991: ALF-15339: Added empty-value check, caused group/user-search in workflows to fail 39999: Reversed revision 36174, thus removing Kofax 40025: Merged BRANCHES/V4.1 to BRANCHES/DEV/V4.1-BUG-FIX (Record Only) 40024: Merged BRANCHES/DEV/V4.1-BUG-FIX to BRANCHES/V4.1 40022: Fix for ALF-15144 - Slow Share doclib high-level folder browsing due to version history retrieval 40028: ALF-15346: Upgrade of Tika to 1.3-SNAPSHOT - Upgraded commons-codec from 1.4 to 1.5 - Upgraded commons-compress from 1.1 to 1.4.1 - Upgraded fontbox from 1.6.0 to 1.7.0 - Upgraded jempbox from 1.6.0 to 1.7.0 - Upgraded pdfbox from 1.6.0-patched to 1.7.0-patched - Upgraded metadata-extractor from 2.4.0-beta-1 to 2.6.2 - Upgraded poi-* from 3.9-beta1-20120329 to 3.9-beta1-20120801 - Upgraded tika-* from 1.2-20120518 to 1.3-20120801 - Added juniversalchardet version 1.0.3 - Added xmpcore version 5.1.2 - Added xz version 1.0 - Changed .classpaths, build.properties, and build.xml to correspond to above git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@40268 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
<#list results as row>
|
||||
{
|
||||
"type": "${row.item.typeShort}",
|
||||
"parentType": "${row.item.parentTypeShort}",
|
||||
"parentType": "${row.item.parentTypeShort!""}",
|
||||
"isContainer": ${row.item.isContainer?string},
|
||||
"name": "${row.item.properties.name!""}",
|
||||
"title": "${row.item.properties.title!""}",
|
||||
|
@@ -1,273 +1,290 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2010 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.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.alfresco.cmis.CMISFilterNotValidException;
|
||||
import org.alfresco.cmis.CMISObjectReference;
|
||||
import org.alfresco.cmis.CMISRendition;
|
||||
import org.alfresco.cmis.CMISRenditionService;
|
||||
import org.alfresco.model.ApplicationModel;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.cmis.reference.ReferenceFactory;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.web.scripts.FileTypeImageUtils;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.FileTypeImageSize;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
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.util.FileCopyUtils;
|
||||
import org.springframework.web.context.ServletContextAware;
|
||||
import org.springframework.web.context.support.ServletContextResource;
|
||||
|
||||
|
||||
/**
|
||||
* 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 ReferenceFactory referenceFactory;
|
||||
private DictionaryService dictionaryService;
|
||||
private NamespaceService namespaceService;
|
||||
private CMISRenditionService renditionService;
|
||||
|
||||
/**
|
||||
* @param
|
||||
*/
|
||||
public void setServletContext(ServletContext servletContext)
|
||||
{
|
||||
this.servletContext = servletContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param reference factory
|
||||
*/
|
||||
public void setReferenceFactory(ReferenceFactory referenceFactory)
|
||||
{
|
||||
this.referenceFactory = referenceFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dictionaryService
|
||||
*/
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param namespaceService
|
||||
*/
|
||||
public void setNamespaceService(NamespaceService namespaceService)
|
||||
{
|
||||
this.namespaceService = namespaceService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param renditionService
|
||||
*/
|
||||
public void setCMISRenditionService(CMISRenditionService renditionService)
|
||||
{
|
||||
this.renditionService = renditionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
CMISObjectReference reference = referenceFactory.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"));
|
||||
|
||||
// stream content on node, or rendition of node
|
||||
String streamId = req.getParameter("streamId");
|
||||
if (streamId != null && streamId.length() > 0)
|
||||
{
|
||||
// render content rendition
|
||||
streamRendition(req, res, reference, streamId, attach);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 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
|
||||
streamContent(req, res, nodeRef, propertyQName, attach);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stream content rendition
|
||||
*
|
||||
* @param req
|
||||
* @param res
|
||||
* @param reference
|
||||
* @param streamId
|
||||
* @param attach
|
||||
* @throws IOException
|
||||
*/
|
||||
private void streamRendition(WebScriptRequest req, WebScriptResponse res, CMISObjectReference reference, String streamId, boolean attach)
|
||||
throws IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
// find rendition
|
||||
CMISRendition rendition = null;
|
||||
List<CMISRendition> renditions = renditionService.getRenditions(reference.getNodeRef(), "*");
|
||||
for (CMISRendition candidateRendition : renditions)
|
||||
{
|
||||
if (candidateRendition.getStreamId().equals(streamId))
|
||||
{
|
||||
rendition = candidateRendition;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (rendition == null)
|
||||
{
|
||||
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find rendition " + streamId + " for " + reference.toString());
|
||||
}
|
||||
|
||||
// determine if special case for icons
|
||||
if (streamId.startsWith("alf:icon"))
|
||||
{
|
||||
streamIcon(res, reference, streamId, attach);
|
||||
}
|
||||
else
|
||||
{
|
||||
streamContent(req, res, rendition.getNodeRef(), ContentModel.PROP_CONTENT, attach);
|
||||
}
|
||||
}
|
||||
catch(CMISFilterNotValidException e)
|
||||
{
|
||||
throw new WebScriptException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Invalid Rendition Filter");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stream Icon
|
||||
*
|
||||
* @param res
|
||||
* @param reference
|
||||
* @param streamId
|
||||
* @param attach
|
||||
* @throws IOException
|
||||
*/
|
||||
private void streamIcon(WebScriptResponse res, CMISObjectReference reference, String streamId, boolean attach)
|
||||
throws IOException
|
||||
{
|
||||
// convert stream id to icon size
|
||||
FileTypeImageSize imageSize = streamId.equals("alf:icon16") ? FileTypeImageSize.Small : FileTypeImageSize.Medium;
|
||||
String iconSize = streamId.equals("alf:icon16") ? "-16" : "";
|
||||
|
||||
// calculate icon file name and path
|
||||
String iconPath = null;
|
||||
if (dictionaryService.isSubClass(nodeService.getType(reference.getNodeRef()), ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
String name = (String)nodeService.getProperty(reference.getNodeRef(), ContentModel.PROP_NAME);
|
||||
iconPath = FileTypeImageUtils.getFileTypeImage(servletContext, name, imageSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
String icon = (String)nodeService.getProperty(reference.getNodeRef(), ApplicationModel.PROP_ICON);
|
||||
if (icon != null)
|
||||
{
|
||||
iconPath = "/images/icons/" + icon + iconSize + ".gif";
|
||||
}
|
||||
else
|
||||
{
|
||||
iconPath = "/images/icons/space-icon-default" + iconSize + ".gif";
|
||||
}
|
||||
}
|
||||
|
||||
// set mimetype
|
||||
String mimetype = MimetypeMap.MIMETYPE_BINARY;
|
||||
int extIndex = iconPath.lastIndexOf('.');
|
||||
if (extIndex != -1)
|
||||
{
|
||||
String ext = iconPath.substring(extIndex + 1);
|
||||
mimetype = mimetypeService.getMimetype(ext);
|
||||
}
|
||||
res.setContentType(mimetype);
|
||||
|
||||
// stream icon
|
||||
ServletContextResource resource = new ServletContextResource(servletContext, iconPath);
|
||||
if (!resource.exists())
|
||||
{
|
||||
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find rendition " + streamId + " for " + reference.toString());
|
||||
}
|
||||
FileCopyUtils.copy(resource.getInputStream(), res.getOutputStream());
|
||||
}
|
||||
|
||||
/*
|
||||
* 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.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.alfresco.cmis.CMISFilterNotValidException;
|
||||
import org.alfresco.cmis.CMISObjectReference;
|
||||
import org.alfresco.cmis.CMISRendition;
|
||||
import org.alfresco.cmis.CMISRenditionService;
|
||||
import org.alfresco.model.ApplicationModel;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.cmis.reference.ReferenceFactory;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.web.scripts.FileTypeImageUtils;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.FileTypeImageSize;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.namespace.NamespaceService;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
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.util.FileCopyUtils;
|
||||
import org.springframework.web.context.ServletContextAware;
|
||||
import org.springframework.web.context.support.ServletContextResource;
|
||||
|
||||
|
||||
/**
|
||||
* 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 ReferenceFactory referenceFactory;
|
||||
private DictionaryService dictionaryService;
|
||||
private NamespaceService namespaceService;
|
||||
private CMISRenditionService renditionService;
|
||||
|
||||
/**
|
||||
* @param
|
||||
*/
|
||||
public void setServletContext(ServletContext servletContext)
|
||||
{
|
||||
this.servletContext = servletContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param reference factory
|
||||
*/
|
||||
public void setReferenceFactory(ReferenceFactory referenceFactory)
|
||||
{
|
||||
this.referenceFactory = referenceFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param dictionaryService
|
||||
*/
|
||||
public void setDictionaryService(DictionaryService dictionaryService)
|
||||
{
|
||||
this.dictionaryService = dictionaryService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param namespaceService
|
||||
*/
|
||||
public void setNamespaceService(NamespaceService namespaceService)
|
||||
{
|
||||
this.namespaceService = namespaceService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param renditionService
|
||||
*/
|
||||
public void setCMISRenditionService(CMISRenditionService renditionService)
|
||||
{
|
||||
this.renditionService = renditionService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
CMISObjectReference reference = referenceFactory.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"));
|
||||
|
||||
// stream content on node, or rendition of node
|
||||
String streamId = req.getParameter("streamId");
|
||||
if (streamId != null && streamId.length() > 0)
|
||||
{
|
||||
// render content rendition
|
||||
streamRendition(req, res, reference, streamId, attach);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 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);
|
||||
streamContent(req, res, nodeRef, propertyQName, attach, name);
|
||||
}
|
||||
else
|
||||
{
|
||||
streamContent(req, res, nodeRef, propertyQName, attach);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stream content rendition
|
||||
*
|
||||
* @param req
|
||||
* @param res
|
||||
* @param reference
|
||||
* @param streamId
|
||||
* @param attach
|
||||
* @throws IOException
|
||||
*/
|
||||
private void streamRendition(WebScriptRequest req, WebScriptResponse res, CMISObjectReference reference, String streamId, boolean attach)
|
||||
throws IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
// find rendition
|
||||
CMISRendition rendition = null;
|
||||
List<CMISRendition> renditions = renditionService.getRenditions(reference.getNodeRef(), "*");
|
||||
for (CMISRendition candidateRendition : renditions)
|
||||
{
|
||||
if (candidateRendition.getStreamId().equals(streamId))
|
||||
{
|
||||
rendition = candidateRendition;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (rendition == null)
|
||||
{
|
||||
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find rendition " + streamId + " for " + reference.toString());
|
||||
}
|
||||
|
||||
// determine if special case for icons
|
||||
if (streamId.startsWith("alf:icon"))
|
||||
{
|
||||
streamIcon(res, reference, streamId, attach);
|
||||
}
|
||||
else
|
||||
{
|
||||
streamContentLocal(req, res, reference.getNodeRef(), attach, ContentModel.PROP_CONTENT);
|
||||
}
|
||||
}
|
||||
catch(CMISFilterNotValidException e)
|
||||
{
|
||||
throw new WebScriptException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Invalid Rendition Filter");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Stream Icon
|
||||
*
|
||||
* @param res
|
||||
* @param reference
|
||||
* @param streamId
|
||||
* @param attach
|
||||
* @throws IOException
|
||||
*/
|
||||
private void streamIcon(WebScriptResponse res, CMISObjectReference reference, String streamId, boolean attach)
|
||||
throws IOException
|
||||
{
|
||||
// convert stream id to icon size
|
||||
FileTypeImageSize imageSize = streamId.equals("alf:icon16") ? FileTypeImageSize.Small : FileTypeImageSize.Medium;
|
||||
String iconSize = streamId.equals("alf:icon16") ? "-16" : "";
|
||||
|
||||
// calculate icon file name and path
|
||||
String iconPath = null;
|
||||
if (dictionaryService.isSubClass(nodeService.getType(reference.getNodeRef()), ContentModel.TYPE_CONTENT))
|
||||
{
|
||||
String name = (String)nodeService.getProperty(reference.getNodeRef(), ContentModel.PROP_NAME);
|
||||
iconPath = FileTypeImageUtils.getFileTypeImage(servletContext, name, imageSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
String icon = (String)nodeService.getProperty(reference.getNodeRef(), ApplicationModel.PROP_ICON);
|
||||
if (icon != null)
|
||||
{
|
||||
iconPath = "/images/icons/" + icon + iconSize + ".gif";
|
||||
}
|
||||
else
|
||||
{
|
||||
iconPath = "/images/icons/space-icon-default" + iconSize + ".gif";
|
||||
}
|
||||
}
|
||||
|
||||
// set mimetype
|
||||
String mimetype = MimetypeMap.MIMETYPE_BINARY;
|
||||
int extIndex = iconPath.lastIndexOf('.');
|
||||
if (extIndex != -1)
|
||||
{
|
||||
String ext = iconPath.substring(extIndex + 1);
|
||||
mimetype = mimetypeService.getMimetype(ext);
|
||||
}
|
||||
res.setContentType(mimetype);
|
||||
|
||||
// stream icon
|
||||
ServletContextResource resource = new ServletContextResource(servletContext, iconPath);
|
||||
if (!resource.exists())
|
||||
{
|
||||
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find rendition " + streamId + " for " + reference.toString());
|
||||
}
|
||||
FileCopyUtils.copy(resource.getInputStream(), res.getOutputStream());
|
||||
}
|
||||
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2011 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2012 Alfresco Software Limited.
|
||||
*
|
||||
* This file is part of Alfresco
|
||||
*
|
||||
@@ -36,6 +36,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.content.filestore.FileContentReader;
|
||||
import org.alfresco.repo.webdav.WebDAVHelper;
|
||||
import org.alfresco.service.cmr.repository.ContentIOException;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentService;
|
||||
@@ -804,7 +805,7 @@ public class StreamContent extends AbstractWebScript implements ResourceLoaderAw
|
||||
if (logger.isDebugEnabled())
|
||||
logger.debug("Attaching content using filename: " + attachFileName);
|
||||
|
||||
headerValue += "; filename=" + attachFileName;
|
||||
headerValue += "; filename*=UTF-8''" + WebDAVHelper.encodeURL(attachFileName) + "; filename=\"" + attachFileName + "\"";
|
||||
}
|
||||
|
||||
// set header based on filename - will force a Save As from the browse if it doesn't recognize it
|
||||
|
Reference in New Issue
Block a user