Class CustomersController


  • @Controller("customersControllerV1")
    @RequestMapping("/{baseSiteId}/customers")
    public class CustomersController
    extends BaseController
    Main Controller for CustomerFacade WebServices
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void changeCustomerPassword​(java.lang.String customerId, java.lang.String newPassword)
      Client should pass old and new password in Body.
      LoginChangeResponse changeLogin​(java.lang.String newLogin, java.lang.String password)
      Web service for changing customer login.
      Sample call: https://localhost:9002/rest/v1/mysite/customers/current/login?newLogin=:newLogin&password=:password
      Method requires customer authentication and is restricted to HTTPS channel.
      Method type : POST.
      void changePassword​(java.lang.String old, java.lang.String newPassword)
      Client should pass old and new password in Body.
      void convertAnonymousUserToCustomer​(java.lang.String password, javax.servlet.http.HttpSession httpSession)
      Converts currently logged guest user to full user.
      AddressData createAddress​(javax.servlet.http.HttpServletRequest request)
      Create new address for current customer
      protected ErrorListWsDTO createResponseErrors​(org.springframework.validation.Errors errors)  
      void deleteAddress​(java.lang.String id)
      Remove address from current customer
      void deletePaymentInfo​(java.lang.String id)
      Web service for deleting current user's credit card payment info by id.
      Sample call: http://localhost:9001/rest/v1/mysite/customers/paymentinfos/123
      Method requires authentication and is restricted to HTTPS channel.
      Method type : DELETE.
      AddressData editAddress​(java.lang.String id, javax.servlet.http.HttpServletRequest request)
      Edit address from current customer
      AddressDataList getAddresses()
      Get all customer's addresses
      UserGroupDataList getAllCustomerGroupsForCurrentCustomer()  
      UserGroupDataList getAllCustomerGroupsForCustomer​(java.lang.String uid)
      Web service for getting customer groups for current user.
      Sample call: https://localhost:9002/rest/v1/mysite/customers/{uid}/customergroups
      Method requires authentication and is restricted to HTTPS channel.
      Method type : GET.
      CustomerData getCurrentCustomer()
      Get customer data
      CCPaymentInfoData getPaymentInfo​(java.lang.String id)
      Web service for getting current user's credit card payment info by id.
      Sample call: https://localhost:9002/rest/v1/mysite/customers/paymentinfos/123
      Method requires authentication and is restricted to HTTPS channel.
      Method type : GET.
      CCPaymentInfoDatas getPaymentInfos​(boolean saved)
      Web service for getting current user's credit card payment infos.
      Sample call: http://localhost:9001/rest/v1/mysite/customers/paymentinfos?saved=true
      Method requires authentication and is restricted to HTTPS channel.
      Method type : GET.
      void guestLogin​(java.lang.String email)
      Creates the user dedicated to do a guest checkout.
      protected boolean isAddressValid​(AddressData addressData, org.springframework.validation.Errors errors, AddressValidationData validationData)
      Checks if address is valid by a validators
      protected void populateErrors​(org.springframework.validation.Errors errors, AddressVerificationResult<AddressVerificationDecision> addressVerificationResult)
      Populates Errors object
      void registerUser​(java.lang.String login, java.lang.String password, java.lang.String titleCode, java.lang.String firstName, java.lang.String lastName)
      Client should pass customer's data as POST Body.
      PasswordRestoreResponse restorePassword​(java.lang.String login)
      Web service for restoring password of current customer.
      Sample call: https://localhost:9002/rest/v1/mysite/customers/current/forgottenpassword?login=:login/
      Method requires client or trusted_client authentication and is restricted to HTTPS channel.
      Method type : POST.
      void updateDefaultAddress​(java.lang.String id)
      Update customer's default address
      void updatePaymentInfo​(java.lang.String paymentInfoId, javax.servlet.http.HttpServletRequest request)
      Web service for modifying existing payment info.
      Sample call: https://localhost:9002/rest/v1/mysite/paymentinfos/123
      Method requires authentication and is restricted to HTTPS channel.
      Method type : PUT.
      void updatePaymentInfoAddress​(java.lang.String paymentInfoId, javax.servlet.http.HttpServletRequest request)
      Web service for modifying billing address data for the specific payment info.
      Sample call: https://localhost:9002/rest/v1/mysite/paymentinfos/123/address
      Method requires authentication and is restricted to HTTPS channel.
      Method type : POST.
      CustomerData updateProfile​(javax.servlet.http.HttpServletRequest request)
      Update customer's profile
      protected AddressValidationData verifyAddresByService​(AddressData addressData, org.springframework.validation.Errors errors, AddressValidationData validationData)
      Verifies address by commerce service
      AddressValidationData verifyAddress​(javax.servlet.http.HttpServletRequest request)
      Verifies address
      • Methods inherited from class java.lang.Object

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

      • CustomersController

        public CustomersController()
    • Method Detail

      • registerUser

        @Secured({"ROLE_CLIENT","ROLE_TRUSTED_CLIENT"})
        @RequestMapping(method=POST)
        @ResponseBody
        @ResponseStatus(CREATED)
        public void registerUser​(@RequestParam
                                 java.lang.String login,
                                 @RequestParam
                                 java.lang.String password,
                                 @RequestParam(required=false)
                                 java.lang.String titleCode,
                                 @RequestParam
                                 java.lang.String firstName,
                                 @RequestParam
                                 java.lang.String lastName)
                          throws DuplicateUidException,
                                 RequestParameterException
        Client should pass customer's data as POST Body. Content-Type needs to be set to application/x-www-form-urlencoded; charset=UTF-8 and sample body (urlencoded) is: old=1234&new=1111
        Sample call: https://localhost:9002/rest/v1/mysite/customers
        Method requires authentication and is restricted to HTTPS channel.
        Method type : POST Register data need to be sent as post body..
        Parameters:
        login - - login to be created
        password - - customer password
        firstName - - customer first name
        lastName - - customer last name
        titleCode - - customer's title
        Throws:
        DuplicateUidException - in case the requested login already exists
        RequestParameterException
      • guestLogin

        @Secured({"ROLE_CLIENT","ROLE_TRUSTED_CLIENT"})
        @RequestMapping(value="/current/guestlogin",
                        method=POST)
        @ResponseBody
        @ResponseStatus(OK)
        public void guestLogin​(@RequestParam
                               java.lang.String email)
                        throws DuplicateUidException
        Creates the user dedicated to do a guest checkout. Newly created user will be available only by cartService and only during the current session.
        Parameters:
        email - - guest user's e-mail, it will be part of user id
        Throws:
        DuplicateUidException
      • convertAnonymousUserToCustomer

        @Secured({"ROLE_CLIENT","ROLE_TRUSTED_CLIENT"})
        @RequestMapping(value="/current/convert",
                        method=POST)
        @ResponseBody
        @ResponseStatus(OK)
        public void convertAnonymousUserToCustomer​(@RequestParam
                                                   java.lang.String password,
                                                   javax.servlet.http.HttpSession httpSession)
                                            throws DuplicateUidException,
                                                   SessionAttributeException
        Converts currently logged guest user to full user. It is possible to call it after guest user has placed order during the same session.
        Parameters:
        password -
        httpSession -
        Throws:
        DuplicateUidException
        SessionAttributeException
      • updateDefaultAddress

        @Secured("ROLE_CUSTOMERGROUP")
        @RequestMapping(value="/current/addresses/default/{id}",
                        method=PUT)
        @ResponseBody
        @ResponseStatus(OK)
        public void updateDefaultAddress​(@PathVariable
                                         java.lang.String id)
                                  throws DuplicateUidException
        Update customer's default address
        Parameters:
        id - - Address id to be set as default address
        Throws:
        DuplicateUidException
      • updateProfile

        @Secured("ROLE_CUSTOMERGROUP")
        @RequestMapping(value="/current/profile",
                        method={PUT,POST})
        @ResponseBody
        public CustomerData updateProfile​(javax.servlet.http.HttpServletRequest request)
                                   throws DuplicateUidException
        Update customer's profile
        Parameters:
        request - - http request
        Returns:
        updated profile
        Throws:
        DuplicateUidException
      • getAddresses

        @Secured({"ROLE_CUSTOMERGROUP","ROLE_GUEST"})
        @RequestMapping(value="/current/addresses",
                        method=GET)
        @ResponseBody
        public AddressDataList getAddresses()
        Get all customer's addresses
        Returns:
        List of customer addresses
      • editAddress

        @Secured({"ROLE_CUSTOMERGROUP","ROLE_GUEST"})
        @RequestMapping(value="/current/addresses/{id}",
                        method=PUT)
        @ResponseBody
        public AddressData editAddress​(@PathVariable
                                       java.lang.String id,
                                       javax.servlet.http.HttpServletRequest request)
                                throws WebserviceValidationException
        Edit address from current customer
        Parameters:
        id - - id of address to be edited
        Returns:
        modified address
        Throws:
        WebserviceValidationException
      • deleteAddress

        @Secured({"ROLE_CUSTOMERGROUP","ROLE_GUEST"})
        @RequestMapping(value="/current/addresses/{id}",
                        method=DELETE)
        @ResponseBody
        public void deleteAddress​(@PathVariable
                                  java.lang.String id)
        Remove address from current customer
        Parameters:
        id - - id of address to be removed
      • getCurrentCustomer

        @Secured({"ROLE_CUSTOMERGROUP","ROLE_GUEST"})
        @RequestMapping(value="/current",
                        method=GET)
        @ResponseBody
        public CustomerData getCurrentCustomer()
        Get customer data
        Returns:
        CustomerData object containing customer information
      • changePassword

        @Secured("ROLE_CUSTOMERGROUP")
        @RequestMapping(value="/current/password",
                        method={PUT,POST})
        @ResponseBody
        @ResponseStatus(ACCEPTED)
        public void changePassword​(@RequestParam
                                   java.lang.String old,
                                   @RequestParam("new")
                                   java.lang.String newPassword)
        Client should pass old and new password in Body. Content-Type needs to be set to application/x-www-form-urlencoded; charset=UTF-8 and sample body (urlencoded) is: old=1234&new=1111
        Parameters:
        old - - old password
        newPassword - - new password
      • getPaymentInfos

        @Secured({"ROLE_CUSTOMERGROUP","ROLE_GUEST"})
        @RequestMapping(value="/current/paymentinfos",
                        method=GET)
        @ResponseBody
        public CCPaymentInfoDatas getPaymentInfos​(@RequestParam(required=false,defaultValue="false")
                                                  boolean saved)
        Web service for getting current user's credit card payment infos.
        Sample call: http://localhost:9001/rest/v1/mysite/customers/paymentinfos?saved=true
        Method requires authentication and is restricted to HTTPS channel.
        Method type : GET.
        Parameters:
        saved - - true to retrieve only saved payment infos. false by default
        Returns:
        List of CCPaymentInfoData as response body
      • getPaymentInfo

        @Secured("ROLE_CUSTOMERGROUP")
        @RequestMapping(value="/current/paymentinfos/{id}",
                        method=GET)
        @ResponseBody
        public CCPaymentInfoData getPaymentInfo​(@PathVariable
                                                java.lang.String id)
        Web service for getting current user's credit card payment info by id.
        Sample call: https://localhost:9002/rest/v1/mysite/customers/paymentinfos/123
        Method requires authentication and is restricted to HTTPS channel.
        Method type : GET.
        Returns:
        CCPaymentInfoData as response body
      • deletePaymentInfo

        @Secured("ROLE_CUSTOMERGROUP")
        @RequestMapping(value="/current/paymentinfos/{id}",
                        method=DELETE)
        @ResponseBody
        public void deletePaymentInfo​(@PathVariable
                                      java.lang.String id)
        Web service for deleting current user's credit card payment info by id.
        Sample call: http://localhost:9001/rest/v1/mysite/customers/paymentinfos/123
        Method requires authentication and is restricted to HTTPS channel.
        Method type : DELETE.
      • updatePaymentInfoAddress

        @RequestMapping(value="/current/paymentinfos/{paymentInfoId}/address",
                        method=POST)
        @ResponseBody
        @Secured("ROLE_CUSTOMERGROUP")
        public void updatePaymentInfoAddress​(@PathVariable
                                             java.lang.String paymentInfoId,
                                             javax.servlet.http.HttpServletRequest request)
                                      throws RequestParameterException
        Web service for modifying billing address data for the specific payment info.
        Sample call: https://localhost:9002/rest/v1/mysite/paymentinfos/123/address
        Method requires authentication and is restricted to HTTPS channel.
        Method type : POST. Address data need to be sent as post body.
        Method uses HttpRequestAddressDataPopulator to populate address data from request parameters.
        Parameters:
        paymentInfoId -
        request -
        Throws:
        RequestParameterException
      • updatePaymentInfo

        @RequestMapping(value="/current/paymentinfos/{paymentInfoId}",
                        method=PUT)
        @ResponseBody
        @Secured("ROLE_CUSTOMERGROUP")
        public void updatePaymentInfo​(@PathVariable
                                      java.lang.String paymentInfoId,
                                      javax.servlet.http.HttpServletRequest request)
                               throws RequestParameterException
        Web service for modifying existing payment info.
        Sample call: https://localhost:9002/rest/v1/mysite/paymentinfos/123
        Method requires authentication and is restricted to HTTPS channel.
        Method type : PUT. PaymentInfo data need to be sent in body.
        Method uses HttpRequestPaymentInfoPopulator to populate payment info data from request parameters.
        Parameters:
        paymentInfoId -
        request -
        Throws:
        RequestParameterException
      • getAllCustomerGroupsForCurrentCustomer

        @Secured("ROLE_CUSTOMERGROUP")
        @RequestMapping(value="/current/customergroups",
                        method=GET)
        @ResponseBody
        public UserGroupDataList getAllCustomerGroupsForCurrentCustomer()
      • getAllCustomerGroupsForCustomer

        @Secured("ROLE_CUSTOMERMANAGERGROUP")
        @RequestMapping(value="/{uid}/customergroups",
                        method=GET)
        @ResponseBody
        public UserGroupDataList getAllCustomerGroupsForCustomer​(@PathVariable
                                                                 java.lang.String uid)
        Web service for getting customer groups for current user.
        Sample call: https://localhost:9002/rest/v1/mysite/customers/{uid}/customergroups
        Method requires authentication and is restricted to HTTPS channel.
        Method type : GET.
        Returns:
        UserGroupDataList as response body
      • restorePassword

        @Secured({"ROLE_CLIENT","ROLE_TRUSTED_CLIENT"})
        @RequestMapping(value="/current/forgottenpassword",
                        method=POST)
        @ResponseBody
        public PasswordRestoreResponse restorePassword​(@RequestParam
                                                       java.lang.String login)
        Web service for restoring password of current customer.
        Sample call: https://localhost:9002/rest/v1/mysite/customers/current/forgottenpassword?login=:login/
        Method requires client or trusted_client authentication and is restricted to HTTPS channel.
        Method type : POST.
        Parameters:
        login -
        Returns:
        PasswordRestoreResponse
      • changeCustomerPassword

        @Secured("ROLE_TRUSTED_CLIENT")
        @RequestMapping(value="/{customerId}/password",
                        method={PUT,POST})
        @ResponseBody
        @ResponseStatus(ACCEPTED)
        public void changeCustomerPassword​(@PathVariable
                                           java.lang.String customerId,
                                           @RequestParam("new")
                                           java.lang.String newPassword)
        Client should pass old and new password in Body. Content-Type needs to be set to application/x-www-form-urlencoded; charset=UTF-8 and sample body (urlencoded) is: new=1111
        Parameters:
        newPassword - - new password
      • verifyAddress

        @Secured({"ROLE_CUSTOMERGROUP","ROLE_GUEST"})
        @RequestMapping(value="/current/addresses/verify",
                        method=POST)
        @ResponseBody
        public AddressValidationData verifyAddress​(javax.servlet.http.HttpServletRequest request)
        Verifies address
        Parameters:
        request -
        Returns:
        address created
      • isAddressValid

        protected boolean isAddressValid​(AddressData addressData,
                                         org.springframework.validation.Errors errors,
                                         AddressValidationData validationData)
        Checks if address is valid by a validators
        Parameters:
        addressData -
        errors -
        validationData -
        Returns:
        true if address is valid; false otherwise
      • verifyAddresByService

        protected AddressValidationData verifyAddresByService​(AddressData addressData,
                                                              org.springframework.validation.Errors errors,
                                                              AddressValidationData validationData)
        Verifies address by commerce service
        Parameters:
        addressData -
        errors -
        validationData -
        Returns:
        verified address
      • createResponseErrors

        protected ErrorListWsDTO createResponseErrors​(org.springframework.validation.Errors errors)