Author: lulabad
Date: 2008-02-10 22:31:11 +0100 (Sun, 10 Feb 2008)
New Revision: 4475

Modified:
   trunk/htroot/Blog.java
   trunk/htroot/BlogComments.java
   trunk/source/de/anomic/data/blogBoard.java
Log:
* some refactoring to Blog
* changed default sort order to reverse (newest first)

Modified: trunk/htroot/Blog.java
===================================================================
--- trunk/htroot/Blog.java      2008-02-10 18:35:28 UTC (rev 4474)
+++ trunk/htroot/Blog.java      2008-02-10 21:31:11 UTC (rev 4475)
@@ -140,12 +140,12 @@
         }
 
         if(hasRights && post.containsKey("delete") && 
post.get("delete").equals("sure")) {
-            page = switchboard.blogDB.read(pagename);
-            final Iterator<String> i = page.comments().iterator();
+            page = switchboard.blogDB.readBlogEntry(pagename);
+            final Iterator<String> i = page.getComments().iterator();
             while(i.hasNext()) {
                 switchboard.blogCommentDB.delete(i.next());
             }
-            switchboard.blogDB.delete(pagename);
+            switchboard.blogDB.deleteBlogEntry(pagename);
             pagename = DEFAULT_PAGE;
         }
 
@@ -169,9 +169,9 @@
             if(pagename.equals(DEFAULT_PAGE)) {
                 pagename = String.valueOf(System.currentTimeMillis());
             } else {
-                page = switchboard.blogDB.read(pagename);
-                comments = page.comments();
-                date = page.date();
+                page = switchboard.blogDB.readBlogEntry(pagename);
+                comments = page.getComments();
+                date = page.getDate();
             }
             final String commentMode = post.get("commentMode", "1");
             final String StrSubject = post.get("subject", "");
@@ -182,7 +182,7 @@
                 subject = StrSubject.getBytes();
             }
 
-            switchboard.blogDB.write(switchboard.blogDB.newEntry(pagename, 
subject, author, ip, date, content, comments, commentMode));
+            
switchboard.blogDB.writeBlogEntry(switchboard.blogDB.newEntry(pagename, 
subject, author, ip, date, content, comments, commentMode));
 
             // create a news message
             final HashMap<String, String> map = new HashMap<String, String>();
@@ -192,7 +192,7 @@
             
yacyCore.newsPool.publishMyNews(yacyNewsRecord.newRecord(yacyNewsPool.CATEGORY_BLOG_ADD,
 map));
         }
 
-        page = switchboard.blogDB.read(pagename); //maybe "if(page == null)"
+        page = switchboard.blogDB.readBlogEntry(pagename); //maybe "if(page == 
null)"
 
         if (post.containsKey("edit")) {
             //edit an entry
@@ -200,10 +200,10 @@
                 try {
                     prop.put("mode", "1"); //edit
                     prop.put("mode_commentMode", page.getCommentMode());
-                    prop.putHTML("mode_author", new 
String(page.author(),"UTF-8"), xml);
-                    prop.put("mode_pageid", page.key());
-                    prop.putHTML("mode_subject", new String(page.subject(), 
"UTF-8"), xml);
-                    prop.put("mode_page-code", new String(page.page(), 
"UTF-8"));
+                    prop.putHTML("mode_author", new 
String(page.getAuthor(),"UTF-8"), xml);
+                    prop.put("mode_pageid", page.getKey());
+                    prop.putHTML("mode_subject", new String(page.getSubject(), 
"UTF-8"), xml);
+                    prop.put("mode_page-code", new String(page.getPage(), 
"UTF-8"));
                 } catch (UnsupportedEncodingException e) {}
             }
             else {
@@ -235,14 +235,14 @@
                 prop.put("mode", "4");
                 prop.put("mode_pageid", pagename);
                 try {
-                    prop.putHTML("mode_author",new String(page.author(), 
"UTF-8"), xml);
+                    prop.putHTML("mode_author",new String(page.getAuthor(), 
"UTF-8"), xml);
                 } catch (UnsupportedEncodingException e) {
-                    prop.putHTML("mode_author",new String(page.author()), xml);
+                    prop.putHTML("mode_author",new String(page.getAuthor()), 
xml);
                 }
                 try {
-                    prop.putHTML("mode_subject",new 
String(page.subject(),"UTF-8"), xml);
+                    prop.putHTML("mode_subject",new 
String(page.getSubject(),"UTF-8"), xml);
                 } catch (UnsupportedEncodingException e) {
-                    prop.putHTML("mode_subject",new String(page.subject()), 
xml);
+                    prop.putHTML("mode_subject",new String(page.getSubject()), 
xml);
                 }
             }
             else prop.put("mode", "3"); //access denied (no rights)
@@ -305,7 +305,7 @@
                 if(0 < start--) continue;
                 putBlogEntry(
                         prop,
-                        switchboard.blogDB.read(pageid),
+                        switchboard.blogDB.readBlogEntry(pageid),
                         address,
                         count++,
                         hasRights,
@@ -342,16 +342,16 @@
     {
         // subject
         try {
-            prop.putHTML("mode_entries_" + number + "_subject", new 
String(entry.subject(),"UTF-8"), xml);
+            prop.putHTML("mode_entries_" + number + "_subject", new 
String(entry.getSubject(),"UTF-8"), xml);
         } catch (UnsupportedEncodingException e) {
-            prop.putHTML("mode_entries_" + number + "_subject", new 
String(entry.subject()), xml);
+            prop.putHTML("mode_entries_" + number + "_subject", new 
String(entry.getSubject()), xml);
         }
 
         // author
         try {
-            prop.putHTML("mode_entries_" + number + "_author", new 
String(entry.author(),"UTF-8"), xml);
+            prop.putHTML("mode_entries_" + number + "_author", new 
String(entry.getAuthor(),"UTF-8"), xml);
         } catch (UnsupportedEncodingException e) {
-            prop.putHTML("mode_entries_" + number + "_author", new 
String(entry.author()), xml);
+            prop.putHTML("mode_entries_" + number + "_author", new 
String(entry.getAuthor()), xml);
         }
 
         // comments
@@ -359,27 +359,27 @@
             prop.put("mode_entries_" + number + "_commentsactive", "0");
         } else {
             prop.put("mode_entries_" + number + "_commentsactive", "1");
-            prop.put("mode_entries_" + number + "_commentsactive_pageid", 
entry.key());
+            prop.put("mode_entries_" + number + "_commentsactive_pageid", 
entry.getKey());
             prop.put("mode_entries_" + number + "_commentsactive_address", 
address);
-            prop.put("mode_entries_" + number + "_commentsactive_comments", 
entry.commentsSize());
+            prop.put("mode_entries_" + number + "_commentsactive_comments", 
entry.getCommentsSize());
         }
 
-        prop.put("mode_entries_" + number + "_date", dateString(entry.date()));
-        prop.put("mode_entries_" + number + "_rfc822date", 
httpc.dateString(entry.date()));
-        prop.put("mode_entries_" + number + "_pageid", entry.key());
+        prop.put("mode_entries_" + number + "_date", 
dateString(entry.getDate()));
+        prop.put("mode_entries_" + number + "_rfc822date", 
httpc.dateString(entry.getDate()));
+        prop.put("mode_entries_" + number + "_pageid", entry.getKey());
         prop.put("mode_entries_" + number + "_address", address);
-        prop.put("mode_entries_" + number + "_ip", entry.ip());
+        prop.put("mode_entries_" + number + "_ip", entry.getIp());
 
         if(xml) {
-            prop.put("mode_entries_" + number + "_page", entry.page());
-            prop.put("mode_entries_" + number + "_timestamp", 
entry.timestamp());
+            prop.put("mode_entries_" + number + "_page", entry.getPage());
+            prop.put("mode_entries_" + number + "_timestamp", 
entry.getTimestamp());
         } else {
-            prop.putWiki("mode_entries_" + number + "_page", entry.page());
+            prop.putWiki("mode_entries_" + number + "_page", entry.getPage());
         }
 
         if(hasRights) {
             prop.put("mode_entries_" + number + "_admin", "1");
-            prop.put("mode_entries_" + number + "_admin_pageid",entry.key());
+            prop.put("mode_entries_" + number + 
"_admin_pageid",entry.getKey());
         } else {
             prop.put("mode_entries_" + number + "_admin", "0");
         }

Modified: trunk/htroot/BlogComments.java
===================================================================
--- trunk/htroot/BlogComments.java      2008-02-10 18:35:28 UTC (rev 4474)
+++ trunk/htroot/BlogComments.java      2008-02-10 21:31:11 UTC (rev 4475)
@@ -126,7 +126,7 @@
             author = StrAuthor.getBytes();
         }
 
