(
env: &mut JNIEnv<'a>,
policies_jstr: JString<'a>,
)
| 654 | } |
| 655 | |
| 656 | fn parse_policies_internal<'a>( |
| 657 | env: &mut JNIEnv<'a>, |
| 658 | policies_jstr: JString<'a>, |
| 659 | ) -> Result<JValueOwned<'a>> { |
| 660 | if policies_jstr.is_null() { |
| 661 | raise_npe(env) |
| 662 | } else { |
| 663 | // Parse the string into the Rust PolicySet |
| 664 | let policies_jstring = env.get_string(&policies_jstr)?; |
| 665 | let policies_string = String::from(policies_jstring); |
| 666 | let policy_set = PolicySet::from_str(&policies_string)?; |
| 667 | |
| 668 | // Enumerate over the parsed policies |
| 669 | let mut policies_java_hash_set = Set::new(env)?; |
| 670 | for policy in policy_set.policies() { |
| 671 | let policy_id = format!("{}", policy.id()); |
| 672 | let policy_text = format!("{}", policy); |
| 673 | let java_policy_object = JPolicy::new( |
| 674 | env, |
| 675 | &env.new_string(&policy_text)?, |
| 676 | &env.new_string(&policy_id)?, |
| 677 | )?; |
| 678 | let _ = policies_java_hash_set.add(env, java_policy_object); |
| 679 | } |
| 680 | |
| 681 | let mut templates_java_hash_set = Set::new(env)?; |
| 682 | for template in policy_set.templates() { |
| 683 | let policy_id = format!("{}", template.id()); |
| 684 | let policy_text = format!("{}", template); |
| 685 | let java_policy_object = JPolicy::new( |
| 686 | env, |
| 687 | &env.new_string(&policy_text)?, |
| 688 | &env.new_string(&policy_id)?, |
| 689 | )?; |
| 690 | let _ = templates_java_hash_set.add(env, java_policy_object); |
| 691 | } |
| 692 | |
| 693 | let java_policy_set = create_java_policy_set( |
| 694 | env, |
| 695 | policies_java_hash_set.as_ref(), |
| 696 | templates_java_hash_set.as_ref(), |
| 697 | ); |
| 698 | |
| 699 | Ok(JValueGen::Object(java_policy_set)) |
| 700 | } |
| 701 | } |
| 702 | |
| 703 | fn create_java_policy_set<'a>( |
| 704 | env: &mut JNIEnv<'a>, |
no test coverage detected