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.AudioProcessorUtil;
021    
022    import java.util.Set;
023    
024    /**
025     * @author Juan Gonzalez
026     */
027    public class AudioCommandReceiver extends BaseFileEntryCommandReceiver {
028    
029            @Override
030            protected String[] getFileEntryMimeTypes() {
031                    Set<String> audioMimeTypes = AudioProcessorUtil.getAudioMimeTypes();
032    
033                    if (audioMimeTypes == null) {
034                            return null;
035                    }
036    
037                    return ArrayUtil.toStringArray(audioMimeTypes.toArray());
038            }
039    
040            @Override
041            protected String getUnavaiablePreviewErrorMessage() {
042                    return _UNAVAIABLE_PREVIEW_ERROR_MESSAGE;
043            }
044    
045            @Override
046            protected int getXugglerDisabledFileUploadReturnValue() {
047                    return ServletResponseConstants.SC_AUDIO_PREVIEW_DISABLED_EXCEPTION;
048            }
049    
050            @Override
051            protected boolean hasFileEntryPreview(FileVersion fileVersion) {
052                    return AudioProcessorUtil.hasAudio(fileVersion);
053            }
054    
055            private static final String _UNAVAIABLE_PREVIEW_ERROR_MESSAGE =
056                    "the-audio-preview-is-not-yet-ready.-please-try-again-later";
057    
058    }