Class ProfileServiceEndPoint


  • @Produces("application/json")
    @Consumes("application/json")
    @Path("/profiles")
    public class ProfileServiceEndPoint
    extends Object
    A JAX-RS endpoint to manage Profiles and Personas.
    • Constructor Detail

      • ProfileServiceEndPoint

        public ProfileServiceEndPoint()
    • Method Detail

      • setProfileService

        public void setProfileService​(ProfileService profileService)
      • setEventService

        public void setEventService​(EventService eventService)
      • setSegmentService

        public void setSegmentService​(SegmentService segmentService)
      • setLocalizationHelper

        public void setLocalizationHelper​(LocalizationHelper localizationHelper)
      • getAllProfilesCount

        @GET
        @Path("/count")
        public long getAllProfilesCount()
        Retrieves the number of unique profiles.
        Returns:
        the number of unique profiles.
      • getProfiles

        @POST
        @Path("/search")
        public PartialList<Profile> getProfiles​(Query query)
        Retrieves profiles matching the specified query.
        Parameters:
        query - a Query specifying which elements to retrieve
        Returns:
        a PartialList of profiles instances matching the specified query
      • getExportProfiles

        @GET
        @Path("/export")
        @Produces("text/csv")
        public javax.ws.rs.core.Response getExportProfiles​(@QueryParam("query")
                                                           String query)
        Retrieves an export of profiles matching the specified query as a downloadable file using the comma-separated values (CSV) format.
        Parameters:
        query - a String JSON representation of the query the profiles to export should match
        Returns:
        a Response object configured to allow caller to download the CSV export file
      • formExportProfiles

        @GET
        @Path("/export")
        @Produces("text/csv")
        @Consumes("application/x-www-form-urlencoded")
        public javax.ws.rs.core.Response formExportProfiles​(@FormParam("query")
                                                            String query)
        A version of getExportProfiles(String) suitable to be called from an HTML form.
        Parameters:
        query - a form-encoded representation of the query the profiles to export should match
        Returns:
        a Response object configured to allow caller to download the CSV export file
      • exportProfiles

        @POST
        @Path("/export")
        @Produces("text/csv")
        public javax.ws.rs.core.Response exportProfiles​(Query query)
        Retrieves an export of profiles matching the specified query as a downloadable file using the comma-separated values (CSV) format.
        Parameters:
        query - a String JSON representation of the query the profiles to export should match
        Returns:
        a Response object configured to allow caller to download the CSV export file
      • batchProfilesUpdate

        @POST
        @Path("/batchProfilesUpdate")
        public void batchProfilesUpdate​(BatchUpdate update)
        Update all profiles in batch according to the specified BatchUpdate
        Parameters:
        update - the batch update specification
      • load

        @GET
        @Path("/{profileId}")
        public Profile load​(@PathParam("profileId")
                            String profileId)
        Retrieves the profile identified by the specified identifier.
        Parameters:
        profileId - the identifier of the profile to retrieve
        Returns:
        the profile identified by the specified identifier or null if no such profile exists
      • save

        @POST
        @Path("/")
        public Profile save​(Profile profile)
        Saves the specified profile in the context server, sending a profileUpdated event.
        Parameters:
        profile - the profile to be saved
        Returns:
        the newly saved profile
      • delete

        @DELETE
        @Path("/{profileId}")
        public void delete​(@PathParam("profileId")
                           String profileId,
                           @QueryParam("persona") @DefaultValue("false")
                           boolean persona)
        Removes the profile (or persona if the persona query parameter is set to true) identified by the specified identifier.
        Parameters:
        profileId - the identifier of the profile or persona to delete
        persona - true if the specified identifier is supposed to refer to a persona, false if it is supposed to refer to a profile
      • getProfileSessions

        @GET
        @Path("/{profileId}/sessions")
        public PartialList<Session> getProfileSessions​(@PathParam("profileId")
                                                       String profileId,
                                                       @QueryParam("q")
                                                       String query,
                                                       @QueryParam("offset") @DefaultValue("0")
                                                       int offset,
                                                       @QueryParam("size") @DefaultValue("50")
                                                       int size,
                                                       @QueryParam("sort")
                                                       String sortBy)
        Retrieves the sessions associated with the profile identified by the specified identifier that match the specified query (if specified), ordered according to the specified sortBy String and and paged: only size of them are retrieved, starting with the offset-th one. TODO: use a Query object instead of distinct parameter?
        Parameters:
        profileId - the identifier of the profile we want to retrieve sessions from
        query - a String of text used for fulltext filtering which sessions we are interested in or null (or an empty String) if we want to retrieve all sessions
        offset - zero or a positive integer specifying the position of the first session in the total ordered collection of matching sessions
        size - a positive integer specifying how many matching sessions should be retrieved or -1 if all of them should be retrieved
        sortBy - an optional (null if no sorting is required) String of comma (,) separated property names on which ordering should be performed, ordering elements according to the property order in the String, considering each in turn and moving on to the next one in case of equality of all preceding ones. Each property name is optionally followed by a column (:) and an order specifier: asc or desc.
        Returns:
        a PartialList of matching sessions
      • getProfileSegments

        @GET
        @Path("/{profileId}/segments")
        public List<Metadata> getProfileSegments​(@PathParam("profileId")
                                                 String profileId)
        Retrieves the list of segment metadata for the segments the specified profile is a member of.
        Parameters:
        profileId - the identifier of the profile for which we want to retrieve the segment metadata
        Returns:
        the (possibly empty) list of segment metadata for the segments the specified profile is a member of
      • getPropertyTypeMapping

        @GET
        @Path("/properties/mappings/{fromPropertyTypeId}")
        public String getPropertyTypeMapping​(@PathParam("fromPropertyTypeId")
                                             String fromPropertyTypeId)
        TODO
        Parameters:
        fromPropertyTypeId - fromPropertyTypeId
        Returns:
        property type mapping
      • getPersonas

        @POST
        @Path("/personas/search")
        public PartialList<Persona> getPersonas​(Query query)
        Retrieves Persona matching the specified query.
        Parameters:
        query - a Query specifying which elements to retrieve
        Returns:
        a PartialList of Persona instances matching the specified query
      • loadPersona

        @GET
        @Path("/personas/{personaId}")
        public Persona loadPersona​(@PathParam("personaId")
                                   String personaId)
        Retrieves the Persona identified by the specified identifier.
        Parameters:
        personaId - the identifier of the persona to retrieve
        Returns:
        the persona identified by the specified identifier or null if no such persona exists
      • loadPersonaWithSessions

        @GET
        @Path("/personasWithSessions/{personaId}")
        public PersonaWithSessions loadPersonaWithSessions​(@PathParam("personaId")
                                                           String personaId)
        Retrieves the persona identified by the specified identifier and all its associated sessions
        Parameters:
        personaId - the identifier of the persona to retrieve
        Returns:
        a PersonaWithSessions instance with the persona identified by the specified identifier and all its associated sessions
      • savePersonaWithSessions

        @POST
        @Path("/personasWithSessions")
        public PersonaWithSessions savePersonaWithSessions​(PersonaWithSessions personaWithSessions)
        Save the posted persona with its sessions
        Parameters:
        personaWithSessions - the persona to save with its sessions.
        Returns:
        a PersonaWithSessions instance with the persona identified by the specified identifier and all its associated sessions
      • savePersona

        @POST
        @Path("/personas")
        public Persona savePersona​(Persona persona)
        Persists the specified Persona in the context server.
        Parameters:
        persona - the persona to persist
        Returns:
        the newly persisted persona
      • deletePersona

        @DELETE
        @Path("/personas/{personaId}")
        public void deletePersona​(@PathParam("personaId")
                                  String personaId,
                                  @QueryParam("persona") @DefaultValue("true")
                                  boolean persona)
        Removes the persona identified by the specified identifier.
        Parameters:
        personaId - the identifier of the persona to delete
        persona - true if the specified identifier is supposed to refer to a persona, false if it is supposed to refer to a profile
      • createPersona

        @PUT
        @Path("/personas/{personaId}")
        @Consumes("application/x-www-form-urlencoded")
        public Persona createPersona​(@PathParam("personaId")
                                     String personaId)
        Creates a persona with the specified identifier and automatically creates an associated session with it.
        Parameters:
        personaId - the identifier to use for the new persona
        Returns:
        the newly created persona
      • getPersonaSessions

        @GET
        @Path("/personas/{personaId}/sessions")
        public PartialList<Session> getPersonaSessions​(@PathParam("personaId")
                                                       String personaId,
                                                       @QueryParam("offset") @DefaultValue("0")
                                                       int offset,
                                                       @QueryParam("size") @DefaultValue("50")
                                                       int size,
                                                       @QueryParam("sort")
                                                       String sortBy)
        Retrieves the sessions associated with the persona identified by the specified identifier, ordered according to the specified sortBy String and and paged: only size of them are retrieved, starting with the offset-th one.
        Parameters:
        personaId - the persona id
        offset - zero or a positive integer specifying the position of the first session in the total ordered collection of matching sessions
        size - a positive integer specifying how many matching sessions should be retrieved or -1 if all of them should be retrieved
        sortBy - an optional (null if no sorting is required) String of comma (,) separated property names on which ordering should be performed, ordering elements according to the property order in the String, considering each in turn and moving on to the next one in case of equality of all preceding ones. Each property name is optionally followed by a column (:) and an order specifier: asc or desc.
        Returns:
        a PartialList of sessions for the persona identified by the specified identifier
      • loadSession

        @GET
        @Path("/sessions/{sessionId}")
        public Session loadSession​(@PathParam("sessionId")
                                   String sessionId)
                            throws ParseException
        Retrieves the session identified by the specified identifier.
        Parameters:
        sessionId - the identifier of the session to be retrieved
        Returns:
        the session identified by the specified identifier
        Throws:
        ParseException - if the date hint cannot be parsed as a proper Date object
      • saveSession

        @POST
        @Path("/sessions/{sessionId}")
        public Session saveSession​(Session session)
        Saves the specified session.
        Parameters:
        session - the session to be saved
        Returns:
        the newly saved session
      • getSessionEvents

        @GET
        @Path("/sessions/{sessionId}/events")
        public PartialList<Event> getSessionEvents​(@PathParam("sessionId")
                                                   String sessionId,
                                                   @QueryParam("eventTypes")
                                                   String[] eventTypes,
                                                   @QueryParam("q")
                                                   String query,
                                                   @QueryParam("offset") @DefaultValue("0")
                                                   int offset,
                                                   @QueryParam("size") @DefaultValue("50")
                                                   int size,
                                                   @QueryParam("sort")
                                                   String sortBy)
        Retrieves Events for the Session identified by the provided session identifier, matching any of the provided event types, ordered according to the specified sortBy String and paged: only size of them are retrieved, starting with the offset-th one. If a query is provided, a full text search is performed on the matching events to further filter them.
        Parameters:
        sessionId - the identifier of the user session we're considering
        eventTypes - an array of event type names; the events to retrieve should at least match one of these
        query - a String to perform full text filtering on events matching the other conditions
        offset - zero or a positive integer specifying the position of the first event in the total ordered collection of matching events
        size - a positive integer specifying how many matching events should be retrieved or -1 if all of them should be retrieved
        sortBy - an optional (null if no sorting is required) String of comma (,) separated property names on which ordering should be performed, ordering elements according to the property order in the String, considering each in turn and moving on to the next one in case of equality of all preceding ones. Each property name is optionally followed by a column (:) and an order specifier: asc or desc.
        Returns:
        a PartialList of matching events
      • getExistingProperties

        @GET
        @Path("/existingProperties")
        public Collection<PropertyType> getExistingProperties​(@QueryParam("tag")
                                                              String tag,
                                                              @QueryParam("isSystemTag")
                                                              boolean isSystemTag,
                                                              @QueryParam("itemType")
                                                              String itemType,
                                                              @HeaderParam("Accept-Language")
                                                              String language,
                                                              @Context
                                                              javax.servlet.http.HttpServletResponse response)
                                                       throws IOException
        Retrieves the existing property types for the specified type as defined by the Item subclass public field ITEM_TYPE and with the specified tag or system tag. TODO: move to a different class
        Parameters:
        tag - the tag we're interested in
        isSystemTag - if we should look in system tags instead of tags
        itemType - the String representation of the item type we want to retrieve the count of, as defined by its class' ITEM_TYPE field
        language - the value of the Accept-Language header to specify in which locale the properties description should be returned TODO unused
        response - the http response object
        Returns:
        all property types defined for the specified item type and with the specified tag
        Throws:
        IOException - if there was an error sending the response
      • getPropertyTypes

        @GET
        @Path("/properties")
        public Map<String,​Collection<PropertyType>> getPropertyTypes​(@HeaderParam("Accept-Language")
                                                                           String language)
        Retrieves all known property types. TODO: move to a different class
        Parameters:
        language - the value of the Accept-Language header to specify in which locale the properties description should be returned TODO unused
        Returns:
        a Map associating targets as keys to related PropertyTypes
      • getPropertyType

        @GET
        @Path("/properties/{propertyId}")
        public PropertyType getPropertyType​(@PathParam("propertyId")
                                            String propertyId,
                                            @HeaderParam("Accept-Language")
                                            String language)
        Retrieves the property type associated with the specified property ID. TODO: move to a different class
        Parameters:
        propertyId - the property ID for which we want to retrieve the associated property type
        language - the value of the Accept-Language header to specify in which locale the properties description should be returned TODO unused
        Returns:
        the property type associated with the specified ID
      • getPropertyTypesByTarget

        @GET
        @Path("/properties/targets/{target}")
        public Collection<PropertyType> getPropertyTypesByTarget​(@PathParam("target")
                                                                 String target,
                                                                 @HeaderParam("Accept-Language")
                                                                 String language)
        Retrieves all the property types associated with the specified target. TODO: move to a different class
        Parameters:
        target - the target for which we want to retrieve the associated property types
        language - the value of the Accept-Language header to specify in which locale the properties description should be returned TODO unused
        Returns:
        a collection of all the property types associated with the specified target
      • getPropertyTypeByTag

        @GET
        @Path("/properties/tags/{tags}")
        public Collection<PropertyType> getPropertyTypeByTag​(@PathParam("tags")
                                                             String tags,
                                                             @HeaderParam("Accept-Language")
                                                             String language)
        Retrieves all property types with the specified tags. TODO: move to a different class TODO: passing a list of tags via a comma-separated list is not very RESTful
        Parameters:
        tags - a comma-separated list of tag identifiers
        language - the value of the Accept-Language header to specify in which locale the properties description should be returned TODO unused
        Returns:
        a Set of the property types with the specified tag
      • getPropertyTypeBySystemTag

        @GET
        @Path("/properties/systemTags/{tags}")
        public Collection<PropertyType> getPropertyTypeBySystemTag​(@PathParam("tags")
                                                                   String tags,
                                                                   @HeaderParam("Accept-Language")
                                                                   String language)
        Retrieves all property types with the specified tags. TODO: move to a different class TODO: passing a list of tags via a comma-separated list is not very RESTful
        Parameters:
        tags - a comma-separated list of tag identifiers
        language - the value of the Accept-Language header to specify in which locale the properties description should be returned TODO unused
        Returns:
        a Set of the property types with the specified tag
      • setPropertyType

        @POST
        @Path("/properties")
        public boolean setPropertyType​(PropertyType property)
        Persists the specified property type in the context server. TODO: move to a different class
        Parameters:
        property - the property type to persist
        Returns:
        true if the property type was properly created, false otherwise (for example, if the property type already existed
      • setPropertyTypes

        @POST
        @Path("/properties/bulk")
        public boolean setPropertyTypes​(List<PropertyType> properties)
        Persists the specified properties type in the context server. TODO: move to a different class
        Parameters:
        properties - the properties type to persist
        Returns:
        true if the property type was properly created, false otherwise (for example, if the property type already existed
      • deleteProperty

        @DELETE
        @Path("/properties/{propertyId}")
        public boolean deleteProperty​(@PathParam("propertyId")
                                      String propertyId)
        Deletes the property type identified by the specified identifier. TODO: move to a different class
        Parameters:
        propertyId - the identifier of the property type to delete
        Returns:
        true if the property type was properly deleted, false otherwise
      • searchSession

        @POST
        @Path("/search/sessions")
        public PartialList<Session> searchSession​(Query query)
        Retrieves sessions matching the specified query.
        Parameters:
        query - a Query specifying which elements to retrieve
        Returns:
        a PartialList of sessions matching the specified query
      • addAliasToProfile

        @POST
        @Path("/{profileId}/aliases/{aliasId}")
        public void addAliasToProfile​(@PathParam("profileId")
                                      String profileId,
                                      @PathParam("aliasId")
                                      String aliasId,
                                      @HeaderParam("X-Unomi-ClientId")
                                      String headerClientID)
      • removeAliasFromProfile

        @DELETE
        @Path("/{profileId}/aliases/{aliasId}")
        public void removeAliasFromProfile​(@PathParam("profileId")
                                           String profileId,
                                           @PathParam("aliasId")
                                           String aliasId,
                                           @HeaderParam("X-Unomi-ClientId")
                                           String headerClientID)
      • listAliasesByProfileId

        @GET
        @Path("/{profileId}/aliases")
        public PartialList<ProfileAlias> listAliasesByProfileId​(@PathParam("profileId")
                                                                String profileId,
                                                                @QueryParam("offset") @DefaultValue("0")
                                                                int offset,
                                                                @QueryParam("size") @DefaultValue("50")
                                                                int size,
                                                                @QueryParam("sort")
                                                                String sortBy)