本文整理汇总了Java中org.alfresco.service.cmr.repository.ContentService.getReader方法的典型用法代码示例。如果您正苦于以下问题:Java ContentService.getReader方法的具体用法?Java ContentService.getReader怎么用?Java ContentService.getReader使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.alfresco.service.cmr.repository.ContentService
的用法示例。
在下文中一共展示了ContentService.getReader方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: copyContentOnly
import org.alfresco.service.cmr.repository.ContentService; //导入方法依赖的package包/类
private void copyContentOnly(FileInfo sourceFileInfo, FileInfo destFileInfo, FileFolderService fileFolderService) throws WebDAVServerException
{
ContentService contentService = getContentService();
ContentReader reader = contentService.getReader(sourceFileInfo.getNodeRef(), ContentModel.PROP_CONTENT);
if (reader == null)
{
// There is no content for the node if it is a folder
if (!sourceFileInfo.isFolder())
{
// Non-folders should have content available.
logger.error("Unable to get ContentReader for source node " + sourceFileInfo.getNodeRef());
throw new WebDAVServerException(HttpServletResponse.SC_NOT_FOUND);
}
}
else
{
ContentWriter contentWriter = contentService.getWriter(destFileInfo.getNodeRef(), ContentModel.PROP_CONTENT, true);
contentWriter.putContent(reader);
}
}
示例2: getReader
import org.alfresco.service.cmr.repository.ContentService; //导入方法依赖的package包/类
public Reader getReader()
{
ContentService contentService = services.getContentService();
ContentReader reader = contentService.getReader(nodeRef, property);
if (reader != null && reader.exists())
{
try
{
return (contentData.getEncoding() == null) ? new InputStreamReader(reader.getContentInputStream()) : new InputStreamReader(reader.getContentInputStream(), contentData.getEncoding());
}
catch (IOException e)
{
// NOTE: fall-through
}
}
return null;
}
示例3: guessMimetype
import org.alfresco.service.cmr.repository.ContentService; //导入方法依赖的package包/类
/**
* Guess the mimetype for the given filename - uses the extension to match on system mimetype map
*/
public void guessMimetype(String filename)
{
ContentService contentService = services.getContentService();
ContentReader reader = contentService.getReader(nodeRef, property);
// MNT-12265 Browser sets a mimetype based on extension of file. But mimeType from browser can be
// different as mapped in Alfresco for current extension. Therefore we need to guess a mimetype based on
// map in Alfresco
String typeByExt = services.getMimetypeService().guessMimetype(filename);
if (reader != null && reader.getMimetype() != null && !typeByExt.equals(MimetypeMap.MIMETYPE_BINARY))
{
setMimetype(typeByExt);
}
else
{
setMimetype(services.getMimetypeService().guessMimetype(filename, reader));
}
}
示例4: transformNode
import org.alfresco.service.cmr.repository.ContentService; //导入方法依赖的package包/类
/**
* Generic method to transform Node content from one mimetype to another.
*
* @param transformer The Transformer delegate supplying the transformation logic
* @param mimetype Mimetype of the destination content
* @param destination Destination folder location for the resulting document
*
* @return Node representing the transformed content - or null if the transform failed
*/
private ScriptNode transformNode(Transformer transformer, String mimetype, NodeRef destination)
{
ScriptNode transformedNode = null;
// get the content reader
ContentService contentService = this.services.getContentService();
ContentReader reader = contentService.getReader(this.nodeRef, ContentModel.PROP_CONTENT);
// only perform the transformation if some content is available
if (reader != null)
{
// Copy the content node to a new node
String copyName = TransformActionExecuter.transformName(this.services.getMimetypeService(), getName(),
mimetype, true);
NodeRef copyNodeRef = this.services.getCopyService().copy(this.nodeRef, destination,
ContentModel.ASSOC_CONTAINS,
QName.createQName(ContentModel.PROP_CONTENT.getNamespaceURI(), QName.createValidLocalName(copyName)),
false);
// modify the name of the copy to reflect the new mimetype
this.nodeService.setProperty(copyNodeRef, ContentModel.PROP_NAME, copyName);
// get the writer and set it up
ContentWriter writer = contentService.getWriter(copyNodeRef, ContentModel.PROP_CONTENT, true);
writer.setMimetype(mimetype); // new mimetype
writer.setEncoding(reader.getEncoding()); // original encoding
// Try and transform the content using the supplied delegate
transformedNode = transformer.transform(contentService, copyNodeRef, reader, writer);
}
return transformedNode;
}
示例5: getContent
import org.alfresco.service.cmr.repository.ContentService; //导入方法依赖的package包/类
/**
* @return the content stream
*/
public String getContent()
{
ContentService contentService = services.getContentService();
ContentReader reader = contentService.getReader(getNodeRef(), property);
return (reader != null && reader.exists()) ? reader.getContentString() : "";
}
示例6: getContentMaxLength
import org.alfresco.service.cmr.repository.ContentService; //导入方法依赖的package包/类
/**
* @return the content stream to the specified maximum length in characters
*/
public String getContentMaxLength(int length)
{
ContentService contentService = services.getContentService();
ContentReader reader = contentService.getReader(getNodeRef(), property);
return (reader != null && reader.exists()) ? reader.getContentString(length) : "";
}
示例7: parse
import org.alfresco.service.cmr.repository.ContentService; //导入方法依赖的package包/类
/** utility function for parsing xml */
public static Document parse(final NodeRef nodeRef,
final ContentService contentService)
throws SAXException,
IOException
{
final ContentReader contentReader =
contentService.getReader(nodeRef, ContentModel.TYPE_CONTENT);
final InputStream in = contentReader.getContentInputStream();
return XMLUtil.parse(in);
}
示例8: getContent
import org.alfresco.service.cmr.repository.ContentService; //导入方法依赖的package包/类
public String getContent()
{
ContentService contentService = services.getContentService();
ContentReader reader = contentService.getReader(nodeRef, property);
return (reader != null && reader.exists()) ? reader.getContentString() : "";
}
示例9: getInputStream
import org.alfresco.service.cmr.repository.ContentService; //导入方法依赖的package包/类
public InputStream getInputStream()
{
ContentService contentService = services.getContentService();
ContentReader reader = contentService.getReader(nodeRef, property);
return (reader != null && reader.exists()) ? reader.getContentInputStream() : null;
}
示例10: getContentAsText
import org.alfresco.service.cmr.repository.ContentService; //导入方法依赖的package包/类
/**
* @param length Length of the character stream to return, or -1 for all
*
* @return the binary content stream converted to text using any available transformer
* if fails to convert then null will be returned
*/
public String getContentAsText(int length)
{
String result = null;
if (MimetypeMap.MIMETYPE_TEXT_PLAIN.equals(getMimetype()))
{
result = getContentMaxLength(length);
}
else
{
// get the content reader
ContentService contentService = services.getContentService();
NodeRef nodeRef = getNodeRef();
ContentReader reader = contentService.getReader(nodeRef, property);
if (reader == null)
{
return ""; // Caller of this method returns "" if there is an IOException
}
// get the writer and set it up for text convert
ContentWriter writer = contentService.getTempWriter();
writer.setMimetype("text/plain");
writer.setEncoding(reader.getEncoding());
TransformationOptions options = new TransformationOptions();
options.setSourceNodeRef(nodeRef);
// try and transform the content
try
{
contentService.transform(reader, writer, options);
ContentReader resultReader = writer.getReader();
if (resultReader != null && reader.exists())
{
if (length != -1)
{
result = resultReader.getContentString(length);
}
else
{
result = resultReader.getContentString();
}
}
}
catch (NoTransformerException|UnsupportedTransformationException e)
{
// ignore
}
}
return result;
}