001/* 002 * (C) Copyright 2006-2011 Nuxeo SAS (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Nuxeo - initial API and implementation 016 * 017 */ 018 019package org.nuxeo.ecm.platform.commandline.executor.api; 020 021/** 022 * Exception indicating that the target command is not available: 023 * <ul> 024 * <li>because it was never registered, 025 * <li>because it was disabled, 026 * <li>because the target command is not installed on the server *. 027 * </ul> 028 * 029 * @author tiry 030 */ 031public class CommandNotAvailable extends Exception { 032 033 private static final long serialVersionUID = 1L; 034 035 protected final CommandAvailability availability; 036 037 public CommandNotAvailable(CommandAvailability availability) { 038 this.availability = availability; 039 } 040 041 public String getInstallMessage() { 042 return availability.getInstallMessage(); 043 } 044 045 public String getErrorMessage() { 046 return availability.getErrorMessage(); 047 } 048 049 /** 050 * @since 5.5 051 */ 052 @Override 053 public String getMessage() { 054 String msg = getErrorMessage() != null ? getErrorMessage() + ". " : ""; 055 msg += getInstallMessage() != null ? getInstallMessage() + ". " : ""; 056 return msg + super.getMessage(); 057 } 058 059}