Interface RestServiceUtils

  • All Known Implementing Classes:
    RestServiceUtilsImpl

    public interface RestServiceUtils
    Utility service for Public REST endpoints
    • Method Detail

      • initEventsRequest

        EventsRequestContext initEventsRequest​(String scope,
                                               String sessionId,
                                               String profileId,
                                               String personaId,
                                               boolean invalidateProfile,
                                               boolean invalidateSession,
                                               javax.servlet.http.HttpServletRequest request,
                                               javax.servlet.http.HttpServletResponse response,
                                               Date timestamp)
        This method is used to initialize the context for a request that would require executing events. It will load existing profile/session for current user or build new ones if necessary IT will also handle anonymous profile/session preferences in case there is specific ones. It will also handle persona in case it is provided And finally it will provide a contextual bean named: EventsRequestContext, that will contain all the required information for the next steps of the request, like: processing the events
        Parameters:
        scope - the current scope (mandatory, in case session need to be created)
        sessionId - the current sessionId (mandatory)
        profileId - the current profileId (optional in case profile doesn't exists yet for incoming visitor)
        personaId - the current personaId (optional in case we don't want to apply persona on current request)
        invalidateProfile - true in case we want to invalidate the current visitor profile, false otherwise
        invalidateSession - true in case we want to invalidate the current visitor session, false otherwise
        request - the current request
        response - the current request response
        timestamp - the current date, for timestamp the current visitor data
        Returns:
        the built EventsRequestContext
      • performEventsRequest

        EventsRequestContext performEventsRequest​(List<Event> events,
                                                  EventsRequestContext eventsRequestContext)
        Execute the list of events using the dedicated eventsRequestContext
        Parameters:
        events - the list of events to he executed
        eventsRequestContext - the current EventsRequestContext
        Returns:
        an updated version of the current eventsRequestContext
      • finalizeEventsRequest

        void finalizeEventsRequest​(EventsRequestContext eventsRequestContext,
                                   boolean crashOnError)
        At the end of an events requests we want to save/update the profile and/or the session depending on the changes Also we want to return a cookie about current visitor profile ID
        Parameters:
        eventsRequestContext - the current EventsRequestContext
        crashOnError - true if we want to throw an Exception in case of errors during events execution, false otherwise (otherwise, no exception, but just an error code directly returned to the HTTP response)
      • getProfileIdCookieValue

        String getProfileIdCookieValue​(javax.servlet.http.HttpServletRequest httpServletRequest)
        Try to extract the current visitor profileId from the current request cookies.
        Parameters:
        httpServletRequest - the current HTTP request
        Returns:
        the profileId if found in the cookies, null otherwise