public static String normalizeArtifactPath(final String path, final File file) { if (StringUtil.isEmpty(path)) { return file.getName(); } else { return FileUtil.normalizeRelativePath(String.format("%s/%s", path, file.getName())); } }
public void run() FileUtil.processXmlFile(SlackNotificationMainConfig.this.myConfigFile, new FileUtil.Processor() { public void process(Element rootElement) { rootElement.setAttribute("enabled", Boolean.toString(SlackNotificationMainConfig.this.enabled));
private IssueData parseIssue(final InputStream _xml) { try { Element issue = FileUtil.parseDocument(_xml, false); String summary = getChildContent(issue, "subject"); String state = getAttribute(issue.getChild("status"), "name"); String url = getUrl(host, id); boolean resolved = state.equalsIgnoreCase("Closed") || getChildContent(issue, "done_ratio").equals("100"); IssueData result = new IssueData(id, summary, state, url, resolved); return result; } catch (JDOMException e) { throw new RuntimeException(String.format("Error parsing XML for issue '%s' on '%s'.", id, host)); } catch (IOException e) { throw new RuntimeException(String.format("Error reading XML for issue '%s' on '%s'.", id, host)); } } }
private void reloadConfiguration() { Loggers.ACTIVITIES.info("Loading configuration file: " + this.myConfigFile.getAbsolutePath()); myConfigDir.mkdirs(); FileUtil.copyResourceIfNotExists(getClass(), "/config_templates/slack-config.xml", new File(this.myConfigDir, "slack-config.xml")); Document document = parseFile(this.myConfigFile); if (document != null) { Element rootElement = document.getRootElement(); readConfigurationFromXmlElement(rootElement); } }
private String getCustomScriptExecutable(AnsibleRunConfig config) throws RunBuildException { String content = null; File scriptFile = null; if (config.getSourceCode() != null) { content = config.getSourceCode().replace("\r\n", "\n").replace("\r", "\n"); } if (StringUtil.isEmptyOrSpaces(content)) { throw new RunBuildException("Custom script source code cannot be empty"); } try { scriptFile = File.createTempFile("ansible_custom_exe", null, getBuildTempDirectory()); FileUtil.writeFileAndReportErrors(scriptFile, content); } catch (IOException e) { throw new RunBuildException("Failed to create a tmp file for custom ansible execution script"); } boolean executable = scriptFile.setExecutable(true, true); if (!executable) { throw new RunBuildException("Failed to set executable permissions to " + scriptFile.getAbsolutePath()); } return scriptFile.getAbsolutePath(); }