本文整理汇总了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);
}