use of com.axway.ats.core.validation.Validator in project ats-framework by Axway.
the class FileSystemOperations method getFilePermissions.
/**
* Get the permissions ( in octal format ) of a file or directory. E.g. 0644 or 1750 or 7605
*
* @param filePath the file to work with
* @return the permissions
*/
@PublicAtsApi
public String getFilePermissions(@Validate(name = "filePath", type = ValidationType.STRING_NOT_EMPTY) String filePath) {
// validate input parameters
new Validator().validateMethodParameters(new Object[] { filePath });
String result = null;
// execute action
IFileSystemOperations operations = getOperationsImplementationFor(atsAgent);
result = operations.getFilePermissions(filePath);
// log the result of the operation
log.debug("Successfully got the permissions of " + filePath + getHostDescriptionSuffix());
return result;
}
use of com.axway.ats.core.validation.Validator in project ats-framework by Axway.
the class FileSystemOperations method createFile.
/**
* Creates a file. The content is set by the user.
*
* @param filePath the file to work with
* @param fileContent the text that will be parsed in the file
* @param userId the identification number of the user this file should belong to
* @param groupId the identification number of the group this file should belong to
*/
@PublicAtsApi
public void createFile(@Validate(name = "filePath", type = ValidationType.STRING_NOT_EMPTY) String filePath, @Validate(name = "fileContent", type = ValidationType.NOT_NULL) String fileContent, @Validate(name = "userId", type = ValidationType.NUMBER_POSITIVE) int userId, @Validate(name = "groupId", type = ValidationType.NUMBER_POSITIVE) int groupId) {
// validate input parameters
new Validator().validateMethodParameters(new Object[] { filePath, fileContent, userId, groupId });
// execute action
IFileSystemOperations operations = getOperationsImplementationFor(atsAgent);
operations.createFile(filePath, fileContent, userId, groupId);
// log the result of the operation
String message = new StringBuilder().append("Successfully created file by the name of ").append(filePath).append(" with content ").append(fileContent).append(" and UID/GID ").append(userId).append("/").append(groupId).toString();
log.info(message);
}
use of com.axway.ats.core.validation.Validator in project ats-framework by Axway.
the class FileSystemOperations method computeMd5Sum.
/**
* Compute a file's MD5 sum
*
* @param filePath the file to work with
* @param mode mode for computing the MD5 sum
* <blockquote>
* ASCII mode - the line endings will be ignored when computing the sum.
* E.g. same file with Windows and Linux style line endings will give same MD5 sum <br/>
* BINARY mode - each byte is affecting the returned result
* </blockquote>
* @return the MD5 sum in hex format
*/
@PublicAtsApi
public String computeMd5Sum(@Validate(name = "filePath", type = ValidationType.STRING_NOT_EMPTY) String filePath, Md5SumMode mode) {
String md5 = null;
// validate input parameters
new Validator().validateMethodParameters(new Object[] { filePath, Md5SumMode.BINARY });
// execute action
IFileSystemOperations operations = getOperationsImplementationFor(atsAgent);
md5 = operations.computeMd5Sum(filePath, mode);
// log the result of the operation
log.debug("Successfully extracted the MD5 sum '" + md5 + "' of " + filePath + getHostDescriptionSuffix());
return md5;
}
use of com.axway.ats.core.validation.Validator in project ats-framework by Axway.
the class MachineInfoAgent method updateMachineInfo.
/**
* Retrieves static info about a machine and stores this info into the
* log DB
*
* @param atsAgent the address of the ATS Agent running on the machine of interest
* @param dbMachineName the name of the machine as it appears in the DB
* @throws Exception
*/
@PublicAtsApi
public void updateMachineInfo(@Validate(name = "atsAgent", type = ValidationType.STRING_SERVER_WITH_PORT) String atsAgent, @Validate(name = "dbMachineName", type = ValidationType.STRING_NOT_EMPTY) String dbMachineName) throws Exception {
// validate input parameters
atsAgent = HostUtils.getAtsAgentIpAndPort(atsAgent);
new Validator().validateMethodParameters(new Object[] { atsAgent, dbMachineName });
log.info("Retrieving info about " + dbMachineName + " from " + atsAgent);
MachineDescriptionOperations mm = new MachineDescriptionOperations(atsAgent);
String machineDescriptionString = mm.getDescription();
log.info("Saving retrieved info about " + dbMachineName + " into the Test Explorer database");
DbWriteAccess dbAccess = new DbAccessFactory().getNewDbWriteAccessObject();
dbAccess.updateMachineInfo(dbMachineName, machineDescriptionString, true);
log.info("Successfully updated the info about " + dbMachineName);
}
use of com.axway.ats.core.validation.Validator in project ats-framework by Axway.
the class SystemMonitor method scheduleProcessMonitoring.
/**
* Schedule monitoring on a system process. This method specifies the name of the user who started the process to monitor.
* </br>No statistics collection will be triggered until the startMonitor method is called.
*
* @param monitoredHost the host where the monitored process lives
* @param processPattern the pattern to use in order to find the process among all system processes.
* <br><b>Note: </b>We match the processes by finding the given processPattern in the start command of the process.
* <br>This means that it is possible to match more than one process. In this case a number is appended to the processAlias.
* <br>For example if the processPattern is "my_process" matching 2 processes will give "my_process" and "my_process [2]"
* @param processAlias the process alias to use when logging into the database
* @param processUsername the name of the user who started this process
* @param processReadingTypes what kind of data to collect. Use some of the SystemMonitor.MONITOR_PROCESS_* constants
*/
@PublicAtsApi
public void scheduleProcessMonitoring(@Validate(name = "monitoredHost", type = ValidationType.STRING_SERVER_WITH_PORT) String monitoredHost, @Validate(name = "processPattern", type = ValidationType.STRING_NOT_EMPTY) String processPattern, @Validate(name = "processAlias", type = ValidationType.STRING_NOT_EMPTY) String processAlias, @Validate(name = "processUsername", type = ValidationType.STRING_NOT_EMPTY) String processUsername, @Validate(name = "processReadingTypes", type = ValidationType.NOT_NULL) String[] processReadingTypes) {
// validate input parameters
monitoredHost = HostUtils.getAtsAgentIpAndPort(monitoredHost);
new Validator().validateMethodParameters(new Object[] { monitoredHost, processPattern, processAlias, processUsername, processReadingTypes });
scheduleProcessMonitoring(monitoredHost, null, processPattern, processAlias, processUsername, processReadingTypes);
}
Aggregations