public string-based JSON interface to be invoked by FFIs. Takes in a `ValidateEntityCall` and (if successful) returns unit value () which is null value when serialized to json.
(input: &str)
| 492 | /// public string-based JSON interface to be invoked by FFIs. Takes in a `ValidateEntityCall` and (if successful) |
| 493 | /// returns unit value () which is null value when serialized to json. |
| 494 | pub fn validate_entities(input: &str) -> serde_json::Result<Answer> { |
| 495 | let validate_entity_call = from_str::<ValidateEntityCall>(&input)?; |
| 496 | let schema = match validate_entity_call.schema { |
| 497 | Value::String(cedarschema_str) => match Schema::from_cedarschema_str(&cedarschema_str) { |
| 498 | Ok(s) => s.0, |
| 499 | Err(e) => return Ok(Answer::fail_bad_request(vec![e.to_string()])), |
| 500 | }, |
| 501 | cedarschema_json_obj => match Schema::from_json_value(cedarschema_json_obj) { |
| 502 | Ok(s) => s, |
| 503 | Err(e) => return Ok(Answer::fail_bad_request(vec![e.to_string()])), |
| 504 | }, |
| 505 | }; |
| 506 | |
| 507 | match CedarEntities::from_json_value(validate_entity_call.entities, Some(&schema)) { |
| 508 | Err(error) => { |
| 509 | let err_message = match error { |
| 510 | EntitiesError::Serialization(err) => err.to_string(), |
| 511 | EntitiesError::Deserialization(err) => err.to_string(), |
| 512 | EntitiesError::Duplicate(err) => err.to_string(), |
| 513 | EntitiesError::TransitiveClosureError(err) => err.to_string(), |
| 514 | EntitiesError::InvalidEntity(err) => err.to_string(), |
| 515 | }; |
| 516 | Ok(Answer::fail_bad_request(vec![err_message])) |
| 517 | } |
| 518 | Ok(_entities) => Ok(Answer::Success { |
| 519 | result: "null".to_string(), |
| 520 | }), |
| 521 | } |
| 522 | } |
| 523 | |
| 524 | #[derive(Debug, Serialize, Deserialize)] |
| 525 | struct JavaInterfaceCall { |
no outgoing calls
no test coverage detected