}
public void run() {
try {
LinkbackExtractor lb = new LinkbackExtractor(
mReferer.getRefererUrl(),mReferer.getRequestUrl());
if ( lb.getTitle()!=null && lb.getExcerpt()!=null ) {
mReferer.setTitle(lb.getTitle());
mReferer.setExcerpt(lb.getExcerpt());
if ( lb.getPermalink() != null ) {
// The presence of a permalink indicates that this
// linkback was parsed out of an RSS feed and is
// presumed to be a good linkback.
mReferer.setRefererPermalink(lb.getPermalink());
// See if this request/permalink is in the DB
List matchRef = getExistingReferers(
mReferer.getWebsite(),
mReferer.getDateString(),
mReferer.getRefererPermalink());
// If it is the first, then set it to be visible
if ( matchRef.size() == 0 ) {
mReferer.setVisible(Boolean.TRUE);
} else {
// We can't throw away duplicates or we will
// end up reparsing them everytime a hit comes
// in from one of them, but we can mark them
// as duplicates.
mReferer.setDuplicate(Boolean.TRUE);
}
saveReferer(mReferer);
}
else {
// Store the new referer
saveReferer(mReferer);
// Hacky Referer URL weighting kludge:
//
// If there are multple referers to a request URL,
// then we want to pick the best one. The others
// are marked as duplicates. To do this we use a
// weight. The weight formula is:
//
// w = URL length + (100 if URL contains anchor)
// LOOP: find the referer with the highest weight
Boolean visible = Boolean.FALSE;
List refs= getReferersWithSameTitle(
mReferer.getWebsite(),
mReferer.getRequestUrl(),
lb.getTitle(),
lb.getExcerpt());
RefererData chosen = null;
int maxweight = 0;
for (Iterator rdItr = refs.iterator();rdItr.hasNext();) {
RefererData referer = (RefererData) rdItr.next();