Search in sources :

Example 6 with IFileSystemOperations

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

the class FileSystemOperations method setFileUID.

/**
     * Set the UID of a file or directory
     *
     * @param filePath the file to work with
     * @param uid the UID number
     */
@PublicAtsApi
public void setFileUID(@Validate(name = "filePath", type = ValidationType.STRING_NOT_EMPTY) String filePath, @Validate(name = "uid", type = ValidationType.NUMBER_POSITIVE) long uid) {
    // validate input parameters
    new Validator().validateMethodParameters(new Object[] { filePath, uid });
    // execute action
    IFileSystemOperations operations = getOperationsImplementationFor(atsAgent);
    operations.setFileUID(filePath, uid);
    // log the result of the operation
    log.debug("Successfully set the UID '" + uid + "' of " + filePath + 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 7 with IFileSystemOperations

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

the class FileSystemOperations method createDirectory.

/**
     * Creates a directory
     *
     * @param directoryName the name of the new directory
     */
@PublicAtsApi
public void createDirectory(@Validate(name = "directoryName", type = ValidationType.STRING_NOT_EMPTY) String directoryName) {
    // validate input parameters
    new Validator().validateMethodParameters(new Object[] { directoryName });
    // execute action
    IFileSystemOperations operations = getOperationsImplementationFor(atsAgent);
    operations.createDirectory(directoryName);
    // log the result of the operation
    log.info("Successfully created directory by the name of " + directoryName + 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 8 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 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
     * @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, @Validate(name = "userId", type = ValidationType.NUMBER_POSITIVE) int userId, @Validate(name = "groupId", type = ValidationType.NUMBER_POSITIVE) int groupId, EndOfLineStyle eolStyle, boolean randomContent) {
    // validate input parameters
    new Validator().validateMethodParameters(new Object[] { filePath, size, userId, groupId, null, randomContent });
    // execute action
    IFileSystemOperations operations = getOperationsImplementationFor(atsAgent);
    operations.createFile(filePath, size, userId, groupId, randomContent, eolStyle);
    // log the result of the operation
    String message = new StringBuilder().append("Successfully created file by the name of ").append(filePath).append(" with size ").append(size).append(" and UID/GID ").append(userId).append("/").append(groupId).toString();
    log.info(message);
}
Also used : IFileSystemOperations(com.axway.ats.core.filesystem.model.IFileSystemOperations) Validator(com.axway.ats.core.validation.Validator) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 9 with IFileSystemOperations

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

the class FileSystemOperations method getFileOwner.

/**
     * Get the owner of a file or directory
     *
     * @param filePath the file to work with
     * @return the owner
     */
@PublicAtsApi
public String getFileOwner(@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.getFileOwner(filePath);
    // log the result of the operation
    log.debug("Successfully got the owner of " + filePath + getHostDescriptionSuffix());
    return result;
}
Also used : IFileSystemOperations(com.axway.ats.core.filesystem.model.IFileSystemOperations) Validator(com.axway.ats.core.validation.Validator) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 10 with IFileSystemOperations

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

the class FileSystemOperations method createBinaryFile.

/**
     * Creates a binary file. The content of the file is a byte sequence. The bytes
     * themselves are either fixed sequence, or randomly generated, depending on the
     * value of the randomContent parameter.
     * </br>File's UID and GID will the ones of the system user which started the remote ATS agent.
     *
     * @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 createBinaryFile(@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.createBinaryFile(filePath, size, randomContent);
    // log the result of the operation
    String message = new StringBuilder().append("Successfully created binary file by the name of ").append(filePath).append(" with size ").append(size).toString();
    log.info(message);
}
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