private String getServername(PropertyList propertyList) throws FTPException {

    Property hostProperty = PropertyHelper.getFromList(propertyList, "SERVERNAME");

    if (hostProperty == null || hostProperty.getType() != PropertyType.TEXT) {
      throw new FTPException("No servername provided for FTP-Connection");
    }
    return ((TextProperty) hostProperty).getValue().getValue();
  }
  /**
   * Extracts the timeout time for the current action on the {@link Metadata} component.
   *
   * @param metadata the current {@link Metadata} object
   * @param actionType the type of action
   * @return the wait time for this object and action
   */
  private Integer getTimeout(Metadata metadata, SwingActionType actionType) {

    NumericProperty property = null;

    try {
      switch (actionType) {
        case LEFTCLICK:
          property =
              (NumericProperty) PropertyHelper.getFromList(metadata.getPropertyList(), WAIT_CLICK);
          break;
        case RIGHTCLICK:
          property =
              (NumericProperty) PropertyHelper.getFromList(metadata.getPropertyList(), WAIT_CLICK);
          break;
        case DOUBLECLICK:
          property =
              (NumericProperty) PropertyHelper.getFromList(metadata.getPropertyList(), WAIT_CLICK);
          break;
        case FIND:
          property =
              (NumericProperty) PropertyHelper.getFromList(metadata.getPropertyList(), WAIT_CLICK);
          break;
        case ENTER:
          property =
              (NumericProperty) PropertyHelper.getFromList(metadata.getPropertyList(), WAIT_ENTER);
          break;
        case READ:
          property =
              (NumericProperty) PropertyHelper.getFromList(metadata.getPropertyList(), WAIT_READ);
          break;
        case COUNT:
          property =
              (NumericProperty) PropertyHelper.getFromList(metadata.getPropertyList(), WAIT_READ);
          break;
        case IS_AVAILABLE:
          property =
              (NumericProperty) PropertyHelper.getFromList(metadata.getPropertyList(), WAIT_READ);
          break;
      }

    } catch (Exception e) {
      logger.warning(
          e,
          "Problem extracting wait time for ",
          metadata.getName().getValue(),
          ", using DEFAULT.");
    }

    Integer waitTime =
        property != null ? property.getValue().getValue().intValue() : DEFAULT_WAIT_TIME;

    return waitTime;
  }
  @Override
  public ActionResponse execute(
      TestContext context,
      PropertyList propertyList,
      List<Metadata> metadataList,
      SubEngineActionType actionType)
      throws SubEngineException {

    Metadata metadata = null;

    try {
      // Validation
      this.validateArguments(context, propertyList, metadataList, actionType);

      SwingActionType swingAction = (SwingActionType) actionType;

      // Init result
      metadata = metadataList.get(metadataList.size() - 1);
      this.initResult(context, metadata, actionType);

      //            this.validateComponent(propertyList, swingAction);

      // Execute Command
      ExecutionCommand command = createCommand(propertyList, metadata, swingAction);
      Integer timeout = getTimeout(metadata, swingAction);
      Property reply = executeCommand(context, command, timeout);

      if (reply != null) {
        PropertyList returnList = PropertyHelper.createPropertyList("Return");
        PropertyHelper.add(reply, returnList);
        result.setReturnProperties(returnList);
      }

    } catch (SwingValidationException e) {
      logger.error(e, "Error validating Swing component.");
      failResult(metadata, actionType, e.getMessage());
    } catch (Exception e) {
      logger.error(e, "Error during Swing component execution.");
      failResult(metadata, actionType);
    }

    return result;
  }
  private int getPort(PropertyList propertyList) {

    Property portProperty = PropertyHelper.getFromList(propertyList, "PORT");

    if (portProperty == null) {
      return FTPClient.DEFAULT_PORT;
    }

    switch (portProperty.getType()) {
      case NUMERIC:
        return ((NumericProperty) portProperty).getValue().getValue().intValue();
      case TEXT:
        String value = ((TextProperty) portProperty).getValue().getValue();
        try {
          return Integer.parseInt(value);
        } catch (NumberFormatException ex) {
          return FTPClient.DEFAULT_PORT;
        }
      default:
        return FTPClient.DEFAULT_PORT;
    }
  }
 @Override
 public Iterator<Property> iterator() {
   return PropertyHelper.extract(this.property.getPropertyList()).iterator();
 }