Author: lulabad
Date: 2008-02-16 10:32:29 +0100 (Sat, 16 Feb 2008)
New Revision: 4483

Modified:
   trunk/htroot/Blog.html
   trunk/htroot/Blog.java
   trunk/htroot/BlogComments.html
   trunk/source/de/anomic/data/blogBoard.java
   trunk/source/de/anomic/data/blogBoardComments.java
Log:
* removed single Blogview, now links direct to BlogComments.html
* some other small changes

Modified: trunk/htroot/Blog.html
===================================================================
--- trunk/htroot/Blog.html      2008-02-16 00:38:47 UTC (rev 4482)
+++ trunk/htroot/Blog.html      2008-02-16 09:32:29 UTC (rev 4483)
@@ -19,7 +19,7 @@
     <!-- 0: viewing -->
     #{entries}#
     <div class="Post">
-      <h2 class="PostSubject"><a 
href="Blog.html?page=#[pageid]#">#[subject]#</a></h2>
+      <h2 class="PostSubject"><a 
href="BlogComments.html?page=#[pageid]#">#[subject]#</a></h2>
       <div class="PostBody">#[page]#</div>
       <p class="PostInfo">
         #[date]# | by #[author]# #(commentsactive)#::| <a 
href="BlogComments.html?page=#[pageid]#">#[comments]# 
Comments</a>#(/commentsactive)#

Modified: trunk/htroot/Blog.java
===================================================================
--- trunk/htroot/Blog.java      2008-02-16 00:38:47 UTC (rev 4482)
+++ trunk/htroot/Blog.java      2008-02-16 09:32:29 UTC (rev 4483)
@@ -291,7 +291,6 @@
             final boolean hasRights,
             final boolean xml) 
     {
-            //final Iterator<String> i = switchboard.blogDB.keys(false);
             final Iterator<String> i = 
switchboard.blogDB.getBlogIterator(false);
             String pageid;
             int count = 0;                        //counts how many entries 
are shown to the user

Modified: trunk/htroot/BlogComments.html
===================================================================
--- trunk/htroot/BlogComments.html      2008-02-16 00:38:47 UTC (rev 4482)
+++ trunk/htroot/BlogComments.html      2008-02-16 09:32:29 UTC (rev 4483)
@@ -9,7 +9,7 @@
     #(mode)#
       <!-- 0: viewing -->
       <div class="Post">
-        <h2 class="PostSubject"><a 
href="Blog.html?page=#[pageid]#">#[subject]#</a></h2>
+        <h2 class="PostSubject"><a 
href="BlogComments.html?page=#[pageid]#">#[subject]#</a></h2>
         <div class="PostBody">#[page]#</div>
         <p class="PostInfo">
           #[date]# | by #[author]# | <a 
href="BlogComments.html?page=#[pageid]#">#[comments]# Comments</a>
@@ -49,16 +49,17 @@
         <p>Comments are not allowed for this posting!</p>
         </fieldset>
       ::
+        <h2>Comment on this Blog</h2>
         <form action="BlogComments.html" method="post" 
enctype="multipart/form-data" accept-charset="UTF-8">
           <fieldset>
             <dl>
               <dt><label for="author">Author:</label></dt>
               <dd>
-                <input name="author" id="author" type="text" size="20" 
maxlength="80" value="#[author]#" />
+                <input name="author" id="author" type="text" size="80" 
maxlength="80" value="#[author]#" />
               </dd>
               <dt><label for="subject">Subject:</label></dt>
               <dd>
-                <input name="subject" id="subject" type="text" size="20" 
maxlength="80" value="" />
+                <input name="subject" id="subject" type="text" size="80" 
maxlength="80" value="" />
               </dd>
               <dt><label for="content">Text:</label></dt>
               <dd>
@@ -92,22 +93,22 @@
           <dl>
             <dt><label for="author">Author:</label></dt>
             <dd>
-              <input name="author" id="author" type="text" size="20" 
maxlength="80" value="#[author]#" />
+              <input name="author" id="author" type="text" size="80" 
maxlength="80" value="#[author]#" />
             </dd>
             <dt><label for="subject">Subject:</label></dt>
             <dd>
-              <input name="subject" id="subject" type="text" size="20" 
maxlength="80" value="#[subject]#" />
+              <input name="subject" id="subject" type="text" size="80" 
maxlength="80" value="#[subject]#" />
             </dd>
             <dt><label for="content">Text:</label></dt>
             <dd>
-              <textarea name="content" id="conten      t" cols="80" 
rows="12">#[page-code]#</textarea>
+              <textarea name="content" id="content" cols="80" 
rows="12">#[page-code]#</textarea>
               <p class="help">
                 You can use <a href="WikiHelp.html" 
onclick="window.open('WikiHelp.html','WikiHelp','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=640,height=480');return
 false;">Yacy-Wiki Code</a> here.
               </p>
             </dd>
           </dl>
           <input type="hidden" name="page" value="#[pageid]#" />
-          <input type="text" name="page" value="#[pageid]#" />
+          <!-- <input type="text" name="page" value="#[pageid]#" /> -->
           <input type="submit" name="submit" value="Submit" />
           <input type="submit" name="preview" value="Preview" />
           <input type="submit" name="view" value="Discard" />

Modified: trunk/source/de/anomic/data/blogBoard.java
===================================================================
--- trunk/source/de/anomic/data/blogBoard.java  2008-02-16 00:38:47 UTC (rev 
4482)
+++ trunk/source/de/anomic/data/blogBoard.java  2008-02-16 09:32:29 UTC (rev 
4483)
@@ -123,163 +123,6 @@
         return new BlogEntry(normalize(key), subject, author, ip, date, page, 
comments, commentMode);
     }
 
