Esempio n. 1
0
 public static ChatUserBoss fromJson(JSONObject jsonObject) {
   if (jsonObject != null) {
     ChatUserBoss chatUserBoss = new ChatUserBoss();
     chatUserBoss.setUid(jsonObject.optLong(JSON_PROPERTIES_UID));
     chatUserBoss.setCompanyName(jsonObject.optString(JSON_PROPERTIES_COMPANY_NAME));
     chatUserBoss.setAddress(jsonObject.optString(JSON_PROPERTIES_ADDRESS));
     chatUserBoss.setApproveStatus(jsonObject.optInt(JSON_PROPERTIES_APPROVE_STATUS));
     chatUserBoss.setJobTitle(jsonObject.optString(JSON_PROPERTIES_JOB_TITLE));
     return chatUserBoss;
   }
   return null;
 }
Esempio n. 2
0
  @Override
  public void setValues(JSONObject formData) {
    gerritHostName = formData.optString("gerritHostName", DEFAULT_GERRIT_HOSTNAME);
    gerritSshPort = formData.optInt("gerritSshPort", DEFAULT_GERRIT_SSH_PORT);
    gerritProxy = formData.optString("gerritProxy", DEFAULT_GERRIT_PROXY);
    gerritUserName = formData.optString("gerritUserName", DEFAULT_GERRIT_USERNAME);
    gerritEMail = formData.optString("gerritEMail", "");
    notificationLevel =
        Notify.valueOf(
            formData.optString("notificationLevel", Config.DEFAULT_NOTIFICATION_LEVEL.toString()));
    String file = formData.optString("gerritAuthKeyFile", null);
    if (file != null) {
      gerritAuthKeyFile = new File(file);
    } else {
      gerritAuthKeyFile = DEFAULT_GERRIT_AUTH_KEY_FILE;
    }
    gerritAuthKeyFilePassword =
        Secret.fromString(
            formData.optString("gerritAuthKeyFilePassword", DEFAULT_GERRIT_AUTH_KEY_FILE_PASSWORD));

    if (formData.has("buildCurrentPatchesOnly")) {
      JSONObject currentPatchesOnly = formData.getJSONObject("buildCurrentPatchesOnly");
      buildCurrentPatchesOnly = BuildCancellationPolicy.createPolicyFromJSON(currentPatchesOnly);
    } else {
      buildCurrentPatchesOnly = new BuildCancellationPolicy();
    }

    numberOfWorkerThreads =
        formData.optInt("numberOfReceivingWorkerThreads", DEFAULT_NR_OF_RECEIVING_WORKER_THREADS);
    if (numberOfWorkerThreads <= 0) {
      numberOfWorkerThreads = DEFAULT_NR_OF_RECEIVING_WORKER_THREADS;
    }
    numberOfSendingWorkerThreads =
        formData.optInt("numberOfSendingWorkerThreads", DEFAULT_NR_OF_SENDING_WORKER_THREADS);
    if (numberOfSendingWorkerThreads <= 0) {
      numberOfSendingWorkerThreads = DEFAULT_NR_OF_SENDING_WORKER_THREADS;
    }

    if (formData.isEmpty()) {
      gerritBuildStartedVerifiedValue = DEFAULT_GERRIT_BUILD_STARTED_VERIFIED_VALUE;
      gerritBuildSuccessfulVerifiedValue = DEFAULT_GERRIT_BUILD_SUCCESSFUL_VERIFIED_VALUE;
      gerritBuildFailedVerifiedValue = DEFAULT_GERRIT_BUILD_FAILURE_VERIFIED_VALUE;
      gerritBuildUnstableVerifiedValue = DEFAULT_GERRIT_BUILD_UNSTABLE_VERIFIED_VALUE;
      gerritBuildNotBuiltVerifiedValue = DEFAULT_GERRIT_BUILD_NOT_BUILT_VERIFIED_VALUE;
      gerritBuildStartedCodeReviewValue = DEFAULT_GERRIT_BUILD_STARTED_CODE_REVIEW_VALUE;
      gerritBuildSuccessfulCodeReviewValue = DEFAULT_GERRIT_BUILD_SUCCESSFUL_CODE_REVIEW_VALUE;
      gerritBuildFailedCodeReviewValue = DEFAULT_GERRIT_BUILD_FAILURE_CODE_REVIEW_VALUE;
      gerritBuildUnstableCodeReviewValue = DEFAULT_GERRIT_BUILD_UNSTABLE_CODE_REVIEW_VALUE;
      gerritBuildNotBuiltCodeReviewValue = DEFAULT_GERRIT_BUILD_NOT_BUILT_CODE_REVIEW_VALUE;
    } else {
      gerritBuildStartedVerifiedValue =
          getValueFromFormData(formData, "gerritBuildStartedVerifiedValue");
      gerritBuildSuccessfulVerifiedValue =
          getValueFromFormData(formData, "gerritBuildSuccessfulVerifiedValue");
      gerritBuildFailedVerifiedValue =
          getValueFromFormData(formData, "gerritBuildFailedVerifiedValue");
      gerritBuildUnstableVerifiedValue =
          getValueFromFormData(formData, "gerritBuildUnstableVerifiedValue");
      gerritBuildNotBuiltVerifiedValue =
          getValueFromFormData(formData, "gerritBuildNotBuiltVerifiedValue");
      gerritBuildStartedCodeReviewValue =
          getValueFromFormData(formData, "gerritBuildStartedCodeReviewValue");
      gerritBuildSuccessfulCodeReviewValue =
          getValueFromFormData(formData, "gerritBuildSuccessfulCodeReviewValue");
      gerritBuildFailedCodeReviewValue =
          getValueFromFormData(formData, "gerritBuildFailedCodeReviewValue");
      gerritBuildUnstableCodeReviewValue =
          getValueFromFormData(formData, "gerritBuildUnstableCodeReviewValue");
      gerritBuildNotBuiltCodeReviewValue =
          getValueFromFormData(formData, "gerritBuildNotBuiltCodeReviewValue");
    }

    gerritVerifiedCmdBuildStarted =
        formData.optString(
            "gerritVerifiedCmdBuildStarted",
            "gerrit review <CHANGE>,<PATCHSET> --message 'Build Started <BUILDURL> <STARTED_STATS>' "
                + "--verified <VERIFIED> --code-review <CODE_REVIEW>");
    gerritVerifiedCmdBuildFailed =
        formData.optString(
            "gerritVerifiedCmdBuildFailed",
            "gerrit review <CHANGE>,<PATCHSET> --message 'Build Failed <BUILDS_STATS>' "
                + "--verified <VERIFIED> --code-review <CODE_REVIEW>");
    gerritVerifiedCmdBuildSuccessful =
        formData.optString(
            "gerritVerifiedCmdBuildSuccessful",
            "gerrit review <CHANGE>,<PATCHSET> --message 'Build Successful <BUILDS_STATS>' "
                + "--verified <VERIFIED> --code-review <CODE_REVIEW>");
    gerritVerifiedCmdBuildUnstable =
        formData.optString(
            "gerritVerifiedCmdBuildUnstable",
            "gerrit review <CHANGE>,<PATCHSET> --message 'Build Unstable <BUILDS_STATS>' "
                + "--verified <VERIFIED> --code-review <CODE_REVIEW>");
    gerritVerifiedCmdBuildNotBuilt =
        formData.optString(
            "gerritVerifiedCmdBuildNotBuilt",
            "gerrit review <CHANGE>,<PATCHSET> --message 'No Builds Executed <BUILDS_STATS>' "
                + "--verified <VERIFIED> --code-review <CODE_REVIEW>");
    gerritFrontEndUrl = formData.optString("gerritFrontEndUrl", DEFAULT_GERRIT_HOSTNAME);
    enableManualTrigger = formData.optBoolean("enableManualTrigger", DEFAULT_ENABLE_MANUAL_TRIGGER);
    enablePluginMessages =
        formData.optBoolean("enablePluginMessages", DEFAULT_ENABLE_PLUGIN_MESSAGES);
    buildScheduleDelay = formData.optInt("buildScheduleDelay", DEFAULT_BUILD_SCHEDULE_DELAY);
    if (buildScheduleDelay < 0) {
      buildScheduleDelay = 0;
    }
    dynamicConfigRefreshInterval =
        formData.optInt("dynamicConfigRefreshInterval", DEFAULT_DYNAMIC_CONFIG_REFRESH_INTERVAL);

    projectListFetchDelay =
        formData.optInt("projectListFetchDelay", DEFAULT_PROJECT_LIST_FETCH_DELAY);

    projectListRefreshInterval =
        formData.optInt("projectListRefreshInterval", DEFAULT_PROJECT_LIST_REFRESH_INTERVAL);
    enableProjectAutoCompletion =
        formData.optBoolean("enableProjectAutoCompletion", DEFAULT_ENABLE_PROJECT_AUTO_COMPLETION);

    categories = new LinkedList<VerdictCategory>();
    if (formData.has("verdictCategories")) {
      Object cat = formData.get("verdictCategories");
      if (cat instanceof JSONArray) {
        for (Object jsonObject : (JSONArray) cat) {
          categories.add(VerdictCategory.createVerdictCategoryFromJSON((JSONObject) jsonObject));
        }
      } else if (cat instanceof JSONObject) {
        categories.add(VerdictCategory.createVerdictCategoryFromJSON((JSONObject) cat));
      }
    }
    watchdogTimeoutMinutes =
        formData.optInt("watchdogTimeoutMinutes", DEFAULT_GERRIT_WATCHDOG_TIMEOUT_MINUTES);
    watchTimeExceptionData = addWatchTimeExceptionData(formData);

    if (formData.has("useRestApi")) {
      useRestApi = true;
      JSONObject restApi = formData.getJSONObject("useRestApi");
      gerritHttpUserName = restApi.optString("gerritHttpUserName", "");
      gerritHttpPassword = Secret.fromString(restApi.optString("gerritHttpPassword", ""));
      restCodeReview = restApi.optBoolean("restCodeReview", true);
      restVerified = restApi.optBoolean("restVerified", true);
    } else {
      useRestApi = false;
    }

    replicationConfig = ReplicationConfig.createReplicationConfigFromJSON(formData);
  }