Class SelectionBasketResource
- java.lang.Object
-
- org.silverpeas.core.web.rs.RESTWebService
-
- org.silverpeas.core.webapi.selection.SelectionBasketResource
-
- All Implemented Interfaces:
ProtectedWebResource
,WebAuthenticationValidation
,WebAuthorizationValidation
,SilverpeasWebResource
@WebService @Authenticated @Path("selection") public class SelectionBasketResource extends RESTWebService
It represents theSelectionBasket
exposed in the web and accessible through a REST-based web API. The selection basket behaves like a FILO list: the first resource put in the basket is at the tail of the basket whereas the last one put is at the head of the basket and hence it will be the first one to get or to pop. The resources put in the basket aren't as such, but they are wrapped within an object that maps them to the context for which they have been put in the basket by the user: aSelectionBasketEntry
instance.- Author:
- mmoquillon
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.silverpeas.core.web.rs.RESTWebService
RESTWebService.WebProcess<R>, RESTWebService.WebTreatment<R>
-
-
Field Summary
-
Fields inherited from class org.silverpeas.core.web.rs.RESTWebService
RESPONSE_HEADER_ARRAYSIZE
-
Fields inherited from interface org.silverpeas.core.web.SilverpeasWebResource
BASE_PATH
-
-
Constructor Summary
Constructors Constructor Description SelectionBasketResource()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<SelectionBasketEntry>
deleteFromBasket(String itemId)
Deletes in the basket the item with the specified unique identifier.List<SelectionBasketEntry>
getAll()
Gets all the content of the selection basket, reverse ordered by the time each item has been put, the last resource put at index 0.String
getComponentId()
Gets the identifier of the component instance to which the requested resource belongs to.protected String
getResourceBasePath()
Gets the base path of the web resource relative to the root path of all the web resources in Silverpeas as given bySilverpeasWebResource.getBasePath()
.List<SelectionBasketEntry>
pop()
Pops the item at the head of the basket.javax.ws.rs.core.Response
putInBasket(SelectionBasketEntry entry)
Puts the specified resource into the basket.List<SelectionBasketEntry>
removeFromBasket(int index)
Deletes in the basket the item placed at the specified position.-
Methods inherited from class org.silverpeas.core.web.rs.RESTWebService
createWebResourceUri, fromPage, getBundle, getBundleLocation, getHighestUserRole, getHttpRequest, getHttpServletRequest, getHttpServletResponse, getOrganisationController, getSilverpeasContext, getUri, getUser, getUserPreferences, getUserRoles, identifiedBy, identifiedBy, initContext, initWebResourceUri, isUserDefined, process
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.silverpeas.core.web.rs.ProtectedWebResource
validateUserAuthorization
-
Methods inherited from interface org.silverpeas.core.web.rs.WebAuthenticationValidation
validateUserAuthentication
-
-
-
-
Method Detail
-
getAll
@GET @Produces("application/json") public List<SelectionBasketEntry> getAll()
Gets all the content of the selection basket, reverse ordered by the time each item has been put, the last resource put at index 0.- Returns:
- a reverse ordered list of basket entries. The last one put being the first one in the list. An entry is a mapping between the Silverpeas resource that has been selected (and hence put into the basket) and its selection context.
-
putInBasket
@POST @Consumes("application/json") @Produces("application/json") public javax.ws.rs.core.Response putInBasket(SelectionBasketEntry entry)
Puts the specified resource into the basket. It will be placed atop of others items in the basket.- Parameters:
entry
- a basket entry. An entry is a mapping between the Silverpeas resource that has been selected and its selection context.- Returns:
- the new state of the basket, that is to say its updated content.
-
pop
@DELETE @Produces("application/json") public List<SelectionBasketEntry> pop()
Pops the item at the head of the basket. Popping is a way to delete the first item in the basket (the last one put into the basket).- Returns:
- the new state of the basket, that is to say its new content without the deleted item.
-
deleteFromBasket
@DELETE @Produces("application/json") @Path("/item/{id}") public List<SelectionBasketEntry> deleteFromBasket(@PathParam("id") String itemId)
Deletes in the basket the item with the specified unique identifier. If no such Silverpeas resource is found in the basket, then aNotFoundException
is thrown.- Parameters:
itemId
- the unique identifier of a Silverpeas resource placed in the basket.- Returns:
- the new state of the basket, that is to say its new content without the deleted item.
-
removeFromBasket
@DELETE @Produces("application/json") @Path("/index/{index}") public List<SelectionBasketEntry> removeFromBasket(@PathParam("index") int index)
Deletes in the basket the item placed at the specified position. If there is no resource at the given position in the basket, then aNotFoundException
is thrown.- Parameters:
index
- the position index of the resource in the basket to remove. The index starts at 0 for the head position.- Returns:
- the new state of the basket, that is to say its new content without the deleted item.
-
getComponentId
public String getComponentId()
Description copied from interface:SilverpeasWebResource
Gets the identifier of the component instance to which the requested resource belongs to.- Returns:
- the identifier of the Silverpeas component instance.
-
getResourceBasePath
protected String getResourceBasePath()
Description copied from class:RESTWebService
Gets the base path of the web resource relative to the root path of all the web resources in Silverpeas as given bySilverpeasWebResource.getBasePath()
.- Specified by:
getResourceBasePath
in classRESTWebService
- Returns:
- the relative path that identifies this REST web service among all other REST web services.
-
-