本文整理汇总了Java中org.alfresco.service.cmr.repository.ContentData类的典型用法代码示例。如果您正苦于以下问题:Java ContentData类的具体用法?Java ContentData怎么用?Java ContentData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ContentData类属于org.alfresco.service.cmr.repository包,在下文中一共展示了ContentData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: contentImpl
import org.alfresco.service.cmr.repository.ContentData; //导入依赖的package包/类
@Override
public void contentImpl(NodeRef nodeRef, QName property, InputStream content, ContentData contentData, int index)
{
// if the content stream to output is empty, then just return content descriptor as is
if (content == null)
{
return;
}
try
{
// ALF-2016
ZipArchiveEntry zipEntry=new ZipArchiveEntry(getPath());
zipStream.putArchiveEntry(zipEntry);
// copy export stream to zip
copyStream(zipStream, content);
zipStream.closeArchiveEntry();
filesAddedCount = filesAddedCount + 1;
}
catch (IOException e)
{
throw new ExporterException("Failed to zip export stream", e);
}
}
示例2: addContent
import org.alfresco.service.cmr.repository.ContentData; //导入依赖的package包/类
/**
*
*/
public void addContent(ContentData data) throws TransferException
{
logger.debug("add content size:" + data.getSize());
buffer.add(data);
/**
* work out whether the buffer has filled up and needs to be flushed
*/
Iterator<ContentData> iter = buffer.iterator();
long totalContentSize = 0;
while (iter.hasNext())
{
ContentData x = (ContentData)iter.next();
totalContentSize += x.getSize();
}
if(logger.isDebugEnabled())
{
logger.debug("elements " + buffer.size() + ", totalContentSize:" + totalContentSize);
}
if(totalContentSize >= chunkSize)
{
flush();
}
}
示例3: Document
import org.alfresco.service.cmr.repository.ContentData; //导入依赖的package包/类
public Document(NodeRef nodeRef, NodeRef parentNodeRef, Map<QName, Serializable> nodeProps, Map<String, UserInfo> mapUserInfo, ServiceRegistry sr)
{
super(nodeRef, parentNodeRef, nodeProps, mapUserInfo, sr);
Serializable val = nodeProps.get(ContentModel.PROP_CONTENT);
if ((val != null) && (val instanceof ContentData)) {
ContentData cd = (ContentData)val;
String mimeType = cd.getMimetype();
String mimeTypeName = sr.getMimetypeService().getDisplaysByMimetype().get(mimeType);
contentInfo = new ContentInfo(mimeType, mimeTypeName, cd.getSize(), cd.getEncoding());
}
setIsFolder(false);
setIsFile(true);
}
示例4: testEnsureCaseSensitiveStorage
import org.alfresco.service.cmr.repository.ContentData; //导入依赖的package包/类
/**
* Ensure that upper and lowercase URLs don't clash
* @throws Exception
*/
public void testEnsureCaseSensitiveStorage() throws Exception
{
ContentData contentData = getContentData();
String contentUrlUpper = contentData.getContentUrl().toUpperCase();
ContentData contentDataUpper = new ContentData(
contentUrlUpper, MimetypeMap.MIMETYPE_TEXT_PLAIN, 0L, "UTF-8", new Locale("FR"));
String contentUrlLower = contentData.getContentUrl().toLowerCase();
ContentData contentDataLower = new ContentData(
contentUrlLower, MimetypeMap.MIMETYPE_TEXT_PLAIN, 0L, "utf-8", new Locale("fr"));
Pair<Long, ContentData> resultPairUpper = create(contentDataUpper);
getAndCheck(resultPairUpper.getFirst(), contentDataUpper);
Pair<Long, ContentData> resultPairLower = create(contentDataLower);
getAndCheck(resultPairLower.getFirst(), contentDataLower);
}
示例5: onSetUpInTransaction
import org.alfresco.service.cmr.repository.ContentData; //导入依赖的package包/类
@Override
protected void onSetUpInTransaction() throws Exception
{
super.onSetUpInTransaction();
this.transactionHelper = (RetryingTransactionHelper)this.applicationContext.getBean("retryingTransactionHelper");
// Create the node used for tests
this.nodeRef = this.nodeService.createNode(
this.rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName("{test}testnode"),
ContentModel.TYPE_CONTENT).getChildRef();
this.nodeService.setProperty(
this.nodeRef,
ContentModel.PROP_CONTENT,
new ContentData(null, MimetypeMap.MIMETYPE_TEXT_PLAIN, 0L, null));
this.folder = this.nodeService.createNode(
this.rootNodeRef,
ContentModel.ASSOC_CHILDREN,
QName.createQName("{test}testFolder"),
ContentModel.TYPE_FOLDER).getChildRef();
// Register the test executor, if needed
SleepActionExecuter.registerIfNeeded(applicationContext);
}
示例6: makeNode
import org.alfresco.service.cmr.repository.ContentData; //导入依赖的package包/类
/**
* Creates a node with two properties
*/
public void makeNode(ContentData contentData)
{
StoreRef storeRef = new StoreRef(StoreRef.PROTOCOL_WORKSPACE, "SpacesStore");
Long rootNodeId = nodeDAO.newStore(storeRef).getFirst();
ChildAssocEntity assoc = nodeDAO.newNode(
rootNodeId,
ContentModel.ASSOC_CHILDREN,
ContentModel.ASSOC_CHILDREN,
storeRef,
null,
ContentModel.TYPE_CONTENT,
I18NUtil.getLocale(),
null,
null);
Long nodeId = assoc.getChildNode().getId();
nodeDAO.addNodeProperty(nodeId, contentQName, contentData);
}
示例7: toContentData
import org.alfresco.service.cmr.repository.ContentData; //导入依赖的package包/类
/**
* ALF-17483: It's possible that even for a single-valued contentdata property, its definition may have been changed
* and the previous persisted value is multi-valued, so let's be careful about converting to ContentData.
*
* @param object
* property value to convert
* @return a ContentData if one can be extracted
*/
private static ContentData toContentData(Object object)
{
if (object == null)
{
return null;
}
if (object instanceof ContentData)
{
return (ContentData) object;
}
if (object instanceof Collection<?> && !((Collection<?>) object).isEmpty())
{
return toContentData(((Collection<?>) object).iterator().next());
}
return null;
}
示例8: getThumbnailDefinitions
import org.alfresco.service.cmr.repository.ContentData; //导入依赖的package包/类
/**
* Returns the names of the thumbnail defintions that can be applied to the content property of
* this node.
* <p>
* Thumbanil defintions only appear in this list if they can produce a thumbnail for the content
* found in the content property. This will be determined by looking at the mimetype of the content
* and the destinatino mimetype of the thumbnail.
*
* @return String[] array of thumbnail names that are valid for the current content type
*/
public String[] getThumbnailDefinitions()
{
ThumbnailService thumbnailService = this.services.getThumbnailService();
List<String> result = new ArrayList<String>(7);
Serializable value = this.nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT);
ContentData contentData = DefaultTypeConverter.INSTANCE.convert(ContentData.class, value);
if (ContentData.hasContent(contentData))
{
String mimetype = contentData.getMimetype();
List<ThumbnailDefinition> thumbnailDefinitions = thumbnailService.getThumbnailRegistry().getThumbnailDefinitions(mimetype, contentData.getSize());
for (ThumbnailDefinition thumbnailDefinition : thumbnailDefinitions)
{
result.add(thumbnailDefinition.getName());
}
}
return (String[])result.toArray(new String[result.size()]);
}
示例9: toApiRendition
import org.alfresco.service.cmr.repository.ContentData; //导入依赖的package包/类
protected Rendition toApiRendition(NodeRef renditionNodeRef)
{
Rendition apiRendition = new Rendition();
String renditionName = (String) nodeService.getProperty(renditionNodeRef, ContentModel.PROP_NAME);
apiRendition.setId(renditionName);
ContentData contentData = getContentData(renditionNodeRef, false);
ContentInfo contentInfo = null;
if (contentData != null)
{
contentInfo = new ContentInfo(contentData.getMimetype(),
getMimeTypeDisplayName(contentData.getMimetype()),
contentData.getSize(),
contentData.getEncoding());
}
apiRendition.setContent(contentInfo);
apiRendition.setStatus(RenditionStatus.CREATED);
return apiRendition;
}
示例10: testDelete
import org.alfresco.service.cmr.repository.ContentData; //导入依赖的package包/类
public void testDelete() throws Exception
{
ContentData contentData = getContentData();
Pair<Long, ContentData> resultPair = create(contentData);
getAndCheck(resultPair.getFirst(), contentData);
delete(resultPair.getFirst());
try
{
getAndCheck(resultPair.getFirst(), contentData);
fail("Entity still exists");
}
catch (Throwable e)
{
// Expected
}
}
示例11: updateContentData
import org.alfresco.service.cmr.repository.ContentData; //导入依赖的package包/类
@Override
public void updateContentData(Long id, ContentData contentData)
{
if (id == null)
{
throw new IllegalArgumentException("Cannot look up ContentData by null ID.");
}
if (contentData == null)
{
throw new IllegalArgumentException("Cannot update ContentData with a null.");
}
contentData = sanitizeMimetype(contentData);
int updated = contentDataCache.updateValue(id, contentData);
if (updated < 1)
{
throw new ConcurrencyFailureException("ContentData with ID " + id + " not updated");
}
}
示例12: deleteContentDataEntity
import org.alfresco.service.cmr.repository.ContentData; //导入依赖的package包/类
@Override
protected int deleteContentDataEntity(Long id)
{
// Get the content urls
try
{
ContentData contentData = getContentData(id).getSecond();
String contentUrl = contentData.getContentUrl();
if (contentUrl != null)
{
// It has been dereferenced and may be orphaned - we'll check later
registerDereferencedContentUrl(contentUrl);
}
}
catch (DataIntegrityViolationException e)
{
// Doesn't exist. The node doesn't enforce a FK constraint, so we protect against this.
}
// Issue the delete statement
Map<String, Object> params = new HashMap<String, Object>(11);
params.put("id", id);
return template.delete(DELETE_CONTENT_DATA, params);
}
示例13: convert
import org.alfresco.service.cmr.repository.ContentData; //导入依赖的package包/类
@Override
Serializable convert(Serializable value)
{
if (value instanceof Long)
{
return value;
}
else if (value instanceof String)
{
logger.warn("Content URL converter has not run to completion: " + value);
return DefaultTypeConverter.INSTANCE.convert(ContentData.class, value);
}
else
{
return DefaultTypeConverter.INSTANCE.convert(ContentData.class, value);
}
}
示例14: getContentData
import org.alfresco.service.cmr.repository.ContentData; //导入依赖的package包/类
protected ContentData getContentData(CMISNodeInfo nodeInfo)
{
if (!nodeInfo.isDocument())
{
return null;
}
if (nodeInfo.containsPropertyValue(CONTENT_PROPERTY))
{
return (ContentData) nodeInfo.getPropertyValue(CONTENT_PROPERTY);
} else
{
ContentData contentData = null;
Serializable value = nodeInfo.getNodeProps().get(ContentModel.PROP_CONTENT);
if (value != null)
{
contentData = DefaultTypeConverter.INSTANCE.convert(ContentData.class, value);
}
nodeInfo.putPropertyValue(CONTENT_PROPERTY, contentData);
return contentData;
}
}
示例15: createCorruptedContent
import org.alfresco.service.cmr.repository.ContentData; //导入依赖的package包/类
private NodeRef createCorruptedContent(NodeRef parentFolder) throws IOException
{
// The below pdf file has been truncated such that it is identifiable as a PDF but otherwise corrupt.
File corruptPdfFile = AbstractContentTransformerTest.loadNamedQuickTestFile("quickCorrupt.pdf");
assertNotNull("Failed to load required test file.", corruptPdfFile);
Map<QName, Serializable> props = new HashMap<QName, Serializable>();
props.put(ContentModel.PROP_NAME, "corrupt.pdf");
NodeRef node = this.secureNodeService.createNode(parentFolder, ContentModel.ASSOC_CONTAINS,
QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "quickCorrupt.pdf"),
ContentModel.TYPE_CONTENT, props).getChildRef();
secureNodeService.setProperty(node, ContentModel.PROP_CONTENT, new ContentData(null,
MimetypeMap.MIMETYPE_PDF, 0L, null));
ContentWriter writer = contentService.getWriter(node, ContentModel.PROP_CONTENT, true);
writer.setMimetype(MimetypeMap.MIMETYPE_PDF);
writer.setEncoding("UTF-8");
writer.putContent(corruptPdfFile);
return node;
}