本文整理汇总了Java中org.alfresco.service.cmr.repository.ContentReader.getContentUrl方法的典型用法代码示例。如果您正苦于以下问题:Java ContentReader.getContentUrl方法的具体用法?Java ContentReader.getContentUrl怎么用?Java ContentReader.getContentUrl使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.alfresco.service.cmr.repository.ContentReader
的用法示例。
在下文中一共展示了ContentReader.getContentUrl方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getReader
import org.alfresco.service.cmr.repository.ContentReader; //导入方法依赖的package包/类
/**
* Performs checks and copies required reader attributes
*/
public final ContentReader getReader() throws ContentIOException
{
String contentUrl = getContentUrl();
if (!isClosed())
{
return new EmptyContentReader(contentUrl);
}
ContentReader reader = createReader();
if (reader == null)
{
throw new AlfrescoRuntimeException("ContentReader failed to create new reader: \n" +
" writer: " + this);
}
else if (reader.getContentUrl() == null || !reader.getContentUrl().equals(contentUrl))
{
throw new AlfrescoRuntimeException("ContentReader has different URL: \n" +
" writer: " + this + "\n" +
" new reader: " + reader);
}
// copy across common attributes
reader.setMimetype(this.getMimetype());
reader.setEncoding(this.getEncoding());
reader.setLocale(this.getLocale());
// done
if (logger.isDebugEnabled())
{
logger.debug("Writer spawned new reader: \n" +
" writer: " + this + "\n" +
" new reader: " + reader);
}
return reader;
}
示例2: getReader
import org.alfresco.service.cmr.repository.ContentReader; //导入方法依赖的package包/类
/**
* Performs checks and copies required reader attributes
*/
public final ContentReader getReader() throws ContentIOException
{
ContentReader reader = createReader();
if (reader == null)
{
throw new AlfrescoRuntimeException("ContentReader failed to create new reader: \n" +
" reader: " + this);
}
else if (reader.getContentUrl() == null || !reader.getContentUrl().equals(getContentUrl()))
{
throw new AlfrescoRuntimeException("ContentReader has different URL: \n" +
" reader: " + this + "\n" +
" new reader: " + reader);
}
// copy across common attributes
reader.setMimetype(this.getMimetype());
reader.setEncoding(this.getEncoding());
reader.setLocale(this.getLocale());
// done
if (logger.isDebugEnabled())
{
logger.debug("Reader spawned new reader: \n" +
" reader: " + this + "\n" +
" new reader: " + reader);
}
return reader;
}
示例3: testLoad_03
import org.alfresco.service.cmr.repository.ContentReader; //导入方法依赖的package包/类
/**
* 15 files; 10 per txn; spoofed; different
*/
@Test
public void testLoad_03() throws Exception
{
try
{
AuthenticationUtil.pushAuthentication();
AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
int created = fileFolderLoader.createFiles(
writeFolderPath,
15, 10, 1024L, 1024L, Long.MAX_VALUE, false,
10, 256L);
assertEquals("Incorrect number of files generated.", 15, created);
// Count
assertEquals(15, nodeService.countChildAssocs(writeFolderNodeRef, true));
// Check the files
List<FileInfo> fileInfos = fileFolderService.listFiles(writeFolderNodeRef);
String lastText = null;
String lastDescr = null;
String lastUrl = null;
for (FileInfo fileInfo : fileInfos)
{
NodeRef fileNodeRef = fileInfo.getNodeRef();
// The URLs must all be unique as we wrote the physical binaries
ContentReader reader = fileFolderService.getReader(fileNodeRef);
assertEquals("UTF-8", reader.getEncoding());
assertEquals(MimetypeMap.MIMETYPE_TEXT_PLAIN, reader.getMimetype());
assertEquals(1024L, reader.getSize());
if (lastUrl == null)
{
lastUrl = reader.getContentUrl();
}
else
{
assertNotEquals("We expect different URLs: ", lastUrl, reader.getContentUrl());
lastUrl = reader.getContentUrl();
}
// Check content
if (lastText == null)
{
lastText = reader.getContentString();
}
else
{
String currentStr = reader.getContentString();
assertNotEquals("All text must differ due to varying seed. ", lastText, currentStr);
lastText = currentStr;
}
// Check description
if (lastDescr == null)
{
lastDescr = DefaultTypeConverter.INSTANCE.convert(String.class, nodeService.getProperty(fileNodeRef, ContentModel.PROP_DESCRIPTION));
assertEquals("cm:description length is incorrect. ", 256, lastDescr.getBytes().length);
}
else
{
String currentDescr = DefaultTypeConverter.INSTANCE.convert(String.class, nodeService.getProperty(fileNodeRef, ContentModel.PROP_DESCRIPTION));
assertNotEquals("All descriptions must differ due to varying seed. ", lastDescr, currentDescr);
lastDescr = currentDescr;
}
}
}
finally
{
AuthenticationUtil.popAuthentication();
}
}
示例4: testLoad_04
import org.alfresco.service.cmr.repository.ContentReader; //导入方法依赖的package包/类
/**
* 10 files; 10 per txn; force storage; identical
*/
@Test
public void testLoad_04() throws Exception
{
try
{
AuthenticationUtil.pushAuthentication();
AuthenticationUtil.setAdminUserAsFullyAuthenticatedUser();
int created = fileFolderLoader.createFiles(
writeFolderPath,
10, 10, 1024L, 1024L, 1L, true,
10, 256L);
assertEquals("Incorrect number of files generated.", 10, created);
// Count
assertEquals(10, nodeService.countChildAssocs(writeFolderNodeRef, true));
// Check the files
List<FileInfo> fileInfos = fileFolderService.listFiles(writeFolderNodeRef);
String lastText = null;
String lastDescr = null;
String lastUrl = null;
for (FileInfo fileInfo : fileInfos)
{
NodeRef fileNodeRef = fileInfo.getNodeRef();
// The URLs must all be unique as we wrote the physical binaries
ContentReader reader = fileFolderService.getReader(fileNodeRef);
assertEquals("UTF-8", reader.getEncoding());
assertEquals(MimetypeMap.MIMETYPE_TEXT_PLAIN, reader.getMimetype());
assertEquals(1024L, reader.getSize());
if (lastUrl == null)
{
lastUrl = reader.getContentUrl();
}
else
{
assertNotEquals("We expect unique URLs: ", lastUrl, reader.getContentUrl());
lastUrl = reader.getContentUrl();
}
// Check content
if (lastText == null)
{
lastText = reader.getContentString();
}
else
{
String currentStr = reader.getContentString();
assertEquals("All text must be identical due to same seed. ", lastText, currentStr);
lastText = currentStr;
}
// Check description
if (lastDescr == null)
{
lastDescr = DefaultTypeConverter.INSTANCE.convert(String.class, nodeService.getProperty(fileNodeRef, ContentModel.PROP_DESCRIPTION));
assertEquals("cm:description length is incorrect. ", 256, lastDescr.getBytes().length);
}
else
{
String currentDescr = DefaultTypeConverter.INSTANCE.convert(String.class, nodeService.getProperty(fileNodeRef, ContentModel.PROP_DESCRIPTION));
assertEquals("All descriptions must be identical due to varying seed. ", lastDescr, currentDescr);
lastDescr = currentDescr;
}
}
}
finally
{
AuthenticationUtil.popAuthentication();
}
}