Class ContextRequest
- java.lang.Object
-
- org.apache.unomi.api.ContextRequest
-
public class ContextRequest extends Object
An incoming request for context information from clients of the context server. This allows clients to specify which type of information they are interested in getting from the context server as well as specify incoming events or content filtering or property/segment overrides for personalization or impersonation. This conditions what the context server will return with its response.Events that are generated on the client as part of its functioning can be specified in the client as part of its request for contextual data. The context server will deliver these events to
EventListenerService
s to be processed. In particular, theRulesService
will trigger any applicableRule
which in turn might triggerAction
s. An appropriate Event is also triggered when a Rule matches so that other rules can react to it. Finally, an event will also be emitted if the userProfile
has been updated as part of the event processing.A client wishing to perform content personalization might also specify filtering condition to be evaluated by the context server so that it can tell the client whether the content associated with the filter should be activated for this profile/session.
It is also possible to clients wishing to perform user impersonation to specify properties or segment to override the proper ones so as to emulate a specific profile, in which case the overridden value will temporarily replace the proper values so that all rules will be evaluated with these values instead of the proper ones.
- See Also:
ContextResponse
,Event
-
-
Constructor Summary
Constructors Constructor Description ContextRequest()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getClientId()
List<Event>
getEvents()
Retrieves the events that the client has generated as part of its processes and wishes the context server to process.List<PersonalizationService.PersonalizedContent>
getFilters()
Retrieves the filters aimed at content personalization that should be evaluated for the given session and/or profile so that the context server can tell the client whether the content associated with the filter should be activated for this profile/session.List<PersonalizationService.PersonalizationRequest>
getPersonalizations()
String
getProfileId()
Retrieve the profileId passed along with the request.Profile
getProfileOverrides()
Retrieves the profile overrides.List<String>
getRequiredProfileProperties()
Retrieves the list of profile properties the context server should return with its context response.List<String>
getRequiredSessionProperties()
Retrieves the list of session properties the context server should return with its context response.String
getSessionId()
Retrieve the sessionId passed along with the request.Map<String,Object>
getSessionPropertiesOverrides()
Retrieves the session properties overrides.Item
getSource()
Retrieves the source of the context request.boolean
isRequireScores()
Specifies whether the profiles scores should be part of the ContextResponse.boolean
isRequireSegments()
Determines whether or not the context server should return the segments associated with the profile from which the request was issued.void
setClientId(String clientId)
void
setEvents(List<Event> events)
Specifies the events to be processed by the context server.void
setFilters(List<PersonalizationService.PersonalizedContent> filters)
Specifies the content filters to be evaluated.void
setPersonalizations(List<PersonalizationService.PersonalizationRequest> personalizations)
void
setProfileId(String profileId)
Sets the profileId in the request.void
setProfileOverrides(Profile overrides)
Sets the profile overrides.void
setRequiredProfileProperties(List<String> requiredProfileProperties)
Specifies which profile properties should be returned with the response.void
setRequiredSessionProperties(List<String> requiredSessionProperties)
Specifies which session properties should be returned with the response.void
setRequireScores(boolean requireScores)
Setting this value to true indicates that the profile scores should be included in the response.void
setRequireSegments(boolean requireSegments)
Specifies whether to return the profile segments with the response.void
setSessionId(String sessionId)
Sets the sessionId in the request.void
setSessionPropertiesOverrides(Map<String,Object> sessionPropertiesOverrides)
Sets the session properties overrides.void
setSource(Item source)
Sets the source.
-
-
-
Method Detail
-
getSource
public Item getSource()
Retrieves the source of the context request.- Returns:
- the source
-
setSource
public void setSource(Item source)
Sets the source.- Parameters:
source
- the source
-
isRequireSegments
public boolean isRequireSegments()
Determines whether or not the context server should return the segments associated with the profile from which the request was issued.- Returns:
true
if the context server should return the profile segments,false otherwise
- See Also:
ContextResponse.getProfileSegments()
-
setRequireSegments
public void setRequireSegments(boolean requireSegments)
Specifies whether to return the profile segments with the response.- Parameters:
requireSegments
-true
if the context server should return the profile segments,false otherwise
-
getRequiredProfileProperties
public List<String> getRequiredProfileProperties()
Retrieves the list of profile properties the context server should return with its context response.- Returns:
- the required profile properties the client requested to be returned with the response
- See Also:
ContextResponse.getProfileProperties()
-
setRequiredProfileProperties
public void setRequiredProfileProperties(List<String> requiredProfileProperties)
Specifies which profile properties should be returned with the response.- Parameters:
requiredProfileProperties
- the profile properties that should be returned with the response
-
getRequiredSessionProperties
public List<String> getRequiredSessionProperties()
Retrieves the list of session properties the context server should return with its context response.- Returns:
- the required session properties the client requested to be returned with the response
- See Also:
ContextResponse.getSessionProperties()
-
setRequiredSessionProperties
public void setRequiredSessionProperties(List<String> requiredSessionProperties)
Specifies which session properties should be returned with the response.- Parameters:
requiredSessionProperties
- the session properties that should be returned with the response
-
isRequireScores
public boolean isRequireScores()
Specifies whether the profiles scores should be part of the ContextResponse.- Returns:
- a boolean indicating if the scores should be part of the response.
-
setRequireScores
public void setRequireScores(boolean requireScores)
Setting this value to true indicates that the profile scores should be included in the response. By default this value is false.- Parameters:
requireScores
- set to true if you want the scores to be part of the context response
-
getFilters
public List<PersonalizationService.PersonalizedContent> getFilters()
Retrieves the filters aimed at content personalization that should be evaluated for the given session and/or profile so that the context server can tell the client whether the content associated with the filter should be activated for this profile/session. The filter identifier is used in theContextResponse
with the associated evaluation result.- Returns:
- the filters aimed at content personalization that should be evaluated for the given session and/or profile
- See Also:
Details on how the filter conditions are evaluated
,Details on how the evaluation results are returned to the client
-
setFilters
public void setFilters(List<PersonalizationService.PersonalizedContent> filters)
Specifies the content filters to be evaluated.- Parameters:
filters
- the content filters to be evaluated
-
getPersonalizations
public List<PersonalizationService.PersonalizationRequest> getPersonalizations()
-
setPersonalizations
public void setPersonalizations(List<PersonalizationService.PersonalizationRequest> personalizations)
-
getEvents
public List<Event> getEvents()
Retrieves the events that the client has generated as part of its processes and wishes the context server to process.- Returns:
- the client events to be processed by the context server
- See Also:
Event
-
setEvents
public void setEvents(List<Event> events)
Specifies the events to be processed by the context server.- Parameters:
events
- the events to be processed by the context server
-
getProfileOverrides
public Profile getProfileOverrides()
Retrieves the profile overrides.- Returns:
- the profile overrides
-
setProfileOverrides
public void setProfileOverrides(Profile overrides)
Sets the profile overrides.- Parameters:
overrides
- the profile overrides
-
getSessionPropertiesOverrides
public Map<String,Object> getSessionPropertiesOverrides()
Retrieves the session properties overrides.- Returns:
- the session properties overrides
-
setSessionPropertiesOverrides
public void setSessionPropertiesOverrides(Map<String,Object> sessionPropertiesOverrides)
Sets the session properties overrides.- Parameters:
sessionPropertiesOverrides
- the session properties overrides
-
getSessionId
public String getSessionId()
Retrieve the sessionId passed along with the request. All events will be processed with this sessionId as a default- Returns:
- the identifier for the session
-
setSessionId
public void setSessionId(String sessionId)
Sets the sessionId in the request. This is the preferred method of passing along a session identifier with the request, as passing it along in the URL can lead to potential security vulnerabilities.- Parameters:
sessionId
- an unique identifier for the session
-
getProfileId
public String getProfileId()
Retrieve the profileId passed along with the request. All events will be processed with this profileId as a default- Returns:
- the identifier for the profile
-
setProfileId
public void setProfileId(String profileId)
Sets the profileId in the request.- Parameters:
profileId
- an unique identifier for the profile
-
getClientId
public String getClientId()
-
setClientId
public void setClientId(String clientId)
-
-