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());
}
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);
}
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);
}
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);
}
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);
}
Aggregations