Package org.json

Examples of org.json.JSONObject.optBoolean()


      JSONArray branchesArray = branches.getJSONArray(ProtocolConstants.KEY_CHILDREN);
      assertEquals(2, branchesArray.length());
      JSONObject branch0 = branchesArray.getJSONObject(0);
      JSONObject branch1 = branchesArray.getJSONObject(1);
      if (branch0.optBoolean(GitConstants.KEY_BRANCH_CURRENT, false))
        assertFalse(branch1.optBoolean(GitConstants.KEY_BRANCH_CURRENT, false));
      else
        assertTrue(branch1.optBoolean(GitConstants.KEY_BRANCH_CURRENT, false));

      // remove branch
      request = getDeleteGitBranchRequest(branchLocation);
View Full Code Here


      JSONObject branch0 = branchesArray.getJSONObject(0);
      JSONObject branch1 = branchesArray.getJSONObject(1);
      if (branch0.optBoolean(GitConstants.KEY_BRANCH_CURRENT, false))
        assertFalse(branch1.optBoolean(GitConstants.KEY_BRANCH_CURRENT, false));
      else
        assertTrue(branch1.optBoolean(GitConstants.KEY_BRANCH_CURRENT, false));

      // remove branch
      request = getDeleteGitBranchRequest(branchLocation);
      response = webConversation.getResponse(request);
      assertTrue(HttpURLConnection.HTTP_OK == response.getResponseCode() || HttpURLConnection.HTTP_ACCEPTED == response.getResponseCode());
View Full Code Here

      assertTrue(status.toString(), status.isOK());
      branches = status.getJsonData();
      branchesArray = branches.getJSONArray(ProtocolConstants.KEY_CHILDREN);
      assertEquals(1, branchesArray.length());
      JSONObject branch = branchesArray.getJSONObject(0);
      assertTrue(branch.optBoolean(GitConstants.KEY_BRANCH_CURRENT, false));
    }
  }

  @Test
  public void testCreateTrackingBranch() throws Exception {
View Full Code Here

    JSONObject attributes = source.optJSONObject(ProtocolConstants.KEY_ATTRIBUTES);
    if (attributes != null) {
      for (int i = 0; i < ATTRIBUTE_KEYS.length; i++) {
        //undefined means the client does not want to change the value, so can't interpret as false
        if (!attributes.isNull(ATTRIBUTE_KEYS[i]))
          destination.setAttribute(ATTRIBUTE_BITS[i], attributes.optBoolean(ATTRIBUTE_KEYS[i]));
      }
    }
  }

  public static IFileInfo fromJSON(HttpServletRequest request) throws IOException, JSONException {
View Full Code Here

        info.expires = new Date(json.getLong(KEY_EXPIRES));

      if (json.has(KEY_TIMESTAMP))
        info.timestamp = new Date(json.getLong(KEY_TIMESTAMP));

      info.lengthComputable = json.optBoolean(KEY_LENGTH_COMPUTABLE);
      if (json.has(KEY_LOADED))
        info.loaded = json.optInt(KEY_LOADED);
      if (json.has(KEY_TOTAL))
        info.total = json.getInt(KEY_TOTAL);
View Full Code Here

    String pattern = requestInfo.relativePath;
    JSONObject requestObject = requestInfo.getJSONRequest();
    try {
      String commitToMerge = requestObject.optString(GitConstants.KEY_MERGE, null);
      if (commitToMerge != null) {
        boolean squash = requestObject.optBoolean(GitConstants.KEY_SQUASH, false);
        return merge(request, response, db, commitToMerge, squash);
      }

      String commitToRebase = requestObject.optString(GitConstants.KEY_REBASE, null);
      String rebaseOperation = requestObject.optString(GitConstants.KEY_OPERATION, null);
View Full Code Here

      return addRemote(request, response, path);
    }
    JSONObject requestObject = OrionServlet.readJSONRequest(request);
    boolean fetch = Boolean.parseBoolean(requestObject.optString(GitConstants.KEY_FETCH, null));
    String srcRef = requestObject.optString(GitConstants.KEY_PUSH_SRC_REF, null);
    boolean tags = requestObject.optBoolean(GitConstants.KEY_PUSH_TAGS, false);
    boolean force = requestObject.optBoolean(GitConstants.KEY_FORCE, false);

    // prepare creds
    GitCredentialsProvider cp = GitUtils.createGitCredentialsProvider(requestObject);
View Full Code Here

    }
    JSONObject requestObject = OrionServlet.readJSONRequest(request);
    boolean fetch = Boolean.parseBoolean(requestObject.optString(GitConstants.KEY_FETCH, null));
    String srcRef = requestObject.optString(GitConstants.KEY_PUSH_SRC_REF, null);
    boolean tags = requestObject.optBoolean(GitConstants.KEY_PUSH_TAGS, false);
    boolean force = requestObject.optBoolean(GitConstants.KEY_FORCE, false);

    // prepare creds
    GitCredentialsProvider cp = GitUtils.createGitCredentialsProvider(requestObject);

    // if all went well, continue with fetch or push
View Full Code Here

    HttpServletResponse response = requestInfo.response;
    Repository db = requestInfo.db;

    String indexMessage = requestPayload.optString(GitConstants.KEY_STASH_INDEX_MESSAGE);
    String workingDirectoryMessage = requestPayload.optString(GitConstants.KEY_STASH_WORKING_DIRECTORY_MESSAGE);
    boolean includeUntracked = requestPayload.optBoolean(GitConstants.KEY_STASH_INCLUDE_UNTRACKED, false);

    try {

      Git git = new Git(db);
      StashCreateCommand stashCreate = git.stashCreate();
View Full Code Here

    Repository db = requestInfo.db;

    /* gitapi/stash/<stashRev>/file/(...) */
    String stashRev = requestInfo.gitSegment;

    boolean applyIndex = requestPayload.optBoolean(GitConstants.KEY_STASH_APPLY_INDEX, true);
    boolean applyUntracked = requestPayload.optBoolean(GitConstants.KEY_STASH_APPLY_UNTRACKED, true);

    try {

      Git git = new Git(db);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.