예제 #1
0
  public Hashtable<String, String> launchStudio() {
    Hashtable<String, String> result = new Hashtable<String, String>();
    if (spinupController.isNewDeployment(loginCredentials)) {
      if (dailyLimit()) {
        result.put(
            "ERROR",
            "Sorry, we have reached the preview limit for today.<BR>Please try back again tomorrow.");
        log(ERROR, "DAILY LIMIT REACHED: " + dailyCounter + " limit is: " + dailyLimit);
        return result;
      }
    }

    try {
      log(INFO, "Performing spinup for: " + loginCredentials.getUsername());
      result =
          spinupController.performSpinup(
              loginCredentials,
              secret,
              transportToken,
              RuntimeAccess.getInstance().getResponse(),
              false);
      recordUserLog(loginCredentials.getUsername());
      log(INFO, "Counter now: " + ++counter);
    } catch (CloudFoundryException cfe) {
      log(ERROR, "Failed to Launch Studio " + cfe.getMessage() + " " + cfe.toString());
      String msg = cfe.toString();
      if (msg.contains("Not enough memory capacity")) {
        String allowed = msg.substring(msg.indexOf("(") + 1, msg.indexOf(")"));
        result.put(
            "ERROR",
            "Insufficent memory to deploy studio to your account.<BR> "
                + allowed
                + "<BR>512M is required to start Studio.");
      } else {
        result.put(
            "ERROR", "Unable to deploy studio to your account.<BR> " + "Cause: " + cfe.toString());
      }
    } catch (Exception e) {
      log(ERROR, "Studio Launch has failed", e);
      result.put("ERROR", "Unable to deploy studio. " + e.getMessage());
      log(ERROR, e.getMessage());
    }
    return result;
  }