mchades commented on code in PR #13571:
URL: https://github.com/apache/gravitino/pull/13571#discussion_r4227961446
##########
server/src/main/java/org/apache/gravitino/server/web/rest/SemanticModelOperations.java:
##########
@@ -162,6 +164,67 @@ public Response createSemanticModel(
}
}
+ /**
+ * Imports a standalone Apache Ossie YAML or JSON document as a Semantic
Model.
+ *
+ * <p>The request body is raw document text, not a JSON-encoded string. The
{@code Content-Type}
+ * header selects the document format; an absent header defaults to YAML.
Parsing does not fall
+ * back to another format if the document is invalid for the selected parser.
+ *
+ * @param metalake The metalake name.
+ * @param catalog The catalog name.
+ * @param schema The schema name.
+ * @param document The standalone Ossie document.
+ * @param headers The request headers specifying the document's media type.
+ * @return A native response containing the created Semantic Model.
+ */
+ @POST
+ @Path("ossie")
+ @Consumes({
+ MediaType.APPLICATION_JSON,
+ OSSIE_YAML_MEDIA_TYPE,
+ OSSIE_X_YAML_MEDIA_TYPE,
+ OSSIE_TEXT_YAML_MEDIA_TYPE
+ })
+ @Produces(VND_GRAVITINO_V1_JSON)
+ @Timed(name = "import-ossie-semantic-model." +
MetricNames.HTTP_PROCESS_DURATION, absolute = true)
+ @ResponseMetered(name = "import-ossie-semantic-model", absolute = true)
+ public Response importOssieDocument(
+ @PathParam("metalake") String metalake,
+ @PathParam("catalog") String catalog,
+ @PathParam("schema") String schema,
+ String document,
+ @Context HttpHeaders headers) {
+ LOG.info(
+ "Received import Apache Ossie Semantic Model request for schema:
{}.{}.{}",
+ metalake,
+ catalog,
+ schema);
+ try {
+ return Utils.doAs(
+ httpRequest,
+ () -> {
+ OssieDocument ossieDocument =
+
MediaType.APPLICATION_JSON_TYPE.isCompatible(headers.getMediaType())
+ ? OssieDocument.json(document)
+ : OssieDocument.yaml(document);
Review Comment:
I'd keep the existing mapping, consistent with native create validation.
Both types return 400 / `ILLEGAL_ARGUMENTS_CODE`, and the client handler in
#12628 already handles both: it preserves `IllegalSemanticModelException` and
falls back to `IllegalArgumentException`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]