001/* 002 * (C) Copyright 2006-2015 Nuxeo SA (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-2.1.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.service; 020 021import java.io.Serializable; 022 023import org.apache.commons.lang3.SystemUtils; 024 025import org.nuxeo.common.xmap.annotation.XNode; 026import org.nuxeo.common.xmap.annotation.XObject; 027 028/** 029 * XMap descriptor for a CommandLine. 030 * 031 * @author tiry 032 */ 033@XObject("command") 034public class CommandLineDescriptor implements Serializable { 035 036 private static final long serialVersionUID = 1L; 037 038 @XNode("@name") 039 protected String name; 040 041 @XNode("@enabled") 042 protected boolean enabled; 043 044 protected boolean available; 045 046 @XNode("commandLine") 047 protected String command; 048 049 @XNode("parameterString") 050 protected String parameterString = ""; 051 052 @XNode("winParameterString") 053 protected String winParameterString; 054 055 @XNode("winCommand") 056 protected String winCommand; 057 058 @XNode("tester") 059 protected String tester; 060 061 @XNode("readOutput") 062 protected boolean readOutput = true; 063 064 @XNode("installationDirective") 065 protected String installationDirective; 066 067 protected String installErrorMessage; 068 069 public String getInstallErrorMessage() { 070 return installErrorMessage; 071 } 072 073 public void setInstallErrorMessage(String installErrorMessage) { 074 this.installErrorMessage = installErrorMessage; 075 } 076 077 public String getName() { 078 if (name == null) { 079 return getCommand(); 080 } 081 return name; 082 } 083 084 public boolean isEnabled() { 085 return enabled; 086 } 087 088 public String getCommand() { 089 if (SystemUtils.IS_OS_WINDOWS && winCommand != null) { 090 return winCommand; 091 } 092 return command; 093 } 094 095 public String getInstallationDirective() { 096 return installationDirective; 097 } 098 099 public String getTester() { 100 return tester; 101 } 102 103 public boolean isAvailable() { 104 return available; 105 } 106 107 public void setAvailable(boolean available) { 108 this.available = available; 109 } 110 111 public boolean getReadOutput() { 112 return readOutput; 113 } 114 115 public String getParametersString() { 116 if (SystemUtils.IS_OS_WINDOWS && winParameterString != null) { 117 return winParameterString; 118 } 119 return parameterString; 120 } 121 122 public String getExecutor() { 123 return CommandLineExecutorComponent.DEFAULT_EXECUTOR; 124 } 125 126}