/******************************************************************************************************************* * * ******************************************************************************************************************/ @Nonnull private Content findPostByExposedUri (final List<Content> allPosts, final @Nonnull ResourcePath exposedUri) throws NotFoundException, IOException { for (final Content post : allPosts) { try { if (exposedUri.equals(post.getExposedUri())) { return post; } } catch (NotFoundException e) { log.warn("{}", e.toString()); } catch (IOException e) { log.warn("", e); } } throw new NotFoundException("Blog post with exposedUri=" + exposedUri.asString()); }
@Override protected List<? extends SiteNode> computeResults() { log.info("findCompositeContents()"); final List<SiteNode> results = new ArrayList<>(); try { final ResourceProperties componentProperties = siteNode.getPropertyGroup(view.getId()); for (final Content post : findAllPosts(componentProperties)) { try { final ResourcePath relativeUri = siteNode.getRelativeUri().appendedWith(post.getExposedUri()); results.add(new ChildSiteNode(siteNode, relativeUri, post.getProperties())); } catch (NotFoundException | IOException e) { log.warn("While reading properties", e); } } } catch (NotFoundException | IOException e) { log.warn("While reading property group", e); } log.info(">>>> returning: {}", results); return results; } };
@Override @Nonnull protected String filter (final @Nonnull Matcher matcher) throws NotFoundException, IOException { final String relativePath = matcher.group(1); final String contentRelativePath = matcher.group(2); final String language = matcher.group(4); final Site site = siteProvider.get().getSite(); final SiteNode siteNode = site.find(SiteNode.class).withRelativePath(relativePath).result(); final Content content = site.find(Content.class).withRelativePath(contentRelativePath).result(); final ResourcePath path = siteNode.getRelativeUri().appendedWith(content.getExposedUri()); final String link = site.createLink(path); return ((language == null) || (postProcessor == null)) ? link : postProcessor.postProcess(link, language); }
@Override @Nonnull protected List<? extends Content> computeResults() { try { final Content content = mock(Content.class); if (relativePath.equals("/")) { when(content.getExposedUri()).thenReturn(new ResourcePath()); } else { when(content.getExposedUri()).thenReturn(new ResourcePath("EXPOSED-" + relativePath.substring(1) .replace('/', '-') .replace(' ', '-'))); } return Arrays.asList(content); } catch (NotFoundException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } }