int count = 0;
int errorCount = 0;
try {
PlanetManager planet = RollerFactory.getRoller().getPlanetManager();
PlanetConfigData config = planet.getConfiguration();
Technorati technorati = null;
try {
if (config.getProxyHost()!=null && config.getProxyPort() != -1) {
technorati = new Technorati(
config.getProxyHost(), config.getProxyPort());
} else {
technorati = new Technorati();
}
} catch (IOException e) {
log.error("Aborting collection of Technorati rankings.\n"
+"technorati.license not found at root of classpath.\n"
+"Get license at http://technorati.com/developers/apikey.html\n"
+"Put the license string in a file called technorati.license.\n"
+"And place that file at the root of Roller's classpath.\n"
+"For example, in the /WEB-INF/classes directory.");
return;
}
UserManager userManager = RollerFactory.getRoller().getUserManager();
try {
int limit = RollerConfig.getIntProperty(
"planet.aggregator.technorati.limit", 500);
int userCount = planet.getSubscriptionCount();
int mod = (userCount / limit) + 1;
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
int day = cal.get(Calendar.DAY_OF_YEAR);
int start = (day % mod) * limit;
int end = start + limit;
end = end > userCount ? userCount : end;
log.info("Updating subscriptions ["+start+":"+end+"]");
Iterator subs = planet.getAllSubscriptions();
while (subs.hasNext()) {
PlanetSubscriptionData sub =
(PlanetSubscriptionData)subs.next();
if (count >= start && count < end) {
try {
Technorati.Result result =
technorati.getBloginfo(sub.getSiteURL());
if (result != null && result.getWeblog() != null) {
sub.setInboundblogs(
result.getWeblog().getInboundblogs());
sub.setInboundlinks(
result.getWeblog().getInboundlinks());