Package com.skava.web
Class CollectionController
java.lang.Object
com.skava.web.CollectionController
This controller class used to handle the collection's manipulation. List of operations handled by this controller
are collection create, collection update, collection retrieval by collection identifier and business identifier and
collection retrieval by business identifier.
- Author:
- Infosys Equinox
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<Collection>
createCollection
(Long businessId, String authToken, @Valid Collection request, String locale, String version, long storeId) This service is used to create collection and returns the created resource as response when the request is valid other wise validation error response will be return as a response with respective http status code using service implementation.org.springframework.http.ResponseEntity<CollectionsResponse>
getAllCollections
(Long businessId, String authToken, int page, int size, String filter, String sort, String locale, String version, long storeId) This service is used to retrieve collection details for the requested business and load collections based on pagination parameters like page and size.org.springframework.http.ResponseEntity<Collection>
getCollectionById
(Long collectionId, Long businessId, String authToken, String locale, String version, long storeId) This service is used to retrieve collection details by collection identifier and business identifier.org.springframework.http.ResponseEntity<Collection>
updateCollection
(Long businessId, String authToken, Long collectionId, Collection request, String locale, String version, long storeId) This service is used to update collection and returns the updated resource as response when the request is valid other wise validation error response will be return as a response with respective http status code using service implementation.
-
Field Details
-
DEFAULT_LIMIT
The default limit.- See Also:
-
-
Constructor Details
-
CollectionController
public CollectionController()The default constructor.
-
-
Method Details
-
createCollection
@PostMapping @PreAuthorize("hasPrivilegeForBusinessById(\'user/create/collections\', #businessId)") @ResponseStatus(CREATED) @Audit(action="createCollection") public org.springframework.http.ResponseEntity<Collection> createCollection(@RequestParam("businessId") @AuditField(field="BUSINESS_ID") Long businessId, @RequestHeader(value="x-auth-token",required=true) @AuditField(field="AUTH_TOKEN") String authToken, @Valid @RequestBody @AuditField(field="COLLECTION") @Valid Collection request, @RequestParam(value="locale",required=false,defaultValue="en_US") @AuditField(field="LOCALE") String locale, @RequestHeader(value="x-version",required=false,defaultValue="8.19.7") @AuditField(field="VERSION") String version, @RequestHeader(value="x-store-id",required=false,defaultValue="0") @AuditField(field="STORE_ID") long storeId) This service is used to create collection and returns the created resource as response when the request is valid other wise validation error response will be return as a response with respective http status code using service implementation. Name of theCollection
is mandatory in request to create.- Parameters:
businessId
- This field holds a valid business identifier.A Business is typically a customer who has signed up with Infosys Equinox to launch a commerce store or a digital experience. An Infosys Equinox Commerce Instance can have multiple Businesses under which there can be multiple stores - Logical entity which binds all the services together to bring in an storefront experience.authToken
- This field holds a valid authorization token generated using the Authorization microservice for an user. Auth token (JWT format) represents claims containing roles and privileges of the user accessing this API. JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. Since the token is a required field for this API it has to be generated before hand by invoking the /auth/sessions API provided by Authorization microservice. The output is three Base64 strings separated by dots that can be easily passed in HTML and HTTP environments, while being more compact when compared to XML-based standards such as SAML. Thus generated token has to be passed to this service and the request will be processed only if the following conditions are met:- Token validation against the secret key
- Expiry time should be in the future
- Necessary privileges are available for the user to perform the action on the subjected resource
request
- HoldsCollection
Holds the collection details that needs to be created. It is given in the form of JSON object. An incorrect JSON would throw Bad request error.locale
- API Response and error messages will be responded in the locale mentioned in this parameter.version
- It hold the value of version number of API. Using this parameter we can access the different version of the API. It is currently unused.storeId
- It Holds a valid unique identifier of the store.- Returns:
- The
ResponseEntity
ofCollection
object.
-
getCollectionById
@GetMapping("/{collectionId}") @Audit(action="getCollection") public org.springframework.http.ResponseEntity<Collection> getCollectionById(@PathVariable("collectionId") @AuditField(field="COLLECTION_ID") Long collectionId, @RequestParam("businessId") @AuditField(field="BUSINESS_ID") Long businessId, @RequestHeader(value="x-auth-token",required=false) @AuditField(field="AUTH_TOKEN") String authToken, @RequestParam(value="locale",required=false,defaultValue="en_US") @AuditField(field="LOCALE") String locale, @RequestHeader(value="x-version",required=false,defaultValue="8.19.7") @AuditField(field="VERSION") String version, @RequestHeader(value="x-store-id",required=false,defaultValue="0") @AuditField(field="STORE_ID") long storeId) This service is used to retrieve collection details by collection identifier and business identifier. This will return the collection details from the system when the request is valid otherwise this will return the validation error response.- Parameters:
businessId
- This field holds a valid business identifier.A Business is typically a customer who has signed up with Infosys Equinox to launch a commerce store or a digital experience. An Infosys Equinox Commerce Instance can have multiple Businesses under which there can be multiple stores - Logical entity which binds all the services together to bring in an storefront experience.authToken
- This field holds a valid authorization token generated using the Authorization microservice for an user. Auth token (JWT format) represents claims containing roles and privileges of the user accessing this API. JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. Since the token is a required field for this API it has to be generated before hand by invoking the /auth/sessions API provided by Authorization microservice. The output is three Base64 strings separated by dots that can be easily passed in HTML and HTTP environments, while being more compact when compared to XML-based standards such as SAML. Thus generated token has to be passed to this service and the request will be processed only if the following conditions are met:- Token validation against the secret key
- Expiry time should be in the future
- Necessary privileges are available for the user to perform the action on the subjected resource
collectionId
- Indicates the identifier of a user collection which is used to delete a particular collection. Holds long value.locale
- API Response and error messages will be responded in the locale mentioned in this parameter.version
- It hold the value of version number of API. Using this parameter we can access the different version of the API. It is currently unused.storeId
- It Holds a valid unique identifier of the store.- Returns:
- The
ResponseEntity
ofCollection
object.
-
getAllCollections
@GetMapping @PreAuthorize("hasPrivilegeForBusinessById(\'user/viewall/collections\', #businessId)") @Audit(action="getCollections") public org.springframework.http.ResponseEntity<CollectionsResponse> getAllCollections(@RequestParam(value="businessId",required=false) @AuditField(field="BUSINESS_ID") Long businessId, @RequestHeader(value="x-auth-token",required=true) @AuditField(field="AUTH_TOKEN") String authToken, @RequestParam(value="page",required=false,defaultValue="1") @AuditField(field="PAGE") int page, @RequestParam(value="size",required=false,defaultValue="10") @AuditField(field="SIZE") int size, @RequestParam(value="filter",required=false) @AuditField(field="FILTER") String filter, @RequestParam(value="sort",required=false) @AuditField(field="SORT") String sort, @RequestParam(value="locale",required=false,defaultValue="en_US") @AuditField(field="LOCALE") String locale, @RequestHeader(value="x-version",required=false,defaultValue="8.19.7") @AuditField(field="VERSION") String version, @RequestHeader(value="x-store-id",required=false,defaultValue="0") @AuditField(field="STORE_ID") long storeId) This service is used to retrieve collection details for the requested business and load collections based on pagination parameters like page and size. This will return the collection details from the system when the request is valid otherwise this will return the validation error response.- Parameters:
businessId
- This field holds a valid business identifier.A Business is typically a customer who has signed up with Infosys Equinox to launch a commerce store or a digital experience . An Infosys Equinox Commerce Instance can have multiple Businesses under which there can be multiple stores - Logical entity which binds all the services together to bring in an storefront experience.authToken
- This field holds a valid authorization token generated using the Authorization microservice for an user. Auth token (JWT format) represents claims containing roles and privileges of the user accessing this API. JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. Since the token is a required field for this API it has to be generated before hand by invoking the /auth/sessions API provided by Authorization microservice. The output is three Base64 strings separated by dots that can be easily passed in HTML and HTTP environments, while being more compact when compared to XML-based standards such as SAML. Thus generated token has to be passed to this service and the request will be processed only if the following conditions are met:- Token validation against the secret key
- Expiry time should be in the future
- Necessary privileges are available for the user to perform the action on the subjected resource
page
- The page number to be retrieved where the size of the page must be specified by the size/offset/pageSize parameter. First page starts with value \"0\".size
- The number of documents being retrieved on the corresponding page specified by page parameter.filter
- Indicates the filter params which is used for searching the collections.sort
- Indicates the sort params which is used for sorting the collection.locale
- API Response and error messages will be responded in the locale mentioned in this parameter.version
- It hold the value of version number of API. Using this parameter we can access the different version of the API. It is currently unused.storeId
- It Holds a valid unique identifier of the store.- Returns:
- The
ResponseEntity
ofCollectionsResponse
object.
-
updateCollection
@PutMapping("/{collectionId}") @PreAuthorize("hasPrivilegeForServiceAndCollection(\'user/update/collections\', #businessId, \'user\', #collectionId)") @Audit(action="updateCollection") public org.springframework.http.ResponseEntity<Collection> updateCollection(@RequestParam("businessId") @AuditField(field="BUSINESS_ID") Long businessId, @RequestHeader(value="x-auth-token",required=true) @AuditField(field="AUTH_TOKEN") String authToken, @PathVariable("collectionId") @AuditField(field="COLLECTION_ID") Long collectionId, @RequestBody @AuditField(field="COLLECTION") Collection request, @RequestParam(value="locale",required=false,defaultValue="en_US") @AuditField(field="LOCALE") String locale, @RequestHeader(value="x-version",required=false,defaultValue="8.19.7") @AuditField(field="VERSION") String version, @RequestHeader(value="x-store-id",required=false,defaultValue="0") @AuditField(field="STORE_ID") long storeId) This service is used to update collection and returns the updated resource as response when the request is valid other wise validation error response will be return as a response with respective http status code using service implementation. Name of theCollection
is mandatory in request to update and also this should be unique under given collection.- Parameters:
businessId
- This field holds a valid business identifier.A Business is typically a customer who has signed up with Infosys Equinox to launch a commerce store or a digital experience. An Infosys Equinox Commerce Instance can have multiple Businesses under which there can be multiple stores - Logical entity which binds all the services together to bring in an storefront experience.authToken
- This field holds a valid authorization token generated using the Authorization microservice for an user. Auth token (JWT format) represents claims containing roles and privileges of the user accessing this API. JSON Web Token (JWT) is an open standard (RFC 7519) that defines a compact and self-contained way for securely transmitting information between parties as a JSON object. Since the token is a required field for this API it has to be generated before hand by invoking the /auth/sessions API provided by Authorization microservice. The output is three Base64 strings separated by dots that can be easily passed in HTML and HTTP environments, while being more compact when compared to XML-based standards such as SAML. Thus generated token has to be passed to this service and the request will be processed only if the following conditions are met:- Token validation against the secret key
- Expiry time should be in the future
- Necessary privileges are available for the user to perform the action on the subjected resource
collectionId
- Indicates the identifier of a user collection which is used to delete a particular collection. Holds long value.request
- HoldsCollection
Holds the collection details that needs to be created. It is given in the form of JSON object. An incorrect JSON would throw Bad request error.locale
- API Response and error messages will be responded in the locale mentioned in this parameter.version
- It hold the value of version number of API. Using this parameter we can access the different version of the API. It is currently unused.storeId
- It Holds a valid unique identifier of the store.- Returns:
- The
ResponseEntity
ofCollection
object.
-