001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portlet.documentlibrary.antivirus;
016    
017    import com.liferay.portal.kernel.exception.PortalException;
018    
019    /**
020     * @author Michael C. Han
021     * @author Hugo Huijser
022     */
023    public class AntivirusScannerException extends PortalException {
024    
025            public static final int PROCESS_FAILURE = 1;
026    
027            public static final int VIRUS_DETECTED = 2;
028    
029            public AntivirusScannerException() {
030                    super();
031            }
032    
033            public AntivirusScannerException(int type) {
034                    _type = type;
035            }
036    
037            public AntivirusScannerException(String msg) {
038                    super(msg);
039            }
040    
041            public AntivirusScannerException(String msg, int type) {
042                    super(msg);
043    
044                    _type = type;
045            }
046    
047            public AntivirusScannerException(String msg, Throwable cause) {
048                    super(msg, cause);
049            }
050    
051            public AntivirusScannerException(Throwable cause) {
052                    super(cause);
053            }
054    
055            public String getMessageKey() {
056                    if (_type == PROCESS_FAILURE) {
057                            return "unable-to-scan-file-for-viruses";
058                    }
059                    else if (_type == VIRUS_DETECTED) {
060                            return "a-virus-was-detected-in-the-file";
061                    }
062    
063                    return null;
064            }
065    
066            private int _type;
067    
068    }