@RestResource(path="/petstore", title="Petstore application", description={"This is a sample server Petstore server based on the Petstore sample at Swagger.io.","You can find out more about Swagger at http://swagger.io."}, properties=@Property(name="SwaggerUI.resolveRefsMaxDepth.i",value="99"), swagger=, staticFiles="htdocs:htdocs", children={SqlQueryResource.class,PhotosResource.class}) @HtmlDocConfig(widgets={ContentTypeMenuItem.class,ThemeMenuItem.class}, navlinks={"up: request:/..","options: servlet:/?method=OPTIONS","init: servlet:/init","$W{ContentTypeMenuItem}","$W{ThemeMenuItem}","source: $C{Source/gitHub}/org/apache/juneau/examples/rest/petstore/$R{servletClassSimple}.java"}, head="<link rel=\'icon\' href=\'$U{servlet:/htdocs/cat.png}\'/>", header={"<h1>$R{resourceTitle}</h1>","<h2>$R{methodSummary}</h2>","$C{PetStore/headerImage}"}, aside={"<div style=\'max-width:400px\' class=\'text\'>","\t<p>This page shows a standard nested REST resource.</p>","\t<p>It shows how different properties can be rendered on the same bean in different views.</p>","\t<p>It also shows examples of HtmlRender classes and @BeanProperty(format) annotations.</p>","\t<p>It also shows how the Queryable converter and query widget can be used to create searchable interfaces.</p>","</div>"}, stylesheet="servlet:/htdocs/themes/dark.css") public class PetStoreResource extends BasicRestJena implements PetStore
Constructor and Description |
---|
PetStoreResource() |
Modifier and Type | Method and Description |
---|---|
Ok |
createUsers(User[] users)
Bulk creates users.
|
Ok |
deleteOrder(long orderId)
Deletes an order from the database.
|
Ok |
deletePet(String apiKey,
long petId)
Deletes the specified pet.
|
Ok |
deleteUser(String username)
Deletes a user from the database.
|
Div |
editPetPage(long petId)
Displays the pet edit page.
|
Collection<Pet> |
findPetsByStatus(PetStatus[] status)
Find all pets with the matching statuses.
|
Collection<Pet> |
findPetsByTags(String[] tags)
Deprecated.
|
Div |
getInit()
Initialize database form entry page.
|
Order |
getOrder(long orderId)
Returns an order from the database.
|
Collection<Order> |
getOrders()
Returns all orders in the database.
|
Pet |
getPet(long petId)
Returns a pet from the database.
|
Collection<Pet> |
getPets()
Returns all pets in the database.
|
ResourceDescriptions |
getStore()
Store navigation page.
|
Map<PetStatus,Integer> |
getStoreInventory()
Returns an inventory of pet statuses and counts.
|
ResourceDescriptions |
getTopPage()
Navigation page
|
User |
getUser(String username)
Returns a user from the database.
|
Collection<User> |
getUsers()
Returns all users in the database.
|
Ok |
login(String username,
String password,
Value<Integer> rateLimit,
Value<ExpiresAfter> expiresAfter,
RestRequest req,
RestResponse res)
User login.
|
Ok |
logout()
User logout.
|
long |
placeOrder(long petId,
String username)
Adds an order to the database.
|
void |
postInit(String initMethod,
RestResponse res)
Initialize database.
|
long |
postPet(CreatePet pet)
Adds a pet to the database.
|
Ok |
postUser(User user)
Adds a new user to the database.
|
void |
startup(RestContextBuilder builder)
Initializes our pet store service during servlet initialization.
|
Ok |
updatePet(UpdatePet pet)
Updates a pet in the database.
|
Ok |
updateUser(String username,
User user)
Updates a user in the database.
|
getOptions
destroy, getContext, getPath, getProperties, getRequest, getResponse, getServletConfig, init, log, log, log, log, logObjects, service, setContext, setRestResourceResolver
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service
getInitParameter, getInitParameterNames, getServletContext, getServletInfo, getServletName, init
public PetStoreResource()
@RestHook(value=INIT) public void startup(RestContextBuilder builder)
builder
- Optional access to rest context builder.@RestMethod(name="GET", path="/", summary="Navigation page") @HtmlDocConfig(style={"INHERIT","body { ","background-image: url(\'petstore/htdocs/background.jpg\'); ","background-color: black; ","background-size: cover; ","background-attachment: fixed; ","}"}) public ResourceDescriptions getTopPage()
@RestMethod(summary="Initialize database form entry page") public Div getInit()
@RestMethod(summary="Initialize database") public void postInit(@FormData(value="init-method") String initMethod, RestResponse res) throws Exception
initMethod
- The method used to initialize the database.res
- HTTP request.Exception
- Error occurred.@RestMethod(name="GET", path="/pet", summary="All pets in the store", swagger=, converters=Queryable.class) @HtmlDocConfig(widgets={QueryMenuItem.class,AddPetMenuItem.class}, navlinks={"INHERIT","[2]:$W{QueryMenuItem}","[3]:$W{AddPetMenuItem}"}) @BeanConfig(bpx="Pet: tags,photo") public Collection<Pet> getPets() throws NotAcceptable
PetStore
getPets
in interface PetStore
NotAcceptable
- Unsupported @RestMethod(name="GET", path="/pet/{petId}", summary="Find pet by ID", description="Returns a single pet", swagger=) public Pet getPet(long petId) throws IdNotFound, NotAcceptable
PetStore
getPet
in interface PetStore
petId
- The ID of the pet to retrieve.IdNotFound
- Pet was not found.NotAcceptable
- Unsupported @RestMethod(summary="Add a new pet to the store", swagger=) public long postPet(CreatePet pet) throws IdConflict, NotAcceptable, UnsupportedMediaType
PetStore
postPet
in interface PetStore
pet
- The pet data to add to the database.Ok
if successful.IdConflict
- ID already in use.NotAcceptable
- Unsupported UnsupportedMediaType
- Unsupported @RestMethod(name="PUT", path="/pet/{petId}", summary="Update an existing pet", swagger=) public Ok updatePet(UpdatePet pet) throws IdNotFound, NotAcceptable, UnsupportedMediaType
PetStore
updatePet
in interface PetStore
pet
- The pet data to add to the database.Ok
if successful.IdNotFound
- ID not found.NotAcceptable
- Unsupported UnsupportedMediaType
- Unsupported @RestMethod(name="GET", path="/pet/findByStatus", summary="Finds Pets by status", description="Multiple status values can be provided with comma separated strings.", swagger=) public Collection<Pet> findPetsByStatus(PetStatus[] status) throws NotAcceptable
PetStore
findPetsByStatus
in interface PetStore
status
- The statuses to match against.NotAcceptable
- Unsupported @RestMethod(name="GET", path="/pet/findByTags", summary="Finds Pets by tags", description="Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", swagger=) @Deprecated public Collection<Pet> findPetsByTags(String[] tags) throws InvalidTag, NotAcceptable
PetStore
findPetsByTags
in interface PetStore
tags
- The tags to match against.InvalidTag
- Invalid tag was specified.NotAcceptable
- Unsupported @RestMethod(name="DELETE", path="/pet/{petId}", summary="Deletes a pet", swagger=) public Ok deletePet(String apiKey, long petId) throws IdNotFound, NotAcceptable
PetStore
deletePet
in interface PetStore
apiKey
- Security key.petId
- ID of pet to delete.Ok
if successful.IdNotFound
- Pet not found.NotAcceptable
- Unsupported @RestMethod(name="GET", path="/pet/{petId}/edit", summary="Pet edit page", swagger=) public Div editPetPage(@Path(name="petId",description="ID of pet to edit",example="123") long petId) throws NotAcceptable, UnsupportedMediaType
petId
- ID of pet to editNotAcceptable
- Unsupported UnsupportedMediaType
- Unsupported @RestMethod(summary="Store navigation page", swagger=) public ResourceDescriptions getStore()
@RestMethod(name="GET", path="/store/order", summary="Petstore orders", swagger=) @HtmlDocConfig(widgets={QueryMenuItem.class,AddOrderMenuItem.class}, navlinks={"INHERIT","[2]:$W{QueryMenuItem}","[3]:$W{AddOrderMenuItem}"}) public Collection<Order> getOrders() throws NotAcceptable
PetStore
getOrders
in interface PetStore
NotAcceptable
- Unsupported @RestMethod(name="GET", path="/store/order/{orderId}", summary="Find purchase order by ID", description="Returns a purchase order by ID.", swagger=) public Order getOrder(long orderId) throws InvalidId, IdNotFound, NotAcceptable
PetStore
getOrder
in interface PetStore
orderId
- The ID of the order to retreieve.InvalidId
- ID was invalid.IdNotFound
- Order was not found.NotAcceptable
- Unsupported @RestMethod(name="POST", path="/store/order", summary="Place an order for a pet", swagger=, pojoSwaps=TemporalDateSwap.IsoLocalDate.class) public long placeOrder(long petId, String username) throws IdConflict, NotAcceptable, UnsupportedMediaType
PetStore
placeOrder
in interface PetStore
petId
- Id of pet to order.username
- The username of the user placing the order.IdConflict
- ID was already in use.NotAcceptable
- Unsupported UnsupportedMediaType
- Unsupported @RestMethod(name="DELETE", path="/store/order/{orderId}", summary="Delete purchase order by ID", description={"For valid response try integer IDs with positive integer value.","Negative or non-integer values will generate API errors."}, swagger=) public Ok deleteOrder(long orderId) throws InvalidId, IdNotFound, NotAcceptable
PetStore
deleteOrder
in interface PetStore
orderId
- The order ID.Ok
if successful.InvalidId
- ID not valid.IdNotFound
- Order not found.NotAcceptable
- Unsupported @RestMethod(name="GET", path="/store/inventory", summary="Returns pet inventories by status", description="Returns a map of status codes to quantities", swagger=) public Map<PetStatus,Integer> getStoreInventory() throws NotAcceptable
PetStore
getStoreInventory
in interface PetStore
NotAcceptable
- Unsupported @RestMethod(name="GET", path="/user", summary="Petstore users", bpx="User: email,password,phone", swagger=) public Collection<User> getUsers() throws NotAcceptable
PetStore
getUsers
in interface PetStore
NotAcceptable
- Unsupported @RestMethod(name="GET", path="/user/{username}", summary="Get user by user name", swagger=) public User getUser(String username) throws InvalidUsername, IdNotFound, NotAcceptable
PetStore
getUser
in interface PetStore
username
- The username.InvalidUsername
- Invalid username.IdNotFound
- username not found.NotAcceptable
- Unsupported @RestMethod(summary="Create user", description="This can only be done by the logged in user.", swagger=) public Ok postUser(User user) throws InvalidUsername, IdConflict, NotAcceptable, UnsupportedMediaType
PetStore
postUser
in interface PetStore
user
- The user to add to the database.Ok
if successful.InvalidUsername
- Username was invalid.IdConflict
- Username already in use.NotAcceptable
- Unsupported UnsupportedMediaType
- Unsupported @RestMethod(name="POST", path="/user/createWithArray", summary="Creates list of users with given input array", swagger=) public Ok createUsers(User[] users) throws InvalidUsername, IdConflict, NotAcceptable, UnsupportedMediaType
PetStore
createUsers
in interface PetStore
users
- The users to add to the database.Ok
if successful.InvalidUsername
- Username was invalid.IdConflict
- Username already in use.NotAcceptable
- Unsupported UnsupportedMediaType
- Unsupported @RestMethod(name="PUT", path="/user/{username}", summary="Update user", description="This can only be done by the logged in user.", swagger=) public Ok updateUser(String username, User user) throws InvalidUsername, IdNotFound, NotAcceptable, UnsupportedMediaType
PetStore
updateUser
in interface PetStore
username
- The username.user
- The updated information.Ok
if successful.InvalidUsername
- Username was invalid.IdNotFound
- User was not found.NotAcceptable
- Unsupported UnsupportedMediaType
- Unsupported @RestMethod(name="DELETE", path="/user/{username}", summary="Delete user", description="This can only be done by the logged in user.", swagger=) public Ok deleteUser(String username) throws InvalidUsername, IdNotFound, NotAcceptable
PetStore
deleteUser
in interface PetStore
username
- The username.Ok
if successful.InvalidUsername
- Username was not valid.IdNotFound
- User was not found.NotAcceptable
- Unsupported @RestMethod(name="GET", path="/user/login", summary="Logs user into the system", swagger=) public Ok login(String username, String password, Value<Integer> rateLimit, Value<ExpiresAfter> expiresAfter, RestRequest req, RestResponse res) throws InvalidLogin, NotAcceptable
PetStore
login
in interface PetStore
username
- The username for login.password
- The password for login in clear text.rateLimit
- Calls per hour allowed by the user.expiresAfter
- The req
- The servlet request.res
- The servlet response.Ok
if successful.InvalidLogin
- Login was unsuccessful.NotAcceptable
- Unsupported @RestMethod(name="GET", path="/user/logout", summary="Logs out current logged in user session", swagger=) public Ok logout() throws NotAcceptable
PetStore
logout
in interface PetStore
Ok
if successful.NotAcceptable
- Unsupported Copyright © 2016–2019 The Apache Software Foundation. All rights reserved.