@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 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); } };
/******************************************************************************************************************* * * Adds to {@code destinationPosts} all the {@code sourcePosts} that matches the selected {@code category}; all * posts if the category is empty. * * @param sourcePosts the source posts * @param destinationPosts the destination posts * @param category the category * ******************************************************************************************************************/ private void filterByCategory (final @Nonnull List<Content> sourcePosts, final @Nonnull List<Content> destinationPosts, final @Nonnull String category) { for (final Content post : sourcePosts) { try { if (category.equals("") || category.equals(post.getProperties().getProperty(PROPERTY_CATEGORY, "---"))) { destinationPosts.add(post); } } catch (IOException e2) { log.warn("", e2); } } }
/******************************************************************************************************************* * * Adds to {@code destinationPosts} all the {@code sourcePosts} that matches the selected {@code tag}; all * posts if the category is empty. * * @param sourcePosts the source posts * @param destinationPosts the destination posts * @param tag the tag * ******************************************************************************************************************/ private void filterByTag (final @Nonnull List<Content> sourcePosts, final @Nonnull List<Content> destinationPosts, final @Nonnull String tag) { for (final Content post : sourcePosts) { try { final List<String> tags = Arrays.asList(post.getProperties().getProperty(PROPERTY_TAGS, "").split(",")); if (tags.contains(tag)) { destinationPosts.add(post); } } catch (IOException e2) { log.warn("", e2); } } }
@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; } };
builder.append(script.getProperties().getProperty(PROPERTY_TEMPLATE));
/******************************************************************************************************************* * * Returns the template. * ******************************************************************************************************************/ @Nonnull private String getTemplate (final @Nonnull ResourceProperties viewProperties) throws IOException { try { final String templateRelativePath = viewProperties.getProperty(PROPERTY_WRAPPER_TEMPLATE_RESOURCE); final Content content = site.find(Content).withRelativePath(templateRelativePath).result(); final ResourceProperties templateProperties = content.getProperties(); return templateProperties.getProperty(PROPERTY_TEMPLATE, "$content$"); } catch (NotFoundException e) { return "$content$"; } } }
for (final String tag : post.getProperties().getProperty(PROPERTY_TAGS).split(","))
htmlBuilder.append(content.getProperties().getProperty(PROPERTY_FULL_TEXT)).append("\n"); htmlBuilder.append(content.getProperties().getProperty(PROPERTY_TEMPLATE)).append("\n");
/******************************************************************************************************************* * * . * ******************************************************************************************************************/ private void setCustomTemplate (final @Nonnull ResourceProperties viewProperties) throws IOException { try { final String templateRelativePath = viewProperties.getProperty(PROPERTY_TEMPLATE_PATH); final Content template = site.find(Content).withRelativePath(templateRelativePath).result(); view.setTemplate(template.getProperties().getProperty(PROPERTY_TEMPLATE)); } catch (NotFoundException e) { log.warn("Cannot find custom template, using default ({})", e.toString()); } }
/******************************************************************************************************************* * ******************************************************************************************************************/ @BeforeMethod public void setup() { ContextManager.Locator.set(null); context = (ClassPathXmlApplicationContext)helper.createSpringContext(); underTest = context.getBean(DefaultContentEditorPresentationControl.class); embeddedServer = context.getBean(EmbeddedServer.class); presentation = context.getBean(ContentEditorPresentation.class); content = mock(Content.class); properties = mock(ResourceProperties.class); presentable = mock(Presentable.class); pm = mock(PresentationModel.class); propertyBinder = mock(PropertyBinder.class); when(embeddedServer.putDocument(anyString(), any(Document.class))).thenReturn(registeredUrl); when(content.getProperties()).thenReturn(properties); when(presentable.createPresentationModel(anyVararg())).thenReturn(pm); when(properties.as(eq(Presentable))).thenReturn(presentable); when(properties.as(eq(PropertyBinder))).thenReturn(propertyBinder); document = new Document().withContent("proxy for: full text") .withMimeType("text/html"); when(propertyBinder.createBoundDocument(any(Key.class), any(PropertyBinder.UpdateCallback.class))) .thenAnswer(invocation -> document); underTest.initialize(); }
final ResourceProperties contentProperties = content.getProperties(); appendTitle(contentProperties, htmlFragmentBuilder, "h" + titleLevel++); appendText(contentProperties, htmlFragmentBuilder);
/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ @Nonnull protected String loadTemplate (final @Nonnull GalleryAdapterContext context, final @Nonnull String templateName) throws IOException { try { final SiteNode siteNode = context.getSiteNode(); final GalleryView view = context.getView(); final Site site = context.getSite(); final ResourceProperties viewProperties = siteNode.getPropertyGroup(view.getId()); final String templateRelativePath = viewProperties.getProperty(new Key<String>(templateName + "Path")); final Content template = site.find(Content).withRelativePath(templateRelativePath).result(); return template.getProperties().getProperty(PROPERTY_TEMPLATE); } catch (NotFoundException e) { return loadDefaultTemplate(templateName + ".txt"); } }
post.getProperties().getProperty(PROPERTY_TITLE); // Skip folders used for categories - this throws exception
@PostConstruct /* package */ void initialize() throws IOException { try { // First search the template in a path, which could be useful for retrieving from a library; if not // found, a property with the contents is searched. final ResourceProperties viewProperties = siteNode.getPropertyGroup(view.getId()); final String templateRelativePath = viewProperties.getProperty(PROPERTY_TEMPLATE_PATH); final Content template = site.find(Content.class).withRelativePath(templateRelativePath).result(); view.setTemplate(template.getProperties().getProperty(PROPERTY_TEMPLATE)); } catch (NotFoundException e) { // ok, use the default template } final ResourceProperties viewProperties = siteNode.getPropertyGroup(view.getId()); view.setClassName(viewProperties.getProperty(PROPERTY_CLASS, "nw-" + view.getId())); } }
view.setTemplate(template.getProperties().getProperty(PROPERTY_TEMPLATE));