Package com.skava.web
Class EventController
java.lang.Object
com.skava.web.EventController
The class Event Controller -
The controller class has service end points to process Event entity like create, update, get, getAll and delete.
The controller class has service end points to process Event entity like create, update, get, getAll and delete.
- Author:
- Infosys Equinox
-
Constructor Summary
ConstructorsConstructorDescriptionEventController
(CreateEventService createEventService, FindEventService findEventService, FindAllEventService findAllEventService, DeleteEventService deleteEventService, UpdateEventService updateEventService, CommonServices commonServices) Instantiates a new event controller. -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<Event>
createEvent
(String locale, String version, long storeId, long collectionId, String authToken, Event request) This method is used to create Event based on given Event Request.org.springframework.http.ResponseEntity<com.skava.core.ResponseModel>
deleteEventById
(String locale, String version, long storeId, long collectionId, String authToken, long id) This method is used to delete a single Event based on given Event Request.org.springframework.http.ResponseEntity<EventsResponse>
findAllEvent
(String locale, String version, long storeId, long collectionId, String authToken, int page, int size, String filter, String sort) This method is used to find all Event based on given Event Request.org.springframework.http.ResponseEntity<Event>
getEventById
(String locale, String version, long storeId, long collectionId, String authToken, long id) This method is used to load single Event based on given Event Request.org.springframework.http.ResponseEntity<Event>
updateEventById
(String locale, String version, long storeId, long collectionId, String authToken, long id, Event request) This method is used to update single Event based on given Event Request.
-
Constructor Details
-
EventController
@Autowired public EventController(CreateEventService createEventService, FindEventService findEventService, FindAllEventService findAllEventService, DeleteEventService deleteEventService, UpdateEventService updateEventService, CommonServices commonServices) Instantiates a new event controller.- Parameters:
createEventService
- the create event servicefindEventService
- the find event servicefindAllEventService
- the find all event servicedeleteEventService
- the delete event serviceupdateEventService
- the update event servicecommonServices
- the common services
-
-
Method Details
-
createEvent
@PostMapping("/events") @PreAuthorize("hasRoleForServiceAndCollection(\'ROLE_MARKETING_MANAGER\', \'notification\', #collectionId) or hasPrivilegeForServiceAndCollection(\'notification/create/event\', \'notification\', #collectionId)") @Audit(action="createEvent") public org.springframework.http.ResponseEntity<Event> createEvent(@RequestHeader(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="STOREID") long storeId, @RequestHeader(value="x-collection-id",required=true) @AuditField(field="COLLECTIONID") long collectionId, @RequestHeader(value="x-auth-token",required=true) @AuditField(field="AUTH_TOKEN") String authToken, @RequestBody(required=true) @AuditField(field="Event") Event request) This method is used to create Event based on given Event Request.- Parameters:
locale
- API Response and error messages will be responded in the locale mentioned in this parameter.collectionId
- This field holds a valid collection identifier of this microservice and requested operation will be performed on this collection identifier. Collection is the top most entity of a microservice under which all the other entities/resources reside. Each collection represents an instance of the microservice with configured properties and these properties can be modified to bring in a different behavior per collection of the same microservice. Store association is the process of associating a microservice collection to a store along with its respective sub-entity. This way storefront can fetch/store the required information from that respective association.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
- It refers to the event request object which consists of the details using which a new event will be created.storeId
- Refers to the unique id of the storeversion
- Refers to the version- Returns:
- It returns the
Event
.
-
getEventById
@GetMapping("/events/{eventId}") @PreAuthorize("hasRoleForServiceAndCollection(\'ROLE_MARKETING_MANAGER\', \'notification\', #collectionId) or hasPrivilegeForServiceAndCollection(\'notification/view/event\', \'notification\', #collectionId)") @Audit(action="getEvent") public org.springframework.http.ResponseEntity<Event> getEventById(@RequestHeader(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="STOREID") long storeId, @RequestHeader(value="x-collection-id",required=true) @AuditField(field="COLLECTIONID") long collectionId, @RequestHeader(value="x-auth-token",required=true) @AuditField(field="AUTH_TOKEN") String authToken, @PathVariable(value="eventId",required=true) @AuditField(field="ID") long id) This method is used to load single Event based on given Event Request.- Parameters:
locale
- API Response and error messages will be responded in the locale mentioned in this parameter.collectionId
- This field holds a valid collection identifier of this microservice and requested operation will be performed on this collection identifier. Collection is the top most entity of a microservice under which all the other entities/resources reside. Each collection represents an instance of the microservice with configured properties and these properties can be modified to bring in a different behavior per collection of the same microservice. Store association is the process of associating a microservice collection to a store along with its respective sub-entity. This way storefront can fetch/store the required information from that respective association.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
id
- It refers to the unique identifier of the Event which is an autogenerated when a Event is retrieved. A valid Event should be present for the given id.storeId
- Refers to the unique id of the storeversion
- Refers to the version- Returns:
- It returns the
Event
.
-
findAllEvent
@GetMapping("/events") @PreAuthorize("hasRoleForServiceAndCollection(\'ROLE_MARKETING_MANAGER\', \'notification\', #collectionId) or hasPrivilegeForServiceAndCollection(\'notification/viewall/event\', \'notification\', #collectionId)") @Audit(action="findAllEvent") public org.springframework.http.ResponseEntity<EventsResponse> findAllEvent(@RequestHeader(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="STOREID") long storeId, @RequestHeader(value="x-collection-id",required=true) @AuditField(field="COLLECTIONID") long collectionId, @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,defaultValue="") @AuditField(field="FILTER") String filter, @RequestParam(value="sort",required=false,defaultValue="id,ASC") String sort) This method is used to find all Event based on given Event Request.- Parameters:
locale
- API Response and error messages will be responded in the locale mentioned in this parameter.collectionId
- This field holds a valid collection identifier of this microservice and requested operation will be performed on this collection identifier. Collection is the top most entity of a microservice under which all the other entities/resources reside. Each collection represents an instance of the microservice with configured properties and these properties can be modified to bring in a different behavior per collection of the same microservice. Store association is the process of associating a microservice collection to a store along with its respective sub-entity. This way storefront can fetch/store the required information from that respective association.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
- This parameter will be available for all the services that supports pagination. This parameter is used to mention the starting index of the items which going to responded by the API.size
- This parameter will be available for all the services that supports pagination. This parameter is used to mention the number of maximum items that needs to be responded for the request.filter
- This field holds the simple query criteria (can be multiple) based on the available fields to limit returned results, eg: fieldname:value.sort
- the sort param.storeId
- Refers to the unique id of the store.version
- Refers to the version.- Returns:
- It returns the
Event
.
-
deleteEventById
@DeleteMapping("/events/{eventId}") @PreAuthorize("hasRoleForServiceAndCollection(\'ROLE_MARKETING_MANAGER\', \'notification\', #collectionId) or hasPrivilegeForServiceAndCollection(\'notification/delete/event\', \'notification\', #collectionId)") @Audit(action="deleteEvent") public org.springframework.http.ResponseEntity<com.skava.core.ResponseModel> deleteEventById(@RequestHeader(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="STOREID") long storeId, @RequestHeader(value="x-collection-id",required=true) @AuditField(field="COLLECTIONID") long collectionId, @RequestHeader(value="x-auth-token",required=true) @AuditField(field="AUTH_TOKEN") String authToken, @PathVariable(value="eventId",required=true) @AuditField(field="ID") long id) This method is used to delete a single Event based on given Event Request.- Parameters:
locale
- API Response and error messages will be responded in the locale mentioned in this parameter.collectionId
- This field holds a valid collection identifier of this microservice and requested operation will be performed on this collection identifier. Collection is the top most entity of a microservice under which all the other entities/resources reside. Each collection represents an instance of the microservice with configured properties and these properties can be modified to bring in a different behavior per collection of the same microservice. Store association is the process of associating a microservice collection to a store along with its respective sub-entity. This way storefront can fetch/store the required information from that respective association.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
id
- It refers to the unique identifier of the Event which is to be deactivated and it is an autogenerated when a Event is created. A valid Event should be present for the given id.storeId
- Refers to the unique id of the storeversion
- Refers to the version- Returns:
- It returns the
Event
.
-
updateEventById
@PatchMapping("/events/{eventId}") @PreAuthorize("hasRoleForServiceAndCollection(\'ROLE_MARKETING_MANAGER\', \'notification\', #collectionId) or hasPrivilegeForServiceAndCollection(\'notification/update/event\', \'notification\', #collectionId)") @Audit(action="updateEvent") public org.springframework.http.ResponseEntity<Event> updateEventById(@RequestHeader(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="STOREID") long storeId, @RequestHeader(value="x-collection-id",required=true) @AuditField(field="COLLECTIONID") long collectionId, @RequestHeader(value="x-auth-token",required=true) @AuditField(field="AUTH_TOKEN") String authToken, @PathVariable(value="eventId",required=true) @AuditField(field="ID") long id, @RequestBody(required=true) @AuditField(field="REQUEST_OBJECT") Event request) This method is used to update single Event based on given Event Request.- Parameters:
locale
- API Response and error messages will be responded in the locale mentioned in this parameter.collectionId
- This field holds a valid collection identifier of this microservice and requested operation will be performed on this collection identifier. Collection is the top most entity of a microservice under which all the other entities/resources reside. Each collection represents an instance of the microservice with configured properties and these properties can be modified to bring in a different behavior per collection of the same microservice. Store association is the process of associating a microservice collection to a store along with its respective sub-entity. This way storefront can fetch/store the required information from that respective association.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
id
- It refers to the unique identifier of the Event which is an auto generated when a Event is created. A valid Event should be present for the given id.request
- It refers to the Event request object which consists of the details to be updated for a Event which is already been created.storeId
- Refers to the unique id of the storeversion
- Refers to the version- Returns:
- It returns the
Event
.
-