Search in sources :

Example 6 with Validator

use of com.axway.ats.core.validation.Validator 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 Validator

use of com.axway.ats.core.validation.Validator 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 Validator

use of com.axway.ats.core.validation.Validator 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 Validator

use of com.axway.ats.core.validation.Validator 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 Validator

use of com.axway.ats.core.validation.Validator 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

Validator (com.axway.ats.core.validation.Validator)67 PublicAtsApi (com.axway.ats.common.PublicAtsApi)66 IFileSystemOperations (com.axway.ats.core.filesystem.model.IFileSystemOperations)45 LocalFileSystemOperations (com.axway.ats.core.filesystem.LocalFileSystemOperations)6 ISystemOperations (com.axway.ats.core.system.model.ISystemOperations)4 FullReadingBean (com.axway.ats.common.performance.monitor.beans.FullReadingBean)3 MachineDescriptionOperations (com.axway.ats.agent.components.monitoring.operations.clients.MachineDescriptionOperations)1 InternalProcessOperations (com.axway.ats.agent.components.system.operations.clients.InternalProcessOperations)1 AgentException (com.axway.ats.agent.core.exceptions.AgentException)1 FileMatchInfo (com.axway.ats.common.filesystem.FileMatchInfo)1 ProcessExecutorException (com.axway.ats.common.process.ProcessExecutorException)1 DbAccessFactory (com.axway.ats.log.autodb.DbAccessFactory)1 DbWriteAccess (com.axway.ats.log.autodb.DbWriteAccess)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1