Search in sources :

Example 21 with Validator

use of com.axway.ats.core.validation.Validator in project ats-framework by Axway.

the class FileSystemOperations method replaceTextInFile.

/**
     * Replaces specific text in file. Supports regular expressions
     *
     * @param filePath the file to work with
     * @param searchText the text to replace
     * @param newText the replacement text
     * @param isRegex if the searched text is a regular expression
     */
@PublicAtsApi
public void replaceTextInFile(@Validate(name = "filePath", type = ValidationType.STRING_NOT_EMPTY) String filePath, @Validate(name = "searchText", type = ValidationType.STRING_NOT_EMPTY) String searchText, @Validate(name = "newText", type = ValidationType.NONE) String newText, @Validate(name = "isRegex", type = ValidationType.NONE) boolean isRegex) {
    // validate input parameters
    new Validator().validateMethodParameters(new Object[] { filePath, searchText, newText, isRegex });
    // execute action
    IFileSystemOperations operations = getOperationsImplementationFor(atsAgent);
    operations.replaceTextInFile(filePath, searchText, newText, isRegex);
    // log the result of the operation
    log.info("Successfully replaced text '" + searchText + "' with '" + newText + "' in file '" + 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 22 with Validator

use of com.axway.ats.core.validation.Validator in project ats-framework by Axway.

the class FileTransferClient method connect.

@PublicAtsApi
public void connect(@Validate(name = "hostname", type = ValidationType.STRING_SERVER_ADDRESS) String hostname) {
    // validate input parameters
    new Validator().validateMethodParameters(new Object[] { hostname });
    doConnect(hostname, null, null);
}
Also used : Validator(com.axway.ats.core.validation.Validator) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 23 with Validator

use of com.axway.ats.core.validation.Validator in project ats-framework by Axway.

the class FileSystemOperations method fileGrep.

/**
     * Returns file lines that match some regular expression. <br />
     * <em>Note</em> that search pattern should match whole line, i.e. it should
     * start/end with some wildcard matcher if you search for text somewhere in the line.
     *
     * @param filePath the file to work with
     * @param searchPattern the search pattern
     * @param isSimpleMode
     * <blockquote>
     * true - expects match using only these (DOS/Win-style) special characters:
     *      <blockquote>
     *      '*' character - matches a sequence of any characters<br/>
     *      '?' character - matches one single character
     *      </blockquote>
     * false - supports any Java regular expression
     * </blockquote>
     * <em>Example:</em>
     * <ul>
     *   <li>for simple mode (true): '*Hello*' matches lines like ' Hello colleagues,' and 'Hello'</li>
     *   <li>for not simple mode: '.*Hello.*' matches lines ' Hello colleagues,' and 'Hello'</li>
     * </ul>
     * @return the matched lines
     *
     */
@PublicAtsApi
public String[] fileGrep(@Validate(name = "filePath", type = ValidationType.STRING_NOT_EMPTY) String filePath, @Validate(name = "searchPattern", type = ValidationType.STRING_NOT_EMPTY) String searchPattern, @Validate(name = "isSimpleMode", type = ValidationType.NONE) boolean isSimpleMode) {
    // validate input parameters
    new Validator().validateMethodParameters(new Object[] { filePath, searchPattern, isSimpleMode });
    // execute action
    IFileSystemOperations operations = getOperationsImplementationFor(atsAgent);
    return operations.fileGrep(filePath, searchPattern, isSimpleMode);
}
Also used : IFileSystemOperations(com.axway.ats.core.filesystem.model.IFileSystemOperations) Validator(com.axway.ats.core.validation.Validator) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 24 with Validator

use of com.axway.ats.core.validation.Validator in project ats-framework by Axway.

the class FileSystemOperations method doesFileExist.

/**
     * Check if a file exists
     *
     * @param filePath the target file path
     * @return <code>true</code> if the file exists and <code>false</code> if it doesn't
     */
@PublicAtsApi
public boolean doesFileExist(@Validate(name = "filePath", type = ValidationType.STRING_NOT_EMPTY) String filePath) {
    // validate input parameters
    new Validator().validateMethodParameters(new Object[] { filePath });
    // execute action
    IFileSystemOperations operations = getOperationsImplementationFor(atsAgent);
    return operations.doesFileExist(filePath);
}
Also used : IFileSystemOperations(com.axway.ats.core.filesystem.model.IFileSystemOperations) Validator(com.axway.ats.core.validation.Validator) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 25 with Validator

use of com.axway.ats.core.validation.Validator in project ats-framework by Axway.

the class FileSystemOperations method getFileUniqueId.

/**
     * @param filePath the file to work with
     * @return unique id formed by the file name, last modification time, GID and UID values,
     * separated with dots
     */
public String getFileUniqueId(@Validate(name = "filePath", type = ValidationType.STRING_NOT_EMPTY) String filePath) {
    // validate input parameters
    new Validator().validateMethodParameters(new Object[] { filePath });
    // execute action
    IFileSystemOperations operations = getOperationsImplementationFor(atsAgent);
    return operations.getFileUniqueId(filePath);
}
Also used : IFileSystemOperations(com.axway.ats.core.filesystem.model.IFileSystemOperations) Validator(com.axway.ats.core.validation.Validator)

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