Package com.amazonaws.util.json

Examples of com.amazonaws.util.json.JSONObject


        byte[] initVectorBytes = symmetricCipher.getIV();
        initVectorBytes = Base64.encodeBase64(initVectorBytes);
        metadata.addUserMetadata(Headers.CRYPTO_IV, new String(initVectorBytes));

        // Put the materials description into the object metadata as JSON
        JSONObject descriptionJSON = new JSONObject(materialsDescription);
        metadata.addUserMetadata(Headers.MATERIALS_DESCRIPTION, descriptionJSON.toString());
    }
View Full Code Here


    /**
     * Returns a JSONObject representation of the instruction object.
     */
    private static JSONObject convertInstructionToJSONObject(EncryptionInstruction instruction) {
        JSONObject instructionJSON = new JSONObject();
        try {
            JSONObject materialsDescriptionJSON = new JSONObject(instruction.getMaterialsDescription());
            byte[] initVector = instruction.getSymmetricCipher().getIV();
            initVector = Base64.encodeBase64(initVector);
            byte[] encryptedKeyBytes = instruction.getEncryptedSymmetricKey();
            encryptedKeyBytes = Base64.encodeBase64(encryptedKeyBytes);

            instructionJSON.put(Headers.MATERIALS_DESCRIPTION, materialsDescriptionJSON.toString());
            instructionJSON.put(Headers.CRYPTO_KEY, new String(encryptedKeyBytes));
            instructionJSON.put(Headers.CRYPTO_IV, new String(initVector));

        } catch (JSONException e) {} // Keys are never null, so JSONException will never be thrown.
        return instructionJSON;
View Full Code Here

     * Parses instruction data retrieved from S3 and returns a JSONObject representing the instruction
     */
    private static JSONObject parseJSONInstruction(S3Object instructionObject) {
        try {
            String instructionString = convertStreamToString(instructionObject.getObjectContent());
            return new JSONObject(instructionString);
        } catch (Exception e) {
            throw new AmazonClientException("Error parsing JSON instruction file: " + e.getMessage());
        }
    }
View Full Code Here

    return StringDateConverter.convert(to);
  }

  public static JSONObject mergeBucketCollectionsAndAddTotalSize(
      List<JSONObject> jsons) throws JSONException {
    JSONObject mergedBuckets = JsonUtils.mergeKey(jsons,
        JsonObjectNames.BUCKET_COLLECTION);
    long size = JsonUtils.sumKeyInNestedJson(mergedBuckets,
        JsonObjectNames.SIZE, JsonObjectNames.BUCKET_COLLECTION);

    return JsonUtils.writeKeyValueAsJson(JsonObjectNames.BUCKET_COLLECTION,
        mergedBuckets.get(JsonObjectNames.BUCKET_COLLECTION),
        JsonObjectNames.BUCKET_COLLECTION_SIZE, size);
  }
View Full Code Here

    logMetricsAtEndpoint(ENDPOINT_BUCKET_THAW);
    // thaw
    BucketThawer bucketThawer = BucketThawerFactory.createDefaultThawer();
    bucketThawer.thawBuckets(index, fromDate, toDate);

    JSONObject json = convertThawInfoToJSON(bucketThawer);
    List<JSONObject> jsons = RequestOnSearchPeers.createPost(
        ENDPOINT_BUCKET_THAW, index, from, to).execute().jsons;
    jsons.add(json);

    return JsonUtils.mergeJsonsWithKeys(jsons,
View Full Code Here

  }

  private void executeRequestOnPeer(DistributedPeer dp,
      Queue<JSONObject> jsons, Queue<RuntimeException> exceptions) {
    try {
      JSONObject json = requestOnSearchPeer.executeRequest(dp);
      if (!Thread.currentThread().isInterrupted())
        jsons.offer(json);
    } catch (RuntimeException e) {
      logger.warn(warn("Executed request on distributed peer", e,
          "will add to exceptions, which can be "
View Full Code Here

        indexes = asList(index);

      List<Bucket> filteredBuckets = filteredBucketsInThaw(indexes, earliest,
          latest);

      JSONObject json = JsonUtils.writeKeyValueAsJson(
          JsonObjectNames.BUCKET_COLLECTION, filteredBuckets);
      List<JSONObject> jsons = RequestOnSearchPeers.createGet(
          ENDPOINT_LIST_THAW, index, from, to).execute().jsons;
      jsons.add(json);
View Full Code Here

      } catch (Exception e) {
        errors.add(e);
      }
    }

    JSONObject json = JsonUtils.writeKeyValueAsJson(
        JsonObjectNames.BUCKET_COLLECTION, flusher.getFlushedBuckets(),
        JsonObjectNames.FAILED_BUCKET_COLLECTION, errors);

    List<JSONObject> jsons = RequestOnSearchPeers.createPost(
        ENDPOINT_BUCKET_FLUSH, index, from, to).execute().jsons;
View Full Code Here

   * @return the configured shuttl port of the Splunk instance which the service
   *         is connected to.
   */
  public int getShuttlPort() {
    HttpGet httpGet = createHttpGetRequest();
    JSONObject jsonObject = restEndpointCaller.getJson(httpGet);
    return getShuttlPortFromJSONResponse(jsonObject);
  }
View Full Code Here

  /**
   * @return server name from a Shuttl server.
   */
  public String getServerName(String hostname, int shuttlPort) {
    HttpGet httpGet = constructServerNameRequest(hostname, shuttlPort);
    JSONObject json = restEndpointCaller.getJson(httpGet);
    return getServerNameFromJsonResponse(json);
  }
View Full Code Here

TOP

Related Classes of com.amazonaws.util.json.JSONObject

Copyright © 2018 www.massapicom. 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.