Class CustomScriptResource


  • @Path("/config/scripts")
    @Consumes("application/json")
    @Produces("application/json")
    public class CustomScriptResource
    extends ConfigBaseResource
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      jakarta.ws.rs.core.Response createScript​(@Valid io.jans.model.custom.script.model.CustomScript customScript, boolean addScriptTemplate)
      Creates a new CustomScript and persists it.
      jakarta.ws.rs.core.Response deleteScript​(@NotNull String inum)
      Delete the custom script identified by the given inum.
      jakarta.ws.rs.core.Response getAllCustomScripts​(int limit, String pattern, int startIndex, String sortBy, String sortOrder, String fieldValuePair)
      Retrieve a paginated list of custom scripts matching the provided filters.
      jakarta.ws.rs.core.Response getCustomScriptByInum​(@NotNull String inum)
      Retrieve the CustomScript identified by the given inum.
      jakarta.ws.rs.core.Response getCustomScriptByName​(@NotNull String name)
      Fetches a custom script by its display name.
      jakarta.ws.rs.core.Response getCustomScriptsByTypePattern​(@NotNull String type, int limit, String pattern, int startIndex, String sortBy, String sortOrder, String fieldValuePair)
      Lists custom scripts of the specified type, supporting pagination, search pattern, sorting, and field-value filtering.
      jakarta.ws.rs.core.Response getCustomScriptTypes()
      Retrieve all available custom script types.
      jakarta.ws.rs.core.Response getCustomScriptTypesDetails()
      Fetches distinct custom script type values.
      jakarta.ws.rs.core.Response patchScript​(@NotNull String inum, @NotNull String pathString)
      Applies a JSON Patch (RFC 6902) to the CustomScript identified by the given inum.
      jakarta.ws.rs.core.Response updateScript​(@Valid @NotNull io.jans.model.custom.script.model.CustomScript customScript)
      Update an existing custom script.
      • Methods inherited from class io.jans.configapi.core.rest.BaseResource

        checkNotEmpty, checkNotEmpty, checkNotNull, checkNotNull, checkNotNull, checkResourceNotNull, createSearchRequest, findRootError, getBadRequestException, getBadRequestException, getBadRequestException, getHttpHeaders, getHttpRequest, getInternalServerException, getInternalServerException, getMissingAttributeError, getNotAcceptableException, getNotFoundError, getNotFoundError, getUriInfo, throwBadRequestException, throwBadRequestException, throwBadRequestException, throwInternalServerException, throwInternalServerException, throwInternalServerException, throwInternalServerException, throwMissingAttributeError, throwNotFoundException, throwNotFoundException
    • Constructor Detail

      • CustomScriptResource

        public CustomScriptResource()
    • Method Detail

      • getAllCustomScripts

        @GET
        public jakarta.ws.rs.core.Response getAllCustomScripts​(@DefaultValue("50") @QueryParam("limit")
                                                               int limit,
                                                               @DefaultValue("") @QueryParam("pattern")
                                                               String pattern,
                                                               @DefaultValue("0") @QueryParam("startIndex")
                                                               int startIndex,
                                                               @DefaultValue("inum") @QueryParam("sortBy")
                                                               String sortBy,
                                                               @DefaultValue("ascending") @QueryParam("sortOrder")
                                                               String sortOrder,
                                                               @DefaultValue("") @QueryParam("fieldValuePair")
                                                               String fieldValuePair)
        Retrieve a paginated list of custom scripts matching the provided filters.
        Parameters:
        limit - maximum number of results to return
        pattern - substring or pattern to filter script attributes
        startIndex - 1-based index of the first result to include
        sortBy - attribute name to sort results by
        sortOrder - sort direction; allowed values are "ascending" and "descending"
        fieldValuePair - comma-separated field=value pairs to further filter results
        Returns:
        a Response containing a PagedResult of CustomScript objects that match the query
      • getCustomScriptByName

        @GET
        @Path("/name/{name}")
        public jakarta.ws.rs.core.Response getCustomScriptByName​(@PathParam("name") @NotNull
                                                                 @NotNull String name)
        Fetches a custom script by its display name.
        Parameters:
        name - the display name of the custom script to retrieve
        Returns:
        the CustomScript that matches the given display name
      • getCustomScriptsByTypePattern

        @GET
        @Path("/type/{type}")
        public jakarta.ws.rs.core.Response getCustomScriptsByTypePattern​(@PathParam("type") @NotNull
                                                                         @NotNull String type,
                                                                         @DefaultValue("50") @QueryParam("limit")
                                                                         int limit,
                                                                         @DefaultValue("") @QueryParam("pattern")
                                                                         String pattern,
                                                                         @DefaultValue("0") @QueryParam("startIndex")
                                                                         int startIndex,
                                                                         @DefaultValue("inum") @QueryParam("sortBy")
                                                                         String sortBy,
                                                                         @DefaultValue("ascending") @QueryParam("sortOrder")
                                                                         String sortOrder,
                                                                         @DefaultValue("") @QueryParam("fieldValuePair")
                                                                         String fieldValuePair)
        Lists custom scripts of the specified type, supporting pagination, search pattern, sorting, and field-value filtering.
        Returns:
        HTTP 200 response containing a paged result of matching CustomScript objects
      • getCustomScriptByInum

        @GET
        @Path("/inum/{inum}")
        public jakarta.ws.rs.core.Response getCustomScriptByInum​(@PathParam("inum") @NotNull
                                                                 @NotNull String inum)
        Retrieve the CustomScript identified by the given inum.
        Parameters:
        inum - the script identifier (Inum)
        Returns:
        a JAX-RS Response containing the CustomScript when found (HTTP 200), or 404 Not Found when no script matches
      • createScript

        @POST
        public jakarta.ws.rs.core.Response createScript​(@Valid
                                                        @Valid io.jans.model.custom.script.model.CustomScript customScript,
                                                        @DefaultValue("false") @QueryParam("addScriptTemplate")
                                                        boolean addScriptTemplate)
        Creates a new CustomScript and persists it. Validates and prepares the provided CustomScript (generating an inum if missing, handling script/template selection, applying file-location adjustments, and setting revision/DN) before storing it and returning the created resource.
        Parameters:
        customScript - the CustomScript to create; must not be null
        addScriptTemplate - if true, a default script template may be added when the script body is blank
        Returns:
        a Response with status 201 and the created CustomScript as the entity
        Throws:
        jakarta.ws.rs.BadRequestException - when the script's location type is invalid (deprecated LDAP location)
      • updateScript

        @PUT
        public jakarta.ws.rs.core.Response updateScript​(@Valid @NotNull
                                                        @Valid @NotNull io.jans.model.custom.script.model.CustomScript customScript)
        Update an existing custom script. Updates the stored CustomScript identified by the provided object's inum, applies revision and file-location adjustments, persists the change, and synchronizes related authentication method state where applicable.
        Parameters:
        customScript - the CustomScript containing updated values (must include a valid `inum`)
        Returns:
        a Response containing the updated CustomScript with HTTP 200 status
      • deleteScript

        @DELETE
        @Path("{inum}")
        public jakarta.ws.rs.core.Response deleteScript​(@PathParam("inum") @NotNull
                                                        @NotNull String inum)
        Delete the custom script identified by the given inum. Removes the script from storage and, if it was configured as the default ACR (authentication method), clears that configuration so it is no longer used.
        Parameters:
        inum - the script identifier (inum) to delete
        Returns:
        an HTTP 204 No Content response on successful deletion
        Throws:
        jakarta.ws.rs.NotFoundException - if the script does not exist or cannot be deleted
      • patchScript

        @PATCH
        @Consumes("application/json-patch+json")
        @Path("{inum}")
        public jakarta.ws.rs.core.Response patchScript​(@PathParam("inum") @NotNull
                                                       @NotNull String inum,
                                                       @NotNull
                                                       @NotNull String pathString)
                                                throws com.github.fge.jsonpatch.JsonPatchException,
                                                       IOException
        Applies a JSON Patch (RFC 6902) to the CustomScript identified by the given inum.
        Parameters:
        inum - the identifier (inum) of the CustomScript to patch
        pathString - a JSON Patch document as a string describing the modifications
        Returns:
        the patched CustomScript
        Throws:
        com.github.fge.jsonpatch.JsonPatchException - if the patch cannot be applied to the existing resource
        IOException - if the patch document cannot be read or parsed
      • getCustomScriptTypes

        @GET
        @Path("/types")
        public jakarta.ws.rs.core.Response getCustomScriptTypes()
        Retrieve all available custom script types.
        Returns:
        a list of CustomScriptType values
      • getCustomScriptTypesDetails

        @GET
        @Path("/script-types")
        public jakarta.ws.rs.core.Response getCustomScriptTypesDetails()
        Fetches distinct custom script type values.
        Returns:
        a Response containing a Set of unique custom script type strings