Search in sources :

Example 31 with IFileSystemOperations

use of com.axway.ats.core.filesystem.model.IFileSystemOperations in project ats-framework by Axway.

the class FileSystemOperations method unlockFile.

/**
     * Unlock file already locked with {@link #lockFile(String) lockFile()} method
     *
     * @param fileName file name
     */
@PublicAtsApi
public void unlockFile(@Validate(name = "fileName", type = ValidationType.STRING_NOT_EMPTY) String fileName) {
    // validate input parameters
    new Validator().validateMethodParameters(new Object[] { fileName });
    // execute action
    IFileSystemOperations operations = getOperationsImplementationFor(atsAgent);
    operations.unlockFile(fileName);
    // log the result of the operation
    log.info("File '" + fileName + "'" + getHostDescriptionSuffix() + " is successfully unlocked");
}
Also used : IFileSystemOperations(com.axway.ats.core.filesystem.model.IFileSystemOperations) Validator(com.axway.ats.core.validation.Validator) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 32 with IFileSystemOperations

use of com.axway.ats.core.filesystem.model.IFileSystemOperations in project ats-framework by Axway.

the class FileSystemOperations method getFileGID.

/**
     * Get the GID of a file or directory
     *
     * @param filePath the file to work with
     * @return the GID number
     */
@PublicAtsApi
public long getFileGID(@Validate(name = "filePath", type = ValidationType.STRING_NOT_EMPTY) String filePath) {
    // validate input parameters
    new Validator().validateMethodParameters(new Object[] { filePath });
    long gid = -1L;
    // execute action
    IFileSystemOperations operations = getOperationsImplementationFor(atsAgent);
    gid = operations.getFileGID(filePath);
    // log the result of the operation
    log.debug("Successfully got the GID of " + filePath + getHostDescriptionSuffix());
    return gid;
}
Also used : IFileSystemOperations(com.axway.ats.core.filesystem.model.IFileSystemOperations) Validator(com.axway.ats.core.validation.Validator) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 33 with IFileSystemOperations

use of com.axway.ats.core.filesystem.model.IFileSystemOperations in project ats-framework by Axway.

the class FileSystemOperations method getFileModificationTime.

/**
     * Get the last modification time for a specified file
     *
     * @param filePath the file to work with
     * @param modificationTime the modification time to set as a timestamp in milliseconds
     */
@PublicAtsApi
public long getFileModificationTime(@Validate(name = "filePath", type = ValidationType.STRING_NOT_EMPTY) String filePath) {
    // validate input parameters
    new Validator().validateMethodParameters(new Object[] { filePath });
    long lastModificationTime = -1l;
    // execute action
    IFileSystemOperations operations = getOperationsImplementationFor(atsAgent);
    lastModificationTime = operations.getFileModificationTime(filePath);
    // log the result of the operation
    log.info("Successfully get the last modification timestamp of file '" + filePath + "'" + getHostDescriptionSuffix());
    return lastModificationTime;
}
Also used : IFileSystemOperations(com.axway.ats.core.filesystem.model.IFileSystemOperations) Validator(com.axway.ats.core.validation.Validator) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 34 with IFileSystemOperations

use of com.axway.ats.core.filesystem.model.IFileSystemOperations in project ats-framework by Axway.

the class FileSystemOperations method deleteDirectoryContent.

/**
     * Deletes all directory's content, but does not touch the directory itself<br/>
     * <b>Note: </b>It does nothing if the directory does not exist
     *
     * @param directoryPath the directory to work with
     */
@PublicAtsApi
public void deleteDirectoryContent(@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.purgeDirectoryContents(directoryPath);
    // log the result of the operation
    log.info("Successfully deleted the content of directory by the name of " + directoryPath + getHostDescriptionSuffix());
}
Also used : IFileSystemOperations(com.axway.ats.core.filesystem.model.IFileSystemOperations) Validator(com.axway.ats.core.validation.Validator) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 35 with IFileSystemOperations

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.
     *
     * @param filePath the file to work with
     * @param size the size of the generated file
     * @param eolStyle the EOL style for this file. If null it uses the EOL style of the current system
     * @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, EndOfLineStyle eolStyle, boolean randomContent) {
    // validate input parameters
    new Validator().validateMethodParameters(new Object[] { filePath, size, null, randomContent });
    // execute action
    IFileSystemOperations operations = getOperationsImplementationFor(atsAgent);
    operations.createFile(filePath, size, randomContent, eolStyle);
    // log the result of the operation
    log.info("Successfully created file by the name of " + filePath + " with size " + size);
}
Also used : IFileSystemOperations(com.axway.ats.core.filesystem.model.IFileSystemOperations) Validator(com.axway.ats.core.validation.Validator) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Aggregations

IFileSystemOperations (com.axway.ats.core.filesystem.model.IFileSystemOperations)46 Validator (com.axway.ats.core.validation.Validator)45 PublicAtsApi (com.axway.ats.common.PublicAtsApi)44 LocalFileSystemOperations (com.axway.ats.core.filesystem.LocalFileSystemOperations)6 FileMatchInfo (com.axway.ats.common.filesystem.FileMatchInfo)1 IProcessExecutor (com.axway.ats.core.process.model.IProcessExecutor)1 MobileOperationException (com.axway.ats.uiengine.exceptions.MobileOperationException)1 NotSupportedOperationException (com.axway.ats.uiengine.exceptions.NotSupportedOperationException)1 ArrayList (java.util.ArrayList)1 Matcher (java.util.regex.Matcher)1