001/* 002 * (C) Copyright 2006-2015 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Nuxeo - initial API and implementation 018 * 019 */ 020 021package org.nuxeo.ecm.platform.commandline.executor.service; 022 023import org.apache.commons.lang3.builder.ToStringBuilder; 024import org.apache.commons.lang3.builder.ToStringStyle; 025import org.apache.commons.lang3.SystemUtils; 026 027import org.nuxeo.common.xmap.annotation.XNode; 028import org.nuxeo.common.xmap.annotation.XObject; 029 030/** 031 * XMap descriptor for a CommandLine. 032 * 033 * @author tiry 034 */ 035@XObject("command") 036public class CommandLineDescriptor { 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 /* 053 * @since 8.4 054 */ 055 @XNode("testParameterString") 056 protected String testParameterString = ""; 057 058 @XNode("winParameterString") 059 protected String winParameterString; 060 061 /* 062 * @since 8.4 063 */ 064 @XNode("winTestParameterString") 065 protected String winTestParameterString = ""; 066 067 @XNode("winCommand") 068 protected String winCommand; 069 070 @XNode("tester") 071 protected String tester; 072 073 @XNode("readOutput") 074 protected boolean readOutput = true; 075 076 @XNode("installationDirective") 077 protected String installationDirective; 078 079 protected String installErrorMessage; 080 081 public String getInstallErrorMessage() { 082 return installErrorMessage; 083 } 084 085 public void setInstallErrorMessage(String installErrorMessage) { 086 this.installErrorMessage = installErrorMessage; 087 } 088 089 public String getName() { 090 if (name == null) { 091 return getCommand(); 092 } 093 return name; 094 } 095 096 public boolean isEnabled() { 097 return enabled; 098 } 099 100 public String getCommand() { 101 if (SystemUtils.IS_OS_WINDOWS && winCommand != null) { 102 return winCommand; 103 } 104 return command; 105 } 106 107 public String getInstallationDirective() { 108 return installationDirective; 109 } 110 111 public String getTester() { 112 return tester; 113 } 114 115 public boolean isAvailable() { 116 return available; 117 } 118 119 public void setAvailable(boolean available) { 120 this.available = available; 121 } 122 123 public boolean getReadOutput() { 124 return readOutput; 125 } 126 127 public String getParametersString() { 128 if (SystemUtils.IS_OS_WINDOWS && winParameterString != null) { 129 return winParameterString; 130 } 131 return parameterString; 132 } 133 134 /* 135 * @since 8.4 136 */ 137 public String getTestParametersString() { 138 if (SystemUtils.IS_OS_WINDOWS && winTestParameterString != null) { 139 return winTestParameterString; 140 } 141 return testParameterString; 142 } 143 144 public String getExecutor() { 145 return CommandLineExecutorComponent.DEFAULT_EXECUTOR; 146 } 147 148 @Override 149 public String toString() { 150 return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); 151 } 152 153}