From 43399ac9d69bd8a666094d1a65ae11b4e5ce8457 Mon Sep 17 00:00:00 2001 From: jgomer2001 Date: Tue, 13 Dec 2022 10:08:12 -0500 Subject: [PATCH] feat: add endpoint to do syntax check only #3277 --- .../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 }))