Class ContractController

java.lang.Object
com.skava.accounts.web.ContractController

@RestController @RequestMapping("/accounts/{accountId}/contracts") public class ContractController extends Object
The Class ContractController-
The controller class has service end points to process contract entity.
Author:
Infosys Equinox
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.http.ResponseEntity<Contracts>
    createContract(String locale, String version, long storeId, long collectionId, String authToken, long accountId, @Valid Contracts request)
    This method is used to create Contract based on given request.
    org.springframework.http.ResponseEntity<Contracts>
    deleteContractById(String locale, String version, long storeId, long collectionId, String authToken, long accountId, long id)
    This method is used to delete single Contract based on given Contract Request.
    org.springframework.http.ResponseEntity<Object>
    deleteDocumentById(String locale, String version, long storeId, long collectionId, String authToken, long accountId, long contractId, long documentId)
    This method is used to delete single document based on given document.
    org.springframework.http.ResponseEntity<ContractsAPIResponse>
    findAllContract(String locale, String version, long storeId, int page, int size, String filter, long collectionId, String authToken, long accountId, String sort)
    This method is used to find all Contracts based on given Contract request.
    org.springframework.http.ResponseEntity<Contracts>
    getContractById(String locale, String version, long storeId, long collectionId, String authToken, long accountId, long id)
    This method is used to load single Contract based on given Request.
    org.springframework.http.ResponseEntity<Documents>
    getDocumentById(String locale, String version, long storeId, long collectionId, String authToken, long accountId, long contractId, long documentId)
    This method is used to get single document based on given document.
    org.springframework.http.ResponseEntity<Contracts>
    updateContractById(String locale, String version, long storeId, long collectionId, String authToken, long accountId, long id, @Valid Contracts request)
    This method is used to update single Contract based on given Contract Request.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ContractController

      public ContractController()
  • Method Details

    • createContract

      @PostMapping @PreAuthorize("hasRoleForServiceAndCollection(\'ROLE_ACCOUNT_ADMIN\', \'account\', #collectionId) or hasRoleForServiceAndCollection(\'ROLE_ACCOUNT_REP\', \'account\', #collectionId) or hasPrivilegeForServiceAndCollectionAndAccount(\'account/viewall/contract\', \'account\', #collectionId, #accountId)") @ResponseStatus(ACCEPTED) @Audit(action="CreateContract") public org.springframework.http.ResponseEntity<Contracts> createContract(@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="AUTHTOKEN") String authToken, @PathVariable(value="accountId",required=true) @AuditField(field="ACCOUNTID") long accountId, @RequestBody(required=true) @Valid @AuditField(field="Contract") @Valid Contracts request)
      This method is used to create Contract based on given 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 micro service and requested operation will be performed on this collection identifier. Collection is the top most entity of a micro service under which all the other entities reside. Each collection represents an instance of the micro service with configured properties and these properties can be modified to bring in a different behavior per collection of the same micro service.
      authToken - This field holds a valid authorization token generated using the Authorization microservice for an user. Auth token represents claims containing roles and privileges of the user accessing this API. Since the token is a required field for this API it has to be generated before hand by invoking the 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
      storeId - Refers to the unique id of the store
      version - Refers to the version
      accountId - It refers to the id of the account which is a unique identifier. An account should exists for the given account id, and also the account should be associated with the given collection id.
      request - It contains the attributes required for the creation of Contract.
      Returns:
      It returns the Contracts.
    • findAllContract

      @GetMapping @PreAuthorize("hasRoleForServiceAndCollection(\'ROLE_ACCOUNT_ADMIN\', \'account\', #collectionId) or hasRoleForServiceAndCollection(\'ROLE_ACCOUNT_REP\', \'account\', #collectionId) or hasRoleForServiceAndCollectionAndAccount(\'ROLE_ACCOUNT_BUYER_ADMIN\', \'account\', #collectionId, #accountId) or hasRoleForServiceAndCollectionAndAccount(\'ROLE_ACCOUNT_BUYER\', \'account\', #collectionId, #accountId) or hasPrivilegeForServiceAndCollectionAndAccount(\'account/viewall/contract\', \'account\', #collectionId, #accountId)") @ResponseStatus(ACCEPTED) @Audit(action="FindAllContract") public org.springframework.http.ResponseEntity<ContractsAPIResponse> findAllContract(@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, @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, @RequestHeader(value="x-collection-id",required=true) @AuditField(field="COLLECTIONID") long collectionId, @RequestHeader(value="x-auth-token",required=true) @AuditField(field="AUTHTOKEN") String authToken, @PathVariable(value="accountId",required=true) @AuditField(field="ACCOUNTID") long accountId, @RequestParam(value="sort",required=false) @AuditField(field="SORT") String sort)
      This method is used to find all Contracts based on given Contract 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 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 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 represents claims containing roles and privileges of the user accessing this API. JSON Web Token is an open standard 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 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
      storeId - Refers to the unique id of the store
      version - Refers to the version
      accountId - It refers to the id of the account which is a unique identifier. An account should exists for the given account id and also the account should be associated with the given collection id.
      sort - the sort.
      page - the page.
      size - the size.
      filter - used to filter the result set.
      Returns:
      It returns the Contracts.
    • getContractById

      @GetMapping("/{contractId}") @PreAuthorize("hasRoleForServiceAndCollection(\'ROLE_ACCOUNT_ADMIN\', \'account\', #collectionId) or hasRoleForServiceAndCollection(\'ROLE_ACCOUNT_REP\', \'account\', #collectionId) or hasRoleForServiceAndCollectionAndAccount(\'ROLE_ACCOUNT_BUYER_ADMIN\', \'account\', #collectionId, #accountId) or hasRoleForServiceAndCollectionAndAccount(\'ROLE_ACCOUNT_BUYER\', \'account\', #collectionId, #accountId) or hasPrivilegeForServiceAndCollectionAndAccount(\'account/view/contract\', \'account\', #collectionId, #accountId)") @ResponseStatus(ACCEPTED) @Audit(action="GetContract") public org.springframework.http.ResponseEntity<Contracts> getContractById(@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="AUTHTOKEN") String authToken, @PathVariable(value="accountId",required=true) @AuditField(field="ACCOUNTID") long accountId, @PathVariable(value="contractId",required=true) @AuditField(field="ID") long id)
      This method is used to load single Contract based on given 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 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 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 represents claims containing roles and privileges of the user accessing this API. JSON Web Token is an open standard 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 API provided by Authorization microservice. sThe 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
      storeId - Refers to the unique id of the store
      version - Refers to the version
      accountId - It refers to the id of the account which is a unique identifier. An account should exists for the given account id, and also the account should be associated with the given collection id.
      id - It refers to the unique identifier of the contract which is to be retrieved. It is autogenerated when a contract is created. A valid contract should be present for the given id.
      Returns:
      It returns the Contracts.
    • updateContractById

      @PatchMapping("/{contractId}") @PreAuthorize("hasRoleForServiceAndCollection(\'ROLE_ACCOUNT_ADMIN\', \'account\', #collectionId) or hasRoleForServiceAndCollection(\'ROLE_ACCOUNT_REP\', \'account\', #collectionId) or hasRoleForServiceAndCollection(\'ROLE_ACCOUNT_BUYER_ADMIN\', \'account\', #collectionId) or hasPrivilegeForServiceAndCollectionAndAccount(\'account/update/contract\', \'account\', #collectionId, #accountId )") @ResponseStatus(ACCEPTED) @Audit(action="UpdateContract") public org.springframework.http.ResponseEntity<Contracts> updateContractById(@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="AUTHTOKEN") String authToken, @PathVariable(value="accountId",required=true) @AuditField(field="ACCOUNTID") long accountId, @PathVariable(value="contractId",required=true) @AuditField(field="ID") long id, @RequestBody(required=true) @Valid @AuditField(field="Contract") @Valid Contracts request)
      This method is used to update single Contract based on given Contract 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 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 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 represents claims containing roles and privileges of the user accessing this API. JSON Web Token is an open standard 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 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
      storeId - Refers to the unique id of the store
      version - Refers to the version
      accountId - It refers to the id of the account which is a unique identifier. An account should exists for the given account id, and also the account should be associated with the given collection id.
      id - It refers to the unique identifier of the contract which is to be updated. It is auto generated when a contract is created. A valid contract should be present for the given id.
      request - It refers to the contract request object which consists of the details to be updated for a contract which is already been created.
      Returns:
      It returns the Contracts.
    • deleteContractById

      @DeleteMapping("/{contractId}") @PreAuthorize("hasRoleForServiceAndCollection(\'ROLE_ACCOUNT_ADMIN\', \'account\', #collectionId) or hasPrivilegeForServiceAndCollectionAndAccount(\'account/delete/contract\', \'account\', #collectionId, #accountId )") @ResponseStatus(ACCEPTED) @Audit(action="DeleteContract") public org.springframework.http.ResponseEntity<Contracts> deleteContractById(@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="AUTHTOKEN") String authToken, @PathVariable(value="accountId",required=true) @AuditField(field="ACCOUNTID") long accountId, @PathVariable(value="contractId",required=true) @AuditField(field="ID") long id)
      This method is used to delete single Contract based on given Contract 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 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 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 represents claims containing roles and privileges of the user accessing this API. JSON Web Token is an open standard 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 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
      storeId - Refers to the unique id of the store
      version - Refers to the version
      accountId - It refers to the id of the account which is a unique identifier. An account should exists for the given account id, and also the account should be associated with the given collection id.
      id - It refers to the unique identifier of the contract which is to be deactivated. It is auto generated when a contract is created. A valid contract should be present for the given id.
      Returns:
      It returns the Contracts.
    • deleteDocumentById

      @DeleteMapping("/{contractId}/documents/{documentId}") @PreAuthorize("hasRoleForServiceAndCollection(\'ROLE_ACCOUNT_ADMIN\', \'account\', #collectionId) or hasPrivilegeForServiceAndCollectionAndAccount(\'account/delete/contract\', \'account\', #collectionId, #account )") @ResponseStatus(ACCEPTED) @Audit(action="DeleteDocument") public org.springframework.http.ResponseEntity<Object> deleteDocumentById(@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="AUTHTOKEN") String authToken, @PathVariable(value="accountId",required=true) @AuditField(field="ACCOUNTID") long accountId, @PathVariable(value="contractId",required=true) @AuditField(field="CONTRACTID") long contractId, @PathVariable(value="documentId",required=true) @AuditField(field="DOCUMENTID") long documentId)
      This method is used to delete single document based on given document.
      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 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 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 represents claims containing roles and privileges of the user accessing this API. JSON Web Token is an open standard 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 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
      storeId - Refers to the unique id of the store
      version - Refers to the version
      accountId - It refers to the id of the account which is a unique identifier. An account should exists for the given account id, and also the account should be associated with the given collection id.
      contractId - It refers to the unique identifier of the contract whose documents are to be deleted. The contract should be associated with the given account id. A valid contract should exists for the given contract id.
      documentId - It refers to the unique identifier of the document which is to be deleted. The document should be associated with the given contract id. A valid document should exists for the given document id.
      Returns:
      response entity
    • getDocumentById

      @GetMapping("/{contractId}/documents/{documentId}") @PreAuthorize("hasRoleForServiceAndCollection(\'ROLE_ACCOUNT_ADMIN\', \'account\', #collectionId) or hasRoleForServiceAndCollectionAndAccount(\'ROLE_ACCOUNT_REP\', \'account\', #collectionId, #accountId) or hasPrivilegeForServiceAndCollectionAndAccount(\'account/view/contract\', \'account\', #collectionId, #accountId )") @ResponseStatus(ACCEPTED) @Audit(action="GetDocument") public org.springframework.http.ResponseEntity<Documents> getDocumentById(@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="AUTHTOKEN") String authToken, @PathVariable(value="accountId",required=true) @AuditField(field="ACCOUNTID") long accountId, @PathVariable(value="contractId",required=true) @AuditField(field="CONTRACTID") long contractId, @PathVariable(value="documentId",required=true) @AuditField(field="DOCUMENTID") long documentId)
      This method is used to get single document based on given document.
      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 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 represents claims containing roles and privileges of the user accessing this API. JSON Web Token is an open standard 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 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
      storeId - Refers to the unique id of the store
      version - Refers to the version
      accountId - It refers to the id of the account which is a unique identifier. An account should exists for the given account id, and also the account should be associated with the given collection id.
      contractId - It refers to the unique identifier of the contract whose documents are to be deleted.
      contractId - It refers to the unique identifier of the contract whose documents are to be loaded. The contract should be associated with the given account id. A valid contract should exists for the given contract id.
      documentId - It refers to the unique identifier of the document which is to be loaded. The document should be associated with the given contract id. A valid document should exists for the given document id.
      Returns:
      It returns the Documents.