-    public class BlogEntry {
-       
-               String key;
-           HashMap<String, String> record;
-       
-           public BlogEntry(String nkey, byte[] subject, byte[] author, String 
ip, Date date, byte[] page, ArrayList<String> comments, String commentMode) {
-                   record = new HashMap<String, String>();
-                   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");
-               }
-               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[] 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;
-               }
-               private void setSubject(byte[] subject) {
-            if (subject == null) 
-                record.put("subject","");
-            else 
-                record.put("subject", 
kelondroBase64Order.enhancedCoder.encode(subject));
-               }
-               public Date getDate() {
-                   try {
-                       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();
-                   }
-               }
-               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");
-                       return serverDate.formatShortSecond();
-                       }
-                       return timestamp;
-               }
-           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;
-           }
-           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));
-                    writeBlogEntry(this);
-            }
-               ArrayList<String> commentsize = 
listManager.string2arraylist(record.get("comments"));
-               return commentsize.size();
-           }
-           public ArrayList<String> getComments() {
-               ArrayList<String> comments = 
listManager.string2arraylist(record.get("comments"));
-               return comments;
-           }
-           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;
-               }
-               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;
-               }        
-               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() {
-               String privacy = record.get("privacy");
-               if (privacy == null)
-                   return true;
-               if(privacy.equalsIgnoreCase("public"))
-                   return true;
-               return false;
-           }
-    }
     /*
      * writes a new page and return the key
      */
@@ -477,4 +320,168 @@
         }
     }
  
