/** * * @param node the node {@link Element} * @param attributeName the attribute name * @param defaultValue a default attribute value * @return the attribute value */ public static String getAttribute( Element node, String attributeName, String defaultValue ) { String attributeValue = getAttribute(node, attributeName); if (attributeValue == null) { attributeValue = defaultValue; } return attributeValue; }
public void setAgentZip( String agentZip ) { this.agentZip = agentZip; XmlUtils.setAttribute(sourceNode, "agentZip", this.agentZip); }
this.home = IoUtils.normalizeDirPath(XmlUtils.getAttribute(sourceNode, AtsProjectConfiguration.NODE_ATTRIBUTE_HOME, "")); List<Element> agentZipElements = XmlUtils.getChildrenByTagName(sourceNode, "agentZip"); if (agentZipElements != null && !agentZipElements.isEmpty()) { this.agentZip = XmlUtils.getMandatoryAttribute(agentZipElements.get(0), AtsProjectConfiguration.NODE_ATTRIBUTE_PATH); boolean absolute = XmlUtils.getBooleanAttribute(agentZipElements.get(0), "absolute", false); if (!absolute) { for (Element folderPathNode : XmlUtils.getChildrenByTagName(sourceNode, AtsProjectConfiguration.NODE_ATTRIBUTE_FOLDER)) { PathInfo folderPath = new PathInfo(folderPathNode, false, this.home); for (Element filePathNode : XmlUtils.getChildrenByTagName(sourceNode, AtsProjectConfiguration.NODE_ATTRIBUTE_FILE)) { this.paths.add(new PathInfo(filePathNode, true, this.home));
this.host = XmlUtils.getMandatoryAttribute(applicationNode, AtsProjectConfiguration.NODE_APPLICATION_PROPERTY_HOST); this.isLocalHost = HostUtils.isLocalHost(host); this.port = XmlUtils.getAttribute(applicationNode, this.home = XmlUtils.getMandatoryAttribute(applicationNode, AtsProjectConfiguration.NODE_ATTRIBUTE_HOME); this.isUnix = this.home.charAt(0) == '/'; String sshPortString = XmlUtils.getAttribute(applicationNode, AtsProjectConfiguration.NODE_APPLICATION_PROPERTY_SSH_PORT); if (sshPortString != null) { this.systemUser = XmlUtils.getMandatoryAttribute(applicationNode, AtsProjectConfiguration.NODE_APPLICATION_PROPERTY_SYSTEM_USER); this.systemPassword = XmlUtils.getAttribute(applicationNode, AtsProjectConfiguration.NODE_APPLICATION_PROPERTY_SYSTEM_PASSWORD); this.sshPrivateKey = XmlUtils.getAttribute(applicationNode, AtsProjectConfiguration.NODE_APPLICATION_PROPERTY_SSH_PRIVATE_KEY); this.sshPrivateKeyPassword = XmlUtils.getAttribute(applicationNode, AtsProjectConfiguration.NODE_APPLICATION_PROPERTY_SSH_PRIVATE_KEY_PASSWORD); this.javaExecutable = XmlUtils.getAttribute(applicationNode, this.memory = XmlUtils.getAttribute(applicationNode, AtsProjectConfiguration.NODE_APPLICATION_PROPERTY_MEMORY); List<Element> postInstallCommandElements = XmlUtils.getChildrenByTagName(applicationNode,
@Override protected void loadMoreInfo( Element applicationNode ) { Element statusCommandNode = getNoMoreThanOneChild(applicationNode, NODE_STATUS_COMMAND); if (statusCommandNode != null) { statusCommandInfo.url = XmlUtils.getMandatoryAttribute(statusCommandNode, NODE_ATTRIBUTE_URL); statusCommandInfo.urlSearchToken = XmlUtils.getMandatoryAttribute(statusCommandNode, NODE_ATTRIBUTE_URL_SEARCH_TOKEN); statusCommandInfo.command = XmlUtils.getAttribute(statusCommandNode, NODE_ATTRIBUTE_COMMAND); statusCommandInfo.stdoutSearchToken = XmlUtils.getAttribute(statusCommandNode, NODE_ATTRIBUTE_STDOUT_SEARCH_TOKEN); } Element startCommandNode = getNoMoreThanOneChild(applicationNode, NODE_START_COMMAND); if (startCommandNode != null) { startCommandInfo.command = XmlUtils.getAttribute(startCommandNode, NODE_ATTRIBUTE_COMMAND); startCommandInfo.stdoutSearchToken = XmlUtils.getAttribute(startCommandNode, NODE_ATTRIBUTE_STDOUT_SEARCH_TOKEN); } Element stopCommandNode = getNoMoreThanOneChild(applicationNode, NODE_STOP_COMMAND); if (stopCommandNode != null) { stopCommandInfo.command = XmlUtils.getAttribute(stopCommandNode, NODE_ATTRIBUTE_COMMAND); stopCommandInfo.stdoutSearchToken = XmlUtils.getAttribute(stopCommandNode, NODE_ATTRIBUTE_STDOUT_SEARCH_TOKEN); } }
this.path = XmlUtils.getMandatoryAttribute(pathNode, AtsProjectConfiguration.NODE_ATTRIBUTE_PATH); boolean isAbsolutePath = XmlUtils.getBooleanAttribute(pathNode, "absolute", false); if (!isFile) { this.isRecursive = XmlUtils.getBooleanAttribute(pathNode, "recursive", false); this.upgrade = XmlUtils.getBooleanAttribute(pathNode, "upgrade", true);
private Element getNoMoreThanOneChild( Element element, String name ) { List<Element> children = XmlUtils.getChildrenByTagName(element, name); if (children.size() == 0) { return null; } else { return children.get(0); } } }
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 " 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"); 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 List<Element> shellCommandsNodes = XmlUtils.getChildrenByTagName(atsProjectNode, NODE_SHELL_COMMANDS); if (shellCommandsNodes.size() > 0) { shellCommandsNodes = XmlUtils.getChildrenByTagName(shellCommandsNodes.get(0), "command"); for (Element commandNode : shellCommandsNodes) { String shellCommandAlias = XmlUtils.getAttribute(commandNode, NODE_ATTRIBUTE_ALIAS); String theCommand = commandNode.getTextContent();
List<Element> globalPropertiesNodes = XmlUtils.getChildrenByTagName(atsProjectNode, NODE_APPLICATION_GLOBAL_PROPERTIES); if (globalPropertiesNodes.size() >= 1) { List<Element> portElements = XmlUtils.getChildrenByTagName(globalPropertiesNode, NODE_APPLICATION_GLOBAL_PROPERTY_PORT); if (portElements.size() >= 1) { List<Element> unixJavaExeElements = XmlUtils.getChildrenByTagName(globalPropertiesNode, NODE_APPLICATION_GLOBAL_PROPERTY_UNIX_JAVA_EXEC); if (unixJavaExeElements.size() >= 1) { List<Element> winJavaExeElements = XmlUtils.getChildrenByTagName(globalPropertiesNode, NODE_APPLICATION_GLOBAL_PROPERTY_WIN_JAVA_EXEC); if (winJavaExeElements.size() >= 1) { List<Element> winStartupLatencyElements = XmlUtils.getChildrenByTagName(globalPropertiesNode, NODE_APPLICATION_GLOBAL_PROPERTY_WIN_STARTUP_LATENCY); if (winStartupLatencyElements.size() >= 1) {
public void setSystemUser( String systemUser ) { this.systemUser = systemUser; XmlUtils.setAttribute(applicationNode, AtsProjectConfiguration.NODE_APPLICATION_PROPERTY_SYSTEM_USER, this.systemUser); }
/** * * @param node the node {@link Element} * @param attributeName the attribute name * @param defaultValue a default attribute value * @return the boolean attribute value */ public static boolean getBooleanAttribute( Element node, String attributeName, boolean defaultValue ) { String attributeValue = getAttribute(node, attributeName); if (attributeValue == null) { return defaultValue; } return Boolean.parseBoolean(attributeValue); }
public void setSystemPassword( String systemPassword ) { this.systemPassword = systemPassword; XmlUtils.setAttribute(applicationNode, AtsProjectConfiguration.NODE_APPLICATION_PROPERTY_SYSTEM_PASSWORD, this.systemPassword); }
/** * * @param node the node {@link Element} * @param attributeName the attribute name * @return the attribute value * @throws XMLException if the mandatory attribute is missing or its value is empty */ public static String getMandatoryAttribute( Element node, String attributeName ) throws XMLException { String attributeValue = getAttribute(node, attributeName); if (StringUtils.isNullOrEmpty(attributeValue)) { throw new XMLException(node.getNodeName() + " is missing mandatory attribute '" + attributeName + "'"); } return attributeValue; }
public void setSSHPrivateKey( String sshPrivateKey ) { this.sshPrivateKey = sshPrivateKey; XmlUtils.setAttribute(applicationNode, AtsProjectConfiguration.NODE_APPLICATION_PROPERTY_SSH_PRIVATE_KEY, this.sshPrivateKey); }
public void setPort( String port ) { this.port = port; XmlUtils.setAttribute(applicationNode, AtsProjectConfiguration.NODE_APPLICATION_PROPERTY_PORT, this.port); }
public void setSSHPrivateKeyPassword( String sshPrivateKeyPassword ) { this.sshPrivateKeyPassword = sshPrivateKeyPassword; XmlUtils.setAttribute(applicationNode, AtsProjectConfiguration.NODE_APPLICATION_PROPERTY_SSH_PRIVATE_KEY_PASSWORD, this.sshPrivateKeyPassword); }
public void setHome( String home ) { this.home = home; XmlUtils.setAttribute(sourceNode, AtsProjectConfiguration.NODE_ATTRIBUTE_HOME, this.home); }
public void setHome( String home ) { this.home = home; XmlUtils.setAttribute(applicationNode, AtsProjectConfiguration.NODE_ATTRIBUTE_HOME, this.home); }
public void setSSHPort( String port ) { try { this.sshPort = Integer.parseInt(port); } catch (NumberFormatException nfe) { throw new AtsConfigurationException("Invalid SSH Port number '" + port + "'"); } XmlUtils.setAttribute(applicationNode, AtsProjectConfiguration.NODE_APPLICATION_PROPERTY_SSH_PORT, port); }
public void setHost( String host ) { this.host = host; XmlUtils.setAttribute(applicationNode, AtsProjectConfiguration.NODE_APPLICATION_PROPERTY_HOST, this.host); this.isLocalHost = HostUtils.isLocalHost(host); }