本文整理匯總了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
}
}
示例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);
}
示例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);
}