Package com.skava.web
Class CollectionController
java.lang.Object
com.skava.web.CollectionController
@RestController
@RequestMapping("/collections")
@Validated
public class CollectionController
extends Object
The Class CollectionController -
This controller class contains service end-points that are used to perform actions as follows, Create Collection,Get All Collections,Get Collection By id, Update Collection and Delete Collection on the Collection Entity.
This controller class contains service end-points that are used to perform actions as follows, Create Collection,Get All Collections,Get Collection By id, Update Collection and Delete Collection on the Collection Entity.
- Author:
- Infosys Equinox
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionCollectionController
(CreateCollectionService createCollectionService, GetCollectionService getCollectionService, GetAllCollectionService getAllCollectionService, UpdateCollectionService updateCollectionService, CommonServices commonServices) The class constructor. -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<Collection>
createCollection
(Long businessId, String version, long storeId, String authToken, @Valid Collection request, String locale) This service is used to create a new collection.org.springframework.http.ResponseEntity<CollectionsResponse>
getAllCollections
(Long businessId, String version, long storeId, String authToken, @jakarta.validation.constraints.Min(value=1L, message="{param.page.min}") int page, @jakarta.validation.constraints.Min(value=1L, message="{param.size.min}"),@jakarta.validation.constraints.Max(value=50L, message="{param.size.max}") int size, String locale, String filter, String sort) This service is used to load all the collections based on the given page,size and businesId.org.springframework.http.ResponseEntity<Collection>
getCollectionById
(String authToken, String version, long storeId, long collectionId, Long businessId, String locale) This service is used to load a collection using id of the collection.org.springframework.http.ResponseEntity<Collection>
updateCollection
(Long businessId, String version, long storeId, String authToken, long collectionId, Collection request, String locale) This service is used to update collection for which collection id given in request
-
Field Details
-
DEFAULT_LIMIT
The default limit- See Also:
-
-
Constructor Details
-
CollectionController
@Autowired public CollectionController(CreateCollectionService createCollectionService, GetCollectionService getCollectionService, GetAllCollectionService getAllCollectionService, UpdateCollectionService updateCollectionService, CommonServices commonServices) The class constructor.
-
-
Method Details
-
createCollection
@PostMapping @ResponseStatus(CREATED) @PreAuthorize("hasPrivilegeForBusinessById(\'notification/create/collection\', #businessId)") @Audit(action="createCollection") public org.springframework.http.ResponseEntity<Collection> createCollection(@RequestParam(value="businessId",required=true) Long businessId, @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="STOREID") long storeId, @RequestHeader(value="x-auth-token",required=true) @AuditField(field="AUTH_TOKEN") String authToken, @Valid @RequestBody(required=true) @AuditField(field="COLLECTION") @Valid Collection request, @RequestParam(value="locale",required=false,defaultValue="en_US") String locale) This service is used to create a new collection. Collection is created based on the provided information.- 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.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.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
- Instance ofCollection
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.storeId
- Refers to the unique id of the store.version
- Refers to the version.- Returns:
- the responseEntity of CommonCollectionResponse Instance of
CommonCollectionResponse
object.
-
getCollectionById
@GetMapping("/{collectionId}") @PreAuthorize("hasPrivilegeForServiceAndCollection(\'notification/view/collection\', #businessId, \'notification\', #collectionId)") @Audit(action="getCollection") public org.springframework.http.ResponseEntity<Collection> getCollectionById(@RequestHeader(value="x-auth-token",required=true) @AuditField(field="AUTH_TOKEN") String authToken, @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="STOREID") long storeId, @PathVariable(value="collectionId",required=true) @AuditField(field="COLLECTIONID") long collectionId, @RequestParam(value="businessId",required=true) Long businessId, @RequestParam(value="locale",required=false,defaultValue="en_US") @AuditField(field="LOCALE") String locale) This service is used to load a collection using id of the 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
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.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.storeId
- Refers to the unique id of the store.version
- Refers to the version.- Returns:
- the responseEntity of CommonCollectionResponse Instance of
CommonCollectionResponse
object.
-
getAllCollections
@GetMapping @PreAuthorize("hasPrivilegeForServiceAndCollection(\'notification/viewall/collection\', #businessId, \'notification\', #collectionId)") @ResponseStatus(OK) @Audit(action="getAllCollection") public org.springframework.http.ResponseEntity<CollectionsResponse> getAllCollections(@RequestParam(value="businessId",required=false,defaultValue="-1") Long businessId, @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="STOREID") long storeId, @RequestHeader(value="x-auth-token",required=true) @AuditField(field="AUTH_TOKEN") String authToken, @RequestParam(value="page",required=false,defaultValue="1") @Min(value=1L,message="{param.page.min}") @AuditField(field="PAGE") @jakarta.validation.constraints.Min(value=1L, message="{param.page.min}") int page, @RequestParam(value="size",required=false,defaultValue="10") @Min(value=1L,message="{param.size.min}") @Max(value=50L,message="{param.size.max}") @AuditField(field="SIZE") @jakarta.validation.constraints.Min(value=1L, message="{param.size.min}"),@jakarta.validation.constraints.Max(value=50L, message="{param.size.max}") int size, @RequestParam(value="locale",required=false,defaultValue="en_US") @AuditField(field="LOCALE") String locale, @RequestParam(value="filter",required=false,defaultValue="") @AuditField(field="FILTER") String filter, @RequestParam(value="sort",required=false,defaultValue="id,ASC") String sort) This service is used to load all the collections based on the given page,size and businesId.- 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.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.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.locale
- API Response and error messages will be responded in the locale mentioned in this 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.storeId
- Refers to the unique id of the store.version
- Refers to the version.- Returns:
- the responseEntity of CollectionsResponse Instance of
CollectionsResponse
object.
-
updateCollection
@PutMapping("/{collectionId}") @PreAuthorize("hasPrivilegeForServiceAndCollection(\'notification/update/collection\', #businessId, \'notification\', #collectionId)") @Audit(action="updateCollection") public org.springframework.http.ResponseEntity<Collection> updateCollection(@RequestParam(value="businessId",required=true) Long businessId, @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="STOREID") long storeId, @RequestHeader(value="x-auth-token",required=true) @AuditField(field="AUTH_TOKEN") String authToken, @PathVariable(value="collectionId",required=true) @AuditField(field="COLLECTIONID") long collectionId, @RequestBody Collection request, @RequestParam(value="locale",required=false,defaultValue="en_US") @AuditField(field="LOCALE") String locale) This service is used to update collection for which collection id given in request- 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.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.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
- Instance ofCollection
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.storeId
- Refers to the unique id of the store.version
- Refers to the version.- Returns:
- the responseEntity of CommonCollectionResponse Instance of
CommonCollectionResponse
object.
-