Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)

75551: Reverse Merge HEAD-BUG-FIX (5.0/Cloud)
      74584: Reverse merged HEAD-BUG-FIX (5.0/Cloud)
         << Requires more work on the EOL branch >>
         74416: Merged EOL to HEAD-BUG-FIX (5.0/Cloud)
            74309: ACE-2010 EOL Legacy CMIS Inputs (2) in 5.0
               - Start replacing references to the original CMIS code with Alfresco and chemistry Open CMIS classes 
            74342: ACE-2010 EOL Legacy CMIS Inputs (2) in 5.0
               - Switch ServiceRegistry over to using Open CMIS classes 
            74406: ACE-2010 EOL Legacy CMIS Inputs (2) in 5.0
               << Compiles and starts Share without error >>
               - Removed Original CMIS classes from the repository, remote-api and thor
               - Moved the CMIS.DictionaryBootstrap bean into opencmis-context.xml before removing cmis-api-context.xml
               - Some code was left under:
                   root\projects\remote-api\source\java\org\alfresco\repo\cmis
                   ...........................................................\client
                   ...........................................................\ws
                   ...........................................................\rest
                   ................................test-java\org\alfresco\repo\cmis
                   ................................................................\ws
                   ................................................................\rest
                 Will have to see if it should be be removed too, or if it is common with OpenCMIS
            74407: ACE-2010 EOL Legally CMIS Inputs (2) in 5.0
               - Removed left over code under:
                   root\projects\remote-api\source\java\org\alfresco\repo\cmis
                   ................................test-java\org\alfresco\repo\cmis
               - Removed an authentication URL test in QuickShareRestApiTest which was failing in
                 the same way as the tests above.
               - Removed CXFAuthenticationSystemTest which appears to be using the original CMIS
         74465: Merged EOL (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud)
            74464: ACE-2010 EOL Legacey CMIS Inputs (2) in 5.0
               - New failure in QuickShareRestApiTest
               - CXFAuthenticationSystemTest (deleted) was still referenced in MiscSystemTestSuite


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@77489 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Mark Rogers
2014-07-22 12:58:48 +00:00
parent d449ca6eaf
commit 75b6831d2a
58 changed files with 21 additions and 11114 deletions

View File

@@ -1,133 +0,0 @@
/*
* 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.Map;
import javax.servlet.http.HttpServletResponse;
import org.alfresco.cmis.CMISObjectReference;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.cmis.reference.ReferenceFactory;
import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;
import org.springframework.extensions.webscripts.AbstractWebScript;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptException;
import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.extensions.webscripts.WebScriptResponse;
/**
* Content Delete Service
*
* Delete content stream from the Repository.
*
* @author davidc
*/
public class ContentDelete extends AbstractWebScript
{
// Component dependencies
private ReferenceFactory referenceFactory;
private NamespaceService namespaceService;
private NodeService nodeService;
/**
* @param reference factory
*/
public void setReferenceFactory(ReferenceFactory referenceFactory)
{
this.referenceFactory = referenceFactory;
}
/**
* @param namespaceService
*/
public void setNamespaceService(NamespaceService namespaceService)
{
this.namespaceService = namespaceService;
}
/**
* @param nodeService
*/
public void setNodeService(NodeService nodeService)
{
this.nodeService = nodeService;
}
/**
* @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 content property
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);
}
}
// retrieve content property
ContentData contentData = (ContentData)nodeService.getProperty(nodeRef, propertyQName);
if (contentData != null)
{
contentData = new ContentData(null, null, 0, null);
nodeService.setProperty(nodeRef, propertyQName, contentData);
}
// no content returned
res.setStatus(Status.STATUS_NO_CONTENT);
}
}

View File

@@ -1,322 +0,0 @@
/*
* 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.security.permissions.AccessDeniedException;
import org.alfresco.repo.web.scripts.FileTypeImageUtils;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.repository.ContentService;
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.io.FilenameUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.extensions.webscripts.Status;
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;
private ContentService contentService;
/**
* @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;
}
/**
* @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
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/"));
try
{
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);
}
}
catch (AccessDeniedException e)
{
throw new WebScriptException(Status.STATUS_FORBIDDEN, e.getMessage());
}
}
/**
* 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, rendition.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());
}
}

View File

@@ -1,113 +0,0 @@
/*
* 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.cmis.CMISObjectReference;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.cmis.reference.ReferenceFactory;
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
{
private ReferenceFactory referenceFactory;
public void setReferenceFactory(ReferenceFactory referenceFactory)
{
this.referenceFactory = referenceFactory;
}
@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
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());
}
// 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);
}
}

View File

@@ -1,187 +0,0 @@
/*
* 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.Map;
import javax.servlet.http.HttpServletResponse;
import org.alfresco.cmis.CMISDictionaryModel;
import org.alfresco.cmis.CMISObjectReference;
import org.alfresco.cmis.CMISServiceException;
import org.alfresco.cmis.CMISServices;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.cmis.reference.ObjectPathReference;
import org.alfresco.repo.cmis.reference.ReferenceFactory;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.dictionary.PropertyDefinition;
import org.alfresco.service.cmr.repository.MimetypeService;
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.AbstractWebScript;
import org.springframework.extensions.webscripts.Status;
import org.springframework.extensions.webscripts.WebScriptException;
import org.springframework.extensions.webscripts.WebScriptRequest;
import org.springframework.extensions.webscripts.WebScriptResponse;
/**
* Content Write Service
*
* Stream content to the Repository.
*
* @author davidc
*/
public class ContentSet extends AbstractWebScript
{
// Logger
@SuppressWarnings("unused")
private static final Log logger = LogFactory.getLog(ContentSet.class);
// Component dependencies
private ReferenceFactory referenceFactory;
private DictionaryService dictionaryService;
private NamespaceService namespaceService;
private CMISServices cmisService;
private MimetypeService mimetypeService;
/**
* @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 cmisServices
*/
public void setCmisService(CMISServices cmisService)
{
this.cmisService = cmisService;
}
/**
* @param mimetypeService
*/
public void setMimetypeService(MimetypeService mimetypeService)
{
this.mimetypeService = mimetypeService;
}
/**
* @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 content property
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);
}
}
PropertyDefinition propertyDef = dictionaryService.getProperty(propertyQName);
if (propertyDef == null)
{
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find content property " + propertyQName + " of " + reference.toString());
}
if (!propertyDef.getDataType().getName().equals(DataTypeDefinition.CONTENT))
{
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Content stream not found");
}
// ensure content can be overwritten
String overwrite = req.getParameter("overwriteFlag");
// establish mimetype
String mimetype = req.getContentType();
if (mimetype == null)
{
if (reference instanceof ObjectPathReference)
{
mimetype = mimetypeService.guessMimetype(((ObjectPathReference)reference).getPath());
}
}
try
{
boolean isUpdate = cmisService.setContentStream((String) cmisService.getProperty(nodeRef,
CMISDictionaryModel.PROP_OBJECT_ID), propertyQName, overwrite == null || overwrite.equals("true"),
req.getContent().getInputStream(), mimetype);
// set status
res.setStatus(isUpdate ? Status.STATUS_OK : Status.STATUS_CREATED);
}
catch (CMISServiceException e)
{
throw new WebScriptException(e.getStatusCode(), e.getMessage(), e);
}
}
}