Package ch.entwine.weblounge.common.impl.content.page

Examples of ch.entwine.weblounge.common.impl.content.page.PageletImpl


      if (requiredPagelets.size() > 0) {
        List<Pagelet> pagelets = new ArrayList<Pagelet>();
        for (String headline : requiredPagelets) {
          String[] parts = headline.split("/");
          if (parts.length > 1) {
            Pagelet pagelet = new PageletImpl(parts[0], parts[1]);
            pagelets.add(pagelet);
          }
        }
        query.withPagelets(All, pagelets.toArray(new Pagelet[pagelets.size()])).inStage();
      }
View Full Code Here


   */
  private Page handleTextPlain(String content, Page page, Language language) {
    for (String paragraph : content.split("\r\n")) {
      if (StringUtils.isBlank(paragraph))
        continue;
      PageletImpl p = new PageletImpl("text", "paragraph");
      p.setContent("text", StringUtils.trim(paragraph), language);
      page.addPagelet(p, page.getStage().getIdentifier());
    }
    return page;
  }
View Full Code Here

    if (this.pagelets == null)
      this.pagelets = new ArrayList<SearchTerms<Pagelet>>();

    int i = 0;
    for (Pagelet p : pagelets) {
      pagelets[i++] = new PageletImpl(p.getModule(), p.getIdentifier());
    }

    clearExpectations();
    with(this.pagelets, quantifier, pagelets);
    configure(pagelets);
View Full Code Here

        renderer = item.getPreviewRenderer();
        if (!(renderer instanceof PageletRenderer)) {
          logger.warn("Skipping search result '{}' since it's preview renderer is not a pagelet", item);
          continue;
        }
        PageletImpl pagelet = new PageletImpl((PageletRenderer) renderer);
        pagelet.setContent(item.getContent());
        page.addPagelet(pagelet, stage);
        continue;
      }

      // The search result item seems to be coming from the search index

      // Convert the search result item into a resource search result item
      ResourceSearchResultItem resourceItem = (ResourceSearchResultItem) item;
      ResourceURI uri = resourceItem.getResourceURI();

      ResourceSerializer<?, ?> serializer = serializerService.getSerializerByType(uri.getType());
      if (serializer == null) {
        logger.debug("Skipping search result since it's type ({}) is unknown", uri.getType());
        continue;
      }

      // Load the resource
      Resource<?> resource = serializer.toResource(site, resourceItem.getMetadata());

      // Get the renderer and make sure it's a pagelet renderer. First check
      // the item itself, there may already be a renderer attached. If not,
      // use the serializer to get the appropriate renderer
      renderer = item.getPreviewRenderer();
      if (renderer == null) {
        renderer = serializer.getSearchResultRenderer(resource);
        if (renderer == null) {
          logger.warn("Skipping search result since a renderer can't be determined");
          continue;
        }
      }

      // Create the pagelet
      PageletRenderer pageletRenderer = (PageletRenderer) renderer;
      PageletImpl pagelet = new PageletImpl(pageletRenderer);
      pagelet.setContent(resource);

      // Add the pagelet's data
      for (ResourceMetadata<?> metadata : resourceItem.getMetadata()) {
        String key = metadata.getName();
        if (metadata.isLocalized()) {
          for (Entry<Language, ?> localizedMetadata : metadata.getLocalizedValues().entrySet()) {
            Language language = localizedMetadata.getKey();
            List<Object> values = (List<Object>) localizedMetadata.getValue();
            for (Object value : values) {
              pagelet.setContent(key, value.toString(), language);
            }
          }
        } else {
          for (Object value : metadata.getValues()) {
            pagelet.addProperty(key, value.toString());
          }
        }
      }

      // TODO: Set modified etc.
View Full Code Here

  public void testDeleteLinkedResource() throws Exception {
    int resources = populateRepository();

    // Add a reference
    Page page = pages[0];
    Pagelet pagelet = new PageletImpl("test", "link");
    pagelet.setProperty("resourceid", imageURI.getIdentifier());
    page.addPagelet(pagelet, "main");
    repository.put(page);

    // Delete image resource which is referenced by page
    try {
View Full Code Here

    if (renderer != null) {
      try {
        pageContext.getOut().flush();

        // Create the virtual pagelet, define properties and elements
        PageletImpl pagelet = new PageletImpl(module.getIdentifier(), rendererId);
        if (properties != null) {
          for (Map.Entry<String, String> property : properties.entrySet()) {
            pagelet.addProperty(property.getKey(), property.getValue());
          }
        }
        if (elements != null) {
          for (Language l : elements.languages()) {
            for (Map.Entry<String, String> element : elements.get(l).entrySet()) {
              pagelet.setContent(element.getKey(), element.getValue(), language);
            }
          }
        }

        // Finally, render the pagelet
View Full Code Here

      Pagelet pagelet = null;
      for (Module m : site.getModules()) {
        if (m.getRenderers().length > 0) {
          PageletRenderer r = m.getRenderers()[0];
          PageletURI pageletURI = new PageletURIImpl(page.getURI(), PageTemplate.DEFAULT_STAGE, 0);
          pagelet = new PageletImpl(pageletURI, m.getIdentifier(), r.getIdentifier());
        }
      }

      // Collect all renderers from modules and ask for precompilation
      List<URL> rendererUrls = new ArrayList<URL>();
View Full Code Here

  public void testUpdate() throws IllegalArgumentException,
      ContentRepositoryException {

    String propertyName = "testproperty";
    String propertyValue = "testvalue";
    Pagelet p = new PageletImpl("testmodule", "testid");
    p.addProperty(propertyName, propertyValue);
    page.addPagelet(p, "stage");

    try {
      idx.add(page);
      assertEquals(1, idx.getResourceCount());
View Full Code Here

   */
  @Before
  public void setUp() throws Exception {
    site = EasyMock.createNiceMock(Site.class);
    EasyMock.replay(site);
    pagelet = new PageletImpl("module", "id");
    query = new SearchQueryImpl(site);
  }
View Full Code Here

      // This is expected
    }

    // Test proper behavior
    query = new SearchQueryImpl(site);
    query.withPagelet(new PageletImpl(pagelet.getModule(), pagelet.getIdentifier()));
    query.andProperty(propertyName, propertyValue);
    assertEquals(1, query.getPagelets().size());
    Collection<SearchTerms<Pagelet>> pagelets = query.getPagelets();
    Pagelet firstPagelet = pagelets.iterator().next().getTerms().iterator().next();
    assertEquals(propertyValue, firstPagelet.getProperty(propertyName));
View Full Code Here

TOP

Related Classes of ch.entwine.weblounge.common.impl.content.page.PageletImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.