//# 0 errors, 126 messages
//#
/*
    //#NewsfeedCache.java:1:1: class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache
 * Licensed to the Apache Software Foundation (ASF) under one or more
 *  contributor license agreements.  The ASF licenses this file to You
 * under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.  For additional information regarding
 * copyright in this work, please see the NOTICE file in the top level
 * directory of this distribution.
 */

package org.apache.roller.weblogger.ui.rendering.velocity.deprecated;

import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.io.SyndFeedInput;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLConnection;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.roller.weblogger.config.WebloggerConfig;
import org.apache.roller.weblogger.util.LRUCache2;


/**
 * Returns parsed RSS feed by pulling one from a cache or by retrieving and
 * parging the specified feed using the Flock RSS parser.
 *
 * TODO: use PlanetRoller to implement NewsfeedCache instead.
 */
public class NewsfeedCache {
    
    private static Log log = LogFactory.getLog(NewsfeedCache.class);
    //#NewsfeedCache.java:41: method: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache.org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache__static_init
    //#NewsfeedCache.java:41: Warning: method not available
    //#    -- call on Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache
    //#    method: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache__static_init
    //#    unanalyzed callee: Log org.apache.commons.logging.LogFactory:getLog(Class)
    //#output(org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/rendering/velocity/deprecated/NewsfeedCache]
    //#output(org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache__static_init): __Dispatch_Table.getChannel(Ljava/lang/String;)Lcom/sun/syndication/feed/synd/SyndFeed;
    //#output(org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache__static_init): instance
    //#output(org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache__static_init): log
    //#post(org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache__static_init): __Descendant_Table[org/apache/roller/weblogger/ui/rendering/velocity/deprecated/NewsfeedCache] == &__Dispatch_Table
    //#post(org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache__static_init): __Dispatch_Table.getChannel(Ljava/lang/String;)Lcom/sun/syndication/feed/synd/SyndFeed; == &getChannel
    //#post(org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache__static_init): instance == null
    //#post(org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache__static_init): init'ed(log)
    
    /** Static singleton * */
    private static NewsfeedCache instance = null;
    //#NewsfeedCache.java:44: end of method: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache.org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache__static_init
    
    /** Instance vars * */
    private boolean aggregator_enabled = true;
    private boolean aggregator_cache_enabled = true;
    private int     aggregator_cache_timeout = 14400;
    
