@Test public void transformWithSourceMetaData() throws Exception { String input = "[[http: Parser parser = this.componentManager.getInstance(Parser.class, "xwiki/2.0"); XDOM xdom = parser.parse(new StringReader(input)); MetaData metaData = new MetaData(); metaData.addMetaData(MetaData.SOURCE, "source"); XDOM newXDOM = new XDOM(xdom.getChildren(), metaData); HTTPChecker httpChecker = this.componentManager.registerMockComponent(HTTPChecker.class); when(httpChecker.check("http: Transformation transformation = this.componentManager.getInstance(Transformation.class, "linkchecker"); transformation.transform(newXDOM, new TransformationContext()); LinkStateManager linkStateManager = this.componentManager.getInstance(LinkStateManager.class); wait(linkStateManager, 1); assertNotNull(linkStateManager.getLinkStates().get("http: }
@Override public void transform(Block source, TransformationContext context) throws TransformationException { if (getLinkQueue().size() < MAX_LINKS_IN_QUEUE) { for (LinkBlock linkBlock : source.<LinkBlock>getBlocks( new ClassBlockMatcher(LinkBlock.class), Block.Axes.DESCENDANT)) { if (linkBlock.getReference().getType().equals(ResourceType.URL)) { String linkReference = linkBlock.getReference().getReference(); String contentReference = extractSourceContentReference(linkBlock); if (contentReference == null) { contentReference = "default"; } Map<String, Object> linkContextData = createLinkContextData(linkReference, contentReference); this.linkQueue.add(new LinkQueueItem(linkReference, contentReference, linkContextData)); } } } }
LinkCheckerTransformation extends AbstractTransformation implements Initializable { @Override public void transform(Block source, TransformationContext context) throws TransformationException { if (getLinkQueue().size() < MAX_LINKS_IN_QUEUE) { for (LinkBlock linkBlock : source.<LinkBlock>getBlocks( new ClassBlockMatcher(LinkBlock.class), Block.Axes.DESCENDANT)) { if (linkBlock.getReference().getType().equals(ResourceType.URL)) { String linkReference = linkBlock.getReference().getReference(); String contentReference = extractSourceContentReference(linkBlock); if (contentReference == null) { contentReference = "default"; } Map<String, Object> linkContextData = createLinkContextData(linkReference, contentReference); this.linkQueue.add(new LinkQueueItem(linkReference, contentReference, linkContextData)); } } } } }
LinkCheckerTransformation extends AbstractTransformation implements Initializable { @Override public void transform(Block source, TransformationContext context) throws TransformationException { if (getLinkQueue().size() < MAX_LINKS_IN_QUEUE) { for (LinkBlock linkBlock : source.<LinkBlock>getBlocks( new ClassBlockMatcher(LinkBlock.class), Block.Axes.DESCENDANT)) { if (linkBlock.getReference().getType().equals(ResourceType.URL)) { String linkReference = linkBlock.getReference().getReference(); String contentReference = extractSourceContentReference(linkBlock); if (contentReference == null) { contentReference = "default"; } Map<String, Object> linkContextData = createLinkContextData(linkReference, contentReference); this.linkQueue.add(new LinkQueueItem(linkReference, contentReference, linkContextData)); } } } }  }
LinkCheckerTransformation extends AbstractTransformation implements Initializable { @Override public void transform(Block source, TransformationContext context) throws TransformationException { if (getLinkQueue().size() < MAX_LINKS_IN_QUEUE) { for (LinkBlock linkBlock : source.<LinkBlock>getBlocks( new ClassBlockMatcher(LinkBlock.class), Block.Axes.DESCENDANT)) { if (linkBlock.getReference().getType().equals(ResourceType.URL)) { String linkReference = linkBlock.getReference().getReference(); String contentReference = extractSourceContentReference(linkBlock); if (contentReference == null) { contentReference = "default"; } Map<String, Object> linkContextData = createLinkContextData(linkReference, contentReference); this.linkQueue.add(new LinkQueueItem(linkReference, contentReference, linkContextData)); } } } }  @Override void initialize(); @Override void transform(Block source, TransformationContext context); void stopLinkCheckerThread(); Queue<LinkQueueItem> getLinkQueue(); }
LinkCheckerTransformation extends AbstractTransformation implements Initializable { @Override public void transform(Block source, TransformationContext context) throws TransformationException { if (getLinkQueue().size() < MAX_LINKS_IN_QUEUE) { for (LinkBlock linkBlock : source.<LinkBlock>getBlocks( new ClassBlockMatcher(LinkBlock.class), Block.Axes.DESCENDANT)) { if (linkBlock.getReference().getType().equals(ResourceType.URL)) { String linkReference = linkBlock.getReference().getReference(); String contentReference = extractSourceContentReference(linkBlock); if (contentReference == null) { contentReference = "default"; } Map<String, Object> linkContextData = createLinkContextData(linkReference, contentReference); this.linkQueue.add(new LinkQueueItem(linkReference, contentReference, linkContextData)); } } } }  @Override void initialize(); @Override void transform(Block source, TransformationContext context); void stopLinkCheckerThread(); Queue<LinkQueueItem> getLinkQueue();  }