-        page = switchboard.blogDB.read(pagename); //maybe "if(page == null)"
+        page = switchboard.blogDB.readBlogEntry(pagename); //maybe "if(page == 
null)"
         
         // comments not allowed
         if (page.getCommentMode() == 0) {
@@ -158,9 +158,9 @@
                     subject = StrSubject.getBytes();
                 }
                 String commentID = String.valueOf(System.currentTimeMillis());
-                BlogEntry blogEntry = switchboard.blogDB.read(pagename);
+                BlogEntry blogEntry = 
switchboard.blogDB.readBlogEntry(pagename);
                 blogEntry.addComment(commentID);
-                switchboard.blogDB.write(blogEntry);
+                switchboard.blogDB.writeBlogEntry(blogEntry);
                 
switchboard.blogCommentDB.write(switchboard.blogCommentDB.newEntry(commentID, 
subject, author, ip, date, content));
                 prop.put("LOCATION","BlogComments.html?page=" + pagename);
 
@@ -171,14 +171,14 @@
                             StrAuthor,
                             yacyCore.seedDB.mySeed().hash,
                             yacyCore.seedDB.mySeed().getName(), 
yacyCore.seedDB.mySeed().hash,
-                            "new blog comment: " + new 
String(blogEntry.subject(),"UTF-8"), content));
+                            "new blog comment: " + new 
String(blogEntry.getSubject(),"UTF-8"), content));
                 } catch (UnsupportedEncodingException e1) {
                     switchboard.messageDB.write(msgEntry = 
switchboard.messageDB.newEntry(
                             "blogComment",
                             StrAuthor,
                             yacyCore.seedDB.mySeed().hash,
                             yacyCore.seedDB.mySeed().getName(), 
yacyCore.seedDB.mySeed().hash,
-                            "new blog comment: " + new 
String(blogEntry.subject()), content));
+                            "new blog comment: " + new 
String(blogEntry.getSubject()), content));
                 }
 
                 messageForwardingViaEmail(env, msgEntry);
