MCPcopy Create free account
hub / github.com/cedar-policy/cedar-java / get_cedar_schema_internal

Function get_cedar_schema_internal

CedarJavaFFI/src/interface.rs:1092–1116  ·  view source on GitHub ↗
(
    env: &mut JNIEnv<'a>,
    schema_json_jstr: JString<'a>,
)

Source from the content-addressed store, hash-verified

1090 }
1091}
1092pub fn get_cedar_schema_internal<'a>(
1093 env: &mut JNIEnv<'a>,
1094 schema_json_jstr: JString<'a>,
1095) -> Result<JValueOwned<'a>> {
1096 let rust_str = env.get_string(&schema_json_jstr)?;
1097 let schema_str = rust_str.to_str()?;
1098
1099 let schema: FFISchema = serde_json::from_str(schema_str)?;
1100 let cedar_format = schema_to_text(schema);
1101
1102 match cedar_format {
1103 SchemaToTextAnswer::Success { text, warnings } => {
1104 let jstr = env.new_string(&text)?;
1105 Ok(JValueGen::Object(JObject::from(jstr)).into())
1106 }
1107 SchemaToTextAnswer::Failure { errors } => {
1108 let joined_errors = errors
1109 .iter()
1110 .map(|e| e.message.clone())
1111 .collect::<Vec<_>>()
1112 .join("; ");
1113 Err(joined_errors.into())
1114 }
1115 }
1116}
1117
1118#[jni_fn("com.cedarpolicy.model.schema.Schema")]
1119pub fn cedarToJsonJni<'a>(mut env: JNIEnv<'a>, _: JClass, cedar_schema: JString<'a>) -> jvalue {

Callers 3

jsonToCedarJniFunction · 0.85

Calls 2

ObjectInterface · 0.85
iterMethod · 0.80

Tested by 2