當前位置: 首頁>>代碼示例>>Java>>正文


Java ContentExistsException類代碼示例

本文整理匯總了Java中org.alfresco.repo.content.ContentExistsException的典型用法代碼示例。如果您正苦於以下問題:Java ContentExistsException類的具體用法?Java ContentExistsException怎麽用?Java ContentExistsException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ContentExistsException類屬於org.alfresco.repo.content包,在下文中一共展示了ContentExistsException類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testConcurrentWriteDetection

import org.alfresco.repo.content.ContentExistsException; //導入依賴的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

示例2: testSpoofedContent

import org.alfresco.repo.content.ContentExistsException; //導入依賴的package包/類
/**
 * Ensure that the store is able to produce readers for spoofed text.
 * 
 * @since 5.1
 */
@Test
public void testSpoofedContent() throws Exception
{
    String url = SpoofedTextContentReader.createContentUrl(Locale.ENGLISH, 0L, 1024L);
    ContentContext ctx = new ContentContext(null, url);
    try
    {
        store.getWriter(ctx);
        fail("FileContentStore should report that all 'spoof' content exists.");
    }
    catch (ContentExistsException e)
    {
        // Expected
    }
    assertFalse("Deletion should be 'false'.", store.delete(url));
    assertTrue("All spoofed content already exists!", store.exists(url));
    ContentReader reader = store.getReader(url);
    assertTrue(reader instanceof SpoofedTextContentReader);
    assertEquals(1024L, reader.getContentString().getBytes("UTF-8").length);
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:26,代碼來源:FileContentStoreTest.java

示例3: getWriter

import org.alfresco.repo.content.ContentExistsException; //導入依賴的package包/類
/**
 *
 * {@inheritDoc}
 */
@Override
public ContentWriter getWriter(final ContentContext context)
{
    if (!this.isWriteSupported())
    {
        LOGGER.debug("Write requests are not supported for this store:\n\tStore:   {}\n\tContext: {}", this, context);
        throw new UnsupportedOperationException("Write operations are not supported by this store: " + this);
    }

    final String contentUrl = context.getContentUrl();
    if (contentUrl != null)
    {
        if (!this.isContentUrlSupported(contentUrl))
        {
            LOGGER.debug("Specific writer content URL is unsupported: \n\tStore:   {}\n\tContext: {}", this, context);
            throw new UnsupportedContentUrlException(this, contentUrl);
        }
        else if (this.exists(contentUrl))
        {
            LOGGER.debug("The content location is already used: \n\tStore:   {}\n\tContext: {}", this, context);
            throw new ContentExistsException(this, contentUrl);
        }
    }

    return this.backingStore.getWriter(context);
}
 
開發者ID:Acosix,項目名稱:alfresco-simple-content-stores,代碼行數:31,代碼來源:CommonFacadingContentStore.java


注:本文中的org.alfresco.repo.content.ContentExistsException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。