001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portal.editor.fckeditor.receiver.impl;
016    
017    import com.liferay.portal.kernel.repository.model.FileVersion;
018    import com.liferay.portal.kernel.servlet.ServletResponseConstants;
019    import com.liferay.portal.kernel.util.ArrayUtil;
020    import com.liferay.portlet.documentlibrary.util.VideoProcessorUtil;
021    
022    import java.util.Set;
023    
024    /**
025     * @author Juan Gonzalez
026     * @author Roberto D??az
027     */
028    public class VideoCommandReceiver extends BaseFileEntryCommandReceiver {
029    
030            @Override
031            protected String[] getFileEntryMimeTypes() {
032                    Set<String> videoMimeTypes = VideoProcessorUtil.getVideoMimeTypes();
033    
034                    if (videoMimeTypes == null) {
035                            return null;
036                    }
037    
038                    return ArrayUtil.toStringArray(videoMimeTypes.toArray());
039            }
040    
041            @Override
042            protected String getUnavaiablePreviewErrorMessage() {
043                    return _UNAVAIABLE_PREVIEW_ERROR_MESSAGE;
044            }
045    
046            @Override
047            protected int getXugglerDisabledFileUploadReturnValue() {
048                    return ServletResponseConstants.SC_VIDEO_PREVIEW_DISABLED_EXCEPTION;
049            }
050    
051            @Override
052            protected boolean hasFileEntryPreview(FileVersion fileVersion) {
053                    return VideoProcessorUtil.hasVideo(fileVersion);
054            }
055    
056            private static final String _UNAVAIABLE_PREVIEW_ERROR_MESSAGE =
057                    "the-video-preview-is-not-yet-ready.-please-try-again-later";
058    
059    }