Changeset 3aba126


Ignore:
Timestamp:
Sep 16, 2005 6:58:55 AM (15 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
dab1b4d
Parents:
cfee643
git-author:
jrandom <jrandom> (09/16/05 06:58:55)
git-committer:
zzz <zzz@…> (09/16/05 06:58:55)
Message:

use the logger, not stdout/stderr

Location:
apps/syndie/java/src/net/i2p/syndie
Files:
16 edited

Legend:

Unmodified
Added
Removed
  • apps/syndie/java/src/net/i2p/syndie/ArchiveIndexer.java

    rcfee643 r3aba126  
    1717   
    1818    public static ArchiveIndex index(I2PAppContext ctx, Archive source) {
    19         LocalArchiveIndex rv = new LocalArchiveIndex();
     19        LocalArchiveIndex rv = new LocalArchiveIndex(ctx);
    2020        rv.setGeneratedOn(ctx.clock().now());
    2121       
     
    5555        int newBlogs = 0;
    5656       
    57         SMLParser parser = new SMLParser();
     57        SMLParser parser = new SMLParser(ctx);
    5858       
    5959        for (int i = 0; i < blogs.size(); i++) {
  • apps/syndie/java/src/net/i2p/syndie/CLI.java

    rcfee643 r3aba126  
    112112        EntryContainer entry = mgr.getArchive().getEntry(new BlogURI(new Hash(Base64.decode(args[2])), id), entryKey);
    113113        if (entry != null) {
    114             HTMLRenderer renderer = new HTMLRenderer();
     114            HTMLRenderer renderer = new HTMLRenderer(I2PAppContext.getGlobalContext());
    115115            boolean summaryOnly = "true".equalsIgnoreCase(args[5]);
    116116            boolean showImages = "true".equalsIgnoreCase(args[6]);
  • apps/syndie/java/src/net/i2p/syndie/data/ArchiveIndex.java

    rcfee643 r3aba126  
    88import net.i2p.syndie.Archive;
    99import net.i2p.syndie.BlogManager;
     10import net.i2p.util.Log;
    1011
    1112/**
     
    1314 */
    1415public class ArchiveIndex {
     16    private I2PAppContext _context;
     17    private Log _log;
    1518    protected String _version;
    1619    protected long _generatedOn;
     
    3235   
    3336    public ArchiveIndex() {
    34         this(false); //true);
    35     }
    36     public ArchiveIndex(boolean shouldLoad) {
     37        this(I2PAppContext.getGlobalContext(), false);
     38    }
     39    public ArchiveIndex(I2PAppContext ctx) {
     40        this(ctx, false); //true);
     41    }
     42    public ArchiveIndex(I2PAppContext ctx, boolean shouldLoad) {
     43        _context = ctx;
     44        _log = ctx.logManager().getLog(ArchiveIndex.class);
    3745        _blogs = new ArrayList();
    3846        _newestBlogs = new ArrayList();
     
    279287            if (tag != null) {
    280288                if (!tag.equals(summary.tag)) {
    281                     System.out.println("Tag [" + summary.tag + "] does not match the requested [" + tag + "] in " + summary.blog.toBase64());
     289                    if (_log.shouldLog(Log.DEBUG))
     290                        _log.debug("Tag [" + summary.tag + "] does not match the requested [" + tag + "] in " + summary.blog.toBase64());
    282291                    if (false) {
    283292                        StringBuffer b = new StringBuffer(tag.length()*2);
     
    291300                            b.append(' ');
    292301                        }
    293                         System.out.println("tag.summary: " + b.toString());
     302                        if (_log.shouldLog(Log.DEBUG))
     303                            _log.debug("tag.summary: " + b.toString());
    294304                    }
    295305                    continue;
  • apps/syndie/java/src/net/i2p/syndie/data/BlogInfo.java

    rcfee643 r3aba126  
    55import net.i2p.data.*;
    66import net.i2p.I2PAppContext;
     7import net.i2p.util.Log;
    78
    89/**
     
    5859   
    5960    public void load(InputStream in) throws IOException {
     61        Log log = I2PAppContext.getGlobalContext().logManager().getLog(getClass());
    6062        BufferedReader reader = new BufferedReader(new InputStreamReader(in, "UTF-8"));
    6163        List names = new ArrayList();
     
    6365        String line = null;
    6466        while ( (line = reader.readLine()) != null) {
    65             System.err.println("Read info line [" + line + "]");
     67            if (log.shouldLog(Log.DEBUG))
     68                log.debug("Read info line [" + line + "]");
    6669            line = line.trim();
    6770            int len = line.length();
     
    8588            _optionNames[i] = (String)names.get(i);
    8689            _optionValues[i] = (String)vals.get(i);
    87             System.out.println("Loaded info: [" + _optionNames[i] + "] = [" + _optionValues[i] + "]");
     90            //System.out.println("Loaded info: [" + _optionNames[i] + "] = [" + _optionValues[i] + "]");
    8891        }
    8992       
     
    120123            if (_optionNames[i].equals(name)) {
    121124                String val = _optionValues[i];
    122                 System.out.println("getProperty[" + name + "] = [" + val + "] [sz=" + val.length() +"]");
    123                 for (int j = 0; j < val.length(); j++) {
    124                     char c = (char)val.charAt(j);
    125                     if (c != (c & 0x7F))
    126                         System.out.println("char " + j + ": " + (int)c);
    127                 }
     125                //System.out.println("getProperty[" + name + "] = [" + val + "] [sz=" + val.length() +"]");
     126                //for (int j = 0; j < val.length(); j++) {
     127                //    char c = (char)val.charAt(j);
     128                //    if (c != (c & 0x7F))
     129                //        System.out.println("char " + j + ": " + (int)c);
     130                //}
    128131                return val;
    129132            }
  • apps/syndie/java/src/net/i2p/syndie/data/EntryContainer.java

    rcfee643 r3aba126  
    77import net.i2p.data.*;
    88import net.i2p.I2PAppContext;
     9import net.i2p.util.Log;
    910
    1011/**
     
    167168   
    168169    public void seal(I2PAppContext ctx, SigningPrivateKey signingKey, SessionKey entryKey) throws IOException {
    169         System.out.println("Sealing " + _entryURI);
     170        Log l = ctx.logManager().getLog(getClass());
     171        if (l.shouldLog(Log.DEBUG))
     172            l.debug("Sealing " + _entryURI);
    170173        if (entryKey == null)
    171174            _format = FORMAT_ZIP_UNENCRYPTED;
     
    273276            byte data[] = (byte[])attachments.get(ZIP_ATTACHMENT_PREFIX + i + ZIP_ATTACHMENT_SUFFIX);
    274277            byte metadata[] = (byte[])attachmentMeta.get(ZIP_ATTACHMENT_META_PREFIX + i + ZIP_ATTACHMENT_META_SUFFIX);
    275             if ( (data != null) && (metadata != null) )
     278            if ( (data != null) && (metadata != null) ) {
    276279                _attachments[i] = new Attachment(data, metadata);
    277             else
    278                 System.out.println("Unable to get " + i + ": " + data + "/" + metadata);
     280            } else {
     281                Log l = ctx.logManager().getLog(getClass());
     282                if (l.shouldLog(Log.WARN))
     283                    l.warn("Unable to get " + i + ": " + data + "/" + metadata);
     284            }
    279285        }
    280286       
     
    349355       
    350356        if (keyHash == null) {
    351             System.err.println("Headers: " + _rawKeys);
    352             System.err.println("Values : " + _rawValues);
    353357            throw new IOException("Missing " + HEADER_BLOGKEY + " header");
    354358        }
     
    359363                entryId = Long.parseLong(idVal.trim());
    360364            } catch (NumberFormatException nfe) {
    361                 System.err.println("Headers: " + _rawKeys);
    362                 System.err.println("Values : " + _rawValues);
    363365                throw new IOException("Invalid format of entryId (" + idVal + ")");
    364366            }
  • apps/syndie/java/src/net/i2p/syndie/data/LocalArchiveIndex.java

    rcfee643 r3aba126  
    22
    33import java.util.*;
     4import net.i2p.I2PAppContext;
    45import net.i2p.data.*;
    56import net.i2p.syndie.Archive;
     7import net.i2p.util.Log;
    68
    79/**
     
    911 */
    1012public class LocalArchiveIndex extends ArchiveIndex {
    11    
    12     public LocalArchiveIndex() {
    13         super(false);
     13    private Log _log;
     14    public LocalArchiveIndex(I2PAppContext ctx) {
     15        super(ctx, false);
     16        _log = ctx.logManager().getLog(getClass());
    1417    }
    1518   
     
    4750                long entryId = Archive.getEntryIdFromIndexName(entry);
    4851                int kb = Archive.getSizeFromIndexName(entry);
    49                 System.out.println("Adding entry " + entryId + ", size=" + kb + "KB [" + entry + "]");
     52                if (_log.shouldLog(Log.INFO))
     53                    _log.info("Adding entry " + entryId + ", size=" + kb + "KB [" + entry + "]");
    5054                EntrySummary entrySummary = new EntrySummary(new BlogURI(key, entryId), kb);
    5155                for (int j = 0; j < summary.entries.size(); j++) {
  • apps/syndie/java/src/net/i2p/syndie/data/TransparentArchiveIndex.java

    rcfee643 r3aba126  
    1313 */
    1414public class TransparentArchiveIndex extends ArchiveIndex {
    15     public TransparentArchiveIndex() { super(false); }
     15    public TransparentArchiveIndex() { super(I2PAppContext.getGlobalContext(), false); }
    1616   
    1717    private static ArchiveIndex index() { return BlogManager.instance().getArchive().getIndex(); }
  • apps/syndie/java/src/net/i2p/syndie/sml/EventReceiverImpl.java

    rcfee643 r3aba126  
    22
    33import java.util.List;
     4import net.i2p.I2PAppContext;
     5import net.i2p.util.Log;
    46
    57/**
     
    79 */
    810public class EventReceiverImpl implements SMLParser.EventReceiver {
     11    private I2PAppContext _context;
     12    private Log _log;
     13   
     14    public EventReceiverImpl(I2PAppContext ctx) {
     15        _context = ctx;
     16        _log = ctx.logManager().getLog(EventReceiverImpl.class);
     17    }
    918    public void receiveHeader(String header, String value) {
    10         System.out.println("Receive header [" + header + "] = [" + value + "]");
     19        if (_log.shouldLog(Log.DEBUG))
     20            _log.debug("Receive header [" + header + "] = [" + value + "]");
    1121    }
    1222    public void receiveLink(String schema, String location, String text) {
    13         System.out.println("Receive link [" + schema + "]/[" + location+ "]/[" + text + "]");
     23        if (_log.shouldLog(Log.DEBUG))
     24            _log.debug("Receive link [" + schema + "]/[" + location+ "]/[" + text + "]");
    1425    }
    1526    public void receiveBlog(String name, String blogKeyHash, String blogPath, long blogEntryId,
    1627                            List blogArchiveLocations, String anchorText) {
    17         System.out.println("Receive blog [" + name + "]/[" + blogKeyHash + "]/[" + blogPath
     28        if (_log.shouldLog(Log.DEBUG))
     29            _log.debug("Receive blog [" + name + "]/[" + blogKeyHash + "]/[" + blogPath
    1830                           + "]/[" + blogEntryId + "]/[" + blogArchiveLocations + "]/[" + anchorText + "]");
    1931    }
    2032    public void receiveArchive(String name, String description, String locationSchema, String location,
    2133                               String postingKey, String anchorText) {
    22         System.out.println("Receive archive [" + name + "]/[" + description + "]/[" + locationSchema
     34        if (_log.shouldLog(Log.DEBUG))
     35            _log.debug("Receive archive [" + name + "]/[" + description + "]/[" + locationSchema
    2336                           + "]/[" + location + "]/[" + postingKey + "]/[" + anchorText + "]");
    2437    }
    2538    public void receiveImage(String alternateText, int attachmentId) {
    26         System.out.println("Receive image [" + alternateText + "]/[" + attachmentId + "]");
     39        if (_log.shouldLog(Log.DEBUG))
     40            _log.debug("Receive image [" + alternateText + "]/[" + attachmentId + "]");
    2741    }
    2842    public void receiveAddress(String name, String schema, String protocol, String location, String anchorText) {
    29         System.out.println("Receive address [" + name + "]/[" + schema + "]/[" + location + "]/[" + anchorText+ "]");
     43        if (_log.shouldLog(Log.DEBUG))
     44            _log.debug("Receive address [" + name + "]/[" + schema + "]/[" + location + "]/[" + anchorText+ "]");
    3045    }
    31     public void receiveBold(String text) { System.out.println("Receive bold [" + text+ "]"); }
    32     public void receiveItalic(String text) { System.out.println("Receive italic [" + text+ "]"); }
    33     public void receiveUnderline(String text) { System.out.println("Receive underline [" + text+ "]"); }
     46    public void receiveBold(String text) {
     47        if (_log.shouldLog(Log.DEBUG))
     48            _log.debug("Receive bold [" + text+ "]");
     49    }
     50    public void receiveItalic(String text) {
     51        if (_log.shouldLog(Log.DEBUG))
     52            _log.debug("Receive italic [" + text+ "]");
     53    }
     54    public void receiveUnderline(String text) {
     55        if (_log.shouldLog(Log.DEBUG))
     56            _log.debug("Receive underline [" + text+ "]");
     57    }
    3458    public void receiveQuote(String text, String whoQuoted, String quoteLocationSchema, String quoteLocation) {
    35         System.out.println("Receive quote [" + text + "]/[" + whoQuoted + "]/[" + quoteLocationSchema + "]/[" + quoteLocation + "]");
     59        if (_log.shouldLog(Log.DEBUG))
     60            _log.debug("Receive quote [" + text + "]/[" + whoQuoted + "]/[" + quoteLocationSchema + "]/[" + quoteLocation + "]");
    3661    }
    3762    public void receiveCode(String text, String codeLocationSchema, String codeLocation) {
    38         System.out.println("Receive code [" + text+ "]/[" + codeLocationSchema + "]/[" + codeLocation + "]");
     63        if (_log.shouldLog(Log.DEBUG))
     64            _log.debug("Receive code [" + text+ "]/[" + codeLocationSchema + "]/[" + codeLocation + "]");
    3965    }
    40     public void receiveCut(String summaryText) { System.out.println("Receive cut [" + summaryText + "]"); }
    41     public void receivePlain(String text) { System.out.println("Receive plain [" + text + "]"); }
    42     public void receiveNewline() { System.out.println("Receive NL"); }
    43     public void receiveLT() { System.out.println("Receive LT"); }
    44     public void receiveGT() { System.out.println("Receive GT"); }
    45     public void receiveBegin() { System.out.println("Receive begin"); }
    46     public void receiveEnd() { System.out.println("Receive end"); }
    47     public void receiveHeaderEnd() { System.out.println("Receive header end"); }
    48     public void receiveLeftBracket() { System.out.println("Receive ["); }
    49     public void receiveRightBracket() { System.out.println("Receive ]"); }
     66    public void receiveCut(String summaryText) {
     67        if (_log.shouldLog(Log.DEBUG))
     68            _log.debug("Receive cut [" + summaryText + "]");
     69    }
     70    public void receivePlain(String text) {
     71        if (_log.shouldLog(Log.DEBUG))
     72            _log.debug("Receive plain [" + text + "]");
     73    }
     74    public void receiveNewline() {
     75        if (_log.shouldLog(Log.DEBUG))
     76            _log.debug("Receive NL");
     77    }
     78    public void receiveLT() {
     79        if (_log.shouldLog(Log.DEBUG))
     80            _log.debug("Receive LT");
     81    }
     82    public void receiveGT() {
     83        if (_log.shouldLog(Log.DEBUG))
     84            _log.debug("Receive GT");
     85    }
     86    public void receiveBegin() {
     87        if (_log.shouldLog(Log.DEBUG))
     88            _log.debug("Receive begin");
     89    }
     90    public void receiveEnd() {
     91        if (_log.shouldLog(Log.DEBUG))
     92            _log.debug("Receive end");
     93    }
     94    public void receiveHeaderEnd() {
     95        if (_log.shouldLog(Log.DEBUG))
     96            _log.debug("Receive header end");
     97    }
     98    public void receiveLeftBracket() {
     99        if (_log.shouldLog(Log.DEBUG))
     100            _log.debug("Receive [");
     101    }
     102    public void receiveRightBracket() {
     103        if (_log.shouldLog(Log.DEBUG))
     104            _log.debug("Receive ]");
     105    }
    50106   
    51107    public void receiveH1(String text) {}
  • apps/syndie/java/src/net/i2p/syndie/sml/HTMLPreviewRenderer.java

    rcfee643 r3aba126  
    44import java.text.*;
    55import java.util.*;
     6import net.i2p.I2PAppContext;
    67import net.i2p.data.*;
    78import net.i2p.syndie.*;
     
    1718    private List _files;
    1819   
    19     public HTMLPreviewRenderer(List filenames, List fileTypes, List files) {
    20         super();
     20    public HTMLPreviewRenderer(I2PAppContext ctx, List filenames, List fileTypes, List files) {
     21        super(ctx);
    2122        _filenames = filenames;
    2223        _fileTypes = fileTypes;
  • apps/syndie/java/src/net/i2p/syndie/sml/HTMLRenderer.java

    rcfee643 r3aba126  
    44import java.text.*;
    55import java.util.*;
     6import net.i2p.I2PAppContext;
    67import net.i2p.data.*;
    78import net.i2p.syndie.*;
    89import net.i2p.syndie.data.*;
    910import net.i2p.syndie.web.*;
     11import net.i2p.util.Log;
    1012
    1113/**
     
    1315 */
    1416public class HTMLRenderer extends EventReceiverImpl {
     17    private Log _log;
    1518    protected SMLParser _parser;
    1619    protected Writer _out;
     
    3235    protected StringBuffer _postBodyBuffer;
    3336   
    34     public HTMLRenderer() {
    35         _parser = new SMLParser();
     37    public HTMLRenderer(I2PAppContext ctx) {
     38        super(ctx);
     39        _log = ctx.logManager().getLog(HTMLRenderer.class);
     40        _parser = new SMLParser(ctx);
    3641    }
    3742
     
    4449            return;
    4550        }
    46         HTMLRenderer renderer = new HTMLRenderer();
     51        HTMLRenderer renderer = new HTMLRenderer(I2PAppContext.getGlobalContext());
    4752        Writer out = null;
    4853        try {
     
    297302     */
    298303    public void receiveBlog(String name, String hash, String tag, long entryId, List locations, String description) {
    299         System.out.println("Receiving the blog: " + name + "/" + hash + "/" + tag + "/" + entryId +"/" + locations + ": "+ description);
     304        if (_log.shouldLog(Log.DEBUG))
     305            _log.debug("Receiving the blog: " + name + "/" + hash + "/" + tag + "/" + entryId +"/" + locations + ": "+ description);
    300306        byte blogData[] = Base64.decode(hash);
    301307        if ( (blogData == null) || (blogData.length != Hash.HASH_LENGTH) )
     
    447453            _bodyBuffer.append(getSpan("addrKnownName")).append("(").append(sanitizeString(knownName)).append(")</span>");
    448454        } else {
    449             System.err.println("Receiving address [" + location + "]");
     455            if (_log.shouldLog(Log.DEBUG))
     456                _log.debug("Receiving address [" + location + "]");
    450457            _bodyBuffer.append("<a ").append(getClass("addrAdd")).append(" href=\"addresses.jsp?");
    451458            if (schema != null)
     
    830837                return str + " [" + (when - dayBegin) + "]";
    831838            } catch (ParseException pe) {
    832                 pe.printStackTrace();
     839                if (_log.shouldLog(Log.WARN))
     840                    _log.warn("Error formatting", pe);
    833841                // wtf
    834842                return "unknown";
  • apps/syndie/java/src/net/i2p/syndie/sml/RSSRenderer.java

    rcfee643 r3aba126  
    44import java.util.*;
    55import java.text.SimpleDateFormat;
     6import net.i2p.I2PAppContext;
    67import net.i2p.data.*;
    78import net.i2p.syndie.*;
     
    1213 */
    1314public class RSSRenderer extends HTMLRenderer {
     15   
     16    public RSSRenderer(I2PAppContext ctx) {
     17        super(ctx);
     18    }
    1419   
    1520    public void render(User user, Archive archive, EntryContainer entry, String urlPrefix, Writer out) throws IOException {
  • apps/syndie/java/src/net/i2p/syndie/sml/SMLParser.java

    rcfee643 r3aba126  
    44import java.util.*;
    55import net.i2p.syndie.data.*;
     6import net.i2p.I2PAppContext;
     7import net.i2p.util.Log;
    68
    79/**
     
    1315 */
    1416public class SMLParser {
     17    private Log _log;
    1518    private static final char TAG_BEGIN = '[';
    1619    private static final char TAG_END = ']';
     
    2427    private static final char CR = '\n';
    2528    private static final char LF = '\f';
     29   
     30    public SMLParser(I2PAppContext ctx) {
     31        _log = ctx.logManager().getLog(SMLParser.class);
     32    }
    2633
    2734    public void parse(String rawSML, EventReceiver receiver) {
     
    274281            receiver.receiveAttachment((int)getLong(P_ATTACHMENT_ID, attr), body);
    275282        } else {
    276             System.out.println("need to learn how to parse the tag [" + tagName + "]");
     283            if (_log.shouldLog(Log.WARN))
     284                _log.warn("need to learn how to parse the tag [" + tagName + "]");
    277285        }
    278286    }
     
    438446    }
    439447    private static void test(String rawSML) {
    440         SMLParser parser = new SMLParser();
    441         parser.parse(rawSML, new EventReceiverImpl());
     448        I2PAppContext ctx = I2PAppContext.getGlobalContext();
     449        SMLParser parser = new SMLParser(ctx);
     450        parser.parse(rawSML, new EventReceiverImpl(ctx));
    442451    }
    443452}
  • apps/syndie/java/src/net/i2p/syndie/web/ArchiveViewerBean.java

    rcfee643 r3aba126  
    298298                if (selector.startsWith(SEL_BLOG)) {
    299299                    String blogStr = selector.substring(SEL_BLOG.length());
    300                     System.out.println("Selector [" + selector + "] blogString: [" + blogStr + "]");
     300                    //System.out.println("Selector [" + selector + "] blogString: [" + blogStr + "]");
    301301                    byte h[] = Base64.decode(blogStr);
    302302                    if (h != null)
    303303                        blog = new Hash(h);
    304                     else
    305                         System.out.println("blog string does not decode properly: [" + blogStr + "]");
     304                    //else
     305                    //    System.out.println("blog string does not decode properly: [" + blogStr + "]");
    306306                } else if (selector.startsWith(SEL_BLOGTAG)) {
    307307                    int tagStart = selector.lastIndexOf('/');
     
    320320                        tag = DataHelper.getUTF8(rawDecode);
    321321                    }
    322                     System.out.println("Selector [" + selector + "] blogString: [" + blogStr + "] tag: [" + tag + "]");
     322                    //System.out.println("Selector [" + selector + "] blogString: [" + blogStr + "] tag: [" + tag + "]");
    323323                    if (false && tag != null) {
    324324                        StringBuffer b = new StringBuffer(tag.length()*2);
     
    333333                            b.append((int)origTag.charAt(j)).append(' ');
    334334                        }
    335                         System.out.println("selected tag: " + b.toString());
     335                        //System.out.println("selected tag: " + b.toString());
    336336                    }
    337337                } else if (selector.startsWith(SEL_TAG)) {
     
    342342                        tag = DataHelper.getUTF8(rawDecode);
    343343                    }
    344                     System.out.println("Selector [" + selector + "] tag: [" + tag + "]");
     344                    //System.out.println("Selector [" + selector + "] tag: [" + tag + "]");
    345345                    if (false && tag != null) {
    346346                        StringBuffer b = new StringBuffer(tag.length()*2);
     
    351351                            b.append(' ');
    352352                        }
    353                         System.out.println("selected tag: " + b.toString());
     353                        //System.out.println("selected tag: " + b.toString());
    354354                    }
    355355                } else if (selector.startsWith(SEL_ENTRY)) {
     
    362362                        if (h.getData() != null)
    363363                            blog = h;
    364                         else
    365                             System.out.println("Blog does not decode [" + blogStr + "]");
    366                         System.out.println("Selector [" + selector + "] blogString: [" + blogStr + "] entry: [" + entry + "]");
     364                        //else
     365                        //    System.out.println("Blog does not decode [" + blogStr + "]");
     366                        //System.out.println("Selector [" + selector + "] blogString: [" + blogStr + "] entry: [" + entry + "]");
    367367                    } catch (NumberFormatException nfe) {}
    368368                } else if (selector.startsWith(SEL_GROUP)) {
    369369                    group = DataHelper.getUTF8(Base64.decode(selector.substring(SEL_GROUP.length())));
    370                     System.out.println("Selector [" + selector + "] group: [" + group + "]");
     370                    //System.out.println("Selector [" + selector + "] group: [" + group + "]");
    371371                }
    372372            }
     
    381381        ArchiveIndex index = archive.getIndex();
    382382        List entries = pickEntryURIs(user, index, blog, tag, entryId, group);
    383         System.out.println("Searching for " + blog + "/" + tag + "/" + entryId + "/" + pageNum + "/" + numPerPage + "/" + group);
    384         System.out.println("Entry URIs: " + entries);
    385        
    386         HTMLRenderer renderer = new HTMLRenderer();
     383        //System.out.println("Searching for " + blog + "/" + tag + "/" + entryId + "/" + pageNum + "/" + numPerPage + "/" + group);
     384        //System.out.println("Entry URIs: " + entries);
     385       
     386        HTMLRenderer renderer = new HTMLRenderer(I2PAppContext.getGlobalContext());
    387387        int start = pageNum * numPerPage;
    388388        int end = start + numPerPage;
     
    408408                    else
    409409                        prevURL = HTMLRenderer.getPageURL(user, selector, numPerPage, pageNum-1);
    410                     System.out.println("prevURL: " + prevURL);
     410                    //System.out.println("prevURL: " + prevURL);
    411411                    out.write(" <a class=\"b_selectorPrevMore\" href=\"" + prevURL + "\">&lt;&lt;</a>");
    412412                } else {
     
    420420                    else
    421421                        nextURL = HTMLRenderer.getPageURL(user, selector, numPerPage, pageNum+1);
    422                     System.out.println("nextURL: " + nextURL);
     422                    //System.out.println("nextURL: " + nextURL);
    423423                    out.write(" <a class=\"b_selectorNextMore\" href=\"" + nextURL + "\">&gt;&gt;</a>");
    424424                } else {
     
    452452       
    453453        if (entries.size() <= 0) end = -1;
    454         System.out.println("Entries.size: " + entries.size() + " start=" + start + " end=" + end);
     454        //System.out.println("Entries.size: " + entries.size() + " start=" + start + " end=" + end);
    455455        for (int i = start; i < end; i++) {
    456456            BlogURI uri = (BlogURI)entries.get(i);
     
    480480            List selectors = (List)user.getBlogGroups().get(group);
    481481            if (selectors != null) {
    482                 System.out.println("Selectors for group " + group + ": " + selectors);
     482                //System.out.println("Selectors for group " + group + ": " + selectors);
    483483                for (int i = 0; i < selectors.size(); i++) {
    484484                    String sel = (String)selectors.get(i);
  • apps/syndie/java/src/net/i2p/syndie/web/PostBean.java

    rcfee643 r3aba126  
    33import java.io.*;
    44import java.util.*;
     5import net.i2p.I2PAppContext;
    56import net.i2p.syndie.*;
    67import net.i2p.syndie.data.BlogURI;
    78import net.i2p.syndie.sml.HTMLPreviewRenderer;
     9import net.i2p.util.Log;
    810
    911/**
     
    1113 */
    1214public class PostBean {
     15    private I2PAppContext _context;
     16    private Log _log;
    1317    private User _user;
    1418    private String _subject;
     
    2327    private boolean _previewed;
    2428   
    25     public PostBean() { reinitialize(); }
     29    public PostBean() {
     30        _context = I2PAppContext.getGlobalContext();
     31        _log = _context.logManager().getLog(PostBean.class);
     32        reinitialize();
     33    }
    2634   
    2735    public void reinitialize() {
    28         System.out.println("Reinitializing " + (_text != null ? "(with " + _text.length() + " bytes of sml!)" : ""));
     36        if (_log.shouldLog(Log.DEBUG))
     37            _log.debug("Reinitializing " + (_text != null ? "(with " + _text.length() + " bytes of sml!)" : ""));
    2938        _user = null;
    3039        _subject = null;
     
    8796        BlogURI uri = BlogManager.instance().createBlogEntry(_user, _subject, _tags, _headers, _text,
    8897                                                             _filenames, localStreams, _fileTypes);
    89         System.err.println("Posted the entry " + uri.toString() + " (archive = " + _archive + ")");
     98        if (_log.shouldLog(Log.DEBUG))
     99            _log.debug("Posted the entry " + uri.toString() + " (archive = " + _archive + ")");
    90100        if ( (uri != null) && (_user.getAllowAccessRemote()) ) {
    91101            PetName pn = _user.getPetNameDB().get(_archive);
    92             System.err.println("Archive to petname? " + pn + " (protocol: " + (pn != null ? pn.getProtocol() : "") + ")");
     102            if (_log.shouldLog(Log.DEBUG))
     103                _log.debug("Archive to petname? " + pn + " (protocol: " + (pn != null ? pn.getProtocol() : "") + ")");
    93104            if ( (pn != null) && ("syndiearchive".equals(pn.getProtocol())) ) {
    94105                RemoteArchiveBean r = new RemoteArchiveBean();
     
    99110                int proxyPort = 4444;
    100111                try { proxyPort = Integer.parseInt(port); } catch (NumberFormatException nfe) {}
    101                 System.err.println("Posting the entry " + uri.toString() + " to " + pn.getLocation());
     112                if (_log.shouldLog(Log.DEBUG))
     113                    _log.debug("Posting the entry " + uri.toString() + " to " + pn.getLocation());
    102114                r.postSelectedEntries(_user, params, proxyHost, proxyPort, pn.getLocation());
    103                 System.err.println("Post status: " + r.getStatus());
     115                if (_log.shouldLog(Log.DEBUG))
     116                    _log.debug("Post status: " + r.getStatus());
    104117            }
    105118        }
     
    108121   
    109122    public void renderPreview(Writer out) throws IOException {
    110         System.out.println("Subject: " + _subject);
    111         System.out.println("Text: " + _text);
    112         System.out.println("Headers: " + _headers);
     123        if (_log.shouldLog(Log.DEBUG))
     124            _log.debug("Subject: " + _subject);
     125        if (_log.shouldLog(Log.DEBUG))
     126            _log.debug("Text: " + _text);
     127        if (_log.shouldLog(Log.DEBUG))
     128            _log.debug("Headers: " + _headers);
    113129        // cache all the _fileStreams into temporary files, storing those files in _localFiles
    114130        // then render the page accordingly with an HTMLRenderer, altered to use a different
     
    116132        cacheAttachments();
    117133        String smlContent = renderSMLContent();
    118         HTMLPreviewRenderer r = new HTMLPreviewRenderer(_filenames, _fileTypes, _localFiles);
     134        HTMLPreviewRenderer r = new HTMLPreviewRenderer(_context, _filenames, _fileTypes, _localFiles);
    119135        r.render(_user, BlogManager.instance().getArchive(), null, smlContent, out, false, true);
    120136        _previewed = true;
     
    150166            in.close();
    151167            _localFiles.add(f);
    152             System.out.println("Caching attachment " + i + " temporarily in "
     168            if (_log.shouldLog(Log.DEBUG))
     169                _log.debug("Caching attachment " + i + " temporarily in "
    153170                               + f.getAbsolutePath() + " w/ " + f.length() + "bytes");
    154171        }
  • apps/syndie/java/src/net/i2p/syndie/web/RSSServlet.java

    rcfee643 r3aba126  
    99import javax.servlet.ServletException;
    1010
     11import net.i2p.I2PAppContext;
    1112import net.i2p.data.*;
    1213import net.i2p.syndie.*;
     
    7475        if (count > 100) count = 100;
    7576       
    76         RSSRenderer r = new RSSRenderer();
     77        RSSRenderer r = new RSSRenderer(I2PAppContext.getGlobalContext());
    7778        for (int i = 0; i < count && i < entries.size(); i++) {
    7879            BlogURI uri = (BlogURI)entries.get(i);
  • apps/syndie/java/src/net/i2p/syndie/web/RemoteArchiveBean.java

    rcfee643 r3aba126  
    1313import net.i2p.syndie.sml.*;
    1414import net.i2p.syndie.*;
     15import net.i2p.util.Log;
    1516
    1617/**
     
    1819 */
    1920public class RemoteArchiveBean {
     21    private I2PAppContext _context;
     22    private Log _log;
    2023    private String _remoteSchema;
    2124    private String _remoteLocation;
     
    2831   
    2932    public RemoteArchiveBean() {
     33        _context = I2PAppContext.getGlobalContext();
     34        _log = _context.logManager().getLog(RemoteArchiveBean.class);
    3035        reinitialize();
    3136    }
     
    312317            _statusMessages.add("Fetch of " + HTMLRenderer.sanitizeString(url) + " successful");
    313318            _fetchIndexInProgress = false;
    314             ArchiveIndex i = new ArchiveIndex(false);
     319            ArchiveIndex i = new ArchiveIndex(I2PAppContext.getGlobalContext(), false);
    315320            try {
    316321                i.load(_archiveFile);
     
    330335                _exportCapable = true;
    331336            } else {
    332                 System.err.println("Header received: [" + key + "] = [" + val + "]");
     337                if (_log.shouldLog(Log.DEBUG))
     338                    _log.debug("Header received: [" + key + "] = [" + val + "]");
    333339            }
    334340        }
     
    367373            }
    368374        } catch (IOException ioe) {
    369             ioe.printStackTrace();
     375            if (_log.shouldLog(Log.WARN))
     376                _log.warn("Error handling metadata", ioe);
    370377        } finally {
    371378            if (in != null) try { in.close(); } catch (IOException ioe) {}
     
    413420                }
    414421            } catch (IOException ioe) {
    415                 ioe.printStackTrace();
     422                if (_log.shouldLog(Log.WARN))
     423                    _log.warn("Error importing", ioe);
    416424            } finally {
    417425                if (in != null) try { in.close(); } catch (IOException ioe) {}
     
    492500                BlogManager.instance().getArchive().regenerateIndex();
    493501            } catch (IOException ioe) {
    494                 ioe.printStackTrace();
     502                if (_log.shouldLog(Log.WARN))
     503                    _log.debug("Error importing", ioe);
    495504                _statusMessages.add("Error importing from " + HTMLRenderer.sanitizeString(url) + ": " + ioe.getMessage());
    496505            } finally {
Note: See TracChangeset for help on using the changeset viewer.