Package org.rssowl.core.persist

Examples of org.rssowl.core.persist.IAttachment


    ICategory category = fFactory.createCategory(null, news1);
    category.setName("category");
    news1.addCategory(category);

    IAttachment attachment = fFactory.createAttachment(null, news1);
    attachment.setLink(new URI("attachment"));
    news1.addAttachment(attachment);

    feed = DynamicDAO.save(feed);

    IFolder root = fFactory.createFolder(null, null, "Root");
View Full Code Here


      List<Action> openActions = new ArrayList<Action>(1);
      Set<String> downloadLocations = getDownloadLocations();

      /* Offer Download Action for each */
      for (final Pair<IAttachment, URI> attachmentPair : attachments) {
        IAttachment attachment = attachmentPair.getFirst();
        final String fileName = URIUtils.getFile(attachmentPair.getSecond(), OwlUI.getExtensionForMime(attachment.getType()));
        String size = OwlUI.getSize(attachment.getLength());

        Action action = new Action(size != null ? (NLS.bind(Messages.ApplicationActionBarAdvisor_FILE_SIZE, fileName, size)) : (fileName)) {
          @Override
          public void run() {
            FileDialog dialog = new FileDialog(shellProvider.getShell(), SWT.SAVE);
View Full Code Here

    assertEquals(sourceLink, news.getSource().getLink());
  }

  private INews createNews(IFeed feed) {
    INews news = fTypesFactory.createNews(null, feed, createDate());
    IAttachment attachment = fTypesFactory.createAttachment(null, news);
    attachment.setLink(createURI("http://attachmenturi.com"));
    ICategory category = fTypesFactory.createCategory(null, news);
    category.setName("Category name #1");
    news.setAuthor(createPersonMary(news));
    news.setBase(createURI("http://www.someuri.com"));
    news.setComments("One comment");
View Full Code Here

  public void testGetAttachmentLinks() throws Exception {
    IFeed feed = fFactory.createFeed(null, new URI("http://www.rssowl.org"));
    INews news1 = fFactory.createNews(null, feed, new Date());
    INews news2 = fFactory.createNews(null, feed, new Date());

    IAttachment att = fFactory.createAttachment(null, news2);

    att = fFactory.createAttachment(null, news2);
    att.setLink(new URI("foobar"));

    INews news3 = fFactory.createNews(null, feed, new Date());

    att = fFactory.createAttachment(null, news3);
    att.setLink(new URI("http://www.rssowl.org/download1.mp3"));

    att = fFactory.createAttachment(null, news3);
    att.setLink(new URI("/download2.mp3"));

    att = fFactory.createAttachment(null, news3);
    att.setLink(new URI("download3.mp3"));

    List<INews> news = new ArrayList<INews>();
    news.add(news1);
    news.add(news2);
    news.add(news3);
View Full Code Here

        processSource(child, news);
    }
  }

  private void processEnclosure(Element element, INews news) {
    IAttachment attachment = Owl.getModelFactory().createAttachment(null, news);

    /* Interpret Attributes */
    List< ? > attachmentAttributes = element.getAttributes();
    for (Iterator< ? > iter = attachmentAttributes.iterator(); iter.hasNext();) {
      Attribute attribute = (Attribute) iter.next();
      String name = attribute.getName().toLowerCase();

      /* Check wether this Attribute is to be processed by a Contribution */
      if (processAttributeExtern(attribute, attachment))
        continue;

      /* URL */
      else if ("url".equals(name)) {//$NON-NLS-1$
        URI uri = URIUtils.createURI(attribute.getValue());
        if (uri != null)
          attachment.setLink(uri);
      }

      /* Type */
      else if ("type".equals(name)) //$NON-NLS-1$
        attachment.setType(attribute.getValue());

      /* Length */
      else if ("length".equals(name)) {//$NON-NLS-1$
        int length = StringUtils.stringToInt(attribute.getValue());
        if (length >= 0)
          attachment.setLength(length);
      }
    }
  }
View Full Code Here

          processNamespaceAttributes(child, news);
        }

        /* Enclosure */
        else if ("enclosure".equals(rel)) { //$NON-NLS-1$
          IAttachment attachment = Owl.getModelFactory().createAttachment(null, news);

          URI uri = URIUtils.createURI(child.getAttributeValue("href")); //$NON-NLS-1$
          if (uri != null)
            attachment.setLink(uri);
          attachment.setType(child.getAttributeValue("type")); //$NON-NLS-1$
          attachment.setLength(StringUtils.stringToInt(child.getAttributeValue("length"))); //$NON-NLS-1$

          processNamespaceAttributes(child, attachment);
        }
      }

View Full Code Here

    boolean root = isRoot(template);
    if (entity instanceof INews) {
      modelEvent = createNewsEvent((INews) entity, template, root);
    }
    else if (entity instanceof IAttachment) {
      IAttachment attachment = (IAttachment) entity;
      modelEvent = new AttachmentEvent(attachment, root);
    }
    else if (entity instanceof ICategory) {
      ICategory category = (ICategory) entity;
      modelEvent = new CategoryEvent(category, root);
View Full Code Here

    news.setState(INews.State.UNREAD);

    final ICategory category = fFactory.createCategory(null, news);
    category.setName("Category name");

    final IAttachment attachment = fFactory.createAttachment(null, news);
    attachment.setLink(new URI("http://attachment.com"));

    feed = DynamicDAO.save(feed);

    final INews savedNews = feed.getNews().get(0);
    savedNews.setTitle("News Title Updated #1");

    Collection<INews> newsList = new ArrayList<INews>();
    newsList.add(savedNews);

    NewsListener newsListener = new NewsAdapter() {
      @Override
      public void entitiesUpdated(Set<NewsEvent> events) {
        assertEquals(1, events.size());
        NewsEvent event = events.iterator().next();
        assertEquals(true, event.getEntity().equals(savedNews));
        INews oldNews = event.getOldNews();
        assertEquals(State.UNREAD, oldNews.getState());
        assertEquals(State.UNREAD, event.getEntity().getState());
        assertEquals(category.getName(), oldNews.getCategories().get(0).getName());
        IAttachment oldAttachment = oldNews.getAttachments().get(0);
        assertEquals(attachment.getLink(), oldAttachment.getLink());
        assertEquals(oldNews.getId(), oldAttachment.getNews().getId());
      }
    };
    DynamicDAO.addEntityListener(INews.class, newsListener);
    try {
      DynamicDAO.saveAll(newsList);
View Full Code Here

      ICategory category = fFactory.createCategory(null, news4);
      category.setName("Roberts");

      /* Attachment Content */
      INews news5 = createNews(feed, "hungry", "http://www.news.com/news5.html", State.NEW);
      IAttachment attachment = fFactory.createAttachment(null, news5);
      attachment.setLink(new URI("http://www.attachment.com/att1news2.file"));
      attachment.setType("Hasselhoff");

      DynamicDAO.save(feed);

      /* Wait for Indexer */
      waitForIndexer();
View Full Code Here

      ICategory category = fFactory.createCategory(null, news4);
      category.setName("Roberts");

      /* Attachment Content */
      INews news5 = createNews(feed, "hungry", "http://www.news.com/news5.html", State.NEW);
      IAttachment attachment = fFactory.createAttachment(null, news5);
      attachment.setLink(new URI("http://www.attachment.com/att1news2.file"));
      attachment.setType("Hasselhoff");

      DynamicDAO.save(feed);

      /* Wait for Indexer */
      waitForIndexer();
View Full Code Here

TOP

Related Classes of org.rssowl.core.persist.IAttachment

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.