@Override protected String resolveType(final JsonObject jsonObject) { return jsonObject.getValueOrThrow(CommandResponse.JsonFields.TYPE); }
@Override public <T> T getValueOrThrow(final JsonFieldDefinition<T> fieldDefinition) { return wrapped.getValueOrThrow(fieldDefinition); }
@Override protected String resolveType(final JsonObject jsonObject) { return jsonObject.getValueOrThrow(CommonCommand.JsonFields.TYPE); }
@Override public <T> T getValueOrThrow(final JsonFieldDefinition<T> fieldDefinition) { return wrapped.getValueOrThrow(fieldDefinition); }
@Override protected String resolveType(final JsonObject jsonObject) { return jsonObject.getValueOrThrow(DevOpsCommandResponse.JsonFields.TYPE); }
protected AbstractEntityIdWithRevision(final JsonObject jsonObject) { requireNonNull(jsonObject); this.id = jsonObject.getValueOrThrow(JsonFields.ID); this.revision = jsonObject.getValueOrThrow(JsonFields.REVISION); }
private static Set<String> getPermissionsFor(final JsonObject jsonObject, final JsonFieldDefinition<JsonArray> effect) { return jsonObject.getValueOrThrow(effect) .stream() .filter(JsonValue::isString) .map(JsonValue::asString) .collect(Collectors.toSet()); }
private DevOpsErrorResponse(@Nullable final String serviceName, @Nullable final String instance, final JsonObject dittoRuntimeException, final DittoHeaders dittoHeaders) { super(TYPE, HttpStatusCode.forInt(dittoRuntimeException.getValueOrThrow(DittoRuntimeException.JsonFields.STATUS)) .orElse(HttpStatusCode.INTERNAL_SERVER_ERROR), dittoHeaders); this.serviceName = serviceName; this.instance = instance; this.dittoRuntimeException = requireNonNull(dittoRuntimeException, "The Ditto Runtime Exception must not be null"); }
private DevOpsErrorResponse(@Nullable final String serviceName, @Nullable final String instance, final JsonObject dittoRuntimeException, final DittoHeaders dittoHeaders) { super(TYPE, HttpStatusCode.forInt(dittoRuntimeException.getValueOrThrow(DittoRuntimeException.JsonFields.STATUS)) .orElse(HttpStatusCode.INTERNAL_SERVER_ERROR), dittoHeaders); this.serviceName = serviceName; this.instance = instance; this.dittoRuntimeException = requireNonNull(dittoRuntimeException, "The Ditto Runtime Exception must not be null"); }
protected static String readMessage(final JsonObject jsonObject) { checkNotNull(jsonObject, "JSON object"); return jsonObject.getValueOrThrow(JsonFields.MESSAGE); }
public static PolicyErrorResponse fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { final String policyId = jsonObject.getValueOrThrow(PolicyCommandResponse.JsonFields.JSON_POLICY_ID); final JsonObject payload = jsonObject.getValueOrThrow(PolicyCommandResponse.JsonFields.PAYLOAD).asObject(); final DittoRuntimeException exception = POLICY_ERROR_REGISTRY.parse(payload, dittoHeaders); return of(policyId, exception, dittoHeaders); }
public static PolicyErrorResponse fromJson(final JsonObject jsonObject, final DittoHeaders dittoHeaders) { final String policyId = jsonObject.getValueOrThrow(PolicyCommandResponse.JsonFields.JSON_POLICY_ID); final JsonObject payload = jsonObject.getValueOrThrow(PolicyCommandResponse.JsonFields.PAYLOAD).asObject(); final DittoRuntimeException exception = POLICY_ERROR_REGISTRY.parse(payload, dittoHeaders); return of(policyId, exception, dittoHeaders); }
private void validateCommandResponseType() { final String actualCommandResponseType = jsonObject.getValueOrThrow(CommandResponse.JsonFields.TYPE); if (!expectedCommandResponseType.equals(actualCommandResponseType)) { final String msgPattern = "Command Response JSON was not a <{0}> command response but a <{1}>!"; final String msg = MessageFormat.format(msgPattern, expectedCommandResponseType, actualCommandResponseType); throw new DittoJsonException(new JsonParseException(msg)); } }
private void validateCommandResponseType() { final String actualCommandResponseType = jsonObject.getValueOrThrow(CommandResponse.JsonFields.TYPE); if (!expectedCommandResponseType.equals(actualCommandResponseType)) { final String msgPattern = "Command Response JSON was not a <{0}> command response but a <{1}>!"; final String msg = MessageFormat.format(msgPattern, expectedCommandResponseType, actualCommandResponseType); throw new DittoJsonException(new JsonParseException(msg)); } }
private static ConnectionType getConnectionTypeOrThrow(final JsonObject jsonObject) { final String readConnectionType = jsonObject.getValueOrThrow(JsonFields.CONNECTION_TYPE); return ConnectionType.forName(readConnectionType) .orElseThrow(() -> JsonParseException.newBuilder() .message(MessageFormat.format("Connection type <{0}> is invalid!", readConnectionType)) .build()); }
private static ConnectionType getConnectionTypeOrThrow(final JsonObject jsonObject) { final String readConnectionType = jsonObject.getValueOrThrow(JsonFields.CONNECTION_TYPE); return ConnectionType.forName(readConnectionType) .orElseThrow(() -> JsonParseException.newBuilder() .message(MessageFormat.format("Connection type <{0}> is invalid!", readConnectionType)) .build()); }
private static ConnectionStatus getConnectionStatusOrThrow(final JsonObject jsonObject) { final String readConnectionStatus = jsonObject.getValueOrThrow(JsonFields.CONNECTION_STATUS); return ConnectionStatus.forName(readConnectionStatus) .orElseThrow(() -> JsonParseException.newBuilder() .message(MessageFormat.format("Connection status <{0}> is invalid!", readConnectionStatus)) .build()); }
private static ConnectionStatus getConnectionStatusOrThrow(final JsonObject jsonObject) { final String readConnectionStatus = jsonObject.getValueOrThrow(JsonFields.CONNECTION_STATUS); return ConnectionStatus.forName(readConnectionStatus) .orElseThrow(() -> JsonParseException.newBuilder() .message(MessageFormat.format("Connection status <{0}> is invalid!", readConnectionStatus)) .build()); }
private static PolicyEntry createPolicyEntryForPut(final String jsonString, final CharSequence labelString) { final JsonObject jsonObject = wrapJsonRuntimeException(() -> JsonFactory.newObject(jsonString)); final Subjects subjects = PoliciesModelFactory.newSubjects(jsonObject.getValueOrThrow(PolicyEntry.JsonFields.SUBJECTS)); final Resources resources = PoliciesModelFactory.newResources(jsonObject.getValueOrThrow(PolicyEntry.JsonFields.RESOURCES)); return PoliciesModelFactory.newPolicyEntry(Label.of(labelString), subjects, resources); }
private static Subject createSubjectForPut(final String jsonString, final CharSequence subjectId) { final JsonObject jsonObject = wrapJsonRuntimeException(() -> JsonFactory.newObject(jsonString)); final String subjectTypeString = jsonObject.getValueOrThrow(Subject.JsonFields.TYPE); final SubjectType subjectType = PoliciesModelFactory.newSubjectType(subjectTypeString); return PoliciesModelFactory.newSubject(SubjectId.newInstance(subjectId), subjectType); }