Skip to content

Commit

Permalink
getting cookie value refactored
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelwechner committed Nov 14, 2012
1 parent 6a88bfc commit a9f7424
Showing 1 changed file with 11 additions and 16 deletions.
Expand Up @@ -80,16 +80,22 @@ protected InputStream getContentXML(String viewId) throws Exception {
return XMLHelper.getInputStream(doc, false, false, null);
}

String cookieVal = cookie.getValue();
if (getResourceConfigProperty("cookie") != null) {
log.warn("Try to get user profile for third party cookie: " + getResourceConfigProperty("cookie"));
cookieVal = getResourceConfigProperty("cookie");
}

Element cookieEl = doc.createElementNS(NAMESPACE, "yanel-cookie-id");
cookieEl.appendChild(doc.createTextNode(cookie.getValue()));
cookieEl.appendChild(doc.createTextNode(cookieVal));
root.appendChild(cookieEl);

// INFO: Get user interests and clickstream
Iterable<String> userInterests;
Iterable<String> clickStream;
try {
userInterests = getUserInterests(service, cookie.getValue(), boost_domain, api_key);
clickStream = getClickstream(service, cookie.getValue(), boost_domain, api_key);
userInterests = getUserInterests(service, cookieVal, boost_domain, api_key);
clickStream = getClickstream(service, cookieVal, boost_domain, api_key);
} catch(ServiceException e) {
// No interests or clickstream
log.error(e, e);
Expand Down Expand Up @@ -178,15 +184,9 @@ private Iterable<String> getClickstream(String boostServiceUrl, String cookie, S
domain = getResourceConfigProperty("domain");
}

String c = cookie;
if (getResourceConfigProperty("cookie") != null) {
log.warn("Try to get user profile for third party cookie: " + getResourceConfigProperty("cookie"));
c = getResourceConfigProperty("cookie");
}

BoostServiceConfig bsc = new BoostServiceConfig(boostServiceUrl, domain, apiKey);
BoostService boost = new BoostService(bsc);
return boost.getClickStream(c);
return boost.getClickStream(cookie);
}

/**
Expand All @@ -207,12 +207,7 @@ private Iterable<String> getUserInterests(String boostServiceUrl, String cookie,
BoostServiceConfig bsc = new BoostServiceConfig(boostServiceUrl, domain, apiKey);
BoostService boost = new BoostService(bsc);

if (getResourceConfigProperty("cookie") != null) {
log.warn("Try to get user profile for third party cookie: " + getResourceConfigProperty("cookie"));
return boost.getUserProfile(getResourceConfigProperty("cookie"));
} else {
return boost.getUserProfile(cookie);
}
return boost.getUserProfile(cookie);
}

/**
Expand Down

0 comments on commit a9f7424

Please sign in to comment.