@Override @Nonnull public ResourceProperties getNodeProperties() { if (contentHolder.get() == null) // FIXME: should never occur { log.warn("NO CONTENT IN CONTEXT"); // Thread.dumpStack(); // FIXME return dynamicNodePropertiesHolder.get(); } return nodeHolder.get().getProperties().merged(dynamicNodePropertiesHolder.get()); }
/******************************************************************************************************************* * * ******************************************************************************************************************/ @PostConstruct private void initialize() { loadItems(siteNode.getProperties()); }
@Override public boolean apply (final @Nonnull SiteNode rssSiteNode) { try { final String title = rssSiteNode.getProperties().getProperty(PROPERTY_TITLE, "RSS"); builder.append(String.format("<link rel=\"alternate\" type=\"%s\" title=\"%s\" href=\"%s\" />%n", RSS_MIME_TYPE, title, site.createLink(rssSiteNode.getRelativeUri()))); } catch (IOException e) { log.warn("", e); // shouldn't occur } return false; }
final XPathFactory xPathFactory = XPathFactory.newInstance(); // FIXME: inject final String s = siteNode.getProperties().getProperty(PROPERTY_IMAGES); final Document document = db.parse(new InputSource(new StringReader(s))); final XPath xPath = xPathFactory.newXPath();
/******************************************************************************************************************* * * ******************************************************************************************************************/ private void appendUrl (final @Nonnull StringBuilder builder, final @Nonnull SiteNode siteNode, final @Nullable SiteNode childSiteNode) throws IOException { final SiteNode n = (childSiteNode != null) ? childSiteNode : siteNode; final DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("yyyy-MM-dd"); final ResourceProperties properties = n.getProperties(); // // FIXME: if you put the sitemap property straightly into the child site node, you can simplify a lot, // just using a single property and only peeking into a single node final Key<String> priorityKey = (childSiteNode == null) ? PROPERTY_SITEMAP_PRIORITY : PROPERTY_SITEMAP_CHILDREN_PRIORITY; final float sitemapPriority = Float.parseFloat(siteNode.getProperties().getProperty(priorityKey, "0.5")); if (sitemapPriority > 0) { builder.append(" <url>\n"); builder.append(String.format(" <loc>%s</loc>%n", site.createLink(n.getRelativeUri()))); builder.append(String.format(" <lastmod>%s</lastmod>%n", dateTimeFormatter.print(getSiteNodeDateTime(properties)))); builder.append(String.format(" <changefreq>%s</changefreq>%n", properties.getProperty(PROPERTY_SITEMAP_CHANGE_FREQUENCY, "daily"))); builder.append(String.format(" <priority>%s</priority>%n", Float.toString(sitemapPriority))); builder.append(" </url>\n"); } }
@Override protected List<? extends SiteNode> computeResults() { log.info("findChildrenSiteNodes()"); final List<SiteNode> results = new ArrayList<SiteNode>(); results.add(new ChildSiteNode(siteNode, siteNode.getRelativeUri().appendedWith("lightbox"), siteNode.getProperties())); for (final Item item : itemMapById.values()) { final ResourcePath relativeUri = siteNode.getRelativeUri().appendedWith(item.getId().stringValue()); results.add(new ChildSiteNode(siteNode, relativeUri, siteNode.getProperties())); } log.info(">>>> returning: {}", results); return results; } };
/******************************************************************************************************************* * * * ******************************************************************************************************************/ @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) { try { // FIXME: should be pushed into @PostConstruct, but can't - see NW-224 final Site site = siteProvider.get().getSite(); final SiteNode rootSiteNode = site.find(SiteNode).withRelativeUri("/").result(); // See NW-223 // END FIXME final String propertyName = matcher.group(1); return rootSiteNode.getProperties().getProperty(new Key<String>(propertyName), ""); } catch (NotFoundException | IOException e) { return "ERR"; } } }
final int currentYear = getCurrentYear(pathParams); final ResourceProperties siteNodeProperties = siteNode.getProperties(); final ResourceProperties viewProperties = siteNode.getPropertyGroup(view.getId());
/******************************************************************************************************************* * ******************************************************************************************************************/ @BeforeMethod public void setup() { ContextManager.Locator.set(null); context = new ClassPathXmlApplicationContext("DefaultStructureEditorPresentationControlTestBeans.xml"); underTest = context.getBean(DefaultStructureEditorPresentationControl.class); presentation = context.getBean(StructureEditorPresentation.class); siteNode = mock(SiteNode.class); properties = mock(ResourceProperties.class); presentable = mock(Presentable.class); pm = mock(PresentationModel.class); when(siteNode.getProperties()).thenReturn(properties); when(presentable.createPresentationModel(anyVararg())).thenReturn(pm); when(properties.as(eq(Presentable))).thenReturn(presentable); }
/* visible for testing */ void onSiteNodeSelected (final @ListensTo @Nonnull SiteNodeSelectedEvent selectionEvent) { log.debug("onSiteNodeSelected({})", selectionEvent); if (!selectionEvent.getSiteNode().isPresent()) { presentation.clear(); } else { final SiteNode siteNode = selectionEvent.getSiteNode().get(); final ResourceProperties properties = siteNode.getProperties(); log.debug(">>>> properties: {}", properties); presentation.populate("Viewer not implemented for " + siteNode.getFile()); presentation.populateProperties(properties.as(Presentable).createPresentationModel()); presentation.showUp(); } } }
final ResourceProperties rootSiteNodeProperties = rootSiteNode.getProperties(); final ResourceProperties properties = rootSiteNodeProperties.getGroup(PROPERTY_GROUP_ID);
@Override public void apply (final @Nonnull ResourceFile folder, final @Nonnull ResourcePath relativePath) { try { final SiteNode siteNode = modelFactory.createSiteNode(DefaultSite.this, folder); nodeMapByRelativePath.put(relativePath.asString(), siteNode); if (!siteNode.isPlaceHolder()) { final ResourcePath relativeUri = siteNode.getRelativeUri(); // Nodes which manage path params are registered with a relativeUri having a wildcard suffix if ("true".equals(siteNode.getProperties().getProperty(SiteNode.PROPERTY_MANAGES_PATH_PARAMS, "false"))) { final String suffix = relativeUri.asString().endsWith("/") ? "(|.*$)" : "(|/.*$)"; nodeMapByRelativeUri.putRegex("^" + RegexTreeMap.escape(relativeUri.asString()) + suffix, siteNode); } else { nodeMapByRelativeUri.put(relativeUri.asString(), siteNode); } } } catch (IOException | NotFoundException e) { throw new RuntimeException(e); } } });
when(siteNode.getProperties()).thenReturn(properties); when(siteNode.getRelativeUri()).thenReturn(new ResourcePath(relativeUri)); when(siteNode.toString()).thenReturn(String.format("Node(path=%s)", path));
/******************************************************************************************************************* * * Initializes this controller. * ******************************************************************************************************************/ @PostConstruct /* package */ void initialize() throws IOException, NotFoundException { final ResourceProperties viewProperties = getViewProperties(); final ResourceProperties siteNodeProperties = siteNode.getProperties(); setCustomTemplate(viewProperties); view.addAttribute("language", requestLocaleManager.getLocales().get(0).getLanguage()); view.addAttribute("titlePrefix", viewProperties.getProperty(PROPERTY_TITLE_PREFIX, "")); view.addAttribute("description", viewProperties.getProperty(PROPERTY_DESCRIPTION, "")); view.addAttribute("title", siteNodeProperties.getProperty(PROPERTY_TITLE, "")); view.addAttribute("screenCssSection", computeScreenCssSection()); view.addAttribute("printCssSection", computePrintCssSection()); view.addAttribute("rssFeeds", computeRssFeedsSection()); view.addAttribute("scripts", computeScriptsSection()); view.addAttribute("inlinedScripts", computeInlinedScriptsSection()); }
final String navigationTitle = targetSiteNode.getProperties().getProperty(PROPERTY_NAVIGATION_LABEL, "no nav. label"); view.addLink(navigationTitle, site.createLink(targetSiteNode.getRelativeUri()));