Esempio n. 1
0
  private boolean checkMandatoryParameters(
      Repository repositoryDocument,
      boolean propertyChanged,
      ArrayList<Property> newPropertyList,
      HashSet<String> configVariableNames) {
    /*
     * mandatory paramters, the ones from param that have not been covered yet.
     */
    // If there was no required parameters given by WPSconfig, host and port defaults will be added
    // (RServe_User and RServe_port won't be added)
    if (configVariableNames.contains(RWPSConfigVariables.RSERVE_HOST.toString().toLowerCase())) {
      Property host = repositoryDocument.addNewProperty();
      host.setActive(true);
      host.setName(RWPSConfigVariables.RSERVE_HOST.toString());
      host.setStringValue(R_Config.getInstance().rServeHost);
      newPropertyList.add(host);
      propertyChanged = true;
    }

    if (configVariableNames.contains(RWPSConfigVariables.RSERVE_PORT.toString().toLowerCase())) {
      Property port = repositoryDocument.addNewProperty();
      port.setActive(true);
      port.setName(RWPSConfigVariables.RSERVE_PORT.toString());
      port.setStringValue(Integer.toString(R_Config.getInstance().rServePort));
      newPropertyList.add(port);
      propertyChanged = true;
    }
    return propertyChanged;
  }
Esempio n. 2
0
  /**
   * Retrieves configuration parameter from WPS config
   *
   * @param property
   * @return true
   */
  private boolean handleConfigVariable(Property property) {
    String pname = property.getName();
    // RWPSConfigVariables.v
    boolean success = false;
    for (RWPSConfigVariables configvariable : RWPSConfigVariables.values()) {
      if (pname.equalsIgnoreCase(configvariable.toString())) {
        R_Config.getInstance().setConfigVariable(configvariable, property.getStringValue());
        success = true;
        break;
      }
    }

    // TODO: Replace outdated variable assignments:

    if (pname.equalsIgnoreCase(RWPSConfigVariables.RSERVE_HOST.toString())) {
      R_Config.getInstance().rServeHost = property.getStringValue();
    } else if (pname.equalsIgnoreCase(RWPSConfigVariables.RSERVE_PORT.toString())) {
      try {
        R_Config.getInstance().rServePort = Integer.parseInt(property.getStringValue());
      } catch (NumberFormatException e) {
        LOGGER.error("Non numeric RServe_Port property found - it will be ignored and deleted");
        return false;
      }
    } else if (pname.equalsIgnoreCase(RWPSConfigVariables.RSERVE_USER.toString())) {
      R_Config.getInstance().rServeUser = property.getStringValue();
    } else if (pname.equalsIgnoreCase(RWPSConfigVariables.RSERVE_PASSWORD.toString())) {
      R_Config.getInstance().rServePassword = property.getStringValue();
    } else if (pname.equalsIgnoreCase(RWPSConfigVariables.SCRIPT_DIR.toString())
        && property.getActive()) {
      R_Config.getInstance().SCRIPT_DIR = property.getStringValue();
      LOGGER.info("Using script dir " + R_Config.getInstance().SCRIPT_DIR);
    } else if (pname.equalsIgnoreCase(RWPSConfigVariables.RESOURCE_DIR.toString())
        && property.getActive()) {
      R_Config.getInstance().resourceDirectory = property.getStringValue();
    } else if (pname.equalsIgnoreCase(RWPSConfigVariables.ENABLE_BATCH_START.toString())
        && property.getActive()) {
      R_Config.getInstance().enableBatchStart = Boolean.parseBoolean(property.getStringValue());
      LOGGER.info(
          "Trying batch start if R is not running: " + R_Config.getInstance().enableBatchStart);
    } // else
    // return false;

    return success;
  }