/** * Converts the specified AWS policy object to a JSON string, suitable for * passing to an AWS service. * * @param policy * The AWS policy object to convert to a JSON string. * * @return The JSON string representation of the specified policy object. * * @throws IllegalArgumentException * If the specified policy is null or invalid and cannot be * serialized to a JSON string. */ public String writePolicyToString(Policy policy) { if(!isNotNull(policy)) throw new IllegalArgumentException("Policy cannot be null"); try { return jsonStringOf(policy); } catch (Exception e) { String message = "Unable to serialize policy to JSON string: " + e.getMessage(); throw new IllegalArgumentException(message, e); } finally { try { writer.close(); } catch (Exception e) { } } }
if (isNotNull(policy.getId())) writeJsonKeyValue(JsonDocumentFields.POLICY_ID, policy.getId()); generator.writeStartObject(); if (isNotNull(statement.getId())) { writeJsonKeyValue(JsonDocumentFields.STATEMENT_ID, statement.getId()); if (isNotNull(principals) && !principals.isEmpty()) writePrincipals(principals); if (isNotNull(actions) && !actions.isEmpty()) writeActions(actions); if (isNotNull(resources) && !resources.isEmpty()) writeResources(resources); if (isNotNull(conditions) && !conditions.isEmpty()) writeConditions(conditions);
/** * Converts the specified AWS policy object to a JSON string, suitable for * passing to an AWS service. * * @param policy The AWS policy object to convert to a JSON string. * @return The JSON string representation of the specified policy object. * @throws IllegalArgumentException If the specified policy is null or * invalid and cannot be serialized to a JSON string. */ public String writePolicyToString(Policy policy) { if (!isNotNull(policy)) throw new IllegalArgumentException("Policy cannot be null"); try { return jsonStringOf(policy); } catch (Exception e) { String message = "Unable to serialize policy to JSON string: " + e.getMessage(); throw new IllegalArgumentException(message, e); } finally { try { writer.close(); } catch (Exception e) { } } }
/** * Converts the specified AWS policy object to a JSON string, suitable for * passing to an AWS service. * * @param policy * The AWS policy object to convert to a JSON string. * * @return The JSON string representation of the specified policy object. * * @throws IllegalArgumentException * If the specified policy is null or invalid and cannot be * serialized to a JSON string. */ public String writePolicyToString(Policy policy) { if(!isNotNull(policy)) throw new IllegalArgumentException("Policy cannot be null"); try { return jsonStringOf(policy); } catch (Exception e) { String message = "Unable to serialize policy to JSON string: " + e.getMessage(); throw new IllegalArgumentException(message, e); } finally { try { writer.close(); } catch (Exception e) { } } }
if (isNotNull(policy.getId())) writeJsonKeyValue(JsonDocumentFields.POLICY_ID, policy.getId()); generator.writeStartObject(); if (isNotNull(statement.getId())) { writeJsonKeyValue(JsonDocumentFields.STATEMENT_ID, statement.getId()); if (isNotNull(principals) && !principals.isEmpty()) writePrincipals(principals); if (isNotNull(actions) && !actions.isEmpty()) writeActions(actions); if (isNotNull(resources) && !resources.isEmpty()) writeResources(resources); if (isNotNull(conditions) && !conditions.isEmpty()) writeConditions(conditions);
if (isNotNull(policy.getId())) writeJsonKeyValue(JsonDocumentFields.POLICY_ID, policy.getId()); jsonWriter.beginObject(); if (isNotNull(statement.getId())) { writeJsonKeyValue(JsonDocumentFields.STATEMENT_ID, statement.getId()); if (isNotNull(principals) && !principals.isEmpty()) writePrincipals(principals); if (isNotNull(actions) && !actions.isEmpty()) writeActions(actions); if (isNotNull(resources) && !resources.isEmpty()) writeResources(resources); if (isNotNull(conditions) && !conditions.isEmpty()) writeConditions(conditions);
/** * Converts the specified AWS policy object to a JSON string, suitable for * passing to an AWS service. * * @param policy The AWS policy object to convert to a JSON string. * @return The JSON string representation of the specified policy object. * @throws IllegalArgumentException If the specified policy is null or * invalid and cannot be serialized to a JSON string. */ public String writePolicyToString(Policy policy) { if (!isNotNull(policy)) throw new IllegalArgumentException("Policy cannot be null"); try { return jsonStringOf(policy); } catch (Exception e) { String message = "Unable to serialize policy to JSON string: " + e.getMessage(); throw new IllegalArgumentException(message, e); } finally { try { writer.close(); } catch (Exception e) { } } }
/** * Converts the specified AWS policy object to a JSON string, suitable for * passing to an AWS service. * * @param policy The AWS policy object to convert to a JSON string. * @return The JSON string representation of the specified policy object. * @throws IllegalArgumentException If the specified policy is null or * invalid and cannot be serialized to a JSON string. */ public String writePolicyToString(Policy policy) { if (!isNotNull(policy)) throw new IllegalArgumentException("Policy cannot be null"); try { return jsonStringOf(policy); } catch (Exception e) { String message = "Unable to serialize policy to JSON string: " + e.getMessage(); throw new IllegalArgumentException(message, e); } finally { try { writer.close(); } catch (Exception e) { } } }
/** * Converts the specified AWS policy object to a JSON string, suitable for * passing to an AWS service. * * @param policy * The AWS policy object to convert to a JSON string. * * @return The JSON string representation of the specified policy object. * * @throws IllegalArgumentException * If the specified policy is null or invalid and cannot be * serialized to a JSON string. */ public String writePolicyToString(Policy policy) { if(!isNotNull(policy)) throw new IllegalArgumentException("Policy cannot be null"); try { return jsonStringOf(policy); } catch (Exception e) { String message = "Unable to serialize policy to JSON string: " + e.getMessage(); throw new IllegalArgumentException(message, e); } finally { try { writer.close(); } catch (Exception e) { } } }
if (isNotNull(policy.getId())) writeJsonKeyValue(JsonDocumentFields.POLICY_ID, policy.getId()); generator.writeStartObject(); if (isNotNull(statement.getId())) { writeJsonKeyValue(JsonDocumentFields.STATEMENT_ID, statement.getId()); if (isNotNull(principals) && !principals.isEmpty()) writePrincipals(principals); if (isNotNull(actions) && !actions.isEmpty()) writeActions(actions); if (isNotNull(resources) && !resources.isEmpty()) writeResources(resources); if (isNotNull(conditions) && !conditions.isEmpty()) writeConditions(conditions);
if (isNotNull(policy.getId())) writeJsonKeyValue(JsonDocumentFields.POLICY_ID, policy.getId()); jsonWriter.beginObject(); if (isNotNull(statement.getId())) { writeJsonKeyValue(JsonDocumentFields.STATEMENT_ID, statement.getId()); if (isNotNull(principals) && !principals.isEmpty()) writePrincipals(principals); if (isNotNull(actions) && !actions.isEmpty()) writeActions(actions); if (isNotNull(resources) && !resources.isEmpty()) writeResources(resources); if (isNotNull(conditions) && !conditions.isEmpty()) writeConditions(conditions);
if (isNotNull(policy.getId())) writeJsonKeyValue(JsonDocumentFields.POLICY_ID, policy.getId()); jsonWriter.beginObject(); if (isNotNull(statement.getId())) { writeJsonKeyValue(JsonDocumentFields.STATEMENT_ID, statement.getId()); if (isNotNull(principals) && !principals.isEmpty()) writePrincipals(principals); if (isNotNull(actions) && !actions.isEmpty()) writeActions(actions); if (isNotNull(resources) && !resources.isEmpty()) writeResources(resources); if (isNotNull(conditions) && !conditions.isEmpty()) writeConditions(conditions);