@@ -232,30 +232,30 @@
             }
             else {
                 //show 1 blog entry
-                prop.put("mode_pageid", page.key());
+                prop.put("mode_pageid", page.getKey());
                 prop.put("mode_allow_pageid", pagename);
                 try {
-                    prop.putHTML("mode_subject", new 
String(page.subject(),"UTF-8"));
+                    prop.putHTML("mode_subject", new 
String(page.getSubject(),"UTF-8"));
                 } catch (UnsupportedEncodingException e) {
-                    prop.putHTML("mode_subject", new String(page.subject()));
+                    prop.putHTML("mode_subject", new 
String(page.getSubject()));
                 }
                 try {
-                    prop.putHTML("mode_author", new 
String(page.author(),"UTF-8"));
+                    prop.putHTML("mode_author", new 
String(page.getAuthor(),"UTF-8"));
                     prop.putHTML("mode_allow_author", new String(author, 
"UTF-8"));
                 } catch (UnsupportedEncodingException e) {
-                    prop.putHTML("mode_author", new String(page.author()));
+                    prop.putHTML("mode_author", new String(page.getAuthor()));
                     prop.putHTML("mode_allow_author", new String(author));
                 }
-                prop.put("mode_comments", page.commentsSize());
-                prop.put("mode_date", dateString(page.date()));
-                prop.putWiki("mode_page", page.page());
+                prop.put("mode_comments", page.getCommentsSize());
+                prop.put("mode_date", dateString(page.getDate()));
+                prop.putWiki("mode_page", page.getPage());
                 if(hasRights) {
                     prop.put("mode_admin", "1");
-                    prop.put("mode_admin_pageid", page.key());
+                    prop.put("mode_admin_pageid", page.getKey());
                 }
                 //show all commments
                 try {
-                    Iterator<String> i = page.comments().iterator();
+                    Iterator<String> i = page.getComments().iterator();
                     int commentMode = page.getCommentMode();
                     String pageid;
                     blogBoardComments.CommentEntry entry;
@@ -303,11 +303,11 @@
                         prop.put("mode_entries_"+count+"_ip", entry.ip());
                         if(hasRights) {
                             prop.put("mode_entries_"+count+"_admin", "1");
-                            prop.put("mode_entries_"+count+"_admin_pageid", 
page.key());
+                            prop.put("mode_entries_"+count+"_admin_pageid", 
page.getKey());
                             prop.put("mode_entries_"+count+"_admin_commentid", 
pageid);
                             if(!entry.isAllowed()) {
                                 
prop.put("mode_entries_"+count+"_admin_moderate", "1");
-                                
prop.put("mode_entries_"+count+"_admin_moderate_pageid", page.key());
+                                
prop.put("mode_entries_"+count+"_admin_moderate_pageid", page.getKey());
                                 
prop.put("mode_entries_"+count+"_admin_moderate_commentid", pageid);
 
                             }
@@ -320,7 +320,7 @@
                         prop.put("mode_moreentries", "1"); //more entries are 
availible
                         prop.put("mode_moreentries_start", nextstart);
                         prop.put("mode_moreentries_num", num);
-                        prop.put("mode_moreentries_pageid", page.key());
+                        prop.put("mode_moreentries_pageid", page.getKey());
                     }
                     else prop.put("mode_moreentries", "0");
                     if(prev) {
@@ -328,7 +328,7 @@
                         if (prevstart < 0) prevstart = 0;
                         prop.put("mode_preventries_start", prevstart);
                         prop.put("mode_preventries_num", num);
-                        prop.put("mode_preventries_pageid", page.key());
+                        prop.put("mode_preventries_pageid", page.getKey());
                     } else prop.put("mode_preventries", "0");
                 } catch (IOException e) {
 

Modified: trunk/source/de/anomic/data/blogBoard.java
===================================================================
--- trunk/source/de/anomic/data/blogBoard.java  2008-02-10 18:35:28 UTC (rev 
4474)
+++ trunk/source/de/anomic/data/blogBoard.java  2008-02-10 21:31:11 UTC (rev 
4475)
@@ -78,28 +78,24 @@
     public  static final int keyLength = 64;
     private static final int recordSize = 512;
     
-    kelondroMapObjects datbase = null;
+    kelondroMapObjects database = null;
     
     public blogBoard(File actpath, long preloadTime) {
                new File(actpath.getParent()).mkdir();
-        if (datbase == null) {
-            datbase = new kelondroMapObjects(new kelondroDyn(actpath, true, 
true, preloadTime, keyLength, recordSize, '_', 
kelondroNaturalOrder.naturalOrder, true, false, false), 500);
+        if (database == null) {
+            database = new kelondroMapObjects(new kelondroDyn(actpath, true, 
true, preloadTime, keyLength, recordSize, '_', 
kelondroNaturalOrder.naturalOrder, true, false, false), 500);
         }
     }
-    
     public int size() {
-        return datbase.size();
+        return database.size();
     }
-    
     public void close() {
-        datbase.close();
+        database.close();
     }
-
     private static String normalize(String key) {
         if (key == null) return "null";
         return key.trim().toLowerCase();
     }
-
     public static String webalize(String key) {
         if (key == null) return "null";
         key = key.trim().toLowerCase();
@@ -108,11 +104,9 @@
             key = key.substring(0, p) + "%20" + key.substring(p +1);
         return key;
     }
-    
     public String guessAuthor(String ip) {
         return wikiBoard.guessAuthor(ip);
     }
-
     public BlogEntry newEntry(String key, byte[] subject, byte[] author, 
String ip, Date date, byte[] page, ArrayList<String> comments, String 
commentMode) {
         return new BlogEntry(normalize(key), subject, author, ip, date, page, 
comments, commentMode);
     }
@@ -124,152 +118,179 @@
        
            public BlogEntry(String nkey, byte[] subject, byte[] author, String 
ip, Date date, byte[] page, ArrayList<String> comments, String commentMode) {
                    record = new HashMap<String, String>();
-                   key = nkey;
-                   if (key.length() > keyLength) key = key.substring(0, 
keyLength);
-                   if(date == null) date = new Date();
-                   record.put("date", serverDate.formatShortSecond(date));
-                   if (subject == null) record.put("subject","");
-                   else record.put("subject", 
kelondroBase64Order.enhancedCoder.encode(subject));
-                   if (author == null) record.put("author","");
-                   else record.put("author", 
kelondroBase64Order.enhancedCoder.encode(author));
-                   if ((ip == null) || (ip.length() == 0)) ip = "";
-                   record.put("ip", ip);
-               if (page == null) record.put("page", "");
-               else record.put("page", 
kelondroBase64Order.enhancedCoder.encode(page));
-               if (comments == null) record.put("comments", 
listManager.collection2string(new ArrayList<String>()));
-               else record.put("comments", 
listManager.collection2string(comments));
-               if (commentMode == null) record.put("commentMode", "1");
-               else record.put("commentMode", commentMode);
+                   setKey(nkey);
+                   setDate(date);
+                   setSubject(subject);
+                   setAuthor(author);
+                   setIp(ip);
+                   setPage(page);
+                   setComments(comments);
+                   setCommentMode(commentMode);
                    
                // TODO: implement this function
                record.put("privacy", "public");
                
                wikiBoard.setAuthor(ip, new String(author));
                }
-       
                private BlogEntry(String key, HashMap<String, String> record) {
                    this.key = key;
                    this.record = record;
                if (this.record.get("comments")==null) 
this.record.put("comments", listManager.collection2string(new 
ArrayList<String>()));
                if (this.record.get("commentMode")==null || 
this.record.get("commentMode").equals("")) this.record.put("commentMode", "1");
                }
-               
-               public String key() {
+               private void setKey(String key) {
+            if (key.length() > keyLength) 
+                this.key = key.substring(0, keyLength);
+            this.key = key;
+               }
+               public String getKey() {
                        return key;
                }
-       
-               public byte[] subject() {
+               public byte[] getSubject() {
                        String m = record.get("subject");
                    if (m == null) return new byte[0];
                    byte[] b = kelondroBase64Order.enhancedCoder.decode(m, 
"de.anomic.data.blogBoard.subject()");
                    if (b == null) return "".getBytes();
                    return b;
                }
-       
-               public Date date() {
+               private void setSubject(byte[] subject) {
+            if (subject == null) 
+                record.put("subject","");
+            else 
+                record.put("subject", 
kelondroBase64Order.enhancedCoder.encode(subject));
+               }
+               public Date getDate() {
                    try {
-                       String c = record.get("date");
-                       if (c == null) {
-                           serverLog.logFinest("Blog", "ERROR: date field 
missing in blogBoard");
-                   //System.out.println("DEBUG - ERROR: date field missing in 
blogBoard");
-                   return new Date();
-               }
-                       return serverDate.parseShortSecond(c);
+                       String date = record.get("date");
+                       if (date == null) {
+                           serverLog.logFinest("Blog", "ERROR: date field 
missing in blogBoard");
+                   return new Date();
+               }
+                   return serverDate.parseShortSecond(date);
                    } catch (ParseException e) {
                        return new Date();
                    }
                }
-               
-               public String timestamp() {
-                       String c = record.get("date");
-                       if (c == null) {
+               private void setDate(Date date) {
+            if(date == null) 
+                date = new Date();
+            record.put("date", serverDate.formatShortSecond(date));
+               }
+               public String getTimestamp() {
+                       String timestamp = record.get("date");
+                       if (timestamp == null) {
                            serverLog.logFinest("Blog", "ERROR: date field 
missing in blogBoard");
-                       //System.out.println("DEBUG - ERROR: date field missing 
in blogBoard");
                        return serverDate.formatShortSecond();
                        }
-                       return c;
+                       return timestamp;
                }
-               
-           public byte[] author() {
-               String m = record.get("author");
-               if (m == null) return new byte[0];
-               byte[] b = kelondroBase64Order.enhancedCoder.decode(m, 
"de.anomic.data.blogBoard.author()");
+           public byte[] getAuthor() {
+               String author = record.get("author");
+               if (author == null) return new byte[0];
+               byte[] b = kelondroBase64Order.enhancedCoder.decode(author, 
"de.anomic.data.blogBoard.author()");
                if (b == null) return "".getBytes();
                return b;
            }
-           
-           public int commentsSize() {
+           private void setAuthor(byte[] author) {
+            if (author == null) 
+                record.put("author","");
+            else 
+                record.put("author", 
kelondroBase64Order.enhancedCoder.encode(author));
+           }
+           public int getCommentsSize() {
             // This ist a Bugfix for Version older than 4443.
             if(record.get("comments").startsWith(",")) {
                     record.put("comments", 
record.get("comments").substring(1));
-                    write(this);
+                    writeBlogEntry(this);
             }
-               ArrayList<String> m = 
listManager.string2arraylist(record.get("comments"));
-               return m.size();
+               ArrayList<String> commentsize = 
listManager.string2arraylist(record.get("comments"));
+               return commentsize.size();
            }
-       
-           public ArrayList<String> comments() {
-               ArrayList<String> m = 
listManager.string2arraylist(record.get("comments"));
-               return m;
+           public ArrayList<String> getComments() {
+               ArrayList<String> comments = 
listManager.string2arraylist(record.get("comments"));
+               return comments;
            }
-       
-               public String ip() {
-                   String a = record.get("ip");
-                   if (a == null) return "127.0.0.1";
-                   return a;
+           private void setComments(ArrayList<String> comments) {
+            if (comments == null) 
+                record.put("comments", listManager.collection2string(new 
ArrayList<String>()));
+            else 
+                record.put("comments", 
listManager.collection2string(comments));
+           }
+           public String getIp() {
+                   String ip = record.get("ip");
+                   if (ip == null) return "127.0.0.1";
+                   return ip;
                }
-       
-               public byte[] page() {
-                   String m = record.get("page");
-                   if (m == null) return new byte[0];
-                   byte[] b = kelondroBase64Order.enhancedCoder.decode(m, 
"de.anomic.data.blogBoard.page()");
-                   if (b == null) return "".getBytes();
-                   return b;
+               private void setIp(String ip) {
+            if ((ip == null) || (ip.length() == 0)) 
+                ip = "";
+            record.put("ip", ip);
+               }
+               public byte[] getPage() {
+                   String page = record.get("page");
+                   if (page == null) return new byte[0];
+                   byte[] page_as_byte = 
kelondroBase64Order.enhancedCoder.decode(page, 
"de.anomic.data.blogBoard.page()");
+                   if (page_as_byte == null) return "".getBytes();
+                   return page_as_byte;
                }        
-       
-           public void addComment(String commentID) {
+               private void setPage(byte[] page) {
+            if (page == null) 
+                record.put("page", "");
+            else 
+                record.put("page", 
kelondroBase64Order.enhancedCoder.encode(page));
+               }
+               public void addComment(String commentID) {
                ArrayList<String> comments = 
listManager.string2arraylist(record.get("comments"));
                comments.add(commentID);
                record.put("comments", listManager.collection2string(comments));
            }
-           
            public boolean removeComment(String commentID) {
                ArrayList<String> comments = 
listManager.string2arraylist(record.get("comments"));
                boolean success = comments.remove(commentID);
                record.put("comments", listManager.collection2string(comments));
                return success;
            }
-           
            public int getCommentMode(){
                return Integer.parseInt(record.get("commentMode"));
            }
+           private void setCommentMode(String mode) {
+            if (mode == null) 
+                record.put("commentMode", "1");
+            else 
+                record.put("commentMode", mode);
+           }
            public boolean isPublic() {
-               return true;
+               String privacy = record.get("privacy");
+               if (privacy == null)
+                   return true;
+               if(privacy.equalsIgnoreCase("public"))
+                   return true;
+               return false;
            }
     }
-
-    public String write(BlogEntry page) {
-        // writes a new page and returns key
+    /*
+     * writes a new page and return the key
+     */
+    public String writeBlogEntry(BlogEntry page) {
         try {
-            datbase.set(page.key, page.record);
+            database.set(page.key, page.record);
             return page.key;
         } catch (IOException e) {
             return null;
         }
     }
-
-    public BlogEntry read(String key) {
-        return read(key, datbase);
+    public BlogEntry readBlogEntry(String key) {
+        return readBlogEntry(key, database);
     }
-
-    private BlogEntry read(String key, kelondroMapObjects base) {
+    private BlogEntry readBlogEntry(String key, kelondroMapObjects base) {
        key = normalize(key);
-        if (key.length() > keyLength) key = key.substring(0, keyLength);
+        if (key.length() > keyLength) 
+            key = key.substring(0, keyLength);
         HashMap<String, String> record = base.getMap(key);
-        if (record == null) return newEntry(key, "".getBytes(), 
"anonymous".getBytes(), "127.0.0.1", new Date(), "".getBytes(), null, null);
+        if (record == null) 
+            return newEntry(key, "".getBytes(), "anonymous".getBytes(), 
"127.0.0.1", new Date(), "".getBytes(), null, null);
         return new BlogEntry(key, record);
     }
-    
     public boolean importXML(String input) {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        try {
@@ -282,7 +303,6 @@
                
        return false;
     }
-    
     private boolean parseXMLimport(Document doc) {
        if(!doc.getDocumentElement().getTagName().equals("blog"))
                return false;
@@ -342,20 +362,18 @@
                                page = StrPage.getBytes();
                        }
 
-               write (newEntry(key, subject, author, ip, date, page, null, 
null));
+               writeBlogEntry (newEntry(key, subject, author, ip, date, page, 
null, null));
        }
        return true;
     }
-    
-    public void delete(String key) {
+    public void deleteBlogEntry(String key) {
        key = normalize(key);
        try {
-                       datbase.remove(key);
+                       database.remove(key);
                } catch (IOException e) { }
     }
-    
     public Iterator<String> keys(boolean up) throws IOException {
-        return datbase.keys(up, false);
+        return database.keys(up, false);
     }
     /**
      * Comparator to sort objects of type Blog according to their timestamps
@@ -368,30 +386,32 @@
          * @param newestFirst newest first, or oldest first?
          */
         public BlogComparator(boolean newestFirst){
-            this.newestFirst=newestFirst;
+            this.newestFirst = newestFirst;
         }
         
         public int compare(String obj1, String obj2) {
-            BlogEntry bm1=read(obj1);
-            BlogEntry bm2=read(obj2);
-            if(bm1==null || bm2==null)
-                return 0; //XXX: i think this should not happen? maybe this 
needs further tracing of the bug
+            BlogEntry blogEntry1=readBlogEntry(obj1);
+            BlogEntry blogEntry2=readBlogEntry(obj2);
+            if(blogEntry1 == null || blogEntry2 == null)
+                return 0;
             if(this.newestFirst){
-                if(Long.valueOf(bm2.timestamp()) - 
Long.valueOf(bm1.timestamp()) >0) return 1;
+                if(Long.valueOf(blogEntry2.getTimestamp()) - 
Long.valueOf(blogEntry1.getTimestamp()) >0) 
+                    return 1;
                 return -1;
             }
-            if(Long.valueOf(bm1.timestamp()) - Long.valueOf(bm2.timestamp()) 
>0) return 1;
+            if(Long.valueOf(blogEntry1.getTimestamp()) - 
Long.valueOf(blogEntry2.getTimestamp()) >0) 
+                return 1;
             return -1;
         }
     }
     public Iterator<String> getBlogIterator(boolean priv){
-        TreeSet<String> set=new TreeSet<String>(new BlogComparator(false));
-        Iterator<BlogEntry> it=blogIterator(true);
-        BlogEntry bm;
-        while(it.hasNext()){
-            bm=(BlogEntry)it.next();
-            if(priv || bm.isPublic()){
-                set.add(bm.key());
+        TreeSet<String> set = new TreeSet<String>(new BlogComparator(true));
+        Iterator<BlogEntry> iterator = blogIterator(priv);
+        BlogEntry blogEntry;
+        while(iterator.hasNext()){
+            blogEntry=(BlogEntry)iterator.next();
+            if(priv || blogEntry.isPublic()){
+                set.add(blogEntry.getKey());
             }
         }
         return set.iterator();
@@ -411,7 +431,7 @@
         blogBoard.BlogEntry nextEntry;
         public BlogIterator(boolean up) throws IOException {
             //flushBookmarkCache(); //XXX: this will cost performance
-            this.blogIter = blogBoard.this.datbase.keys(up, false);
+            this.blogIter = blogBoard.this.database.keys(up, false);
             this.nextEntry = null;
         }
         
@@ -426,7 +446,7 @@
         
         public BlogEntry next() {
             try {
-                return read((String) this.blogIter.next());
+                return readBlogEntry((String) this.blogIter.next());
             } catch (kelondroException e) {
                 //resetDatabase();
                 return null;
@@ -436,8 +456,8 @@
         public void remove() {
             if (this.nextEntry != null) {
                 try {
-                    Object blogKey = this.nextEntry.key();
-                    if (blogKey != null) delete((String) blogKey);
+                    Object blogKey = this.nextEntry.getKey();
+                    if (blogKey != null) deleteBlogEntry((String) blogKey);
                 } catch (kelondroException e) {
                     //resetDatabase();
                 }

_______________________________________________
YaCy-svn mailing list
YaCy-svn@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/yacy-svn

Antwort per Email an