Package de.nava.informa.core

Examples of de.nava.informa.core.ChannelIF


    // TODO id: Feed and all entries have a unique id string. This can
    // be the URL of the website. Supporting this will require API change.
    // TODO: Feed can optionally have category information

    // title element
    ChannelIF chnl = cBuilder.createChannel(channel,
                                            channel.getChildTextTrim("title",
                                                                     defNS));

    chnl.setFormat(ChannelFormat.ATOM_1_0);

    // description element
    if (channel.getChild("subtitle") != null) {
      chnl.setDescription(channel.getChildTextTrim("subtitle", defNS));
    }

    // TODO: should we use summary element?

    // lastbuild element : updated ?
    Element updated = channel.getChild("updated", defNS);

    if (updated != null) {
      chnl.setPubDate(ParserUtils.getDate(updated.getTextTrim()));
    }

    // author element
    List authors = channel.getChildren("author", defNS);

    chnl.setCreator(getAuthorString(authors, defNS));

    // TODO we are ignoring contributors information

    // generator element
    Element generator = channel.getChild("generator", defNS);

    if (generator != null) {
      chnl.setGenerator(generator.getTextTrim());
    }

    // TODO generator can have URI and version information

    // copyright element
    Element rights = channel.getChild("rights", defNS);

    if (rights != null) {
      chnl.setCopyright(AtomParserUtils.getValue(rights, getMode(rights)));
    }

    List links = channel.getChildren("link", defNS);
    Iterator i = links.iterator();

    URL linkUrl = null;

    while (i.hasNext()) {
      Element linkElement = (Element) i.next();

      // use first 'alternate' link
      // if rel is not present, use first link without rel
      String rel = linkElement.getAttributeValue("rel");
      String href = linkElement.getAttributeValue("href");

      // TODO we need to handle relative links also
      if ((rel == null) && (href != null) && (linkUrl == null)) {
        linkUrl = ParserUtils.getURL(href);
      } else if ((rel != null) && (href != null) && rel.equals("alternate")) {
        linkUrl = ParserUtils.getURL(href);

        break;
      }
    }

    if (linkUrl != null) {
      chnl.setSite(linkUrl);
    }

    List items = channel.getChildren("entry", defNS);

    i = items.iterator();

    while (i.hasNext()) {
      Element item = (Element) i.next();

      // Lower the case of these tags to simulate case-insensitive parsing
      ParserUtils.matchCaseOfChildren(item,
                                      new String[] {
                                        "title", "link", "content", "summary",
                                        "published", "author"
                                      });

      // TODO entry, if copied from some other feed, may have source element
      // TODO each entry can have its own rights declaration

      // get title element
      Element elTitle = item.getChild("title", defNS);
      String strTitle = "<No Title>";

      if (elTitle != null) {
        strTitle = AtomParserUtils.getValue(elTitle, getMode(elTitle));
        LOGGER.debug("Parsing title " + elTitle.getTextTrim() + "->" +
                     strTitle);
      }

      if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Entry element found (" + strTitle + ").");
      }

      // get link element
      String strLink = AtomParserUtils.getItemLink(item, defNS);

      // get description element
      String strDesc = getDescription(item, defNS);

      // generate new news item (link to article)
      ItemIF curItem = cBuilder.createItem(item, chnl, strTitle, strDesc,
                                           ParserUtils.getURL(strLink));

      //TODO enclosure data
      curItem.setFound(dateParsed);

      List itemAuthors = item.getChildren("author", defNS);

      curItem.setCreator(getAuthorString(itemAuthors, defNS));

      // get published element
      Element elIssued = item.getChild("published", defNS);

      if (elIssued == null) {
        // published element may not be present (but updated should be)
        Element elUpdated = item.getChild("updated", defNS);

        // TODO there should be some way to determining which one are we
        // returning
        if (elUpdated != null) {
          curItem.setDate(ParserUtils.getDate(elUpdated.getTextTrim()));
        }
      } else {
        curItem.setDate(ParserUtils.getDate(elIssued.getTextTrim()));
      }

      // get category element
      Element elCategory = item.getChild("category", defNS);

      if (elCategory != null) {
        // TODO: multiple category elements may be present
        curItem.setSubject(elCategory.getTextTrim());
      }
    }

    // set to current date
    chnl.setLastUpdated(dateParsed);

    return chnl;
  }
