08-31-2011 12:03 PM
// Check to see if this is an image, audio or video
ContentReader reader = contentService.getReader(childNode, ContentModel.PROP_CONTENT);
if (reader != null && reader.exists())
{
String mimetype = reader.getMimetype();
if (mimetype != null && mimetype.trim().length() != 0)
{
if (isImageMimetype(reader.getMimetype()) == true)
{
// Make content node an image
nodeService.setType(childNode, TYPE_IMAGE);
}
else if (isAudioMimetype(reader.getMimetype()) == true)
{
// Make content node an audio
nodeService.setType(childNode, TYPE_AUDIO);
}
else if (isVideoMimetype(reader.getMimetype()) == true)
{
// Make content node a video
nodeService.setType(childNode, TYPE_VIDEO);
}
else if (mimetypeMap.isText(reader.getMimetype()) == true)
{
// Make the content node an article
nodeService.setType(childNode, TYPE_ARTICLE);
}
}
}
/**
* Indicates whether this is an image mimetype or not.
*
* @param mimetype
* mimetype
* @return boolean true if image mimetype, false otherwise
*/
private boolean isImageMimetype(String mimetype)
{
return mimetype.startsWith("image");
}
/**
* Indicates whether this is an audio mimetype or not.
*
* @param mimetype
* mimetype
* @return boolean true if audio mimetype, false otherwise
*/
private boolean isAudioMimetype(String mimetype)
{
return mimetype.startsWith("audio");
}
/**
* Indicates whether this is a video mimetype or not.
*
* @param mimetype
* mimetype
* @return boolean true if video mimetype, false otherwise
*/
private boolean isVideoMimetype(String mimetype)
{
return mimetype.startsWith("video");
}
08-31-2011 12:06 PM
08-31-2011 12:29 PM
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.