Search in sources :

Example 41 with Validator

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

the class ProcessExecutor method killExternalProcess.

/**
     * Killing external process(such not started by us) on a remote host. <br/>
     * The process is found by a token which is contained in the start command.
     * No regex supported.
     *
     * @param atsAgent the address of the remote ATS agent which will run the kill command
     * @param startCommandSnippet the token to search for in the process start command.
     * The minimum allowed length is 2 characters
     * @return the number of killed processes
     */
@PublicAtsApi
public static int killExternalProcess(@Validate(name = "atsAgent", type = ValidationType.STRING_SERVER_WITH_PORT) String atsAgent, @Validate(name = "startCommandSnippet", type = ValidationType.STRING_NOT_EMPTY) String startCommandSnippet) {
    // validate input parameters
    atsAgent = HostUtils.getAtsAgentIpAndPort(atsAgent);
    new Validator().validateMethodParameters(new Object[] { atsAgent, startCommandSnippet });
    try {
        return new InternalProcessOperations(atsAgent).killExternalProcess(startCommandSnippet);
    } catch (AgentException e) {
        throw new ProcessExecutorException(e);
    }
}
Also used : InternalProcessOperations(com.axway.ats.agent.components.system.operations.clients.InternalProcessOperations) AgentException(com.axway.ats.agent.core.exceptions.AgentException) ProcessExecutorException(com.axway.ats.common.process.ProcessExecutorException) Validator(com.axway.ats.core.validation.Validator) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 42 with Validator

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

the class RegistryOperations method createPath.

/**
     * Creates path in the registry.
     *
     * Will fail if the path exists already.
     *
     * If want to create a nested path(for example "Software\\MyCompany\\MyApplication\\Configuration"),
     * it is needed to call this method for each path token(first for "Software\\MyCompany", then for "Software\\MyCompany\\MyApplication" etc)
     *
     * @param keyPath path to the key
     */
@PublicAtsApi
public void createPath(@Validate(name = "keyPath", type = ValidationType.STRING_NOT_EMPTY) String keyPath) {
    // validate input parameters
    new Validator().validateMethodParameters(new Object[] { keyPath });
    registryOperationsImpl.createPath(rootKey, keyPath);
}
Also used : Validator(com.axway.ats.core.validation.Validator) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 43 with Validator

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

the class SystemOperations method setTime.

/**
     * Set the system time
     *
     * @param timestamp the timestamp to set
     * @param inMilliseconds whether the timestamp is in milliseconds or a formatted date string
     * @throws SystemOperationException
     */
@PublicAtsApi
public void setTime(@Validate(name = "timestamp", type = ValidationType.STRING_NOT_EMPTY) String timestamp, @Validate(name = "inMilliseconds", type = ValidationType.NONE) boolean inMilliseconds) {
    // validate input parameters
    new Validator().validateMethodParameters(new Object[] { timestamp, inMilliseconds });
    // execute action
    ISystemOperations operations = getOperationsImplementationFor(atsAgent);
    operations.setTime(timestamp, inMilliseconds);
}
Also used : ISystemOperations(com.axway.ats.core.system.model.ISystemOperations) Validator(com.axway.ats.core.validation.Validator) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 44 with Validator

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

the class SystemOperations method createScreenshot.

/**
     * Creates screenshot image file.<br/>
     * The currently supported image formats/types are PNG, JPG, JPEG, GIF and BMP
     *
     * @param filePath the screenshot image file path. If the file extension is not specified, the default format PNG will be used
     */
@PublicAtsApi
public void createScreenshot(@Validate(name = "filePath", type = ValidationType.STRING_NOT_EMPTY) String filePath) {
    // validate input parameters
    new Validator().validateMethodParameters(new Object[] { filePath });
    ISystemOperations operations = getOperationsImplementationFor(atsAgent);
    operations.createScreenshot(filePath);
}
Also used : ISystemOperations(com.axway.ats.core.system.model.ISystemOperations) Validator(com.axway.ats.core.validation.Validator) PublicAtsApi(com.axway.ats.common.PublicAtsApi)

Example 45 with Validator

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

the class SystemOperations method getSystemProperty.

/**
     * Get the value of the environment's system property.<br/>
     *
     * It calls internally System.getProperty("property name");
     *
     * @param propertyName the name of the system property
     * @return the value of the system property
     */
@PublicAtsApi
public String getSystemProperty(@Validate(name = "propertyName", type = ValidationType.NOT_NULL) String propertyName) {
    // validate input parameters
    new Validator().validateMethodParameters(new Object[] { propertyName });
    // execute action
    ISystemOperations operations = getOperationsImplementationFor(atsAgent);
    return operations.getSystemProperty(propertyName);
}
Also used : ISystemOperations(com.axway.ats.core.system.model.ISystemOperations) 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