View Full Code Here


    if (this == o)
      return true;
    if (!(o instanceof ChannelIF))
      return false;

    final ChannelIF channel = (ChannelIF) o;

    // Comparison of links uses synchronized code of Java-NET.
    // This may hurt multi-threaded applications. So, please think twice
    // before using direct comparison of links.
    final URL channelLocation = channel.getLocation();
    if (location != null ? channelLocation == null
        || !location.toString().equalsIgnoreCase(channelLocation.toString())
        : channelLocation != null)
      return false;

    final String channelTitle = channel.getTitle();
    if (title != null ? !title.equals(channelTitle) : channelTitle != null)
      return false;

    final String channelDescription = channel.getDescription();
    if (description != null ? !description.equals(channelDescription)
        : channelDescription != null)
      return false;

    return true;
View Full Code Here

   *
   * @param chan
   * @param info -
   */
  private void handleChannelItems(Channel chan, UpdateChannelInfo info) {
    ChannelIF tempChannel = null;
    int logHowManySearched = 0;
    int logHowManyAdded = 0;

    // TODO: [Aleksey Gureev] I don't see locking of builder here. Locking of the whole peice will
    // be very
    // great resource consumption. It's necessary to rework whole method to lock builder for a
    // minimal time.

    try {
      builder.beginTransaction();
      builder.reload(chan);
      /*
       * We will now parse the new channel's information into a *memory based* temporary channel. We
       * will then see which items that we received from the feed are already present and add the
       * new ones.
       */
      tempChannel = FeedParser.parse(tempBuilder, chan.getLocation());
      InformaUtils.copyChannelProperties(tempChannel, chan);
      /*
       * Tricky: this channel might have been loaded into memory by Hibernate in a preceding
       * Hibernate Session. We need to make it available in this session so it will be written back
       * to disk when the transaction is committed.
       */
      chan.setLastUpdated(new Date());
      mgr.notifyChannelRetrieved(chan);
      /*
       * Compare with the existing items, and only add new ones. In the future this is where we
       * would put code to diff an item to see how blog author has edited a certain item over time.
       */
      if (!tempChannel.getItems().isEmpty()) {
        Iterator it = tempChannel.getItems().iterator();
        while (it.hasNext()) {
          logHowManySearched++;
          de.nava.informa.impl.basic.Item transientItem = (de.nava.informa.impl.basic.Item) it
              .next();
          if (!chan.getItems().contains(transientItem)) {
View Full Code Here

        "errorReportsTo", "webMaster", "language", "rights", "copyright",
        "rating", "date", "issued", "pubdate", "lastBuildDate", "modified",
        "generatorAgent", "updatePeriod", "updateFrequency", "updateBase" });

    // title element
    ChannelIF chnl = cBuilder.createChannel(channel, channel.getChildTextTrim(
        "title", defNS));

    // set channel format
    chnl.setFormat(ChannelFormat.RSS_1_0);

    // description element
    chnl.setDescription(channel.getChildTextTrim("description", defNS));

    // link element
    chnl.setSite(ParserUtils.getURL(channel.getChildTextTrim("link", defNS)));

    // creator element
    Element creator = channel.getChild("creator", dcNS);
    if (creator == null) {
      creator = channel.getChild("managingEditor", rss091NS);
    }
    if (creator != null) {
      chnl.setCreator(creator.getTextTrim());
    }

    // publisher element
    String publisher = channel.getChildTextTrim("publisher", dcNS);
    if (publisher == null) {
      Element elErrorReportsTo = channel.getChild("errorReportsTo", adminNS);
      if (elErrorReportsTo != null) {
        publisher = elErrorReportsTo.getAttributeValue("resource", ParserUtils
            .getNamespace(elErrorReportsTo, "rdf"));
      }
    }
    if (publisher == null) {
      publisher = channel.getChildTextTrim("webMaster", rss091NS);
    }
    chnl.setPublisher(publisher);

    // language element
    Element language = channel.getChild("language", dcNS);
    if (language == null) {
      language = channel.getChild("language", rss091NS);
    }
    if (language != null) {
      chnl.setLanguage(language.getTextTrim());
    }

    // rights element
    Element copyright = channel.getChild("rights", dcNS);
    if (copyright == null) {
      copyright = channel.getChild("copyright", rss091NS);
    }
    if (copyright != null) {
      chnl.setCopyright(copyright.getTextTrim());
    }

    // 0..1 Rating element
    Element rating = channel.getChild("rating", rss091NS);
    if (rating != null) {
      chnl.setRating(rating.getTextTrim());
    }

    // 0..1 Docs element
    // use namespace URI
    chnl.setDocs(defNS.getURI());

    // 0..1 pubDate element
    Element pubDate = channel.getChild("date", dcNS);
    if (pubDate == null) {
      pubDate = channel.getChild("issued", dctermsNS);
    }
    if (pubDate == null) {
      pubDate = channel.getChild("pubdate", rss091NS);
    }
    if (pubDate != null) {
      chnl.setPubDate(ParserUtils.getDate(pubDate.getTextTrim()));
    }

    // 0..1 lastBuildDate element
    Element lastBuildDate = channel.getChild("lastBuildDate");
    if (lastBuildDate == null) {
      lastBuildDate = channel.getChild("modified", dctermsNS);
    }
    if (lastBuildDate == null) {
      lastBuildDate = channel.getChild("lastBuildDate", rss091NS);
    }
    if (lastBuildDate != null) {
      chnl.setLastBuildDate(ParserUtils.getDate(lastBuildDate.getTextTrim()));
    }

    // RSS 1.0 Administration Module support

    // 0..1 generator element
    Element elGenerator = channel.getChild("generatorAgent", adminNS);
    if (elGenerator != null) {
      Attribute generator = elGenerator.getAttribute("resource", ParserUtils
          .getNamespace(elGenerator, "rdf"));
      if (generator != null) {
        chnl.setGenerator(generator.getValue());
      }
    }

    // RSS 1.0 Syndication Module support

    // 0..1 update period element
    Element updatePeriod = channel.getChild("updatePeriod", syNS);
    if (updatePeriod != null) {
      try {
        ChannelUpdatePeriod channelUpdatePeriod = ChannelUpdatePeriod
            .valueFromText(updatePeriod.getTextTrim());
        chnl.setUpdatePeriod(channelUpdatePeriod);
      } catch (IllegalArgumentException ex) {
        logger.warn(updatePeriod.getTextTrim(), ex);
      }
    }

    // 0..1 update frequency element
    Element updateFrequency = channel.getChild("updateFrequency", syNS);
    if (updateFrequency != null) {
      chnl.setUpdateFrequency((new Integer(updateFrequency.getTextTrim()))
          .intValue());
    }

    // 0..1 update base element
    Element updateBase = channel.getChild("updateBase", syNS);
    if (updateBase != null) {
      chnl.setUpdateBase(ParserUtils.getDate(updateBase.getTextTrim()));
    }

    if ((updatePeriod != null) && updateFrequency != null) {
      int ttl = getTTL(chnl.getUpdatePeriod(), chnl.getUpdateFrequency());
      chnl.setTtl(ttl);
    }

    // item elements
    List items = root.getChildren("item", defNS);
    Iterator i = items.iterator();
    while (i.hasNext()) {
      Element item = (Element) i.next();

      ParserUtils.matchCaseOfChildren(item, new String[] { "title", "link",
          "encoded", "description", "creator", "subject", "date", "sourceURL",
          "source", "timestamp", "reference" });

      // get title element
      Element elTitle = item.getChild("title", defNS);
      String strTitle = "<No Title>";
      if (elTitle != null) {
        strTitle = elTitle.getTextTrim();
      }
      if (logger.isDebugEnabled()) {
        logger.debug("Item element found (" + strTitle + ").");
      }

      // get link element
      Element elLink = item.getChild("link", defNS);
      String strLink = "";
      if (elLink != null) {
        strLink = elLink.getTextTrim();
      }

      // get description element
      Element elDesc = item.getChild("encoded", contentNS);
      if (elDesc == null) {
        elDesc = item.getChild("description", defNS);
      }
      if (elDesc == null) {
        elDesc = item.getChild("description", dcNS);
      }
      String strDesc = "";
      if (elDesc != null) {
        strDesc = elDesc.getTextTrim();
      }

      // generate new RSS item (link to article)
      ItemIF rssItem = cBuilder.createItem(item, chnl, strTitle, strDesc,
          ParserUtils.getURL(strLink));
      rssItem.setFound(dateParsed);

      // get creator element
      Element elCreator = item.getChild("creator", dcNS);
      if (elCreator != null) {
        rssItem.setCreator(elCreator.getTextTrim());
      }

      // get subject element
      Element elSubject = item.getChild("subject", dcNS);
      if (elSubject != null) {
        // TODO: Mulitple subject elements not handled currently
        rssItem.setSubject(elSubject.getTextTrim());
      }

      // get date element
      Element elDate = item.getChild("date", dcNS);
      if (elDate != null) {
        rssItem.setDate(ParserUtils.getDate(elDate.getTextTrim()));
      }

      // get source element - default to Aggregation module, then try Dublin Core
      String sourceName = null;
      String sourceLocation = null;
      Date sourceTimestamp = null;

      Element elSourceURL = item.getChild("sourceURL", agNS);
      if (elSourceURL == null) { //  No Aggregation module - try Dublin Core
        elSourceURL = item.getChild("source", dcNS);
        if (elSourceURL != null) {
          sourceLocation = elSourceURL.getTextTrim();
          sourceName = "Source";
        }
      } else { // Aggregation module
        sourceLocation = elSourceURL.getTextTrim();
        Element elSourceName = item.getChild("source", agNS);
        if (elSourceName != null) {
          sourceName = elSourceName.getTextTrim();
        }
        Element elSourceTimestamp = item.getChild("timestamp", agNS);
        if (elSourceTimestamp != null) {
          sourceTimestamp = ParserUtils
              .getDate(elSourceTimestamp.getTextTrim());
        }
      }

      if (sourceLocation != null) {
        ItemSourceIF itemSource = cBuilder.createItemSource(rssItem,
            sourceName, sourceLocation, sourceTimestamp);
        rssItem.setSource(itemSource);
      }

      // comments element - use Annotation module
      Element elReference = item.getChild("reference", annotateNS);
      if (elReference != null) {
        Attribute resource = elReference.getAttribute("resource", ParserUtils
            .getNamespace(elReference, "rdf"));
        if (resource != null) {
          URL resourceURL = ParserUtils.getURL(resource.getValue());
          if (resourceURL != null) {
            rssItem.setComments(resourceURL);
          }
        }
      }

    }

    // image element
    Element image = root.getChild("image", defNS);
    if (image != null) {

      ParserUtils.matchCaseOfChildren(image, new String[] { "title", "url",
          "link", "width", "height", "description" });

      ImageIF rssImage = cBuilder.createImage(image.getChildTextTrim("title",
          defNS), ParserUtils.getURL(image.getChildTextTrim("url", defNS)),
          ParserUtils.getURL(image.getChildTextTrim("link", defNS)));
      Element imgWidth = image.getChild("width", defNS);
      if (imgWidth != null) {
        try {
          rssImage.setWidth(Integer.parseInt(imgWidth.getTextTrim()));
        } catch (NumberFormatException e) {
          logger.warn(e);
        }
      }
      Element imgHeight = image.getChild("height", defNS);
      if (imgHeight != null) {
        try {
          rssImage.setHeight(Integer.parseInt(imgHeight.getTextTrim()));
        } catch (NumberFormatException e) {
          logger.warn(e);
        }
      }
      Element imgDescr = image.getChild("description", defNS);
      if (imgDescr != null) {
        rssImage.setDescription(imgDescr.getTextTrim());
      }
      chnl.setImage(rssImage);
    }

    // textinput element
    Element txtinp = root.getChild("textinput", defNS);
    if (txtinp != null) {

      ParserUtils.matchCaseOfChildren(image, new String[] { "title",
          "description", "name", "link" });

      String tiTitle = null;
      if (txtinp.getChild("title", defNS) != null) {
        tiTitle = txtinp.getChild("title", defNS).getTextTrim();
      }
      String tiDescr = null;
      if (txtinp.getChild("description", defNS) != null) {
        tiDescr = txtinp.getChild("description", defNS).getTextTrim();
      }
      String tiName = null;
      if (txtinp.getChild("name", defNS) != null) {
        tiName = txtinp.getChild("name", defNS).getTextTrim();
      }
      URL tiLink = null;
      if (txtinp.getChild("link", defNS) != null) {
        tiLink = ParserUtils.getURL(txtinp.getChild("link", defNS)
            .getTextTrim());
      }
      TextInputIF rssTextInput = cBuilder.createTextInput(tiTitle, tiDescr,
          tiName, tiLink);
      chnl.setTextInput(rssTextInput);
    }

    chnl.setLastUpdated(dateParsed);

    return chnl;
  }
View Full Code Here

   *
   * @param record record to process.
   */
  protected final void processRecord(ChannelRecord record) {
    if (matcher != null && observer != null) {
      final ChannelIF channel = record.getChannel();

      observer.cleaningStarted(channel);

      final ItemIF[] items = (ItemIF[]) channel.getItems().toArray(new ItemIF[0]);
      for (int i = 0; i < items.length; i++) {
        checkItem(items[i], channel);
      }

      observer.cleaningFinished(channel);
View Full Code Here

        logger.error("problem NPE " + uri + " conn=" + conn, e);
        conn = null;
        throw new FeedManagerException(e);
      }

      ChannelIF channel = null;
      /*
       * if ( conn == null ) { channel = FeedParser.parse(getChannelBuilder(),
       * uri); } else {
       */
      channel = FeedParser.parse(getChannelBuilder(), conn.getInputStream());
View Full Code Here

      } catch (java.lang.ClassCastException e) {
        logger.warn("problem cast to HttpURLConnection (reading from a file?) "
            + feedUrl, e);
      }

      ChannelIF channel = null;
      if (conn == null) {
        channel = FeedParser.parse(getChannelBuilder(), feedUrl);
      } else {
        channel = FeedParser.parse(getChannelBuilder(), conn.getInputStream());
      }
View Full Code Here

  }

  public int compare(Object obj1, Object obj2) {

    if (obj1 instanceof ChannelIF) {
      ChannelIF channel1 = (ChannelIF) obj1;

      if (obj2 instanceof ChannelIF) {
        ChannelIF channel2 = (ChannelIF) obj2;

        if (!channel1.equals(channel2)) {
          return CHANNEL_MISMATCH;
        }

        if (channel1.getItems().size() != channel2.getItems().size()) {
          return CHANNEL_CHANGED;
        }

        Iterator items = channel1.getItems().iterator();

        while (items.hasNext()) {
          if (!channel2.getItems().contains(items.next())) {
            return CHANNEL_CHANGED;
          }
        }

        return CHANNEL_IDENTICAL;
View Full Code Here

        }
      }
      try {
        synchronized (channel) {
          builder.beginTransaction();
          ChannelIF tempChannel =
            FeedParser.parse(tempBuilder, channel.getLocation());
          logger.info(
            "Updating channel from "
              + channel.getLocation()
              + ": "
              + tempChannel
              + "(new)    "
              + channel
              + "(old)");
          InformaUtils.copyChannelProperties(tempChannel, channel);
          builder.update(channel);
          channel.setLastUpdated(new Date());
          // compare with existing items, only add new ones
          if (tempChannel.getItems().isEmpty()) {
            logger.warn("No items found in channel " + channel);
          } else {
            Iterator it = tempChannel.getItems().iterator();
            while (it.hasNext()) {
              ItemIF item = (ItemIF) it.next();
              if (!channel.getItems().contains(item)) {
                logger.debug("Found new item: " + item);
                channel.addItem(builder.createItem(null, item));
View Full Code Here

    ParserUtils.matchCaseOfChildren(channel, new String[] {
      "title", "description", "link", "language", "item", "image", "textinput", "copyright",
      "rating", "pubDate", "lastBuildDate", "docs", "managingEditor", "webMaster", "cloud" });

    // 1 title element
    ChannelIF chnl =
      cBuilder.createChannel(channel, channel.getChildTextTrim("title"));

    chnl.setFormat(ChannelFormat.RSS_0_91);

    // 1 description element
    chnl.setDescription(channel.getChildTextTrim("description"));

    // 1 link element
    chnl.setSite(ParserUtils.getURL(channel.getChildTextTrim("link")));

    // 1 language element
    chnl.setLanguage(channel.getChildTextTrim("language"));

    // 1..n item elements
    List items = channel.getChildren("item");
    Iterator i = items.iterator();
    while (i.hasNext()) {
      Element item = (Element) i.next();

      ParserUtils.matchCaseOfChildren(item, new String[] {
        "title", "link", "description", "source", "enclosure" });

      // get title element
      Element elTitle = item.getChild("title");
      String strTitle = "<No Title>";
      if (elTitle != null) {
        strTitle = elTitle.getTextTrim();
      }
      if (logger.isDebugEnabled()) {
        logger.debug("Item element found (" + strTitle + ").");
      }

      // get link element
      Element elLink = item.getChild("link");
      String strLink = "";
      if (elLink != null) {
        strLink = elLink.getTextTrim();
      }

      // get description element
      Element elDesc = item.getChild("description");
      String strDesc = "";
      if (elDesc != null) {
        strDesc = elDesc.getTextTrim();
      }

      // generate new RSS item (link to article)
      ItemIF rssItem =
        cBuilder.createItem(
          item,
          chnl,
          strTitle,
          strDesc,
          ParserUtils.getURL(strLink));
      rssItem.setFound(dateParsed);

      // get source element (an RSS 0.92 element)
      Element source = item.getChild("source");
      if (source != null) {
        String sourceName = source.getTextTrim();
        Attribute sourceAttribute = source.getAttribute("url");
        if (sourceAttribute != null) {
          String location = sourceAttribute.getValue().trim();
          ItemSourceIF itemSource =
            cBuilder.createItemSource(rssItem, sourceName, location, null);
          rssItem.setSource(itemSource);
        }
      }

      // get enclosure element (an RSS 0.92 element)
      Element enclosure = item.getChild("enclosure");
      if (enclosure != null) {
        URL location = null;
        String type = null;
        int length = -1;
        Attribute urlAttribute = enclosure.getAttribute("url");
        if (urlAttribute != null) {
          location = ParserUtils.getURL(urlAttribute.getValue().trim());
        }
        Attribute typeAttribute = enclosure.getAttribute("type");
        if (typeAttribute != null) {
          type = typeAttribute.getValue().trim();
        }
        Attribute lengthAttribute = enclosure.getAttribute("length");
        if (lengthAttribute != null) {
          try {
            length = Integer.parseInt(lengthAttribute.getValue().trim());
          } catch (NumberFormatException e) {
            logger.warn(e);
          }
        }
        ItemEnclosureIF itemEnclosure =
          cBuilder.createItemEnclosure(rssItem, location, type, length);
        rssItem.setEnclosure(itemEnclosure);
      }
    }

    // 0..1 image element
    Element image = channel.getChild("image");
    if (image != null) {

      ParserUtils.matchCaseOfChildren(image, new String[] {
        "title", "url", "link", "width", "height", "description" });

      ImageIF rssImage =
        cBuilder.createImage(
          image.getChildTextTrim("title"),
          ParserUtils.getURL(image.getChildTextTrim("url")),
          ParserUtils.getURL(image.getChildTextTrim("link")));
      Element imgWidth = image.getChild("width");
      if (imgWidth != null) {
        try {
          rssImage.setWidth(Integer.parseInt(imgWidth.getTextTrim()));
        } catch (NumberFormatException e) {
          logger.warn(e);
        }
      }
      Element imgHeight = image.getChild("height");
      if (imgHeight != null) {
        try {
          rssImage.setHeight(Integer.parseInt(imgHeight.getTextTrim()));
        } catch (NumberFormatException e) {
          logger.warn(e);
        }
      }
      Element imgDescr = image.getChild("description");
      if (imgDescr != null) {
        rssImage.setDescription(imgDescr.getTextTrim());
      }
      chnl.setImage(rssImage);
    }

    // 0..1 textinput element
    Element txtinp = channel.getChild("textinput");
    if (txtinp != null) {

      ParserUtils.matchCaseOfChildren(txtinp, new String[] {
        "title", "description", "name", "link"});

      TextInputIF rssTextInput =
        cBuilder.createTextInput(
          txtinp.getChild("title").getTextTrim(),
          txtinp.getChild("description").getTextTrim(),
          txtinp.getChild("name").getTextTrim(),
          ParserUtils.getURL(txtinp.getChild("link").getTextTrim()));
      chnl.setTextInput(rssTextInput);
    }

    // 0..1 copyright element
    Element copyright = channel.getChild("copyright");
    if (copyright != null) {
      chnl.setCopyright(copyright.getTextTrim());
    }

    // 0..1 rating element
    Element rating = channel.getChild("rating");
    if (rating != null) {
      chnl.setRating(rating.getTextTrim());
    }

    // 0..1 pubDate element
    Element pubDate = channel.getChild("pubDate");
    if (pubDate != null) {
      chnl.setPubDate(ParserUtils.getDate(pubDate.getTextTrim()));
    }

    // 0..1 lastBuildDate element
    Element lastBuildDate = channel.getChild("lastBuildDate");
    if (lastBuildDate != null) {
      chnl.setLastBuildDate(ParserUtils.getDate(lastBuildDate.getTextTrim()));
    }

    // 0..1 docs element
    Element docs = channel.getChild("docs");
    if (docs != null) {
      chnl.setDocs(docs.getTextTrim());
    }

    // 0..1 managingEditor element
    Element managingEditor = channel.getChild("managingEditor");
    if (managingEditor != null) {
      chnl.setCreator(managingEditor.getTextTrim());
    }

    // 0..1 webMaster element
    Element webMaster = channel.getChild("webMaster");
    if (webMaster != null) {
      chnl.setPublisher(webMaster.getTextTrim());
    }

    // 0..1 cloud element
    Element cloud = channel.getChild("cloud");
    if (cloud != null) {
      String _port = cloud.getAttributeValue("port");
      int port = -1;
      if (_port != null) {
        try {
          port = Integer.parseInt(_port);
        } catch (NumberFormatException e) {
          logger.warn(e);
        }
      }
      chnl.setCloud(
        cBuilder.createCloud(
          cloud.getAttributeValue("domain"),
          port,
          cloud.getAttributeValue("path"),
          cloud.getAttributeValue("registerProcedure"),
          cloud.getAttributeValue("protocol")));
    }

    chnl.setLastUpdated(dateParsed);
    // 0..1 skipHours element
    // 0..1 skipDays element

    return chnl;
  }
View Full Code Here

TOP

Related Classes of de.nava.informa.core.ChannelIF

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.