use of com.axway.ats.core.atsconfig.exceptions.AtsConfigurationException in project ats-framework by Axway.
the class AtsProjectConfiguration method save.
public void save() throws AtsConfigurationException {
// save the XML file
try {
OutputFormat format = new OutputFormat(doc);
format.setIndenting(true);
format.setIndent(4);
format.setLineWidth(1000);
XMLSerializer serializer = new XMLSerializer(new FileOutputStream(new File(atsConfigurationFile)), format);
serializer.serialize(doc);
} catch (Exception e) {
throw new AtsConfigurationException("Error saving ATS configuration in '" + atsConfigurationFile + "'", e);
}
}
use of com.axway.ats.core.atsconfig.exceptions.AtsConfigurationException in project ats-framework by Axway.
the class PathInfo method loadInternalFilesMap.
public void loadInternalFilesMap() throws AtsConfigurationException {
if (!isFile) {
File folder = new File(this.path);
if (!folder.exists() || !folder.isDirectory()) {
throw new AtsConfigurationException("Directory '" + this.path + "' doesn't exist or is not a directory");
}
collectFiles(folder, isRecursive);
}
}
use of com.axway.ats.core.atsconfig.exceptions.AtsConfigurationException in project ats-framework by Axway.
the class AtsProjectConfiguration method loadConfigurationFile.
public void loadConfigurationFile() {
sourceProject = null;
agents.clear();
applications.clear();
shellCommands.clear();
try {
doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new File(atsConfigurationFile));
doc.getDocumentElement().normalize();
} catch (Exception e) {
throw new AtsConfigurationException("Error reading ATS configuration file '" + atsConfigurationFile + "'", e);
}
Element atsProjectNode = doc.getDocumentElement();
if (!NODE_ATS_PROJECT.equals(atsProjectNode.getNodeName())) {
throw new AtsConfigurationException("Bad ATS configuration file. Root node name is expected to be '" + NODE_ATS_PROJECT + "', but it is '" + atsProjectNode.getNodeName() + "'");
}
// project with source libraries
List<Element> sourceNodes = XmlUtils.getChildrenByTagName(atsProjectNode, NODE_SOURCE_PROJECT);
if (sourceNodes.size() != 1) {
throw new AtsConfigurationException("Bad ATS configuration file. We must have exactly 1 " + NODE_SOURCE_PROJECT + " node, but we got " + sourceNodes.size());
}
sourceProject = new AtsSourceProjectInfo(sourceNodes.get(0));
// load the default agent values
final Map<String, String> agentDefaultValues = readAgentGlobalProperties(atsProjectNode);
// ATS agents
List<Element> agentNodes = XmlUtils.getChildrenByTagName(atsProjectNode, NODE_ATS_AGENT);
for (Element agentNode : agentNodes) {
String agentAlias = XmlUtils.getMandatoryAttribute(agentNode, NODE_ATTRIBUTE_ALIAS);
if (agents.containsKey(agentAlias)) {
throw new AtsConfigurationException("'" + agentAlias + "' is not a unique agent alias");
}
agents.put(agentAlias, new AgentInfo(agentAlias, agentNode, agentDefaultValues));
}
// make sure we do not have same: host + port or host + path
checkForDuplicatedHostAndPort(agents);
checkForDuplicatedHostAndHome(agents);
// Generic applications
List<Element> applicationNodes = XmlUtils.getChildrenByTagName(atsProjectNode, NODE_APPLICATION);
for (Element applicationNode : applicationNodes) {
String applicationAlias = XmlUtils.getMandatoryAttribute(applicationNode, NODE_ATTRIBUTE_ALIAS);
if (applications.containsKey(applicationAlias)) {
throw new AtsConfigurationException("'" + applicationAlias + "' is not a unique application alias");
}
applications.put(applicationAlias, new ApplicationInfo(applicationAlias, applicationNode, agentDefaultValues));
}
// make sure we do not have same: host + port or host + path
checkForDuplicatedHostAndPort(applications);
checkForDuplicatedHostAndHome(applications);
// Shell commands
List<Element> shellCommandsNodes = XmlUtils.getChildrenByTagName(atsProjectNode, NODE_SHELL_COMMANDS);
if (shellCommandsNodes.size() > 0) {
// now get the actual commands
shellCommandsNodes = XmlUtils.getChildrenByTagName(shellCommandsNodes.get(0), "command");
for (Element commandNode : shellCommandsNodes) {
String shellCommandAlias = XmlUtils.getAttribute(commandNode, NODE_ATTRIBUTE_ALIAS);
String theCommand = commandNode.getTextContent();
shellCommands.add(new ShellCommand(shellCommandAlias, theCommand));
}
}
}
Aggregations