Package org.apache.unomi.rest.endpoints
Class ProfileServiceEndPoint
java.lang.Object
org.apache.unomi.rest.endpoints.ProfileServiceEndPoint
@Produces("application/json")
@Consumes("application/json")
@Path("/profiles")
public class ProfileServiceEndPoint
extends Object
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAliasToProfile(String profileId, String aliasId, String headerClientID) voidbatchProfilesUpdate(BatchUpdate update) Update all profiles in batch according to the specifiedBatchUpdatecreatePersona(String personaId) Creates a persona with the specified identifier and automatically creates an associated session with it.voidRemoves the profile (or persona if thepersonaquery parameter is set totrue) identified by the specified identifier.voiddeletePersona(String personaId, boolean persona) Removes the persona identified by the specified identifier.booleandeleteProperty(String propertyId) Deletes the property type identified by the specified identifier.javax.ws.rs.core.ResponseexportProfiles(Query query) Retrieves an export of profiles matching the specified query as a downloadable file using the comma-separated values (CSV) format.findProfileSessions(String profileId) javax.ws.rs.core.ResponseformExportProfiles(String query) A version ofgetExportProfiles(String)suitable to be called from an HTML form.longRetrieves the number of unique profiles.getExistingProperties(String tag, boolean isSystemTag, String itemType, String language, javax.servlet.http.HttpServletResponse response) Retrieves the existing property types for the specified type as defined by the Item subclass public fieldITEM_TYPEand with the specified tag or system tag.javax.ws.rs.core.ResponsegetExportProfiles(String query) Retrieves an export of profiles matching the specified query as a downloadable file using the comma-separated values (CSV) format.getPersonas(Query query) RetrievesPersonamatching the specified query.getPersonaSessions(String personaId, int offset, int size, String sortBy) Retrieves the sessions associated with the persona identified by the specified identifier, ordered according to the specifiedsortByString and and paged: onlysizeof them are retrieved, starting with theoffset-th one.getProfiles(Query query) Retrieves profiles matching the specified query.getProfileSegments(String profileId) Retrieves the list of segment metadata for the segments the specified profile is a member of.getProfileSessions(String profileId, String query, int offset, int size, 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 specifiedsortByString and and paged: onlysizeof them are retrieved, starting with theoffset-th one.getPropertyType(String propertyId, String language) Retrieves the property type associated with the specified property ID.getPropertyTypeBySystemTag(String tags, String language) Retrieves all property types with the specified tags.getPropertyTypeByTag(String tags, String language) Retrieves all property types with the specified tags.getPropertyTypeMapping(String fromPropertyTypeId) TODOgetPropertyTypes(String language) Retrieves all known property types.getPropertyTypesByTarget(String target, String language) Retrieves all the property types associated with the specified target.getSessionEvents(String sessionId, String[] eventTypes, String query, int offset, int size, String sortBy) listAliasesByProfileId(String profileId, int offset, int size, String sortBy) Retrieves the profile identified by the specified identifier.loadPersona(String personaId) Retrieves thePersonaidentified by the specified identifier.loadPersonaWithSessions(String personaId) Retrieves the persona identified by the specified identifier and all its associated sessionsloadSession(String sessionId) Retrieves the session identified by the specified identifier.booleanmatchCondition(Condition condition, Profile profile, Session session) voidremoveAliasFromProfile(String profileId, String aliasId, String headerClientID) Saves the specified profile in the context server, sending aprofileUpdatedevent.savePersona(Persona persona) Persists the specifiedPersonain the context server.savePersonaWithSessions(PersonaWithSessions personaWithSessions) Save the posted persona with its sessionssaveSession(Session session) Saves the specified session.searchSession(Query query) Retrieves sessions matching the specified query.voidsetEventService(EventService eventService) voidsetLocalizationHelper(LocalizationHelper localizationHelper) voidsetProfileService(ProfileService profileService) booleansetPropertyType(PropertyType property) Persists the specified property type in the context server.booleansetPropertyTypes(List<PropertyType> properties) Persists the specified properties type in the context server.voidsetSegmentService(SegmentService segmentService)
-
Constructor Details
-
ProfileServiceEndPoint
public ProfileServiceEndPoint()
-
-
Method Details
-
setProfileService
-
setEventService
-
setSegmentService
-
setLocalizationHelper
-
getAllProfilesCount
@GET @Path("/count") public long getAllProfilesCount()Retrieves the number of unique profiles.- Returns:
- the number of unique profiles.
-
getProfiles
Retrieves profiles matching the specified query.- Parameters:
query- aQueryspecifying which elements to retrieve- Returns:
- a
PartialListof 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 ofgetExportProfiles(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
Update all profiles in batch according to the specifiedBatchUpdate- Parameters:
update- the batch update specification
-
load
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
nullif no such profile exists
-
save
Saves the specified profile in the context server, sending aprofileUpdatedevent.- 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 thepersonaquery parameter is set totrue) identified by the specified identifier.- Parameters:
profileId- the identifier of the profile or persona to deletepersona-trueif the specified identifier is supposed to refer to a persona,falseif 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 specifiedsortByString and and paged: onlysizeof them are retrieved, starting with theoffset-th one. TODO: use a Query object instead of distinct parameter?- Parameters:
profileId- the identifier of the profile we want to retrieve sessions fromquery- a String of text used for fulltext filtering which sessions we are interested in ornull(or an empty String) if we want to retrieve all sessionsoffset- zero or a positive integer specifying the position of the first session in the total ordered collection of matching sessionssize- a positive integer specifying how many matching sessions should be retrieved or-1if all of them should be retrievedsortBy- an optional (nullif 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:ascordesc.- Returns:
- a
PartialListof 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
RetrievesPersonamatching the specified query.- Parameters:
query- aQueryspecifying which elements to retrieve- Returns:
- a
PartialListof Persona instances matching the specified query
-
loadPersona
@GET @Path("/personas/{personaId}") public Persona loadPersona(@PathParam("personaId") String personaId) Retrieves thePersonaidentified by the specified identifier.- Parameters:
personaId- the identifier of the persona to retrieve- Returns:
- the persona identified by the specified identifier or
nullif 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
PersonaWithSessionsinstance 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
PersonaWithSessionsinstance with the persona identified by the specified identifier and all its associated sessions
-
savePersona
Persists the specifiedPersonain 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 deletepersona-trueif the specified identifier is supposed to refer to a persona,falseif 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 specifiedsortByString and and paged: onlysizeof them are retrieved, starting with theoffset-th one.- Parameters:
personaId- the persona idoffset- zero or a positive integer specifying the position of the first session in the total ordered collection of matching sessionssize- a positive integer specifying how many matching sessions should be retrieved or-1if all of them should be retrievedsortBy- an optional (nullif 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:ascordesc.- Returns:
- a
PartialListof 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 properDateobject
-
saveSession
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) RetrievesEvents for theSessionidentified by the provided session identifier, matching any of the provided event types, ordered according to the specifiedsortByString and paged: onlysizeof them are retrieved, starting with theoffset-th one. If aqueryis 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 consideringeventTypes- an array of event type names; the events to retrieve should at least match one of thesequery- a String to perform full text filtering on events matching the other conditionsoffset- zero or a positive integer specifying the position of the first event in the total ordered collection of matching eventssize- a positive integer specifying how many matching events should be retrieved or-1if all of them should be retrievedsortBy- an optional (nullif 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:ascordesc.- Returns:
- a
PartialListof matching events
-
findProfileSessions
-
matchCondition
-
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 fieldITEM_TYPEand with the specified tag or system tag. TODO: move to a different class- Parameters:
tag- the tag we're interested inisSystemTag- if we should look in system tags instead of tagsitemType- the String representation of the item type we want to retrieve the count of, as defined by its class'ITEM_TYPEfieldlanguage- the value of theAccept-Languageheader to specify in which locale the properties description should be returned TODO unusedresponse- 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 theAccept-Languageheader 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 typelanguage- the value of theAccept-Languageheader 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 typeslanguage- the value of theAccept-Languageheader 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 identifierslanguage- the value of theAccept-Languageheader 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 identifierslanguage- the value of theAccept-Languageheader 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
Persists the specified property type in the context server. TODO: move to a different class- Parameters:
property- the property type to persist- Returns:
trueif the property type was properly created,falseotherwise (for example, if the property type already existed
-
setPropertyTypes
Persists the specified properties type in the context server. TODO: move to a different class- Parameters:
properties- the properties type to persist- Returns:
trueif the property type was properly created,falseotherwise (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:
trueif the property type was properly deleted,falseotherwise
-
searchSession
Retrieves sessions matching the specified query.- Parameters:
query- aQueryspecifying which elements to retrieve- Returns:
- a
PartialListof sessions matching the specified query
-
addAliasToProfile
-
removeAliasFromProfile
-
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)
-