Class UsersRest
java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
org.apache.juneau.rest.server.servlet.RestServlet
org.apache.juneau.rest.server.servlet.BasicRestServlet
org.apache.juneau.petstore.console.PetstoreConsolePage
org.apache.juneau.petstore.console.users.UsersRest
- All Implemented Interfaces:
jakarta.servlet.Servlet,jakarta.servlet.ServletConfig,Serializable,BasicUniversalConfig,DefaultConfig,DefaultHtmlConfig
The Users page and its endpoints. The password is write-only: every read goes through
UsersRest.UserView, which has
no password, so it never leaves the server; an update with no password keeps the stored one.
Example:
<@card type="datatables" id="users"> { dataMode:'server', dataUrl:'/console/users/query', columns:[{key:'username', label:'Username'}, ...] } </@card>
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA user as the console shows it: everything but the password.Nested classes/interfaces inherited from class org.apache.juneau.rest.server.servlet.RestServlet
RestServlet.Builder<R extends RestServlet,SELF extends RestServlet.Builder<R, SELF>>, RestServlet.DefaultBuilder<R extends RestServlet> -
Field Summary
Fields inherited from class org.apache.juneau.petstore.console.PetstoreConsolePage
PAGE_HEADER, TEMPLATESFields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreate(RestRequest req, JsonMap body) Creates a user.delete(RestRequest req, String username) Deletes a user.The add/edit dialog form.page(RestRequest req) The Users page.query(DataTablesRequest req) Server-mode DataTables query over all users, as password-free views.update(RestRequest req, String username, JsonMap body) Updates a user.Methods inherited from class org.apache.juneau.petstore.console.PetstoreConsolePage
builder, freemarker, store, twinMethods inherited from class org.apache.juneau.rest.server.servlet.RestServlet
builder, createAuthenticator, destroy, doLog, getContext, getPath, getPaths, getRequest, getResponse, getRestBuilder, init, log, log, service, setContextMethods inherited from class jakarta.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPatch, doPost, doPut, doTrace, getLastModified, isSensitiveHeader, serviceMethods inherited from class jakarta.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
-
Constructor Details
-
UsersRest
public UsersRest()
-
-
Method Details
-
page
The Users page.- Parameters:
req- The request;?builderrenders the builder twin.- Returns:
- The page.
-
form
The add/edit dialog form. The password field is write-only: it is never pre-filled.- Parameters:
username- The user to edit, ornull to add.- Returns:
- The modal.
- Throws:
NotFound- Ifusernamenames no user.
-
query
Server-mode DataTables query over all users, as password-free views.- Parameters:
req- The DataTables request.- Returns:
- One page of users, or a 200
errorenvelope for a malformed search expression.
-
get
- Parameters:
username- The username.- Returns:
- The user, without the password.
- Throws:
NotFound- If it does not exist.
-
create
Creates a user.- Parameters:
req- The request (write gate, audit actor).body-{username, firstName, lastName, password}, either plain or as the dialog envelope{fields:{...}}.- Returns:
- The result toast, carrying the user without the password.
- Throws:
BadRequest- On a blank username.Conflict- If the username is taken.
-
update
public ActionResult update(RestRequest req, @Path("username") String username, @Content JsonMap body) Updates a user. A field left out of the body, and a null or blank password, keep their stored values.- Parameters:
req- The request.username- The username.body- The new state, either plain or as the dialog envelope{fields:{...}}.- Returns:
- The result toast, carrying the user without the password.
- Throws:
NotFound- If the user does not exist.
-
delete
Deletes a user.- Parameters:
req- The request.username- The username.- Returns:
- The result toast.
- Throws:
NotFound- If the user does not exist.
-