当前位置: 首页>>代码示例>>Java>>正文


Java ContentReader类代码示例

本文整理汇总了Java中org.alfresco.service.cmr.repository.ContentReader的典型用法代码示例。如果您正苦于以下问题:Java ContentReader类的具体用法?Java ContentReader怎么用?Java ContentReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ContentReader类属于org.alfresco.service.cmr.repository包,在下文中一共展示了ContentReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testProjectTrivialDiffProjectFiles

import org.alfresco.service.cmr.repository.ContentReader; //导入依赖的package包/类
/**
 * Open and close of a project file changes certain header properties.
 * Test File 1 has been opened and closed.
 * @throws Exception
 */
public void testProjectTrivialDiffProjectFiles() throws Exception
{
    CIFSContentComparator contentComparator = new CIFSContentComparator();
    contentComparator.init();
    
    ClassPathResource file0Resource = new ClassPathResource("filesys/ContentComparatorTest0.mpp");
    assertNotNull("unable to find test resource filesys/ContentComparatorTest0.mpp", file0Resource);
    
    ClassPathResource file1Resource = new ClassPathResource("filesys/ContentComparatorTest1.mpp");
    assertNotNull("unable to find test resource filesys/ContentComparatorTest1.mpp", file1Resource);
            
    /**
     * Compare trivially different project files, should ignore trivial differences and be equal 
     */
    {
        File file0 = file0Resource.getFile();
        File file1 = file1Resource.getFile();

        ContentReader reader = new FileContentReader(file0);
        reader.setMimetype("application/vnd.ms-project");
        reader.setEncoding("UTF-8");
        boolean result = contentComparator.isContentEqual(reader, file1);
        assertTrue("compare trivially different project file, should be equal", result);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:31,代码来源:CIFSContentComparatorTest.java

示例2: copyContentOnly

import org.alfresco.service.cmr.repository.ContentReader; //导入依赖的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);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:21,代码来源:MoveMethod.java

示例3: getReader

import org.alfresco.service.cmr.repository.ContentReader; //导入依赖的package包/类
@Override
public ContentReader getReader(String contentUrl) {
	if (logger.isDebugEnabled()) {
		logger.debug(String.format("Content Reader for %s", contentUrl));
	}

	// Use pool of locks - which one is determined by a hash of the URL.
	// This will stop the content from being read/cached multiple times from
	// the backing store
	// when it should only be read once - cached versions should be returned
	// after that.
	ReadLock readLock = readWriteLock(contentUrl).readLock();
	readLock.lock();
	try {
		return this.objectStorageService.getReader(contentUrl);
	} catch (IOException e) {
		logger.error(e.getMessage(), e);
	} finally {
		readLock.unlock();
	}

	return null;
}
 
开发者ID:jeci-sarl,项目名称:alfresco-object-storage-connectors,代码行数:24,代码来源:ObjectStorageContentStore.java

示例4: toComment

import org.alfresco.service.cmr.repository.ContentReader; //导入依赖的package包/类
private Comment toComment(NodeRef nodeRef, NodeRef commentNodeRef, List<String> include)
  {
      Map<QName, Serializable> nodeProps = nodeService.getProperties(commentNodeRef);

      ContentReader reader = contentService.getReader(commentNodeRef, ContentModel.PROP_CONTENT);
      if(reader != null)
      {
       String content = reader.getContentString();
       nodeProps.put(Comment.PROP_COMMENT_CONTENT, content);
       nodeProps.remove(ContentModel.PROP_CONTENT);
      }


      Map<String, Boolean> map = commentService.getCommentPermissions(nodeRef, commentNodeRef);
      boolean canEdit = map.get(CommentService.CAN_EDIT);
      boolean canDelete =  map.get(CommentService.CAN_DELETE);

Person createdBy = people.getPerson((String) nodeProps.get(ContentModel.PROP_CREATOR), include);
nodeProps.put(Comment.PROP_COMMENT_CREATED_BY, createdBy);

Person modifiedBy = people.getPerson((String) nodeProps.get(ContentModel.PROP_MODIFIER), include);
nodeProps.put(Comment.PROP_COMMENT_MODIFIED_BY, modifiedBy);

      Comment comment = new Comment(commentNodeRef.getId(), nodeProps, canEdit, canDelete);
      return comment;
  }
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:27,代码来源:CommentsImpl.java

示例5: testXmlMetadataExtracter

import org.alfresco.service.cmr.repository.ContentReader; //导入依赖的package包/类
public void testXmlMetadataExtracter() throws Exception
{
    // Load the example files
    ContentReader alfrescoModelReader = getReader(FILE_ALFRESCO_MODEL);
    assertTrue(alfrescoModelReader.exists());
    ContentReader eclipseProjectReader = getReader(FILE_ECLIPSE_PROJECT);
    assertTrue(eclipseProjectReader.exists());
    
    // Pass the Alfresco Model xml to the extractor
    PropertyMap checkAlfrescoModelProperties = new PropertyMap();
    xmlMetadataExtracter.extract(alfrescoModelReader, checkAlfrescoModelProperties);
    // Check the values
    assertEquals("Gavin Cornwell", getPropertyValue(checkAlfrescoModelProperties, ContentModel.PROP_AUTHOR));
    assertEquals("fm:forummodel",  getPropertyValue(checkAlfrescoModelProperties, ContentModel.PROP_TITLE));
    assertEquals("Forum Model",    getPropertyValue(checkAlfrescoModelProperties, ContentModel.PROP_DESCRIPTION));

    // Pass the Eclipse Project xml to the extractor
    PropertyMap checkEclipseProjectProperties = new PropertyMap();
    xmlMetadataExtracter.extract(eclipseProjectReader, checkEclipseProjectProperties);
    // Check the values
    assertEquals("Repository",    getPropertyValue(checkEclipseProjectProperties, ContentModel.PROP_TITLE));
    assertEquals("JavaCC Nature", getPropertyValue(checkEclipseProjectProperties, ContentModel.PROP_DESCRIPTION));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:24,代码来源:XmlMetadataExtracterTest.java

示例6: lastModified

import org.alfresco.service.cmr.repository.ContentReader; //导入依赖的package包/类
public long lastModified(final String documentPath) throws IOException
{
    return AuthenticationUtil.runAs(new AuthenticationUtil.RunAsWork<Long>()
    {
        public Long doWork() throws Exception
        {
            return retryingTransactionHelper.doInTransaction(new RetryingTransactionCallback<Long>()
            {
                public Long execute() throws Exception
                {
                    ContentReader reader = contentService.getReader(
                            findNodeRef(documentPath), ContentModel.PROP_CONTENT);
                    return reader.getLastModified();
                }
            }, true, false);
        }
    }, AuthenticationUtil.getSystemUserName());            
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:19,代码来源:RepoStore.java

示例7: render

import org.alfresco.service.cmr.repository.ContentReader; //导入依赖的package包/类
@Override
protected void render(RenderingContext context)
{
    ContentReader contentReader = context.makeContentReader();
    String sourceMimeType = contentReader.getMimetype();
    
    // Check that Tika supports the supplied file
    AutoDetectParser p = new AutoDetectParser(tikaConfig);
    MediaType sourceMediaType = MediaType.parse(sourceMimeType);
    if(! p.getParsers().containsKey(sourceMediaType))
    {
       throw new RenditionServiceException(
             "Source mime type of " + sourceMimeType + 
             " is not supported by Tika for HTML conversions"
       );
    }
    
    // Make the HTML Version using Tika
    // This will also extract out any images as found
    generateHTML(p, context);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:22,代码来源:HTMLRenderingEngine.java

示例8: testEmptyHtmlToEmptyPdf

import org.alfresco.service.cmr.repository.ContentReader; //导入依赖的package包/类
/**
 * ALF-219. Transforamtion from .html to .pdf for empty file.
 * @throws Exception
 */
public void testEmptyHtmlToEmptyPdf() throws Exception
{
    if (!isOpenOfficeWorkerAvailable())
    {
        // no connection
        System.err.println("ooWorker not available - skipping testEmptyHtmlToEmptyPdf !!");
        return;
    }
    URL url = this.getClass().getClassLoader().getResource("misc/empty.html");
    assertNotNull("URL was unexpectedly null", url);

    File htmlSourceFile = new File(url.getFile());
    assertTrue("Test file does not exist.", htmlSourceFile.exists());
    
    File pdfTargetFile = TempFileProvider.createTempFile(getName() + "-target-", ".pdf");
    
    ContentReader reader = new FileContentReader(htmlSourceFile);
    reader.setMimetype(MimetypeMap.MIMETYPE_HTML);
    ContentWriter writer = new FileContentWriter(pdfTargetFile);
    writer.setMimetype(MimetypeMap.MIMETYPE_PDF);
    
    transformer.transform(reader, writer);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:28,代码来源:OpenOfficeContentTransformerTest.java

示例9: testGeneralUse

import org.alfresco.service.cmr.repository.ContentReader; //导入依赖的package包/类
@Test
public void testGeneralUse()
{
    for (int i = 0 ; i < 20; i++)
    {
        ContentContext contentContext = new ContentContext(null, null);
        ContentWriter writer = routingStore.getWriter(contentContext);
        String content = "This was generated by " + this.getClass().getName() + "#testGeneralUse number " + i;
        writer.putContent(content);
        // Check that it exists
        String contentUrl = writer.getContentUrl();
        checkForContent(contentUrl, content);
        
        // Now go direct to the routing store and check that it is able to find the appropriate URLs
        ContentReader reader = routingStore.getReader(contentUrl);
        assertNotNull("Null reader returned", reader);
        assertTrue("Reader should be onto live content", reader.exists());
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:RoutingContentStoreTest.java

示例10: testSimpleNonTempWriter

import org.alfresco.service.cmr.repository.ContentReader; //导入依赖的package包/类
/**
 * Check that a valid writer into the content store can be retrieved and used.
 */
public void testSimpleNonTempWriter() throws Exception
{
    ContentWriter writer = contentService.getWriter(null, null, false);
    assertNotNull("Writer should not be null", writer);
    assertNotNull("Content URL should not be null", writer.getContentUrl());
    
    // write some content
    writer.putContent(SOME_CONTENT);
    writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
    writer.setEncoding("UTF-16");
    writer.setLocale(Locale.CHINESE);
    
    // set the content property manually
    nodeService.setProperty(contentNodeRef, ContentModel.PROP_CONTENT, writer.getContentData());
    
    // get the reader
    ContentReader reader = contentService.getReader(contentNodeRef, ContentModel.PROP_CONTENT);
    assertNotNull("Reader should not be null", reader);
    assertNotNull("Content URL should not be null", reader.getContentUrl());
    assertEquals("Content Encoding was not set", "UTF-16", reader.getEncoding());
    assertEquals("Content Locale was not set", Locale.CHINESE, reader.getLocale());
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:26,代码来源:RoutingContentServiceTest.java

示例11: testRFC822ToText

import org.alfresco.service.cmr.repository.ContentReader; //导入依赖的package包/类
/**
 * Test transforming a valid eml file to text
 */
public void testRFC822ToText() throws Exception
{
    File emlSourceFile = loadQuickTestFile("eml");
    File txtTargetFile = TempFileProvider.createTempFile("test", ".txt");
    ContentReader reader = new FileContentReader(emlSourceFile);
    reader.setMimetype(MimetypeMap.MIMETYPE_RFC822);
    ContentWriter writer = new FileContentWriter(txtTargetFile);
    writer.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);

    transformer.transform(reader, writer);

    ContentReader reader2 = new FileContentReader(txtTargetFile);
    reader2.setMimetype(MimetypeMap.MIMETYPE_TEXT_PLAIN);
    assertTrue(reader2.getContentString().contains(QUICK_EML_CONTENT));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:19,代码来源:EMLTransformerTest.java

示例12: transformDocument

import org.alfresco.service.cmr.repository.ContentReader; //导入依赖的package包/类
private ScriptNode transformDocument(String mimetype, NodeRef destination)
{
    ParameterCheck.mandatoryString("Mimetype", mimetype);
    ParameterCheck.mandatory("Destination Node", destination);
    final NodeRef sourceNodeRef = nodeRef;
    
    // the delegate definition for transforming a document
    Transformer transformer = new AbstractTransformer()
    {
        protected void doTransform(ContentService contentService,
            ContentReader reader, ContentWriter writer)
        {
            TransformationOptions options = new TransformationOptions();
            options.setSourceNodeRef(sourceNodeRef);
            contentService.transform(reader, writer, options);
        }
    };
    
    return transformNode(transformer, mimetype, destination);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:21,代码来源:ScriptNode.java

示例13: strictMimetypeCheck

import org.alfresco.service.cmr.repository.ContentReader; //导入依赖的package包/类
private void strictMimetypeCheck(ContentReader reader, TransformationOptions options, String sourceMimetype)
    throws UnsupportedTransformationException
{
    if (strictMimeTypeCheck && depth.get() == 1)
    {
        String differentType = getMimetypeService().getMimetypeIfNotMatches(reader.getReader());

        if (!transformerConfig.strictMimetypeCheck(sourceMimetype, differentType))
        {
            String fileName = transformerDebug.getFileName(options, true, 0);
            String readerSourceMimetype = reader.getMimetype();
            String message = "Transformation of ("+fileName+
                ") has not taken place because the declared mimetype ("+
                readerSourceMimetype+") does not match the detected mimetype ("+
                differentType+").";
            logger.warn(message);
            throw new UnsupportedTransformationException(message);
        }
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:21,代码来源:AbstractContentTransformer2.java

示例14: putContent

import org.alfresco.service.cmr.repository.ContentReader; //导入依赖的package包/类
/**
 * @see ContentReader#getContentInputStream()
 * @see #putContent(InputStream) 
 */
public void putContent(ContentReader reader) throws ContentIOException
{
    try
    {
        // get the stream to read from
        InputStream is = reader.getContentInputStream();
        // put the content
        putContent(is);
    }
    catch (Throwable e)
    {
        throw new ContentIOException("Failed to copy reader content to writer: \n" +
                "   writer: " + this + "\n" +
                "   source reader: " + reader,
                e);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:22,代码来源:AbstractContentWriter.java

示例15: extractRaw

import org.alfresco.service.cmr.repository.ContentReader; //导入依赖的package包/类
@Override
protected Map<String, Serializable> extractRaw(ContentReader reader) throws Throwable
{
    Map<String, Serializable> properties = new HashMap<String, Serializable>(10);
    long startTime = (new Date()).getTime();
    boolean done = false;
    int i = 0;
    try
    {
        while(!done)
        {
            Thread.sleep(50); // working hard
            long extractTime = (new Date()).getTime() - startTime;
            properties.put("key" + i, extractTime);
            i++;
            done = extractTime > delay;
        }
        properties.put("a", "value1");
    }
    catch (InterruptedException e)
    {
        // Asked to stop
        return null;
    }
    return properties;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:27,代码来源:MetadataExtracterLimitsTest.java


注:本文中的org.alfresco.service.cmr.repository.ContentReader类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。