+    public class BlogEntry {
+        
+        String key;
+        HashMap<String, String> record;
+    
+        public BlogEntry(String nkey, byte[] subject, byte[] author, String 
ip, Date date, byte[] page, ArrayList<String> comments, String commentMode) {
+            record = new HashMap<String, String>();
+            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");
+        }
+        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[] 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;
+        }
+        private void setSubject(byte[] subject) {
+            if (subject == null) 
+                record.put("subject","");
+            else 
+                record.put("subject", 
kelondroBase64Order.enhancedCoder.encode(subject));
+        }
+        public Date getDate() {
+            try {
+                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();
+            }
+        }
+        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");
+                return serverDate.formatShortSecond();
+            }
+            return timestamp;
+        }
+        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;
+        }
+        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));
+                    writeBlogEntry(this);
+            }
+            ArrayList<String> commentsize = 
listManager.string2arraylist(record.get("comments"));
+            return commentsize.size();
+        }
+        public ArrayList<String> getComments() {
+            ArrayList<String> comments = 
listManager.string2arraylist(record.get("comments"));
+            return comments;
+        }
+        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;
+        }
+        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;
+        }        
+        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;
+        }
+        /**
+         * returns the comment mode
+         * 0 - no comments allowed
+         * 1 - comments allowed
+         * 2 - comments moderated
+         * @return comment mode
+         */
+        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() {
+            String privacy = record.get("privacy");
+            if (privacy == null)
+                return true;
+            if(privacy.equalsIgnoreCase("public"))
+                return true;
+            return false;
+        }
+    }
 }

Modified: trunk/source/de/anomic/data/blogBoardComments.java
===================================================================
--- trunk/source/de/anomic/data/blogBoardComments.java  2008-02-16 00:38:47 UTC 
(rev 4482)
+++ trunk/source/de/anomic/data/blogBoardComments.java  2008-02-16 09:32:29 UTC 
(rev 4483)
@@ -81,35 +81,28 @@
     static {
         SimpleFormatter.setTimeZone(TimeZone.getTimeZone("GMT"));
     }
-
     private kelondroMapObjects database = null;
-    
     public blogBoardComments(File actpath, long preloadTime) {
                new File(actpath.getParent()).mkdir();
         if (database == null) {
             database = new kelondroMapObjects(new kelondroDyn(actpath, true, 
true, preloadTime, keyLength, recordSize, '_', 
kelondroNaturalOrder.naturalOrder, false, false, false), 500);
         }
     }
-    
     public int size() {
         return database.size();
     }
-    
     public void close() {
         database.close();
     }
-
     private static String dateString(Date date) {
         synchronized (SimpleFormatter) {
             return SimpleFormatter.format(date);
         }
     }
-
     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();
@@ -118,138 +111,12 @@
             key = key.substring(0, p) + "%20" + key.substring(p +1);
         return key;
     }
-    
     public String guessAuthor(String ip) {
         return wikiBoard.guessAuthor(ip);
     }
-
     public CommentEntry newEntry(String key, byte[] subject, byte[] author, 
String ip, Date date, byte[] page) {
         return new CommentEntry(normalize(key), subject, author, ip, date, 
page);
     }
