use of com.axway.ats.environment.AdditionalAction in project ats-framework by Axway.
the class ConfigurationParser method parseDirectoryEnvironment.
/**
* Parse the directory environment node in the Agent descriptor.
*
* @param directoryEnvironmentNode the directory environment node.
* @throws AgentException on error.
*/
private EnvironmentUnit parseDirectoryEnvironment(Node directoryEnvironmentNode, String backupFolder) {
String originalDir = directoryEnvironmentNode.getAttributes().getNamedItem("path").getNodeValue();
originalDir = IoUtils.normalizeDirPath(originalDir);
String backupName;
if (directoryEnvironmentNode.getAttributes().getNamedItem("backupName") != null) {
backupName = directoryEnvironmentNode.getAttributes().getNamedItem("backupName").getNodeValue();
} else {
// remove the last slash and get the directory name as a file name
backupName = IoUtils.getFileName(originalDir.substring(0, originalDir.length() - 1));
}
// get the optional addition actions to executed on directory restore
List<AdditionalAction> additionalActions = parseAdditionalActions(directoryEnvironmentNode);
DirectoryEnvironmentUnit directoryEnvironment = new DirectoryEnvironmentUnit(originalDir, backupFolder, backupName);
directoryEnvironment.addAdditionalActions(additionalActions);
return directoryEnvironment;
}
use of com.axway.ats.environment.AdditionalAction in project ats-framework by Axway.
the class ConfigurationParser method parseAdditionalActions.
/**
* @param environmentNode
* @return
*/
private List<AdditionalAction> parseAdditionalActions(Node environmentNode) {
NodeList environmentNodeChildren = environmentNode.getChildNodes();
List<AdditionalAction> actions = new ArrayList<AdditionalAction>();
for (int i = 0; i < environmentNodeChildren.getLength(); i++) {
Node environmentNodeChild = environmentNodeChildren.item(i);
if (environmentNodeChild.getNodeName().equals("action")) {
String shellCommand;
int sleepInterval;
Node shellCommandNode = environmentNodeChild.getAttributes().getNamedItem("command");
Node sleepNode = environmentNodeChild.getAttributes().getNamedItem("sleep");
if (shellCommandNode != null && sleepNode != null) {
shellCommand = shellCommandNode.getNodeValue();
sleepInterval = Integer.parseInt(sleepNode.getNodeValue().trim());
actions.add(new SystemProcessAction(shellCommand, sleepInterval));
}
}
}
return actions;
}
use of com.axway.ats.environment.AdditionalAction in project ats-framework by Axway.
the class ConfigurationParser method parseFileEnvironment.
/**
* Parse the file environment node in the Agent descriptor.
*
* @param fileEnvironmentNode the file environment node.
* @throws AgentException on error.
*/
private EnvironmentUnit parseFileEnvironment(Node fileEnvironmentNode, String backupFolder) {
// get the original file
String originalFile = fileEnvironmentNode.getAttributes().getNamedItem("path").getNodeValue();
originalFile = IoUtils.normalizeUnixFile(originalFile);
// get the backup file
String backupName;
if (fileEnvironmentNode.getAttributes().getNamedItem("backupName") != null) {
backupName = fileEnvironmentNode.getAttributes().getNamedItem("backupName").getNodeValue();
} else {
backupName = IoUtils.getFileName(originalFile);
}
// get the optional addition actions to executed on file restore
List<AdditionalAction> additionalActions = parseAdditionalActions(fileEnvironmentNode);
FileEnvironmentUnit fileEnvironment = new FileEnvironmentUnit(originalFile, backupFolder, backupName);
fileEnvironment.addAdditionalActions(additionalActions);
return fileEnvironment;
}
Aggregations