Author: bback
Date: 2006-02-11 19:24:36 +0000 (Sat, 11 Feb 2006)
New Revision: 8018

Removed:
   trunk/apps/frost-0.7/source/frost/messaging/MessageHashes.java
   trunk/apps/frost-0.7/source/frost/messaging/MessageHashesDAO.java
   trunk/apps/frost-0.7/source/frost/messaging/MessageHashesHsqldbDAO.java
   trunk/apps/frost-0.7/source/frost/messaging/MessageHashesXmlDAO.java
   trunk/apps/frost-0.7/source/frost/messaging/MessagingManager.java
Log:
remove old files

Deleted: trunk/apps/frost-0.7/source/frost/messaging/MessageHashes.java
===================================================================
--- trunk/apps/frost-0.7/source/frost/messaging/MessageHashes.java      
2006-02-11 19:22:16 UTC (rev 8017)
+++ trunk/apps/frost-0.7/source/frost/messaging/MessageHashes.java      
2006-02-11 19:24:36 UTC (rev 8018)
@@ -1,102 +0,0 @@
-/*
- MessageHashes.java / Frost
- Copyright (C) 2003  Jan-Thomas Czornack <jantho at users.sourceforge.net>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package frost.messaging;
-
-import java.util.*;
-
-import frost.storage.*;
-
-/**
- * This class contains the hashes of all the messages. It is used to check
- * if a message is a duplicate of those we already have a local copy of.
- * Class maintains a maximum of MAX_HASHES digests, eldest entries are
- * removed if a new entry is added.
- */
-public class MessageHashes implements Savable {
-
-//     private static Logger logger = 
Logger.getLogger(MessageHashes.class.getName());
-    
-    private final static int MAX_HASHES = 3000; // 30 new files for 100 boards 
per day, is this enough?
-
-    private final OwnLinkedHashMap hashesMap = new OwnLinkedHashMap(); // uses 
insertion order, load/save care about this  
-    
-    private class OwnLinkedHashMap extends LinkedHashMap {
-        public OwnLinkedHashMap() {
-            super(MAX_HASHES); // initialCapacity
-        }
-        protected boolean removeEldestEntry(Map.Entry eldest) {
-            return size() > MAX_HASHES; // let remove eldest if list is full
-        }
-    }
-    
-       /**
-        * This method initializes the instance of MessageHashes and reads its 
contents
-        * from disk.
-        * @throws StorageException if there was any error while initializing 
the instance.
-        */
-       public void initialize() throws StorageException {
-               MessageHashesDAO hashesDAO = 
DAOFactory.getFactory(DAOFactory.XML).getMessageHashesDAO();
-               if (!hashesDAO.exists()) {
-                       // The storage doesn't exist yet. We create it.
-                       hashesDAO.create();
-               } else {
-                       // Storage exists. Load from it.
-                       hashesDAO.load(this);
-               }
-       }
-
-       /**
-        * This method saves to disk the contents of the instance of 
MessageHashes.
-        * Its implementation is thread safe.
-        * @throws StorageException if there was any error while saving the 
contents.
-        */
-       public void save() throws StorageException {
-               MessageHashesDAO hashesDAO = 
DAOFactory.getFactory(DAOFactory.XML).getMessageHashesDAO();
-               synchronized (hashesMap) {
-                       hashesDAO.save(this);
-               }
-       }
-       
-       /**
-        * This method adds the given digest to the set of message hashes. Its
-        * implementation is thread safe.
-        * @param digest the new digest to add to the set of message hashes.
-        */
-       public synchronized void add(String digest) {
-        hashesMap.put(digest, digest);
-       }
-
-       /**
-        * This method returns true if the set of message hashes contains the 
-        * digest given as a paremeter. Its implementation is thread safe.
-        * @param digest digest whose presence in this set is to be tested
-        * @return true if this set contains the specified digest.
-        */
-       public synchronized boolean contains(String digest) {
-        return hashesMap.containsKey(digest);
-       }
-       /**
-        * This method returns an Iterator with all of the message
-        * hashes. Not thread-safe.
-        * @return an Iterator with all of the message hashes.
-        */
-       protected Iterator getHashes() {
-               return hashesMap.keySet().iterator();
-       }
-}