-
-    public class CommentEntry {
-       
-       String key;
-        HashMap<String, String> record;
-    
-        public CommentEntry(String nkey, byte[] subject, byte[] author, String 
ip, Date date, byte[] page) {
-           record = new HashMap<String, String>();
-           
-           setKey(nkey);
-           setDate(date);
-           setSubject(subject);
-           setAuthor(author);
-           setIp(ip);
-           setPage(page);
-           
-            wikiBoard.setAuthor(ip, new String(author));
-       }
-    
-       private CommentEntry(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>()));
-       }
-       
-       public String getKey() {
-               return key;
-       }
-       private void setKey(String var) {
-           key = var;
-            if (key.length() > keyLength) 
-                key = var.substring(0, keyLength);
-       }
-       private void setSubject(byte[] subject) {
-            if (subject == null) 
-                record.put("subject","");
-            else 
-                record.put("subject", 
kelondroBase64Order.enhancedCoder.encode(subject));
-       }
-       public byte[] getSubject() {
-               String subject = (String) record.get("subject");
-           if (subject == null) return new byte[0];
-           byte[] subject_bytes = 
kelondroBase64Order.enhancedCoder.decode(subject, 
"de.anomic.data.blogBoardComments.subject()");
-           if (subject_bytes == null) return "".getBytes();
-           return subject_bytes;
-       }
-       private void setDate(Date date) {
-            if(date == null) 
-                date = new Date(); 
-            record.put("date", dateString(date));
-       }
-       public Date getDate() {
-           try {
-                       String date = (String) record.get("date");
-                       if (date == null) {
-                           serverLog.logFinest("Blog", "ERROR: date field 
missing in blogBoard");
-                    return new Date();
-                }
-                synchronized (SimpleFormatter) {
-                    return SimpleFormatter.parse(date);
-                }
-           } catch (ParseException e) {
-               return new Date();
-           }
-       }
-       
-       public String getTimestamp() {
-               String timestamp = (String) record.get("date");
-               if (timestamp == null) {
-                   serverLog.logFinest("Blog", "ERROR: date field missing in 
blogBoard");
-               return dateString(new Date());
-               }
-               return timestamp;
-       }
-       private void setAuthor(byte[] author) {
-            if (author == null) 
-                record.put("author","");
-            else 
-                record.put("author", 
kelondroBase64Order.enhancedCoder.encode(author));
-       }
-        public byte[] getAuthor() {
-            String author = (String) record.get("author");
-            if (author == null) 
-                return new byte[0];
-            byte[] author_byte = 
kelondroBase64Order.enhancedCoder.decode(author, 
"de.anomic.data.blogBoardComments.author()");
-            if (author_byte == null) 
-                return "".getBytes();
-            return author_byte;
-        }
-       private void setIp(String ip) {
-            if ((ip == null) || (ip.length() == 0)) 
-                ip = "";
-            record.put("ip", ip);
-       }
-       public String getIp() {
-           String ip = (String) record.get("ip");
-           if (ip == null) 
-               return "127.0.0.1";
-           return ip;
-       }
-       private void setPage(byte[] page) {
-            if (page == null) 
-                record.put("page", "");
-            else 
-                record.put("page", 
kelondroBase64Order.enhancedCoder.encode(page));
-       }
-       public byte[] getPage() {
-           String page = (String) record.get("page");
-           if (page == null) 
-               return new byte[0];
-           byte[] page_byte = kelondroBase64Order.enhancedCoder.decode(page, 
"de.anomic.data.blogBoardComments.page()");
-           if (page_byte == null) 
-               return "".getBytes();
-           return page_byte;
-       }        
-        public boolean isAllowed() {
-            return (record.get("moderated") != null) && 
record.get("moderated").equals("true");
-        } 
-        public void allow() {
-            record.put("moderated", "true");
-        } 
-    
-    }
-
     public String write(CommentEntry page) {
         // writes a new page and returns key
        try {
@@ -259,12 +126,10 @@
            return null;
        }
     }
-
     public CommentEntry read(String key) {
         //System.out.println("DEBUG: read from blogBoardComments");
         return read(key, database);
     }
-
     private CommentEntry read(String key, kelondroMapObjects base) {
         key = normalize(key);
         if (key.length() > keyLength) key = key.substring(0, keyLength);
@@ -272,20 +137,6 @@
         if (record == null) return newEntry(key, "".getBytes(), 
"anonymous".getBytes(), "127.0.0.1", new Date(), "".getBytes());
         return new CommentEntry(key, record);
     }
-    
-/*    private CommentEntry read(String key, kelondroMapObjects base) {
-        key = normalize(key);
-        if (key.length() > keyLength) key = key.substring(0, keyLength);
-        CommentEntry record = null;
-        try {
-            record = (CommentEntry) base.get(key);
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-        if (record == null) return newEntry(key, "".getBytes(), 
"anonymous".getBytes(), "127.0.0.1", new Date(), "".getBytes());
-        return new CommentEntry(key, record.record);
-    }*/
-    
     public boolean importXML(String input) {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        try {
@@ -298,7 +149,6 @@
                
        return false;
     }
-    
     private boolean parseXMLimport(Document doc) {
        if(!doc.getDocumentElement().getTagName().equals("blog"))
                return false;
@@ -362,16 +212,143 @@
        }
        return true;
     }
-    
     public void delete(String key) {
        key = normalize(key);
        try {
                        database.remove(key);
                } catch (IOException e) { }
     }
-    
     public Iterator<String> keys(boolean up) throws IOException {
         return database.keys(up, false);
     }
 
+    public class CommentEntry {
+        
+        String key;
+        HashMap<String, String> record;
+    
+        public CommentEntry(String nkey, byte[] subject, byte[] author, String 
ip, Date date, byte[] page) {
+            record = new HashMap<String, String>();
+            
+            setKey(nkey);
+            setDate(date);
+            setSubject(subject);
+            setAuthor(author);
+            setIp(ip);
+            setPage(page);
+            
+            wikiBoard.setAuthor(ip, new String(author));
+        }
+    
+        private CommentEntry(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>()));
+        }
+        
+        public String getKey() {
+            return key;
+        }
+        private void setKey(String var) {
+            key = var;
+            if (key.length() > keyLength) 
+                key = var.substring(0, keyLength);
+        }
+        private void setSubject(byte[] subject) {
+            if (subject == null) 
+                record.put("subject","");
+            else 
+                record.put("subject", 
kelondroBase64Order.enhancedCoder.encode(subject));
+        }
+        public byte[] getSubject() {
+            String subject = (String) record.get("subject");
+            if (subject == null) return new byte[0];
+            byte[] subject_bytes = 
kelondroBase64Order.enhancedCoder.decode(subject, 
"de.anomic.data.blogBoardComments.subject()");
+            if (subject_bytes == null) return "".getBytes();
+            return subject_bytes;
+        }
+        private void setDate(Date date) {
+            if(date == null) 
+                date = new Date(); 
+            record.put("date", dateString(date));
+        }
+        public Date getDate() {
+            try {
+                String date = (String) record.get("date");
+                if (date == null) {
+                    serverLog.logFinest("Blog", "ERROR: date field missing in 
blogBoard");
+                    return new Date();
+                }
+                synchronized (SimpleFormatter) {
+                    return SimpleFormatter.parse(date);
+                }
+            } catch (ParseException e) {
+                return new Date();
+            }
+        }
+        
+        public String getTimestamp() {
+            String timestamp = (String) record.get("date");
+            if (timestamp == null) {
+                serverLog.logFinest("Blog", "ERROR: date field missing in 
blogBoard");
+                return dateString(new Date());
+            }
+            return timestamp;
+        }
+        private void setAuthor(byte[] author) {
+            if (author == null) 
+                record.put("author","");
+            else 
+                record.put("author", 
kelondroBase64Order.enhancedCoder.encode(author));
+        }
+        public byte[] getAuthor() {
+            String author = (String) record.get("author");
+            if (author == null) 
+                return new byte[0];
+            byte[] author_byte = 
kelondroBase64Order.enhancedCoder.decode(author, 
"de.anomic.data.blogBoardComments.author()");
+            if (author_byte == null) 
+                return "".getBytes();
+            return author_byte;
+        }
+        private void setIp(String ip) {
+            if ((ip == null) || (ip.length() == 0)) 
+                ip = "";
+            record.put("ip", ip);
+        }
+        public String getIp() {
+            String ip = (String) record.get("ip");
+            if (ip == null) 
+                return "127.0.0.1";
+            return ip;
+        }
+        private void setPage(byte[] page) {
+            if (page == null) 
+                record.put("page", "");
+            else 
+                record.put("page", 
kelondroBase64Order.enhancedCoder.encode(page));
+        }
+        public byte[] getPage() {
+            String page = (String) record.get("page");
+            if (page == null) 
+                return new byte[0];
+            byte[] page_byte = kelondroBase64Order.enhancedCoder.decode(page, 
"de.anomic.data.blogBoardComments.page()");
+            if (page_byte == null) 
+                return "".getBytes();
+            return page_byte;
+        }        
+        /**
+         * Is the comment allowed? 
+         * this is possible for moderated blog entry only and means 
+         * the administrator has explicit allowed the comment.
+         * @return 
+         */
+        public boolean isAllowed() {
+            return (record.get("moderated") != null) && 
record.get("moderated").equals("true");
+        } 
+        public void allow() {
+            record.put("moderated", "true");
+        } 
+    
+    }
+
 }

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

Antwort per Email an