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,RowDetailMixin,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_HEADFields inherited from interface org.apache.juneau.console.views.RowDetailMixin
ROW_ID, SEGMENT -
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.The Orders tab of the user row detail: the orders a user placed from the console, by id.page(RestRequest req) The Users page.query(DataTablesRequest req) Server-mode DataTables query over all users, as password-free views.The bean-backed details this resource serves.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, logMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.juneau.console.views.RowDetailMixin
rowDetail, rowDetailCounts, rowDetailIndex, rowDetailTab, validRowId
-
Constructor Details
-
UsersRest
public UsersRest()
-
-
Method Details
-
page
The Users page.- Parameters:
req- The request;?builderrenders the builder twin.- Returns:
- The page.
-
rowDetails
Description copied from interface:RowDetailMixinThe bean-backed details this resource serves.- Specified by:
rowDetailsin interfaceRowDetailMixin- Returns:
- The details. Each must have a distinct key.
-
orderRows
The Orders tab of the user row detail: the orders a user placed from the console, by id.- Parameters:
username- The username.- Returns:
- The orders, whose create was audited under this user.
- Throws:
NotFound- Ifusernameis missing or names no user.
-
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.
-