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


Java ContentWriter.getContentUrl方法代码示例

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


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

示例1: getExistingContentUrl

import org.alfresco.service.cmr.repository.ContentWriter; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 * <p>
 * This implementation creates some content in the store and returns the new content URL.
 */
protected String getExistingContentUrl()
{
    ContentWriter writer = getWriter();
    writer.putContent("Content for getExistingContentUrl");
    return writer.getContentUrl();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:12,代码来源:AggregatingContentStoreTest.java

示例2: testGeneralUse

import org.alfresco.service.cmr.repository.ContentWriter; //导入方法依赖的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

示例3: testStoreWillReadFromCacheWhenAvailable

import org.alfresco.service.cmr.repository.ContentWriter; //导入方法依赖的package包/类
public void testStoreWillReadFromCacheWhenAvailable()
{
    final String content = "Content for " + getName() + " test.";
    
    // Write some content to the backing store.
    ContentWriter writer = backingStore.getWriter(ContentContext.NULL_CONTEXT);
    writer.putContent(content);
    final String contentUrl = writer.getContentUrl();
    
    // Read content using the CachingContentStore - will cause content to be cached.
    String retrievedContent = store.getReader(contentUrl).getContentString();
    assertEquals(content, retrievedContent);
    
    // Remove the original content from the backing store.
    backingStore.delete(contentUrl);
    assertFalse("Original content should have been deleted", backingStore.exists(contentUrl));
    
    // The cached version is still available.
    String contentAfterDelete = store.getReader(contentUrl).getContentString();
    assertEquals(content, contentAfterDelete);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:22,代码来源:CachingContentStoreSpringTest.java

示例4: testStoreWillRecoverFromDeletedCacheFile

import org.alfresco.service.cmr.repository.ContentWriter; //导入方法依赖的package包/类
public void testStoreWillRecoverFromDeletedCacheFile()
{
    final String content = "Content for " + getName() + " test.";
    
    // Write some content to the backing store.
    ContentWriter writer = backingStore.getWriter(ContentContext.NULL_CONTEXT);
    writer.putContent(content);
    final String contentUrl = writer.getContentUrl();
    
    // Read content using the CachingContentStore - will cause content to be cached.
    String retrievedContent = store.getReader(contentUrl).getContentString();
    assertEquals(content, retrievedContent);
    
    // Remove the cached disk file
    File cacheFile = new File(cache.getCacheFilePath(contentUrl));
    cacheFile.delete();   
    assertTrue("Cached content should have been deleted", !cacheFile.exists());
  
    // Should still be able to ask for this content, even though the cache file was
    // deleted and the record of the cache is still in the in-memory cache/lookup.
    String contentAfterDelete = store.getReader(contentUrl).getContentString();
    assertEquals(content, contentAfterDelete);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:24,代码来源:CachingContentStoreSpringTest.java

示例5: testConcurrentWriteDetection

import org.alfresco.service.cmr.repository.ContentWriter; //导入方法依赖的package包/类
/**
 * Checks that the store disallows concurrent writers to be issued to the same URL.
 */
@SuppressWarnings("unused")
@Test
public void testConcurrentWriteDetection() throws Exception
{
    ByteBuffer buffer = ByteBuffer.wrap("Something".getBytes());
    ContentStore store = getStore();

    ContentContext firstContentCtx = ContentStore.NEW_CONTENT_CONTEXT;
    ContentWriter firstWriter = store.getWriter(firstContentCtx);
    String contentUrl = firstWriter.getContentUrl();

    ContentContext secondContentCtx = new ContentContext(null, contentUrl);
    try
    {
        ContentWriter secondWriter = store.getWriter(secondContentCtx);
        fail("Store must disallow more than one writer onto the same content URL: " + store);
    }
    catch (ContentExistsException e)
    {
        // expected
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:26,代码来源:FileContentStoreTest.java

示例6: before

import org.alfresco.service.cmr.repository.ContentWriter; //导入方法依赖的package包/类
@Before
public void before() throws Exception
{
    // create a store that uses a subdirectory of the temp directory
    File tempDir = TempFileProvider.getTempDir();
    store = new FileContentStore(ctx,
            tempDir.getAbsolutePath() +
            File.separatorChar +
            getName());
    // Put some content into it
    ContentWriter writer = store.getWriter(new ContentContext(null, null));
    writer.putContent("Content for getExistingContentUrl");
    this.contentUrl = writer.getContentUrl();
    // disallow random access
    store.setReadOnly(true);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:17,代码来源:ReadOnlyFileContentStoreTest.java

示例7: testSimpleUse

import org.alfresco.service.cmr.repository.ContentWriter; //导入方法依赖的package包/类
/**
 * Get a writer and write a little bit of content before reading it.
 */
@Test
public void testSimpleUse()
{
    ContentStore store = getStore();
    String content = "Content for testSimpleUse";
    
    ContentWriter writer = store.getWriter(ContentStore.NEW_CONTENT_CONTEXT);
    assertNotNull("Writer may not be null", writer);
    // Ensure that the URL is available
    String contentUrlBefore = writer.getContentUrl();
    assertNotNull("Content URL may not be null for unused writer", contentUrlBefore);
    assertTrue("URL is not valid: " + contentUrlBefore, AbstractContentStore.isValidContentUrl(contentUrlBefore));
    // Write something
    writer.putContent(content);
    String contentUrlAfter = writer.getContentUrl();
    assertTrue("URL is not valid: " + contentUrlBefore, AbstractContentStore.isValidContentUrl(contentUrlAfter));
    assertEquals("The content URL may not change just because the writer has put content", contentUrlBefore, contentUrlAfter);
    // Get the readers
    ContentReader reader = store.getReader(contentUrlBefore);
    assertNotNull("Reader from store is null", reader);
    assertEquals(reader.getContentUrl(), writer.getContentUrl());
    String checkContent = reader.getContentString();
    assertEquals("Content is different", content, checkContent);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:28,代码来源:AbstractWritableContentStoreTest.java

示例8: testDeleteSimple

import org.alfresco.service.cmr.repository.ContentWriter; //导入方法依赖的package包/类
@Test
public void testDeleteSimple() throws Exception
{
    ContentStore store = getStore();
    ContentWriter writer = getWriter();
    writer.putContent("Content for testDeleteSimple");
    String contentUrl = writer.getContentUrl();
    assertTrue("Content must now exist", store.exists(contentUrl));
    try
    {
        store.delete(contentUrl);
    }
    catch (UnsupportedOperationException e)
    {
        logger.warn("Store test testDeleteSimple not possible on " + store.getClass().getName());
        return;
    }
    assertFalse("Content must now be removed", store.exists(contentUrl));
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:20,代码来源:AbstractWritableContentStoreTest.java

示例9: testAddContent

import org.alfresco.service.cmr.repository.ContentWriter; //导入方法依赖的package包/类
public void testAddContent() throws Exception
{
    ContentWriter writer = getWriter();
    writer.putContent(SOME_CONTENT);
    String contentUrl = writer.getContentUrl();
    
    checkForUrl(contentUrl, true);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:9,代码来源:AggregatingContentStoreTest.java

示例10: testDelete

import org.alfresco.service.cmr.repository.ContentWriter; //导入方法依赖的package包/类
public void testDelete() throws Exception
{
    
    // write some content
    ContentWriter writer = getWriter();
    writer.putContent(SOME_CONTENT);
    String contentUrl = writer.getContentUrl();
    
    ContentReader reader = primaryStore.getReader(contentUrl);
    assertTrue("Content was not in the primary store", reader.exists());
    assertEquals("The content was incorrect", SOME_CONTENT, reader.getContentString());

    getStore().delete(contentUrl);
    checkForUrl(contentUrl, false);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:16,代码来源:AggregatingContentStoreTest.java

示例11: testReadFromSecondaryStore

import org.alfresco.service.cmr.repository.ContentWriter; //导入方法依赖的package包/类
public void testReadFromSecondaryStore()
{
    // pick a secondary store and write some content to it
    ContentStore secondaryStore = secondaryStores.get(2);
    ContentWriter writer = secondaryStore.getWriter(ContentContext.NULL_CONTEXT);
    writer.putContent(SOME_CONTENT);
    String contentUrl = writer.getContentUrl();
    
    checkForUrl(contentUrl, true);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:11,代码来源:AggregatingContentStoreTest.java

示例12: writeSingleFileInMB

import org.alfresco.service.cmr.repository.ContentWriter; //导入方法依赖的package包/类
private String writeSingleFileInMB(int sizeInMb) throws IOException
{
    ContentWriter writer = store.getWriter(ContentContext.NULL_CONTEXT);
    File content = createFileOfSize(sizeInMb * 1024);
    writer.putContent(content);
    return writer.getContentUrl();
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:8,代码来源:StandardQuotaStrategyTest.java

示例13: testGetRawReader

import org.alfresco.service.cmr.repository.ContentWriter; //导入方法依赖的package包/类
public void testGetRawReader() throws Exception
{
    ContentReader reader = contentService.getRawReader("test://non-existence");
    assertNotNull("A reader is expected with content URL referencing no content", reader);
    assertFalse("Reader should not have any content", reader.exists());
    // Now write something
    ContentWriter writer = contentService.getWriter(contentNodeRef, ContentModel.PROP_CONTENT, false);
    writer.putContent("ABC from " + getName());
    // Try again
    String contentUrl = writer.getContentUrl();
    reader = contentService.getRawReader(contentUrl);
    assertNotNull("Expected reader for live, raw content", reader);
    assertEquals("Content sizes don't match", writer.getSize(), reader.getSize());
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:15,代码来源:RoutingContentServiceTest.java

示例14: getWriter

import org.alfresco.service.cmr.repository.ContentWriter; //导入方法依赖的package包/类
@Override
public ContentWriter getWriter(final ContentContext context)
{
    if (cacheOnInbound)
    {
        final ContentWriter bsWriter = backingStore.getWriter(context);

        if (!quota.beforeWritingCacheFile(0))
        {
            return bsWriter;
        }
        
        // Writing will be performed straight to the cache.
        final String url = bsWriter.getContentUrl();
        final BackingStoreAwareCacheWriter cacheWriter = new BackingStoreAwareCacheWriter(cache.getWriter(url), bsWriter);
        
        // When finished writing perform these actions.
        cacheWriter.addListener(new ContentStreamListener()
        {
            @Override
            public void contentStreamClosed() throws ContentIOException
            {
                // Finished writing to the cache, so copy to the backing store -
                // ensuring that the encoding attributes are set to the same as for the cache writer.
                bsWriter.setEncoding(cacheWriter.getEncoding());
                bsWriter.setLocale(cacheWriter.getLocale());
                bsWriter.setMimetype(cacheWriter.getMimetype());
                bsWriter.putContent(cacheWriter.getReader());
                boolean contentUrlChanged = !url.equals(bsWriter.getContentUrl());
                
                // MNT-11758 fix, re-cache files for which content url has changed after write to backing store (e.g. XAM, Centera)
                if (!quota.afterWritingCacheFile(cacheWriter.getSize()) || contentUrlChanged)
                {
                    if (contentUrlChanged)
                    {
                        // MNT-11758 fix, cache file with new and correct contentUrl after write operation to backing store completed
                        cache.put(bsWriter.getContentUrl(), cacheWriter.getReader());
                    }
                    // Quota manager has requested that the new cache file is not kept.
                    cache.deleteFile(url);
                    cache.remove(url);
                }
            }
        });
        
        return cacheWriter;
    }
    else
    {
        // No need to invalidate the cache for this content URL, since a content URL
        // is only ever written to once.
        return backingStore.getWriter(context);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:55,代码来源:CachingContentStore.java

示例15: testGetReader

import org.alfresco.service.cmr.repository.ContentWriter; //导入方法依赖的package包/类
/**
 * Checks that the various methods of obtaining a reader are supported.
 */
@Test
public synchronized void testGetReader() throws Exception
{
    ContentStore store = getStore();
    ContentWriter writer = store.getWriter(ContentStore.NEW_CONTENT_CONTEXT);
    String contentUrl = writer.getContentUrl();
    
    // Check that a reader is available from the store
    ContentReader readerFromStoreBeforeWrite = store.getReader(contentUrl);
    assertNotNull("A reader must always be available from the store", readerFromStoreBeforeWrite);
    
    // check that a reader is available from the writer
    ContentReader readerFromWriterBeforeWrite = writer.getReader();
    assertNotNull("A reader must always be available from the writer", readerFromWriterBeforeWrite);
    
    String content = "Content for testGetReader";
    
    // write some content
    long before = System.currentTimeMillis();
    this.wait(1000L);
    writer.setMimetype("text/plain");
    writer.setEncoding("UTF-8");
    writer.setLocale(Locale.CHINESE);
    writer.putContent(content);
    this.wait(1000L);
    long after = System.currentTimeMillis();
    
    // get a reader from the store
    ContentReader readerFromStore = store.getReader(contentUrl);
    assertNotNull(readerFromStore);
    assertTrue(readerFromStore.exists());
    // Store-provided readers don't have context other than URLs
    // assertEquals(writer.getContentData(), readerFromStore.getContentData());
    assertEquals(content, readerFromStore.getContentString());
    
    // get a reader from the writer
    ContentReader readerFromWriter = writer.getReader();
    assertNotNull(readerFromWriter);
    assertTrue(readerFromWriter.exists());
    assertEquals(writer.getContentData(), readerFromWriter.getContentData());
    assertEquals(content, readerFromWriter.getContentString());
    
    // get another reader from the reader
    ContentReader readerFromReader = readerFromWriter.getReader();
    assertNotNull(readerFromReader);
    assertTrue(readerFromReader.exists());
    assertEquals(writer.getContentData(), readerFromReader.getContentData());
    assertEquals(content, readerFromReader.getContentString());
    
    // check that the length is correct
    int length = content.getBytes(writer.getEncoding()).length;
    assertEquals("Reader content length is incorrect", length, readerFromWriter.getSize());

    // check that the last modified time is correct
    long modifiedTimeCheck = readerFromWriter.getLastModified();

    // On some versionms of Linux (e.g. Centos) this test won't work as the 
    // modified time accuracy is only to the second.
    long beforeSeconds = before/1000L;
    long afterSeconds = after/1000L;
    long modifiedTimeCheckSeconds = modifiedTimeCheck/1000L;

    assertTrue("Reader last modified is incorrect", beforeSeconds <= modifiedTimeCheckSeconds);
    assertTrue("Reader last modified is incorrect", modifiedTimeCheckSeconds <= afterSeconds);
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:69,代码来源:AbstractWritableContentStoreTest.java


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