Class AttributesResource


  • @Path("/attributes")
    @Consumes("application/json")
    @Produces("application/json")
    public class AttributesResource
    extends ConfigBaseResource
    Author:
    Mougang T.Gasmyr
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      jakarta.ws.rs.core.Response createAttribute​(@Valid io.jans.model.JansAttribute attribute)
      Creates a new JansAttribute if valid and not conflicting.
      jakarta.ws.rs.core.Response deleteAttribute​(@NotNull String inum)
      Deletes the attribute identified by the provided inum.
      jakarta.ws.rs.core.Response getAttributeByInum​(@NotNull String inum)
      Retrieve the JansAttribute identified by the provided inum.
      jakarta.ws.rs.core.Response getAttributes​(int limit, String pattern, String status, int startIndex, String sortBy, String sortOrder, String fieldValuePair)
      Retrieve a paged list of Jans attributes matching the provided filters.
      jakarta.ws.rs.core.Response patchAtribute​(@NotNull String inum, @NotNull String pathString)
      Apply a JSON Patch to the JansAttribute identified by the given inum.
      jakarta.ws.rs.core.Response updateAttribute​(@Valid io.jans.model.JansAttribute attribute)
      Update an existing JansAttribute identified by its inum.
      • 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

      • AttributesResource

        public AttributesResource()
    • Method Detail

      • getAttributes

        @GET
        public jakarta.ws.rs.core.Response getAttributes​(@DefaultValue("50") @QueryParam("limit")
                                                         int limit,
                                                         @DefaultValue("") @QueryParam("pattern")
                                                         String pattern,
                                                         @DefaultValue("all") @QueryParam("status")
                                                         String status,
                                                         @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 paged list of Jans attributes matching the provided filters.
        Parameters:
        limit - maximum number of results to return
        pattern - search pattern to match attribute fields
        status - attribute status filter (use ApiConstants.ALL to include all)
        startIndex - 1-based index of the first result to return
        sortBy - attribute field used to sort results
        sortOrder - sorting direction; allowed values are "ascending" and "descending"
        fieldValuePair - comma-separated field=value pairs to further filter results (e.g. "adminCanEdit=true,dataType=string")
        Returns:
        a Response containing a PagedResult of JansAttribute objects that match the query
      • getAttributeByInum

        @GET
        @Path("{inum}")
        public jakarta.ws.rs.core.Response getAttributeByInum​(@PathParam("inum") @NotNull
                                                              @NotNull String inum)
        Retrieve the JansAttribute identified by the provided inum.
        Parameters:
        inum - the attribute's inum (unique identifier)
        Returns:
        the attribute that matches the given inum
      • createAttribute

        @POST
        public jakarta.ws.rs.core.Response createAttribute​(@Valid
                                                           @Valid io.jans.model.JansAttribute attribute)
        Creates a new JansAttribute if valid and not conflicting. Validates required fields (name, displayName, dataType), ensures the attribute name is unique and defined in the DB schema, assigns a new inum and DN, persists the attribute, and returns the created resource.
        Parameters:
        attribute - the JansAttribute to create; must include non-null name, displayName, and dataType
        Returns:
        the created JansAttribute with assigned inum and dn
      • updateAttribute

        @PUT
        public jakarta.ws.rs.core.Response updateAttribute​(@Valid
                                                           @Valid io.jans.model.JansAttribute attribute)
        Update an existing JansAttribute identified by its inum. Validates required fields, checks for name conflicts and schema definition, applies the update, and returns the persisted attribute.
        Parameters:
        attribute - the JansAttribute to update; must include a valid `inum` and non-null `name`, `displayName`, and `dataType`
        Returns:
        the updated JansAttribute
        Throws:
        jakarta.ws.rs.WebApplicationException - if the attribute type is not defined in the DB schema (results in 406 Not Acceptable)
        jakarta.ws.rs.WebApplicationException - if the target attribute (by inum) is not found
        jakarta.ws.rs.WebApplicationException - if another attribute with the same name but a different inum exists (bad request)
      • patchAtribute

        @PATCH
        @Consumes("application/json-patch+json")
        @Path("{inum}")
        public jakarta.ws.rs.core.Response patchAtribute​(@PathParam("inum") @NotNull
                                                         @NotNull String inum,
                                                         @NotNull
                                                         @NotNull String pathString)
                                                  throws com.github.fge.jsonpatch.JsonPatchException,
                                                         IOException
        Apply a JSON Patch to the JansAttribute identified by the given inum. Retrieves the attribute, applies the provided JSON Patch document, persists the update, and returns the modified attribute.
        Parameters:
        inum - the identifier of the attribute to patch
        pathString - the JSON Patch document as a string (RFC 6902)
        Returns:
        the updated JansAttribute
        Throws:
        com.github.fge.jsonpatch.JsonPatchException - if the patch document is invalid or cannot be applied to the attribute
        IOException - if the patch cannot be read or parsed
      • deleteAttribute

        @DELETE
        @Path("{inum}")
        public jakarta.ws.rs.core.Response deleteAttribute​(@PathParam("inum") @NotNull
                                                           @NotNull String inum)
        Deletes the attribute identified by the provided inum.
        Parameters:
        inum - the attribute identifier (inum)
        Returns:
        a Response with HTTP 204 No Content when deletion succeeds