    /** LRU cache */
    LRUCache2 mCache = null;
    
    
    /** Constructor */
    private NewsfeedCache() {
    //#NewsfeedCache.java:56: method: void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache.org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache()
    //#input(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache()): "ERROR 'aggregator.cache.timeout'not a valid integer: "._tainted
    //#input(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache()): log
    //#input(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache()): this
    //#output(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache()): new LRUCache2(NewsfeedCache#2) num objects
    //#output(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache()): this.aggregator_cache_enabled
    //#output(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache()): this.aggregator_cache_timeout
    //#output(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache()): this.aggregator_enabled
    //#output(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache()): this.mCache
    //#new obj(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache()): new LRUCache2(NewsfeedCache#2)
    //#pre[1] (void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache()): (soft) log != null
    //#post(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache()): this.aggregator_cache_enabled == 1
    //#post(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache()): init'ed(this.aggregator_cache_timeout)
    //#post(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache()): this.aggregator_enabled == 1
    //#post(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache()): this.mCache == &new LRUCache2(NewsfeedCache#2)
    //#post(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache()): new LRUCache2(NewsfeedCache#2) num objects == 1
    //#test_vector(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache()): java.lang.String:equalsIgnoreCase(...)@62: {0}, {1}
    //#test_vector(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache()): java.lang.String:equalsIgnoreCase(...)@65: {0}, {1}
    //#test_vector(void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache()): org.apache.roller.weblogger.config.WebloggerConfig:getProperty(...)@60: Addr_Set{null}, Inverse{null}
        // lookup the props we need
        String enabled = WebloggerConfig.getProperty("aggregator.enabled");
    //#NewsfeedCache.java:58: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache
    //#    method: void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache()
    //#    unanalyzed callee: String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String)
        String usecache = WebloggerConfig.getProperty("aggregator.cache.enabled");
    //#NewsfeedCache.java:59: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache
    //#    method: void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache()
    //#    unanalyzed callee: String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String)
        String cachetime = WebloggerConfig.getProperty("aggregator.cache.timeout");
    //#NewsfeedCache.java:60: Warning: method not available
    //#    -- call on String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache
    //#    method: void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache()
    //#    unanalyzed callee: String org.apache.roller.weblogger.config.WebloggerConfig:getProperty(String)
        
        if("true".equalsIgnoreCase(enabled))
            this.aggregator_enabled = true;
        
        if("true".equalsIgnoreCase(usecache))
            this.aggregator_cache_enabled = true;
        
        try {
            if (cachetime != null) {
                this.aggregator_cache_timeout = Integer.parseInt(cachetime);
            }
        } catch(NumberFormatException e) { 
            log.error("ERROR 'aggregator.cache.timeout'not a valid integer: " + cachetime);
    //#NewsfeedCache.java:73: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:error(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache
    //#    method: void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:error(Object)
        }
        
        // finally ... create the cache
        this.mCache = new LRUCache2(100, 1000 * this.aggregator_cache_timeout);
    //#NewsfeedCache.java:77: Warning: method not available
    //#    -- call on void org.apache.roller.weblogger.util.LRUCache2(int, long)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache
    //#    method: void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache()
    //#    unanalyzed callee: void org.apache.roller.weblogger.util.LRUCache2(int, long)
    }
    //#NewsfeedCache.java:78: end of method: void org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache.org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache()
    
    
    /** static singleton retriever */
    public static NewsfeedCache getInstance() {
        synchronized (NewsfeedCache.class) {
    //#NewsfeedCache.java:83: method: NewsfeedCache org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache.getInstance()
    //#input(NewsfeedCache getInstance()): "ERROR 'aggregator.cache.timeout'not a valid integer: "._tainted
    //#input(NewsfeedCache getInstance()): instance
    //#input(NewsfeedCache getInstance()): log
    //#output(NewsfeedCache getInstance()): instance
    //#output(NewsfeedCache getInstance()): new LRUCache2(NewsfeedCache#2) num objects
    //#output(NewsfeedCache getInstance()): new NewsfeedCache(getInstance#1) num objects
    //#output(NewsfeedCache getInstance()): new NewsfeedCache(getInstance#1).__Tag
    //#output(NewsfeedCache getInstance()): new NewsfeedCache(getInstance#1).aggregator_cache_enabled
    //#output(NewsfeedCache getInstance()): new NewsfeedCache(getInstance#1).aggregator_cache_timeout
    //#output(NewsfeedCache getInstance()): new NewsfeedCache(getInstance#1).aggregator_enabled
    //#output(NewsfeedCache getInstance()): new NewsfeedCache(getInstance#1).mCache
    //#output(NewsfeedCache getInstance()): return_value
    //#new obj(NewsfeedCache getInstance()): new LRUCache2(NewsfeedCache#2)
    //#new obj(NewsfeedCache getInstance()): new NewsfeedCache(getInstance#1)
    //#pre[2] (NewsfeedCache getInstance()): init'ed(instance)
    //#pre[1] (NewsfeedCache getInstance()): (soft) log != null
    //#post(NewsfeedCache getInstance()): instance == One-of{old instance, &new NewsfeedCache(getInstance#1)}
    //#post(NewsfeedCache getInstance()): instance != null
    //#post(NewsfeedCache getInstance()): return_value == One-of{old instance, &new NewsfeedCache(getInstance#1)}
    //#post(NewsfeedCache getInstance()): return_value != null
    //#post(NewsfeedCache getInstance()): new LRUCache2(NewsfeedCache#2) num objects <= 1
    //#post(NewsfeedCache getInstance()): new NewsfeedCache(getInstance#1) num objects <= 1
    //#post(NewsfeedCache getInstance()): new NewsfeedCache(getInstance#1).__Tag == org/apache/roller/weblogger/ui/rendering/velocity/deprecated/NewsfeedCache
    //#post(NewsfeedCache getInstance()): new NewsfeedCache(getInstance#1).aggregator_cache_enabled == 1
    //#post(NewsfeedCache getInstance()): init'ed(new NewsfeedCache(getInstance#1).aggregator_cache_timeout)
    //#post(NewsfeedCache getInstance()): new NewsfeedCache(getInstance#1).aggregator_enabled == 1
    //#post(NewsfeedCache getInstance()): new NewsfeedCache(getInstance#1).mCache == &new LRUCache2(NewsfeedCache#2)
    //#unanalyzed(NewsfeedCache getInstance()): Effects-of-calling:org.apache.roller.weblogger.config.WebloggerConfig:getProperty
    //#unanalyzed(NewsfeedCache getInstance()): Effects-of-calling:java.lang.String:equalsIgnoreCase
    //#unanalyzed(NewsfeedCache getInstance()): Effects-of-calling:java.lang.Integer:parseInt
    //#unanalyzed(NewsfeedCache getInstance()): Effects-of-calling:java.lang.Throwable:__curr_excep_obj
    //#unanalyzed(NewsfeedCache getInstance()): Effects-of-calling:java.lang.StringBuilder
    //#unanalyzed(NewsfeedCache getInstance()): Effects-of-calling:java.lang.StringBuilder:append
    //#unanalyzed(NewsfeedCache getInstance()): Effects-of-calling:java.lang.StringBuilder:toString
    //#unanalyzed(NewsfeedCache getInstance()): Effects-of-calling:org.apache.commons.logging.Log:error
    //#unanalyzed(NewsfeedCache getInstance()): Effects-of-calling:org.apache.roller.weblogger.util.LRUCache2
    //#test_vector(NewsfeedCache getInstance()): org.apache.commons.logging.Log:isDebugEnabled(...)@85: {0}, {1}
            if (instance == null) {
                if (log.isDebugEnabled()) {
    //#NewsfeedCache.java:85: Warning: method not available
    //#    -- call on bool org.apache.commons.logging.Log:isDebugEnabled()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache
    //#    method: NewsfeedCache getInstance()
    //#    unanalyzed callee: bool org.apache.commons.logging.Log:isDebugEnabled()
                    log.debug("Instantiating new NewsfeedCache");
    //#NewsfeedCache.java:86: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache
    //#    method: NewsfeedCache getInstance()
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
                }
                instance = new NewsfeedCache();
            }
        }
        return instance;
    //#NewsfeedCache.java:91: end of method: NewsfeedCache org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache.getInstance()
    }
    
    
    /**
     * Returns a Channel object for the supplied RSS newsfeed URL.
     *
     * @param feedUrl RSS newsfeed URL.
     * @return FlockFeedI for specified RSS newsfeed URL.
     */
    public SyndFeed getChannel(String feedUrl) {
        
        SyndFeed feed = null;
    //#NewsfeedCache.java:103: method: SyndFeed org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache.getChannel(String)
    //#input(SyndFeed getChannel(String)): "Error parsing RSS: "._tainted
    //#input(SyndFeed getChannel(String)): "Newsfeed: not using Cache for "._tainted
    //#input(SyndFeed getChannel(String)): "Newsfeed: use Cache for "._tainted
    //#input(SyndFeed getChannel(String)): feedUrl
    //#input(SyndFeed getChannel(String)): feedUrl._tainted
    //#input(SyndFeed getChannel(String)): log
    //#input(SyndFeed getChannel(String)): this
    //#input(SyndFeed getChannel(String)): this.aggregator_cache_enabled
    //#input(SyndFeed getChannel(String)): this.aggregator_enabled
    //#input(SyndFeed getChannel(String)): this.mCache
    //#output(SyndFeed getChannel(String)): return_value
    //#pre[3] (SyndFeed getChannel(String)): (soft) log != null
    //#pre[5] (SyndFeed getChannel(String)): (soft) init'ed(this.aggregator_cache_enabled)
    //#pre[6] (SyndFeed getChannel(String)): (soft) init'ed(this.aggregator_enabled)
    //#pre[9] (SyndFeed getChannel(String)): (soft) this.mCache != null
    //#presumption(SyndFeed getChannel(String)): java.lang.String:indexOf(...)@147 + java.lang.String:length(...)@151 in -2_147_483_648..4_294_967_295
    //#presumption(SyndFeed getChannel(String)): java.net.URL:openConnection(...)@141 != null
    //#post(SyndFeed getChannel(String)): init'ed(return_value)
    //#test_vector(SyndFeed getChannel(String)): this.aggregator_cache_enabled: {0}, {1}
    //#test_vector(SyndFeed getChannel(String)): this.aggregator_enabled: {1}, {0}
    //#test_vector(SyndFeed getChannel(String)): java.lang.String:indexOf(...)@147: {-2_147_483_648..-1}, {0..4_294_967_295}
    //#test_vector(SyndFeed getChannel(String)): java.lang.String:indexOf(...)@149: {-2_147_483_648..-2, 0..4_294_967_295}, {-1}
    //#test_vector(SyndFeed getChannel(String)): java.net.URLConnection:getContentType(...)@143: Addr_Set{null}, Inverse{null}
    //#test_vector(SyndFeed getChannel(String)): org.apache.commons.logging.Log:isDebugEnabled(...)@111: {0}, {1}
    //#test_vector(SyndFeed getChannel(String)): org.apache.commons.logging.Log:isDebugEnabled(...)@117: {0}, {1}
    //#test_vector(SyndFeed getChannel(String)): org.apache.commons.logging.Log:isDebugEnabled(...)@136: {0}, {1}
    //#test_vector(SyndFeed getChannel(String)): org.apache.roller.weblogger.util.LRUCache2:get(...)@116: Inverse{null}, Addr_Set{null}
        try {
            // If aggregator has been disable return null
            if (!aggregator_enabled) {
                return null;
            }
            
            if (aggregator_cache_enabled) {
                if (log.isDebugEnabled()) {
    //#NewsfeedCache.java:111: Warning: method not available
    //#    -- call on bool org.apache.commons.logging.Log:isDebugEnabled()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache
    //#    method: SyndFeed getChannel(String)
    //#    unanalyzed callee: bool org.apache.commons.logging.Log:isDebugEnabled()
                    log.debug("Newsfeed: use Cache for " + feedUrl);
    //#NewsfeedCache.java:112: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache
    //#    method: SyndFeed getChannel(String)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
                }
                
                // Get pre-parsed feed from the cache
                feed = (SyndFeed) mCache.get(feedUrl);
    //#NewsfeedCache.java:116: Warning: method not available
    //#    -- call on Object org.apache.roller.weblogger.util.LRUCache2:get(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache
    //#    method: SyndFeed getChannel(String)
    //#    unanalyzed callee: Object org.apache.roller.weblogger.util.LRUCache2:get(Object)
                if (log.isDebugEnabled()) {
    //#NewsfeedCache.java:117: Warning: method not available
    //#    -- call on bool org.apache.commons.logging.Log:isDebugEnabled()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache
    //#    method: SyndFeed getChannel(String)
    //#    unanalyzed callee: bool org.apache.commons.logging.Log:isDebugEnabled()
                    log.debug("Newsfeed: got from Cache");
    //#NewsfeedCache.java:118: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache
    //#    method: SyndFeed getChannel(String)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
                }
                
                if (feed == null) {
                    try {
                        // Parse the feed
                        SyndFeedInput feedInput = new SyndFeedInput();
    //#NewsfeedCache.java:124: Warning: method not available
    //#    -- call on void com.sun.syndication.io.SyndFeedInput()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache
    //#    method: SyndFeed getChannel(String)
    //#    unanalyzed callee: void com.sun.syndication.io.SyndFeedInput()
                        feed = feedInput.build(new InputStreamReader(
    //#NewsfeedCache.java:125: Warning: method not available
    //#    -- call on SyndFeed com.sun.syndication.io.SyndFeedInput:build(Reader)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache
    //#    method: SyndFeed getChannel(String)
    //#    unanalyzed callee: SyndFeed com.sun.syndication.io.SyndFeedInput:build(Reader)
                                new URL(feedUrl).openStream()));
                    } catch (Exception e1) {
                        log.info("Error parsing RSS: " + feedUrl);
    //#NewsfeedCache.java:128: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:info(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache
    //#    method: SyndFeed getChannel(String)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:info(Object)
                    }
                }
                // Store parsed feed in the cache
                mCache.put(feedUrl, feed);
    //#NewsfeedCache.java:132: Warning: method not available
    //#    -- call on void org.apache.roller.weblogger.util.LRUCache2:put(Object, Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache
    //#    method: SyndFeed getChannel(String)
    //#    unanalyzed callee: void org.apache.roller.weblogger.util.LRUCache2:put(Object, Object)
                log.debug("Newsfeed: not in Cache");
    //#NewsfeedCache.java:133: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache
    //#    method: SyndFeed getChannel(String)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
                
            } else {
                if (log.isDebugEnabled()) {
    //#NewsfeedCache.java:136: Warning: method not available
    //#    -- call on bool org.apache.commons.logging.Log:isDebugEnabled()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache
    //#    method: SyndFeed getChannel(String)
    //#    unanalyzed callee: bool org.apache.commons.logging.Log:isDebugEnabled()
                    log.debug("Newsfeed: not using Cache for " + feedUrl);
    //#NewsfeedCache.java:137: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache
    //#    method: SyndFeed getChannel(String)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object)
                }
                try {
                    // charset fix from Jason Rumney (see ROL-766)
                    URLConnection connection = new URL(feedUrl).openConnection();
                    connection.connect();
                    String contentType = connection.getContentType();
                    // Default charset to UTF-8, since we are expecting XML
                    String charset = "UTF-8";
                    if (contentType != null) {
                        int charsetStart = contentType.indexOf("charset=");
                        if (charsetStart >= 0) {
                            int charsetEnd = contentType.indexOf(";", charsetStart);
                            if (charsetEnd == -1) charsetEnd = contentType.length();
                            charsetStart += "charset=".length();
                            charset = contentType.substring(charsetStart, charsetEnd);
                            // Check that charset is recognized by Java
                            try {
                                byte[] test = "test".getBytes(charset);
    //#NewsfeedCache.java:155: Warning: unused assignment
    //#    unused assignment into test
    //#    severity: LOW
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache
    //#    method: SyndFeed getChannel(String)
                            } catch (UnsupportedEncodingException codingEx) {
                                // default to UTF-8
                                charset = "UTF-8";
                            }
                        }
                    }
                    // Parse the feed
                    SyndFeedInput feedInput = new SyndFeedInput();
    //#NewsfeedCache.java:163: Warning: method not available
    //#    -- call on void com.sun.syndication.io.SyndFeedInput()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache
    //#    method: SyndFeed getChannel(String)
    //#    unanalyzed callee: void com.sun.syndication.io.SyndFeedInput()
                    feed = feedInput.build(new InputStreamReader(
    //#NewsfeedCache.java:164: Warning: method not available
    //#    -- call on SyndFeed com.sun.syndication.io.SyndFeedInput:build(Reader)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache
    //#    method: SyndFeed getChannel(String)
    //#    unanalyzed callee: SyndFeed com.sun.syndication.io.SyndFeedInput:build(Reader)
                            connection.getInputStream(), charset));
                } catch (Exception e1) {
                    log.info("Error parsing RSS: " + feedUrl);
    //#NewsfeedCache.java:167: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:info(Object)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache
    //#    method: SyndFeed getChannel(String)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:info(Object)
                }
            }
            
        } catch (Exception ioe) {
            if (log.isDebugEnabled()) {
    //#NewsfeedCache.java:172: Warning: method not available
    //#    -- call on bool org.apache.commons.logging.Log:isDebugEnabled()
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache
    //#    method: SyndFeed getChannel(String)
    //#    unanalyzed callee: bool org.apache.commons.logging.Log:isDebugEnabled()
                log.debug("Newsfeed: Unexpected exception", ioe);
    //#NewsfeedCache.java:173: Warning: method not available
    //#    -- call on void org.apache.commons.logging.Log:debug(Object, Throwable)
    //#    severity: INFORMATIONAL
    //#    class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache
    //#    method: SyndFeed getChannel(String)
    //#    unanalyzed callee: void org.apache.commons.logging.Log:debug(Object, Throwable)
            }
        }
        
        return feed;
    //#NewsfeedCache.java:177: end of method: SyndFeed org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache.getChannel(String)
    }
    
}
    //#NewsfeedCache.java:: end of class: org.apache.roller.weblogger.ui.rendering.velocity.deprecated.NewsfeedCache
