From 3b236360ca7e2c3d7edcae9c356ffd2b193c42c2 Mon Sep 17 00:00:00 2001 From: Jose Date: Tue, 13 Dec 2022 11:34:27 -0500 Subject: [PATCH] feat: add endpoint to do syntax check only #3277 (#3299) --- .../rest/resource/auth/AgamaResource.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/AgamaResource.java b/jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/AgamaResource.java index 6b6efc42fb4..79cbc579d8f 100644 --- a/jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/AgamaResource.java +++ b/jans-config-api/server/src/main/java/io/jans/configapi/rest/resource/auth/AgamaResource.java @@ -148,6 +148,26 @@ public Response createFlow(@Valid Flow flow) return Response.status(Response.Status.CREATED).entity(minimize(flow, false)).build(); } + @POST + @Consumes(MediaType.TEXT_PLAIN) + @ProtectedApi(scopes = { ApiAccessConstants.AGAMA_READ_ACCESS }, groupScopes = { + ApiAccessConstants.AGAMA_WRITE_ACCESS }, superScopes = { ApiAccessConstants.SUPER_ADMIN_READ_ACCESS }) + @Path("/syntax-check/" + ApiConstants.QNAME_PATH) + public Response doSyntaxCheck(@PathParam(ApiConstants.QNAME) String qname, String source) { + + Exception e = null; + try { + Transpiler.runSyntaxCheck(qname, source); + e = new TranspilerException(""); + } catch (SyntaxException | TranspilerException te) { + logger.info("Syntax check failed"); + e = te; + } + e.setStackTrace(new StackTraceElement[0]); + return Response.ok().entity(e).build(); + + } + @Operation(summary = "Create a new agama flow from source", description = "Create a new agama flow from source.", operationId = "post-agama-flow-from-source", tags = { "Agama - Configuration" }, security = @SecurityRequirement(name = "oauth2", scopes = { ApiAccessConstants.AGAMA_WRITE_ACCESS }))