final boolean sameType = this.getTypeUri().equals(override.getTypeUri()); this.typeUri = override.getTypeUri(); // FIXME: don't like this approach, as it requires typeUri non final for (final Layout overridingChild : override.findChildren().results()) final Layout overriddenChild = childrenMapById.get(overridingChild.getId()); childrenMapById.put(overridingChild.getId(), overridingChild); final int i = children.indexOf(overriddenChild); this.childrenMapById.clear(); for (final Layout overridingChild : override.findChildren().results())
@Nonnull private ComponentType createComponent (@Nonnull Layout layout) { try { return (ComponentType)layout.createView(siteNode); } catch (NotFoundException e) { return createPlaceHolderComponent(layout); } }
if (!layout.getTypeUri().startsWith("http://northernwind.tidalwave.it/component/Sitemap/")) layout.accept(new VisitorSupport<Layout, Void>()
layout = (layout == null) ? overridingLayout : layout.withOverride(overridingLayout); layout.accept(new LayoutLoggerVisitor(LayoutLoggerVisitor.Level.INFO));
/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ @Override @Nonnull // TODO: push up to CompositeSupport public <Type> Type accept (final @Nonnull Visitor<Layout, Type> visitor) throws NotFoundException { visitor.preVisit(this); visitor.visit(this); for (final Layout child : children) { child.accept(visitor); } visitor.postVisit(this); return visitor.getValue(); }
/******************************************************************************************************************* * * {@inheritDoe} * ******************************************************************************************************************/ @Nonnull private Layout loadLayout() throws IOException, NotFoundException { Layout layout = null; for (final FileObject layoutFile : Utilities.getInheritedPropertyFiles(resource.getFile(), "Layout_en.xml")) { log.trace(">>>> reading layout from /{}...", layoutFile.getPath()); final DefaultLayout overridingLayout = new DefaultLayoutXmlUnmarshaller(layoutFile).unmarshal(); layout = (layout == null) ? overridingLayout : layout.withOverride(overridingLayout); if (log.isDebugEnabled()) { overridingLayout.accept(new LayoutLoggerVisitor(LayoutLoggerVisitor.Level.DEBUG)); } } return layout; } }
/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ public void add (final @Nonnull Layout layout) // FIXME: drop this - used only by the CloneVisitor and Infoglue converter { children.add(layout); // FIXME: clone childrenMapById.put(layout.getId(), layout);// FIXME: clone }
/******************************************************************************************************************* * ******************************************************************************************************************/ @Nonnull private DefaultLayout loadLayout (final @Nonnull ResourceFile layoutFile) throws IOException { log.trace(">>>> reading layout from {}...", layoutFile.getPath().asString()); final @Cleanup InputStream is = layoutFile.getInputStream(); return modelFactory.createLayout().build().as(Unmarshallable).unmarshal(is); } }
/******************************************************************************************************************* * * Creates a new instance with the given configuration file and mapped to the given URI. * * @param file the file with the configuration * @param relativeUri the bound URI * ******************************************************************************************************************/ public DefaultSiteNode (final @Nonnull FileObject file) throws IOException, NotFoundException { resource = new DefaultResource(file); layout = loadLayout(); if (site.isLogConfigurationEnabled() || log.isDebugEnabled()) { log.info(">>>> layout for /{}:", resource.getFile().getPath()); layout.accept(new LayoutLoggerVisitor(LayoutLoggerVisitor.Level.INFO)); } }
/******************************************************************************************************************* * * {@inheritDoc} * ******************************************************************************************************************/ @Override @Nonnull public Layout withChild (final @Nonnull Layout layout) { final DefaultLayout clone = clone(); clone.children.add(layout); clone.childrenMapById.put(layout.getId(), layout); return clone; }