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 Constructor Description ProfileServiceEndPoint()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAliasToProfile(String profileId, String aliasId, String headerClientID)voidbatchProfilesUpdate(BatchUpdate update)Update all profiles in batch according to the specifiedBatchUpdatePersonacreatePersona(String personaId)Creates a persona with the specified identifier and automatically creates an associated session with it.voiddelete(String profileId, boolean persona)Removes 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.PartialList<Session>findProfileSessions(String profileId)javax.ws.rs.core.ResponseformExportProfiles(String query)A version ofgetExportProfiles(String)suitable to be called from an HTML form.longgetAllProfilesCount()Retrieves the number of unique profiles.Collection<PropertyType>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.PartialList<Persona>getPersonas(Query query)RetrievesPersonamatching the specified query.PartialList<Session>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.PartialList<Profile>getProfiles(Query query)Retrieves profiles matching the specified query.List<Metadata>getProfileSegments(String profileId)Retrieves the list of segment metadata for the segments the specified profile is a member of.PartialList<Session>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.PropertyTypegetPropertyType(String propertyId, String language)Retrieves the property type associated with the specified property ID.Collection<PropertyType>getPropertyTypeBySystemTag(String tags, String language)Retrieves all property types with the specified tags.Collection<PropertyType>getPropertyTypeByTag(String tags, String language)Retrieves all property types with the specified tags.StringgetPropertyTypeMapping(String fromPropertyTypeId)TODOMap<String,Collection<PropertyType>>getPropertyTypes(String language)Retrieves all known property types.Collection<PropertyType>getPropertyTypesByTarget(String target, String language)Retrieves all the property types associated with the specified target.PartialList<Event>getSessionEvents(String sessionId, String[] eventTypes, String query, int offset, int size, String sortBy)PartialList<ProfileAlias>listAliasesByProfileId(String profileId, int offset, int size, String sortBy)Profileload(String profileId)Retrieves the profile identified by the specified identifier.PersonaloadPersona(String personaId)Retrieves thePersonaidentified by the specified identifier.PersonaWithSessionsloadPersonaWithSessions(String personaId)Retrieves the persona identified by the specified identifier and all its associated sessionsSessionloadSession(String sessionId)Retrieves the session identified by the specified identifier.booleanmatchCondition(Condition condition, Profile profile, Session session)voidremoveAliasFromProfile(String profileId, String aliasId, String headerClientID)Profilesave(Profile profile)Saves the specified profile in the context server, sending aprofileUpdatedevent.PersonasavePersona(Persona persona)Persists the specifiedPersonain the context server.PersonaWithSessionssavePersonaWithSessions(PersonaWithSessions personaWithSessions)Save the posted persona with its sessionsSessionsaveSession(Session session)Saves the specified session.PartialList<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)
-
-
-
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- 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
@POST @Path("/batchProfilesUpdate") public void batchProfilesUpdate(BatchUpdate update)Update all profiles in batch according to the specifiedBatchUpdate- 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
nullif no such profile exists
-
save
@POST @Path("/") public Profile save(Profile profile)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
@POST @Path("/personas/search") public PartialList<Persona> getPersonas(Query query)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
@POST @Path("/personas") public Persona savePersona(Persona persona)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 ParseExceptionRetrieves 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
@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)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
public PartialList<Session> findProfileSessions(String profileId)
-
matchCondition
public boolean matchCondition(Condition condition, Profile profile, Session session)
-
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 IOExceptionRetrieves 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
@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:
trueif the property type was properly created,falseotherwise (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:
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
@POST @Path("/search/sessions") public PartialList<Session> searchSession(Query query)Retrieves sessions matching the specified query.- Parameters:
query- aQueryspecifying which elements to retrieve- Returns:
- a
PartialListof 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)
-
-