protected void doPost()

in cloud-vmware-server/src/main/java/jetbrains/buildServer/clouds/vmware/web/VMWareEditProfileController.java [98:137]


  protected void doPost(@NotNull final HttpServletRequest request, @NotNull final HttpServletResponse response, @NotNull final Element xmlResponse) {
    final ActionErrors errors = new ActionErrors();

    final BasePropertiesBean propsBean = new BasePropertiesBean(null);
    PluginPropertiesUtil.bindPropertiesFromRequest(request, propsBean, true);

    final Map<String, String> props = propsBean.getProperties();
    final String serverUrl = props.get(VMWareWebConstants.SERVER_URL);
    final String username = props.get(VMWareWebConstants.USERNAME);
    final String password = props.get(VMWareWebConstants.SECURE_PASSWORD);

    IOGuard.allowNetworkCall(() -> {
      try {
        final VMWareApiConnector myApiConnector = VmwareApiConnectorsPool.getOrCreateConnector(
          new URL(serverUrl), username, password, null, null, null, mySslTrustStoreProvider);
        myApiConnector.test();
        xmlResponse.addContent(getVirtualMachinesAsElement(myApiConnector.getVirtualMachines(true)));
        xmlResponse.addContent(getFoldersAsElement(myApiConnector.getFolders()));
        xmlResponse.addContent(getResourcePoolsAsElement(myApiConnector.getResourcePools()));
        xmlResponse.addContent(getCustomizationSpecsAsElement(myApiConnector.getCustomizationSpecs()));
      } catch (Exception ex) {
        LOG.warnAndDebugDetails("Unable to get vCenter details: " + ex.toString(), ex);
        if (ex.getCause() != null && ex.getCause() instanceof SSLException){
          errors.addError(
            "errorFetchResultsSSL",
            SimpleErrorMessages.getInstance().getFriendlyErrorMessage(
              ex, "Please check the connection parameters. See the teamcity-clouds.log for details"
            )
          );
        } else {
          errors.addError(
            "errorFetchResults",
            SimpleErrorMessages.getInstance().getFriendlyErrorMessage(
              ex, "Please check the connection parameters. See the teamcity-clouds.log for details")
          );
        }
        writeErrors(xmlResponse, errors);
      }
    });
  }