Java Code Examples for org.alfresco.service.cmr.repository.ContentData.hasContent()

The following are Jave code examples for showing how to use hasContent() of the org.alfresco.service.cmr.repository.ContentData class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: alfresco-repository   File: ScriptNode.java   View Source Code Vote up 6 votes
/**
 * 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()]);
}
 
Example 2
Project: alfresco-repository   File: ScriptNode.java   View Source Code Vote up 5 votes
/**
 * Constructor
 * 
 * @param contentData      The ContentData object this object wraps
 * @param property         The property the ContentData is attached too
 */
public ScriptContentData(ContentData contentData, QName property)
{
    this.contentData = contentData;
    this.property = property;
    this.isDirty = ContentData.hasContent(contentData);
}
 
Example 3
Project: alfresco-remote-api   File: RenditionsImpl.java   View Source Code Vote up 5 votes
private ContentData getContentData(NodeRef nodeRef, boolean validate)
{
    ContentData contentData = (ContentData) nodeService.getProperty(nodeRef, ContentModel.PROP_CONTENT);
    if (validate && !ContentData.hasContent(contentData))
    {
        throw new InvalidArgumentException("Node id '" + nodeRef.getId() + "' has no content.");
    }
    return contentData;
}