| 628 | } |
| 629 | |
| 630 | fn policy_set_to_json_internal<'a>( |
| 631 | env: &mut JNIEnv<'a>, |
| 632 | policy_set_jstr: JString<'a>, |
| 633 | ) -> Result<JValueOwned<'a>> { |
| 634 | if policy_set_jstr.is_null() { |
| 635 | raise_npe(env) |
| 636 | } else { |
| 637 | let policy_set_jstring = env.get_string(&policy_set_jstr)?; |
| 638 | let policy_set_string = String::from(policy_set_jstring); |
| 639 | let policy_set_ffi: PolicySetFFI = serde_json::from_str(&policy_set_string)?; |
| 640 | let policy_set = policy_set_ffi |
| 641 | .parse() |
| 642 | .map_err(|err| format!("Error parsing policy set: {:?}", err))?; |
| 643 | let policy_set_json = serde_json::to_string(&policy_set.to_json().unwrap())?; |
| 644 | Ok(JValueGen::Object(env.new_string(&policy_set_json)?.into())) |
| 645 | } |
| 646 | } |
| 647 | |
| 648 | #[jni_fn("com.cedarpolicy.model.policy.PolicySet")] |
| 649 | pub fn parsePoliciesJni<'a>(mut env: JNIEnv<'a>, _: JClass, policies_jstr: JString<'a>) -> jvalue { |