use of com.axway.ats.core.filesystem.model.IFileSystemOperations in project ats-framework by Axway.
the class FileSystemOperations method copyDirectoryTo.
/**
* Copies the contents of a directory to a new one
*
* @param fromDirName the source file to copy
* @param toDirName the destination file to copy to
* @param isRecursive whether to copy recursively or not
*/
@PublicAtsApi
public void copyDirectoryTo(@Validate(name = "fromDirName", type = ValidationType.STRING_NOT_EMPTY) String fromDirName, @Validate(name = "toDirName", type = ValidationType.STRING_NOT_EMPTY) String toDirName, @Validate(name = "isRecursive", type = ValidationType.NONE) boolean isRecursive) {
// validate input parameters
new Validator().validateMethodParameters(new Object[] { fromDirName, toDirName, isRecursive });
// execute action
IFileSystemOperations operations = getOperationsImplementationFor(this.atsAgent);
if (operations instanceof LocalFileSystemOperations) {
((LocalFileSystemOperations) operations).copyDirectory(fromDirName, toDirName, isRecursive, this.failOnError);
log.info("Successfully copied directory " + fromDirName + " to " + toDirName);
} else {
((RemoteFileSystemOperations) operations).copyDirectory(fromDirName, toDirName, isRecursive, this.failOnError);
log.info("Successfully copied directory " + fromDirName + " from local host to " + toDirName + " on " + this.atsAgent);
}
}
use of com.axway.ats.core.filesystem.model.IFileSystemOperations in project ats-framework by Axway.
the class FileSystemOperations method createFile.
/**
* Creates a file. The content of the file is the letters of the English alphabet.
* The letters themselves are either alphabetically sorted, or randomly generated,
* depending on the value of the randomContent parameter.
* The end of line character will be the default one for the system where this action is run.
*
* @param filePath the file to work with
* @param size the size of the generated file
* @param randomContent if true the method would generate a file with a random content
*/
@PublicAtsApi
public void createFile(@Validate(name = "filePath", type = ValidationType.STRING_NOT_EMPTY) String filePath, @Validate(name = "size", type = ValidationType.NUMBER_POSITIVE) long size, boolean randomContent) {
// validate input parameters
new Validator().validateMethodParameters(new Object[] { filePath, size, randomContent });
// execute action
IFileSystemOperations operations = getOperationsImplementationFor(atsAgent);
operations.createFile(filePath, size, randomContent);
// log the result of the operation
log.info("Successfully created file by the name of " + filePath + " with size " + size);
}
use of com.axway.ats.core.filesystem.model.IFileSystemOperations in project ats-framework by Axway.
the class FileSystemOperations method getFileUID.
/**
* Get the UID of a file or directory
*
* @param filePath the file to work with
* @return the UID number
*/
@PublicAtsApi
public long getFileUID(@Validate(name = "filePath", type = ValidationType.STRING_NOT_EMPTY) String filePath) {
// validate input parameters
new Validator().validateMethodParameters(new Object[] { filePath });
long uid = -1L;
// execute action
IFileSystemOperations operations = getOperationsImplementationFor(atsAgent);
uid = operations.getFileUID(filePath);
// log the result of the operation
log.debug("Successfully got the UID of " + filePath + getHostDescriptionSuffix());
return uid;
}
use of com.axway.ats.core.filesystem.model.IFileSystemOperations in project ats-framework by Axway.
the class FileSystemOperations method readFile.
/**
* Read file from specific byte position. Used for file tail.<br/>
* <b>NOTE:</b> If the file is replaced with the same byte content, then no change is assumed and 'null' is returned
*
* @param fileName file name
* @param fromBytePosition byte offset. Example: for already read 100 bytes next method call is expected to have 100 as value for this parameter
* @return {@link FileTailInfo} object
*/
@PublicAtsApi
public FileTailInfo readFile(@Validate(name = "fileName", type = ValidationType.STRING_NOT_EMPTY) String fileName, @Validate(name = "fromBytePosition", type = ValidationType.NONE) long fromBytePosition) {
// validate input parameters
new Validator().validateMethodParameters(new Object[] { fileName, fromBytePosition });
// execute action
IFileSystemOperations operations = getOperationsImplementationFor(atsAgent);
return operations.readFile(fileName, fromBytePosition);
}
use of com.axway.ats.core.filesystem.model.IFileSystemOperations in project ats-framework by Axway.
the class FileSystemOperations method getLastLinesFromFile.
/**
* Get the last lines from a file
*
* @param filePath the file to work with
* @param numberOfLinesToRead the number of lines to read
* @return the last lines
*/
@PublicAtsApi
public String[] getLastLinesFromFile(@Validate(name = "filePath", type = ValidationType.STRING_NOT_EMPTY) String filePath, @Validate(name = "numLinesToRead", type = ValidationType.NUMBER_GREATER_THAN_ZERO) int numberOfLinesToRead) {
String[] lastLines = null;
// validate input parameters
new Validator().validateMethodParameters(new Object[] { filePath, numberOfLinesToRead });
// execute action
IFileSystemOperations operations = getOperationsImplementationFor(atsAgent);
lastLines = operations.getLastLinesFromFile(filePath, numberOfLinesToRead);
// log the result of the operation
log.debug("Successfully got the last " + numberOfLinesToRead + " lines of '" + filePath + "'" + getHostDescriptionSuffix());
return lastLines;
}
Aggregations