AnsweredAssumed Answered

Types for audio and video

Question asked by aussen2 on Aug 31, 2011
Latest reply on Aug 31, 2011 by aussen2
I would like to suggest that you add general types for audio and video (ws:audio and ws:video) like you did for images (ws:image). For my current project I added theses types and the necessary changes were quite simple. But I also had to implement some minor additions to SectionType.java in order to get uploaded files specialized correctly according to their mimetype). It would be great if I would not have to re-implement these changes for every future release. :-)


// 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");
}

Outcomes