String executable;
String workingDir = null;
Map<String, String> envvars = null;
if (executableProp == null) {
throw new InvalidPluginConfigurationException("Missing required plugin config: " + PLUGINCONFIG_EXECUTABLE);
} else {
executable = executableProp.getStringValue();
if (executable == null || executable.length() == 0) {
throw new InvalidPluginConfigurationException("Bad plugin config: " + PLUGINCONFIG_EXECUTABLE);
}
}
if (workingDirProp != null) {
workingDir = workingDirProp.getStringValue();
if (workingDir != null && workingDir.length() == 0) {
workingDir = null; // empty string is as good as unsetting it (i.e. making it null)
}
}
if (envvarsProp != null) {
try {
// we want envvars to be null if there are no envvars defined, so the agent env is passed
// but if there are 1 or more envvars in our config, then we define our envvars list
List<Property> listOfMaps = envvarsProp.getList();
if (listOfMaps.size() > 0) {
envvars = new HashMap<String, String>();
for (Property envvarMap : listOfMaps) {
PropertySimple name = (PropertySimple) ((PropertyMap) envvarMap).get(PLUGINCONFIG_ENVVAR_NAME);
PropertySimple value = (PropertySimple) ((PropertyMap) envvarMap)
.get(PLUGINCONFIG_ENVVAR_VALUE);
envvars.put(name.getStringValue(), value.getStringValue());
}
}
} catch (Exception e) {
throw new InvalidPluginConfigurationException("Bad plugin config: " + PLUGINCONFIG_ENVVARS
+ ". Cause: " + e);
}
}
ProcessExecution processExecution = new ProcessExecution(executable);