Class SystemAttributes


  • @RequiredRole("admin")
    public class SystemAttributes
    extends APIRequestHandler
    /api/admin/systemattributes : Administration of system attribute records.

    Allows administration (Read/Update) of system attribute records via JSON-encoded objects with the following attributes:

    attribute
    ID of the attribute.
    type
    The type of the attribute - "string", "integer", "boolean", "select", etc.
    style
    Style definition which depends on type
    - e.g. whether the "boolean" is shown as a checkbox or radio buttons, etc.
    label
    User-facing label for the attribute.
    description
    User-facing (long) description of the attribute.
    options
    If type
    is "select", this is an object defining the valid options for the attribute, where the object key is the attribute value and the key's value is the user-facing label for the option.
    value
    The value of the attribute.

    The following operations, specified by the HTTP method, are supported:

    GET
    Read the records.
    • Response Body - the standard JSON envelope, with the model as a corresponding list of records.
    • Response Status
      • 200 : The records could be listed.
    PUT
    Update an existing record, specified by the systemAttribute given in the request body.
    • Request Body - a JSON-encoded object representing the record.
    • Response Body - the standard JSON envelope, with the model as an object representing the record.
    • Response Status
      • 200 : The record was successfully updated.
      • 400 : The record has type == "readonly" found.
      • 404 : The record was not found.

    Author:
    Robert Fromont robert@fromont.net.nz
    • Constructor Detail

      • SystemAttributes

        public SystemAttributes()
        Default constructor.
    • Method Detail

      • get

        public void get​(javax.json.stream.JsonGenerator jsonOut,
                        Consumer<Integer> httpStatus)
        GET handler lists all rows.

        The return is JSON encoded, unless the "Accept" request header, or the "Accept" request parameter, is "text/csv", in which case CSV is returned.

        Parameters:
        jsonOut - Generator for JSON response body.
        httpStatus - Receives the response statsu code, in case or error.
      • put

        public javax.json.JsonObject put​(InputStream requestBody,
                                         Consumer<Integer> httpStatus)
        PUT handler - update an existing row.
        Parameters:
        requestBody - Stream supplying the body of the request.
        httpStatus - Receives the response status code, in case or error.