Deleted: trunk/apps/frost-0.7/source/frost/messaging/MessageHashesDAO.java
===================================================================
--- trunk/apps/frost-0.7/source/frost/messaging/MessageHashesDAO.java   
2006-02-11 19:22:16 UTC (rev 8017)
+++ trunk/apps/frost-0.7/source/frost/messaging/MessageHashesDAO.java   
2006-02-11 19:24:36 UTC (rev 8018)
@@ -1,44 +0,0 @@
-/*
- * Created on 27-ene-2005
- * 
- */
-package frost.messaging;
-
-import frost.storage.StorageException;
-
-/**
- * @author $Author: kevloral $
- * @version $Revision: 1.2 $
- */
-public interface MessageHashesDAO {
-       /**
-        * This method checks if underlying storage exists. If it does, it
-        * returns true. If it doesn't (for instance, when the application
-        * is started for the first time) it returns false.
-        * @return true if the underlying storage exists. False otherwise.
-        */
-       public boolean exists();
-       
-       /**
-        * This method loads the information contained in the storage and fills
-        * the given MessageHashes object with it.
-        * @param messageHashes MessageHashes object to be filled with the 
information
-        * in the storage
-        * @throws StorageException if there was a problem while loading the 
information.
-        */
-       public void load(MessageHashes messageHashes) throws StorageException;
-       
-       /**
-        * This method saves the information contained in the given 
MessageHashes object
-        * on the storage.
-        * @param messageHashes MessageHashes whose information is going to be 
saved
-        * @throws StorageException if there was a problem while saving the 
information.
-        */
-       public void save(MessageHashes messageHashes) throws StorageException;
-       
-       /**
-        * This method creates the underlying storage.
-        * @throws StorageException if there was a problem while creating the 
storage.
-        */
-       public void create() throws StorageException;
-}

Deleted: trunk/apps/frost-0.7/source/frost/messaging/MessageHashesHsqldbDAO.java
===================================================================
--- trunk/apps/frost-0.7/source/frost/messaging/MessageHashesHsqldbDAO.java     
2006-02-11 19:22:16 UTC (rev 8017)
+++ trunk/apps/frost-0.7/source/frost/messaging/MessageHashesHsqldbDAO.java     
2006-02-11 19:24:36 UTC (rev 8018)
@@ -1,47 +0,0 @@
-/*
- * Created on 27-ene-2005
- * 
- */
-package frost.messaging;
-
-import frost.storage.StorageException;
-
-/**
- * @author $Author: kevloral $
- * @version $Revision: 1.2 $
- */
-public class MessageHashesHsqldbDAO implements MessageHashesDAO {
-
-       /* (non-Javadoc)
-        * @see frost.messaging.MessageHashesDAO#exists()
-        */
-       public boolean exists() {
-               // TODO Auto-generated method stub
-               return false;
-       }
-
-       /* (non-Javadoc)
-        * @see 
frost.messaging.MessageHashesDAO#load(frost.messaging.MessageHashes)
-        */
-       public void load(MessageHashes messageHashes) throws StorageException {
-               // TODO Auto-generated method stub
-               
-       }
-
-       /* (non-Javadoc)
-        * @see 
frost.messaging.MessageHashesDAO#save(frost.messaging.MessageHashes)
-        */
-       public void save(MessageHashes messageHashes) throws StorageException {
-               // TODO Auto-generated method stub
-               
-       }
-
-       /* (non-Javadoc)
-        * @see frost.messaging.MessageHashesDAO#create()
-        */
-       public void create() throws StorageException {
-               // TODO Auto-generated method stub
-               
-       }
-
-}

