Package com.xmultra.processor.rss

Examples of com.xmultra.processor.rss.RssItem$Image


        }

        System.out.println(" =========  images ======== ");
        List<Image> images = artist.getImages();
        for (int i = 0; i < images.size(); i++) {
            Image image = images.get(i);
            image.dump();
        }

        System.out.println(" =========  news ======== ");
        List<News> newsList = artist.getNews();
        for (int i = 0; i < newsList.size(); i++) {
View Full Code Here


            if (itemText.charAt(0) == '<') {
                itemText = "\t\t" + itemText;
            }

            RssItem item = null;

            // An item in a prioritized feed containing MediaNewsRssItem objects
            // must be used even if its timestamp is older than the timestamp
            // on a non-prioritized item. We initialize itemPriority so we have
            // a priority even for an RssItem object.
            int itemPriority = Integer.MAX_VALUE;

            try {
                if (isCleanFeed) {
                    item = new RssItem(itemText, keepCDataSections);
                }
                else {
                    item = new MediaNewsRssItem(itemText, keepCDataSections, this.reader);
                    itemPriority = ((MediaNewsRssItem)item).getPriority();
                }

                if ( this.mergeType.equals(XmultraConfig.MERGE_TYPE_ROUND_ROBIN) ) {
                    // Round robin sort key allows merging one item
                    // from the first file, then one from the next file, etc.
                    itemCount++;
                    roundRobinSortKey = itemCount * 100 + sourceFileNumber;
                    item.setRoundRobinSortKey(roundRobinSortKey);
                }

                // Use headline, trimmed and converted to lowercase, as deduplication key
                // unless a custom key generator class was configured.
                String key = this.keyGenerator.getKey(item);
View Full Code Here

                            RssItem item,
                            String key,
                            int itemPriority) {
   
        // Get matching item from map.
        RssItem storedItem = dedupedItems.get(key);

        // Use priority or pubDate to determine which item to use.
        int storedPriority = Integer.MAX_VALUE;
        Date thisPubDate   = item.getPubDate();
        Date storedPubDate = storedItem.getPubDate();

        // If this map contains items from a most-popular feed, the
        // page-view count element values should be added.
        int totalCount = 0;
View Full Code Here

            // Check to see if we had this item last time we generated this feed.
            if ( previousItems.containsKey(newHeadline) ) {

                // This item was in the previous output.
                RssItem previousItem = (RssItem)previousItems.get(newHeadline);

                // Check to see if we also had this item in the previous source.
                if (previousSourceItems.containsKey(newHeadline) ) {

                    // This item also was in the previous source.
                    RssItem previousSourceItem = (RssItem)previousSourceItems.get(newHeadline);
                    Date previousSourcePubDate = previousSourceItem.getPubDate();
                   
                    // Test the previous source date against the new source date.
                    if ( newPubDate.equals(previousSourcePubDate) ) {
                        // Source dates match, so new source item is not an update and we
                        // can use the previous output date.
View Full Code Here

            try {
                // Check to see if we had this item last time we generated this feed.
                if ( previousItems.containsKey(newHeadline) ) {

                    // This item was in the previous output.
                    RssItem previousItem = previousItems.get(newHeadline);

                    // Check to see if we also had this item in the previous source.
                    if (previousSourceItems.containsKey(newHeadline) ) {

                        // This item also was in the previous source.
                        RssItem previousSourceItem = previousSourceItems.get(newHeadline);
                        Date previousSourcePubDate = previousSourceItem.getPubDate();
                       
                        // Test the previous source date against the new source date.
                        if ( newPubDate.equals(previousSourcePubDate) ) {

                            // Source dates match, so new source item is not an update and we
View Full Code Here

            if ( !elementToAdd.equals("") )    {
                itemText = strings.substitute("(\\s*</item>)", elementToAdd + "$1", itemText);
            }

            RssItem item = null;

            try {
                item = new RssItem(itemText, keepCDataSections);
                itemCount++;

                if ( this.mergeType.equals(XmultraConfig.MERGE_TYPE_ROUND_ROBIN) ) {
                    // Round robin sort key allows merging one item
                    // from the first file, then one from the next file, etc.
                    roundRobinSortKey = itemCount * 100 + sourceFileNumber;
                    item.setRoundRobinSortKey(roundRobinSortKey);
                }

                // Use headline, trimmed and converted to lowercase, as deduplication key
                // unless a custom key generator class was configured.
                String key = keyGenerator.getKey(item);
View Full Code Here

        Iterator iter = sortedItems.listIterator();

        int itemCount = 0;

        while (iter.hasNext() && itemCount < this.maxItems) {
            RssItem item = (RssItem)iter.next();

            // Skip items that are too old.
            if (item.getPubDate().compareTo(this.minimumPubDate) < 0) {
                continue;
            }

            items += item.getText();
            itemCount++;
        }

        RssItemSet itemSet = new RssItemSet(items, itemCount);
View Full Code Here

        // Iterate over unduplicated items and retrieve their text.
        Iterator iter = dedupedItems.keySet().iterator();

        while ( iter.hasNext() ) {
            String key = (String)iter.next();
            RssItem item = (RssItem)(dedupedItems.get( key ));
            items += item.getText();
        }

        return items;
    }
View Full Code Here

            if (connection == null) {
                connection = this.dataSource.getConnection();
            }

            RssItem item = (RssItem)entry.getValue();

            // Strip tags before passing guid to stored function.
            String guid = strings.strip( "</?guid[^>]*>", item.getGuid() );

            // Strip tags and escape apostrophes before passing title to stored function.
            String title = strings.strip( "</?title>", item.getTitle() );
            title = strings.substitute("'", "''", title);

            // Escape dollar signs in title before using in substitution.
            title = title.replace("\\$", "\\\\$");

            // Fill in placeholder parameters from stored function node in config file.
            boolean deepCopy = true;
            Node functionNode = this.dbFunctionNode.cloneNode(deepCopy);
            NodeList functionParameters = ((Element)functionNode).getElementsByTagName(DBXmlConfig.DB_PARAM);

            for (int i = 0; i < functionParameters.getLength(); i++) {
                // Each parameter node contains a text node whose value is the actual parameter value.
                Node parameter = functionParameters.item(i);
                String parameterValue = parameter.getFirstChild().getNodeValue();
                parameterValue = parameterValue.replace(XmultraConfig.RSS_ITEM_GUID_SYMBOL, guid);
                parameterValue = parameterValue.replace(XmultraConfig.RSS_ITEM_TITLE_SYMBOL, title);
                parameter.getFirstChild().setNodeValue(parameterValue);
            }

            String fileName = (String)dataSource.callStoredFunction(connection, functionNode);
            String fileContents = "";

            if (fileName != null) {
                fileContents = fileUtils.readFile( fileUtils.addRoot(fileName) );
            }

            if ( !fileContents.equals("") ) {

                RssItem fullTextItem = null;

                try {
                    boolean keepCDataSections = true;
                    fullTextItem = new RssItem(fileContents, keepCDataSections);
                    String fullText = fullTextItem.getContentEncoded();
                    item.setContentEncoded(fullText, updateText);

                    // Retrieve byline and credit line from full-text item if necessary,
                    // as when a Daylife feed is being processed.
                    String itemCreator = item.getCreator();

                    if ( itemCreator == null || itemCreator.equals("") ) {
                        String fullTextItemCreator = fullTextItem.getCreator();

                        if ( fullTextItemCreator != null && !fullTextItemCreator.equals("") ) {
                            item.setCreator(fullTextItemCreator, updateText);
                        }
                    }
View Full Code Here

    private boolean itemHasFullText(Map.Entry entry,
                                    Map<String,RssItem> previousItems,
                                    Map<String,RssItem> previousSourceItems) {

        String title = (String)entry.getKey();
        RssItem newItem = (RssItem)entry.getValue();

        Date newPubDate = newItem.getPubDate();

        boolean hasFullText = false;
        boolean updateText = true;

        // Check to see if we had this item last time we generated this feed.
        if ( previousItems.containsKey(title) ) {

            // This item was in the previous output.
            RssItem previousItem = previousItems.get(title);

            // Check to see if we also had this item in the previous source.
            if (previousSourceItems.containsKey(title) ) {

                // This item also was in the previous source.
                RssItem previousSourceItem = previousSourceItems.get(title);
                Date previousSourcePubDate = previousSourceItem.getPubDate();
               
                // Test the previous source date against the new source date.
                if ( newPubDate.equals(previousSourcePubDate) ) {
                    // Source dates match, so new source item is not an update and we
                    // can use the previous output's full text and, if necessary, dc:creator.
View Full Code Here

TOP

Related Classes of com.xmultra.processor.rss.RssItem$Image

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.