public class VisitorsClient extends Object implements AutoCloseable
VisitorsClient
provides functionality for Visitor Services back-end Java REST APIs. Java client is used when Visitor Services and consumer applications owned by Oracle interact.Constructor and Description |
---|
VisitorsClient(AuthType authentication, String url)
Constructor for VisitorsClient.
|
VisitorsClient(AuthType authentication, String url, Map<String,Object> params)
Allocate and initialize a VisitorsClient object.
|
VisitorsClient(String url)
Allocate and initialize a
VisitorsClient object. |
Modifier and Type | Method and Description |
---|---|
boolean |
addActivity(String visitorId, Map<String,String> activities)
Add visitor's activity to Visitor Services storage
|
void |
close() |
String |
getAggregatedProfile(String visitorId, String rule)
Get an aggregated profile from Visitor Services using existing visitor's ID All the linked profiles for the visitor are background updated in different profile storages.
|
String |
getAggregatedProfile(String visitorId, String rule, boolean updated)
Get an aggregated profile from Visitor Services using existing visitor's ID All the linked profiles for the visitor are updated in different profile storages.
|
List<ActivityApi> |
getLatest(String visitorId, String type, int limit)
Get a list of visitor's activities sorted by date
|
LinkedProfilesApi |
getLinkedProfiles(String visitorId)
Returns linked profiles from Visitor Services using existing visitor's ID.
|
LinkedProfilesApi |
getLinkedProfiles(String visitorId, boolean updated)
Returns linked profiles from Visitor Services using existing visitor's ID.
|
List<ActivityApi> |
getRated(String visitorId, String type, int limit)
Get a list of visitor's activities sorted by rating
|
String |
getVisitorId(javax.servlet.http.HttpServletRequest request)
Get visitor's ID from Visitor Services using external ID from Single Sign On solution.
|
Boolean |
isExist(String visitorId)
Verify if the visitor ID exists in database.
|
Boolean |
isGuest(String visitorId)
Verifies if the visitor is a guest profile or has no profile in DB.
|
boolean |
linkProfiles(String[] ids)
Add visitors into the linked group.
|
String |
registerGuest(String guestId)
Register visitor as guest in the database.
|
String |
registerGuest(String guestId, Map<String,String> formParams)
Deprecated.
|
String |
saveExtendedAttributes(String visitorId, Map<String,String> formParams)
Save extended attribute for visitor profile.
|
boolean |
unlinkProfiles(String[] ids)
Remove specified visitors from current linked group.
|
public VisitorsClient(AuthType authentication, String url, Map<String,Object> params)
authentication
- AuthType
object. AuthType
is an authentication type for getting access to Visitor Services back-end REST.url
- String
object. Is a base URL to Visitor Services REST. For example, http://example.com:8080/visitors-webapp
params
- Map
object. Map for Jersey Client initializationpublic VisitorsClient(AuthType authentication, String url)
Constructor for VisitorsClient.
Initializes a newly createdVisitorsClient
public String getVisitorId(javax.servlet.http.HttpServletRequest request)
REST API information:
POST http://host:port/context/rest/v1/visitor/getId
Content type: application/x-www-form-urlencoded
Return: IdProfilesResponse
visitorId
- visitor ID from SVS.
request
- HttpServletRequest
object.String
.UnauthorizedAccessException
- when there is a mismatch between access credentials passed while creating visitor client object and the expected credentials that visitor services expects javax.ws.rs.WebApplicationException in case the response status code of the response returned by the server is not successful
.public Boolean isExist(String visitorId)
true
. Visitor ID can be guest user or register user.
REST API information:
GET http://host:port/context/rest/v1/visitor/id/visitorId/check/exist
Accept
:application/json, application/xml
Return: BooleanResponse
visitorId
- String
object.true
if the visitor ID exists in the database. in the database
false
if the visitor ID does not exist.
UnauthorizedAccessException
- when there is a mismatch between access credentials passed while creating visitor client object and the expected credentials that visitor services expects javax.ws.rs.WebApplicationException in case the response status code of the response returned by the server is not successful
.public Boolean isGuest(String visitorId)
REST API information:
GET http://host:port/context/rest/v1/visitor/id/visitorId/check/guest
Accept
:application/json, application/xml
Return: BooleanResponse
visitorId
- a String
object.false
if visitor has one non guest profile between linked profiles.
Possible 5 cases:
1. true
if no profile in database.
2. true
if one guest profile in database.
3. false
if one non guest profile in database.
4. true
if more then one linked profile exists and all profiles are guest profiles/
5. false
if more than one linked profile exists and one profile is not a guest profile
UnauthorizedAccessException
- when there is a mismatch between access credentials passed while creating visitor client object and the expected credentials that visitor services expects javax.ws.rs.WebApplicationException in case the response status code of the response returned by the server is not successful
.public String getAggregatedProfile(String visitorId, String rule, boolean updated)
REST API information:
GET http://host:port/context/rest/v1/visitor/id/visitorId/profile/aggregated/rule
Accept
:application/json, application/xml
Path Params: visitorId, rule
Query Params: updated
Return: AggregatedProfileResponse
aggregated profile
for visitor with id as visitorId
aggregated by rule
aggregation template.
visitorId
- String
object.rule
- String
object. Aggregation template nameupdated
- - If true, method executes profile update and enrichment in synchronous way and returns profile attributes from fresh data. If false, then depending on whether profile has expired it executes profile update and enirchment process as below - If profile has expired and a) JMS is configured in Visitor Services, method submits the update and enrichment task and returns profile data from old data, b) JMS is not configured in Visitor Services, method executes update and enrichment in synchronous way and method returns profile data from fresh data If profile has not expired, it has same effect as passing value 'false', i.e. returns profile data from data present in Visitor Services storage.String
object in JSON format.UnauthorizedAccessException
- when there is a mismatch between access credentials passed while creating visitor client object and the expected credentials that visitor services expects javax.ws.rs.WebApplicationException in case the response status code of the response returned by the server is not successful
.public String getAggregatedProfile(String visitorId, String rule)
REST API information:
GET http://host:port/context/rest/v1/visitor/id/visitorId/profile/aggregated/rule
Accept
:application/json, application/xml
Path Params: visitorId, rule
Query Params: updated
Return: AggregatedProfileResponse
aggregated profile
for visitor with id as visitorId
aggregated by rule
aggregation template.
visitorId
- String
object.rule
- String
object. Aggregation template nameString
object in JSON format. It has same effect as calling the overloaded method with param updated=false.UnauthorizedAccessException
- when there is a mismatch between access credentials passed while creating visitor client object and the expected credentials that visitor services expects javax.ws.rs.WebApplicationException in case the response status code of the response returned by the server is not successful
.public LinkedProfilesApi getLinkedProfiles(String visitorId)
REST API information:
GET http://host:port/context/rest/v1/visitor/id/visitorId/profiles/linked
Accept
:application/json, application/xml
Path Params: visitorId
Query Params: updated
Return: LinkedProfilesResponse
linked profiles
for visitor with id as visitorId
visitorId
- String
object.LinkedProfilesApi
object. It has same effect as calling the overloaded method with param updated=false.UnauthorizedAccessException
- when there is a mismatch between access credentials passed while creating visitor client object and the expected credentials that visitor services expects javax.ws.rs.WebApplicationException in case the response status code of the response returned by the server is not successful
.public LinkedProfilesApi getLinkedProfiles(String visitorId, boolean updated)
REST API information:
GET http://host:port/context/rest/v1/visitor/id/visitorId/profiles/linked
Accept
:application/json, application/xml
Path Params: visitorId
Query Params: updated
Return: LinkedProfilesResponse
linked profiles
for visitor with id as visitorId
visitorId
- String
object.updated
- - If true, method executes profile update and enrichment in synchronous way and returns profile attributes from fresh data. If false, then depending on whether profile has expired it executes profile update and enirchment process as below - If profile has expired and a) JMS is configured in Visitor Services, method submits the update and enrichment task and returns profile data from old data, b) JMS is not configured in Visitor Services, method executes update and enrichment in synchronous way and method returns profile data from fresh data If profile has not expired, it has same effect as passing value 'false', i.e. returns profile data from data present in Visitor Services storage.LinkedProfilesApi
object.UnauthorizedAccessException
- when there is a mismatch between access credentials passed while creating visitor client object and the expected credentials that visitor services expects javax.ws.rs.WebApplicationException in case the response status code of the response returned by the server is not successful
.public boolean addActivity(String visitorId, Map<String,String> activities)
REST API information:
POST http://host:port/context/rest/v1/visitor/id/visitorId/activity/add
Path Params: visitorId
Form Params: activities map. Format: activityType=activity
Accept
:application/json, application/xml
Content type: application/x-www-form-urlencoded
Return: RestResponse
visitorId
- String
object.activities
- Map
object. The format is activityType=activity
UnauthorizedAccessException
- when there is a mismatch between access credentials passed while creating visitor client object and the expected credentials that visitor services expects javax.ws.rs.WebApplicationException in case the response status code of the response returned by the server is not successful
.public List<ActivityApi> getRated(String visitorId, String type, int limit)
REST API information:
GET http://host:port/context/rest/v1/visitor/id/visitorId/activity/type/attivityType/rated ?limit=activitiesLimit
Path Params: visitorId, attivityType
Query Params: limit
Accept
:application/json, application/xml
Return: ActivitiesResponse
visitorId
- String
object.type
- any String
value that represent type of visitors activities. For example for visitor's searches it can be search_query
.limit
- int.List
of visitor's ActivityApi
objects sorted by rating.UnauthorizedAccessException
- when there is a mismatch between access credentials passed while creating visitor client object and the expected credentials that visitor services expects javax.ws.rs.WebApplicationException in case the response status code of the response returned by the server is not successful
.public List<ActivityApi> getLatest(String visitorId, String type, int limit)
REST API information:
GET http://host:port/context/rest/v1/visitor/id/visitorId/activity/type/attivityType/latest ?limit=activitiesLimit
Path Params: visitorId, attivityType
Query Params: limit
Accept
:application/json, application/xml
Return: ActivitiesResponse
visitorId
- a String
object.type
- any String
value that represent type of visitors activities. For example for visitor's searches it can be search_query
.limit
- int.List
of visitor's ActivityApi
objects sorted by date.UnauthorizedAccessException
- when there is a mismatch between access credentials passed while creating visitor client object and the expected credentials that visitor services expects javax.ws.rs.WebApplicationException in case the response status code of the response returned by the server is not successful
.public String saveExtendedAttributes(String visitorId, Map<String,String> formParams)
REST API information:
POST http://host:port/context/rest/v1/visitor/id/visitorId/attributes/save
Path Params: visitorId
Form Params: array of custom visitor attributes
Accept
:application/json, application/xml
Content type: application/x-www-form-urlencoded
Return: RestResponse
visitorId
- String
object.formParams
- Map
object with extended attributes. For example, "gender"="male", "locale"="us".String
object. "success" or "failure" statusUnauthorizedAccessException
- when there is a mismatch between access credentials passed while creating visitor client object and the expected credentials that visitor services expects javax.ws.rs.WebApplicationException in case the response status code of the response returned by the server is not successful
.public String registerGuest(String guestId)
REST API information:
POST http://host:port/context/rest/v1/visitor/register?id=guestId
Query Params: id
Accept
:application/json, application/xml
Return: IdProfilesResponse
guestId
- String
object. visitor ID from SVSString
value.UnauthorizedAccessException
- when there is a mismatch between access credentials passed while creating visitor client object and the expected credentials that visitor services expects javax.ws.rs.WebApplicationException in case the response status code of the response returned by the server is not successful
.@Deprecated public String registerGuest(String guestId, Map<String,String> formParams)
REST API information:
POST http://host:port/context/rest/v1/visitor/register?id=guestId
Query Params: id
Form Params: post form attributes - array of custom visitor attributes
Accept
:application/json, application/xml
Return: IdProfilesResponse
guestId
- String
object. visitor ID from SVSformParams
- Map
object. Array of custom visitor attributesString
value.UnauthorizedAccessException
- when there is a mismatch between access credentials passed while creating visitor client object and the expected credentials that visitor services expects javax.ws.rs.WebApplicationException in case the response status code of the response returned by the server is not successful
.public boolean linkProfiles(String[] ids)
REST API information:
POST http://host:port/context/rest/v1/visitor/link?ids=id1,id2,...idN
Query Params: id1,id2,...idN - comma separated list of visitorIDs that need tobe moved to the separate group.
Form Params: post form attributes - array of custom visitor attributes
Accept
:application/json, application/xml
Return: RestResponse
ids
- array of String
objects.true
if operation successUnauthorizedAccessException
- when there is a mismatch between access credentials passed while creating visitor client object and the expected credentials that visitor services expects javax.ws.rs.WebApplicationException in case the response status code of the response returned by the server is not successful
.public boolean unlinkProfiles(String[] ids)
REST API information:
POST http://host:port/context/rest/v1/visitor/unlink?ids=id1,id2,...idN
Query Params: id1,id2,...idN - comma separated list of visitorIDs that need tobe moved to the separate group.
Form Params: post form attributes - array of custom visitor attributes
Accept
:application/json, application/xml
Return: RestResponse
ids
- array of String
objects.true
if operation successUnauthorizedAccessException
- when there is a mismatch between access credentials passed while creating visitor client object and the expected credentials that visitor services expects javax.ws.rs.WebApplicationException in case the response status code of the response returned by the server is not successful
.public void close() throws Exception
close
in interface AutoCloseable
Exception
Copyright © 2015 Oracle and/or its affiliates. All rights reserved.