Deleted: trunk/apps/frost-0.7/source/frost/messaging/MessageHashesXmlDAO.java
===================================================================
--- trunk/apps/frost-0.7/source/frost/messaging/MessageHashesXmlDAO.java        
2006-02-11 19:22:16 UTC (rev 8017)
+++ trunk/apps/frost-0.7/source/frost/messaging/MessageHashesXmlDAO.java        
2006-02-11 19:24:36 UTC (rev 8018)
@@ -1,182 +0,0 @@
-/*
- MessageHashesXmlDAO.java / Frost
- Copyright (C) 2003  Jan-Thomas Czornack <jantho at users.sourceforge.net>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package frost.messaging;
-
-import java.io.*;
-import java.util.*;
-import java.util.logging.*;
-
-import org.w3c.dom.*;
-
-import frost.*;
-import frost.storage.*;
-
-public class MessageHashesXmlDAO implements MessageHashesDAO {
-       
-       private static Logger logger = 
Logger.getLogger(MessageHashesXmlDAO.class.getName());
-       
-       private static final String XML_FILENAME = "hashes.xml";
-       private static final String TMP_FILENAME = "hashes.xml.tmp";
-       private static final String BAK_FILENAME = "hashes.xml.bak";
-
-       /* (non-Javadoc)
-        * @see frost.messaging.MessageHashesDAO#exists()
-        */
-       public boolean exists() {
-               File xmlFile = new File(XML_FILENAME);
-               if (xmlFile.length() == 0) {
-                       xmlFile.delete();
-               }
-               if (xmlFile.isFile()) {
-                       return true;
-               } else {
-                       return false;
-               }
-       }
-
-       /* (non-Javadoc)
-        * @see 
frost.messaging.MessageHashesDAO#load(frost.messaging.MessageHashes)
-        */
-       public void load(MessageHashes messageHashes) throws StorageException {
-
-        if( exists() == false ) {
-            return;
-        }
-        
-               try {
-            logger.info("Loading " + XML_FILENAME);
-            Document doc = XMLTools.parseXmlFile(XML_FILENAME, false);
-            Element rootNode = doc.getDocumentElement();
-            
-            if (rootNode.getTagName().equals("MessageHashes") == false) {
-                throw new StorageException("The message hashes XML file is 
invalid: does not contain the root tag MessageHashes.");
-            }
-            
-            // check if rootnode contains only a single entry wich must be 
MessageHashesList
-            ArrayList nodelist = XMLTools.getChildElementsByTagName(rootNode, 
"MessageHashesList");
-            if (nodelist.size() != 1) {
-                throw new StorageException("The message hashes XML file is 
invalid: MessageHashesList not found or duplicated.");
-            }
-
-            // not longer used, free
-            rootNode = null;
-            doc = null;
-
-            Element hashesListRootNode = (Element) nodelist.get(0);
-            nodelist = XMLTools.getChildElementsByTagName(hashesListRootNode, 
"MessageHash");
-            if (nodelist.size() == 0) {
-                logger.info("The message hashes XML file has no hashes.");  
-            } else {
-                // read hashes, first one is the oldest
-                for (int x = 0; x < nodelist.size(); x++) {
-                    Element element = (Element) nodelist.get(x);
-                    
-                    String value = element.getAttribute("value");
-                    if( value == null || value.length() == 0 ) {
-                        CDATASection txtname = 
(CDATASection)element.getFirstChild();
-                        if( txtname == null ) {
-                            logger.warning("No hash value found in 
MessageHash, continuing.");
-                        }
-                        value = txtname.getData().trim();
-                    }
-                    messageHashes.add(value);
-                }
-                logger.info("Loaded "+nodelist.size()+" hashes.");  
-            }
-               } catch (Throwable e) {
-                       throw new StorageException("Exception while loading the 
new message hashes format. Starting empty hashes list.", e);
-               }
-       }
-
-       /* (non-Javadoc)
-        * @see 
frost.messaging.MessageHashesDAO#save(frost.messaging.MessageHashes)
-        */
-       public void save(MessageHashes messageHashes) throws StorageException {
-               logger.info("Saving " + XML_FILENAME);
-               
-               // First we copy "hashes.xml" to "hashes.xml.bak"
-               File hashesFile = new File(XML_FILENAME);
-               if (hashesFile.exists()) {
-                       File bakFile = new File(BAK_FILENAME);
-                       bakFile.delete();
-                       if( !FileAccess.copyFile(XML_FILENAME, BAK_FILENAME) ) {
-                               logger.log(Level.SEVERE, "Error while copying " 
+ XML_FILENAME + " to " + BAK_FILENAME);
-                       }
-               }
-
-               // prepare xml
-               Document doc = XMLTools.createDomDocument();
-               Element rootElement = doc.createElement("MessageHashes");
-               doc.appendChild(rootElement);
-               Element listRoot = doc.createElement("MessageHashesList");
-               rootElement.appendChild(listRoot);
-               
-               // now add all hashes to listRoot
-               Iterator hashes = messageHashes.getHashes();
-               while (hashes.hasNext()) {
-                       String hash = hashes.next().toString();
-                       Element element = doc.createElement("MessageHash");
-            CDATASection cdata = doc.createCDATASection(hash);
-            element.appendChild(cdata);
-                       listRoot.appendChild(element);
-               }               
-               
-        //We delete "hashes.xml.tmp"
-        File hashesTmpFile = new File(TMP_FILENAME);
-        if (hashesTmpFile.isFile()) {
-            hashesTmpFile.delete();
-        }
-               // We save message hashes to "hashes.xml.tmp"
-               if (XMLTools.writeXmlFile(doc, TMP_FILENAME)) {
-                       //Success
-                       if (hashesTmpFile.isFile()) {
-                               //We replace "hashes.xml" by "hashes.xml.tmp"
-                               hashesFile.delete();
-                               if (!hashesTmpFile.renameTo(hashesFile)) {
-                                       //Replacement failed. We try to restore 
"hashes.xml" from "hashes.xml.bak"
-                                       if( !FileAccess.copyFile(BAK_FILENAME, 
XML_FILENAME) ) {
-                                               //Uh, oh, we are having a bad, 
bad day.
-                                               throw new 
StorageException("Error while restoring " + XML_FILENAME);
-                                       }
-                               }
-                       } else {
-                               //This shouldn't happen, but...
-                               throw new StorageException("Could not save " + 
XML_FILENAME);
-                       }
-               } else {
-                       //Failure
-                       throw new StorageException("Could not save " + 
XML_FILENAME);
-               }
-       }
-
-       /* (non-Javadoc)
-        * @see frost.messaging.MessageHashesDAO#create()
-        */
-       public void create() throws StorageException {
-               File xmlHashes = new File(XML_FILENAME);
-               try {
-                       boolean success = xmlHashes.createNewFile();
-                       if (!success) {
-                               throw new StorageException("There was a problem 
while creating the storage.");
-                       }
-               } catch (IOException ioe) {
-                       throw new StorageException("There was a problem while 
creating the storage.", ioe);
-               }               
-       }
-}

Deleted: trunk/apps/frost-0.7/source/frost/messaging/MessagingManager.java
===================================================================
--- trunk/apps/frost-0.7/source/frost/messaging/MessagingManager.java   
2006-02-11 19:22:16 UTC (rev 8017)
+++ trunk/apps/frost-0.7/source/frost/messaging/MessagingManager.java   
2006-02-11 19:24:36 UTC (rev 8018)
@@ -1,62 +0,0 @@
-/*
- MessagingManager.java / Frost
- Copyright (C) 2003  Jan-Thomas Czornack <jantho at users.sourceforge.net>
-
- This program is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License as
- published by the Free Software Foundation; either version 2 of
- the License, or (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- */
-package frost.messaging;
-
-import java.util.logging.*;
-
-import frost.*;
-
-public class MessagingManager {
-       
-    private static Logger logger = 
Logger.getLogger(MessagingManager.class.getName());
-
-    private SettingsClass settings;
-       
-       private MessageHashes messageHashes;
-       
-       /**
-        * 
-        */
-       public MessagingManager(SettingsClass settings) {
-               super();
-               this.settings = settings;
-       }
-       
-       /**
-        * 
-        */
-       public void initialize() {
-        try {
-            getMessageHashes().initialize();
-        } catch(Throwable t) {
-            logger.log(Level.SEVERE, "Exception when loading hashes, 
continuing", t);
-            messageHashes = new MessageHashes();
-        }
-       }
-
-       /**
-        * @return
-        */
-       public MessageHashes getMessageHashes() {
-               if (messageHashes == null) {
-                       messageHashes = new MessageHashes();    
-               }
-               return messageHashes;
-       }
-}


Reply via email to