use of com.axway.ats.core.filesystem.model.IFileSystemOperations in project ats-framework by Axway.
the class FileSystemOperations method renameFile.
/**
* Renames a file
*
* @param sourceFile source file name
* @param destinationFile destination file name
* @param overwrite whether to override the destination file if already exists
*/
@PublicAtsApi
public void renameFile(@Validate(name = "sourceFile", type = ValidationType.STRING_NOT_EMPTY) String sourceFile, @Validate(name = "destinationFile", type = ValidationType.STRING_NOT_EMPTY) String destinationFile, @Validate(name = "overwrite", type = ValidationType.NONE) boolean overwrite) {
// validate input parameters
new Validator().validateMethodParameters(new Object[] { sourceFile, destinationFile, overwrite });
// execute action
IFileSystemOperations operations = getOperationsImplementationFor(atsAgent);
operations.renameFile(sourceFile, destinationFile, overwrite);
// log the result of the operation
log.info("Successfully renamed '" + sourceFile + "' to '" + destinationFile + "'" + getHostDescriptionSuffix());
}
use of com.axway.ats.core.filesystem.model.IFileSystemOperations in project ats-framework by Axway.
the class FileSystemOperations method appendToFile.
/**
* Appends content to existing file.
* It simply appends the provided bytes to the file.
* It does not touch the new line characters in the new content.
*
* <br/><b>Note:</b> It will fail if the file does not exist
*
* @param filePath the file to work with
* @param contentToAdd the content to add
*/
@PublicAtsApi
public void appendToFile(@Validate(name = "filePath", type = ValidationType.STRING_NOT_EMPTY) String filePath, @Validate(name = "contentToAdd", type = ValidationType.STRING_NOT_EMPTY) String contentToAdd) {
// validate input parameters
new Validator().validateMethodParameters(new Object[] { filePath, contentToAdd });
// execute action
IFileSystemOperations operations = getOperationsImplementationFor(atsAgent);
operations.appendToFile(filePath, contentToAdd);
// log the result of the operation
String message = new StringBuilder().append("Successfully appended ").append(contentToAdd.length()).append(" characters to file ").append(filePath).toString();
log.info(message);
}
use of com.axway.ats.core.filesystem.model.IFileSystemOperations in project ats-framework by Axway.
the class FileSystemOperations method setFilePermissions.
/**
* Set the permissions ( in octal format ) of a file or directory. E.g. 0644 or 1750 or 7605
*
* @param filePath the file to work with
* @param permissions the permissions to set
*/
@PublicAtsApi
public void setFilePermissions(@Validate(name = "filePath", type = ValidationType.STRING_NOT_EMPTY) String filePath, @Validate(name = "permissions", type = ValidationType.STRING_NOT_EMPTY) String permissions) {
// validate input parameters
new Validator().validateMethodParameters(new Object[] { filePath, permissions });
// execute action
IFileSystemOperations operations = getOperationsImplementationFor(atsAgent);
operations.setFilePermissions(filePath, permissions);
// log the result of the operation
log.debug("Successfully set the permissions '" + permissions + "' of " + filePath + getHostDescriptionSuffix());
}
use of com.axway.ats.core.filesystem.model.IFileSystemOperations in project ats-framework by Axway.
the class FileSystemOperations method deleteDirectory.
/**
* Deletes a directory and all its content. <br/>
* <b>Note: </b>It does nothing if the directory does not exist
*
* @param directoryPath the directory to work with
*/
@PublicAtsApi
public void deleteDirectory(@Validate(name = "directoryPath", type = ValidationType.STRING_NOT_EMPTY) String directoryPath) {
// validate input parameters
new Validator().validateMethodParameters(new Object[] { directoryPath });
// execute action
IFileSystemOperations operations = getOperationsImplementationFor(atsAgent);
operations.deleteDirectory(directoryPath, true);
// log the result of the operation
log.info("Successfully deleted a directory by the name of " + directoryPath + getHostDescriptionSuffix());
}
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 is set by the user.
*
* @param filePath the file to work with
* @param fileContent the text that will be parsed in the file
*/
@PublicAtsApi
public void createFile(@Validate(name = "filePath", type = ValidationType.STRING_NOT_EMPTY) String filePath, @Validate(name = "fileContent", type = ValidationType.NOT_NULL) String fileContent) {
// validate input parameters
new Validator().validateMethodParameters(new Object[] { filePath, fileContent });
// execute action
IFileSystemOperations operations = getOperationsImplementationFor(atsAgent);
operations.createFile(filePath, fileContent);
// log the result of the operation
log.info("Successfully created file by the name of " + filePath + " with content " + fileContent);
}
Aggregations