public boolean apply(Jobs jobs) {
MessageQueue mq = jobs.getMessageQueue();
for (ListIterator<JobEnvelope> it = jobs.getJobs().listIterator();
it.hasNext();) {
JobEnvelope env = it.next();
if (env.fromCache) { continue; }
Job job = env.job;
if (job.getType() != ContentType.HTML) { continue; }
Dom dom = (Dom) job.getRoot();
Node node = dom.getValue();
URI baseUri = baseUri(node, job.getBaseUri(), dom.getFilePosition());
if (baseUri != null) {
try {
baseUri = URI.create(UriUtil.normalizeUri(baseUri.toString()));
} catch (URISyntaxException ex) {
mq.addMessage(
PluginMessageType.MALFORMED_URL, dom.getFilePosition(),
MessagePart.Factory.valueOf(baseUri.toString()));
baseUri = null;
}
}
if (baseUri != null) {
resolveRelativeUrls(node, baseUri, mq);
it.set(env.withJob(Job.domJob(dom, baseUri)));
}
}
return true;
}