@Override public <Type> Type getProperty (final @Nonnull Key<Type> key) throws NotFoundException, IOException { try { requestContext.setContent(content); return delegate.getProperty(key); } finally { requestContext.clearContent(); } }
/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ @Override @Nonnull public ResourceProperties getExtraViewProperties (final @Nonnull Id viewId) { return modelFactory.createProperties().withId(viewId).build(); }
@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 String filter (final @Nonnull Matcher matcher) throws NotFoundException { final String relativePath = matcher.group(1); final Site site = siteProvider.get().getSite(); final SiteNode siteNode = site.find(SiteNode.class).withRelativePath(relativePath).result(); return site.createLink(siteNode.getRelativeUri()); } }
@Override public void apply (final @Nonnull ResourceFile folder, final @Nonnull ResourcePath relativePath) { documentMapByRelativePath.put(relativePath.asString(), modelFactory.createContent().withFolder(folder).build()); } });
/******************************************************************************************************************* * * * ******************************************************************************************************************/ @Nonnull private String getMetadataString (final @Nonnull Id id, final @Nonnull String format) throws NotFoundException { // FIXME: should use current SiteNode properties final ResourceProperties properties = siteProvider.get().getSite().find(SiteNode.class) .withRelativePath("/") .result() .getProperties(); return mediaMetadataProvider.getMetadataString(id, format, properties); }
@Override @Nonnull protected String filter (final @Nonnull Matcher matcher) { final ResourcePath relativePath = new ResourcePath(matcher.group(1)).prependedWith("media"); return siteProvider.get().getSite().createLink(relativePath); } }
@Override @Nonnull public ResourceProperties getContentProperties() { if (contentHolder.get() == null) // FIXME: should never occur { log.warn("NO CONTENT IN CONTEXT"); // Thread.dumpStack(); // FIXME return modelFactory.createProperties().build(); } return contentHolder.get().getProperties(); }
@Override @Nonnull public Finder<Content> findChildren() { return new ResourceFinder<>( getResource().getFile(), folder -> modelFactory.createContent().withFolder(folder).build()); }
@Override public void apply (final @Nonnull ResourceFile file, final @Nonnull ResourcePath relativePath) { libraryMapByRelativePath.put(relativePath.asString(), modelFactory.createResource().withFile(file).build()); } });
/******************************************************************************************************************* * * ******************************************************************************************************************/ private void emptyFolder (final @Nonnull ResourceFile folder) throws IOException { log.trace("emptyFolder({}, {}", folder); for (final ResourceFile child : folder.findChildren().results()) { child.delete(); } }
@Override @Nonnull protected String filter (final @Nonnull Matcher matcher) { final ResourcePath relativePath = new ResourcePath(matcher.group(1)); return siteProvider.get().getSite().createLink(relativePath); } }
@Override public void apply (final @Nonnull ResourceFile file, final @Nonnull ResourcePath relativePath) { mediaMapByRelativePath.put(relativePath.asString(), modelFactory.createMedia().withFile(file).build()); } });
@Override public void setNode (final @Nonnull SiteNode node) { nodeHolder.set(node); dynamicNodePropertiesHolder.set(modelFactory.createProperties().build()); }
/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ @Override @Nonnull public String getPathParams (final @Nonnull SiteNode siteNode) { final String siteNodeRelativeUri = siteNode.getRelativeUri().asString(); return (relativeUri.length() <= siteNodeRelativeUri.length()) ? "" : relativeUri.substring(siteNodeRelativeUri.length()); }
@Nonnull public static ResourceFile folder (final @Nonnull ResourceFile parent, final @Nonnull String fileName) { final ResourcePath parentPath = parent.getPath(); return new MockResourceFile(parent, parentPath.appendedWith(fileName), true); }
@Override public int compare (final @Nonnull Content post1, final @Nonnull Content post2) { final DateTime dateTime1 = post1.getProperties().getDateTimeProperty(DATE_KEYS, TIME0); final DateTime dateTime2 = post2.getProperties().getDateTimeProperty(DATE_KEYS, TIME0); return dateTime2.compareTo(dateTime1); } };
@Override public <Type> Type getProperty (final @Nonnull Key<Type> key, final @Nonnull Type defaultValue) throws IOException { try { requestContext.setContent(content); return delegate.getProperty(key, defaultValue); } finally { requestContext.clearContent(); } } }