Author: jflesch
Date: 2007-12-03 01:41:41 +0000 (Mon, 03 Dec 2007)
New Revision: 16211

Modified:
   trunk/apps/Thaw/src/thaw/core/ConfigWindow.java
   trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java
   trunk/apps/Thaw/src/thaw/plugins/index/DatabaseManager.java
   trunk/apps/Thaw/src/thaw/plugins/index/Index.java
Log:
During an index tree importation : If an index is already in tree, then just 
check if the private key can be updated

Modified: trunk/apps/Thaw/src/thaw/core/ConfigWindow.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/ConfigWindow.java     2007-12-03 01:08:37 UTC 
(rev 16210)
+++ trunk/apps/Thaw/src/thaw/core/ConfigWindow.java     2007-12-03 01:41:41 UTC 
(rev 16211)
@@ -183,7 +183,7 @@
         * Called when apply button is pressed.
         */
        public void actionPerformed(final ActionEvent e) {
-               if((e.getSource() == okButton) && !core.canDisconnect()) {
+               if((e.getSource() == okButton) && !core.canDisconnect() && 
needConnectionReset) {
                        final int ret = 
JOptionPane.showOptionDialog((java.awt.Component)null,
                                                                       
I18n.getMessage("thaw.warning.isWritingSoApplyLater"),
                                                                       
I18n.getMessage("thaw.warning.title"),

Modified: trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java
===================================================================
--- trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java      2007-12-03 01:08:37 UTC 
(rev 16210)
+++ trunk/apps/Thaw/src/thaw/fcp/FCPClientGet.java      2007-12-03 01:41:41 UTC 
(rev 16211)
@@ -252,6 +252,12 @@
                transferedBlocks = 0;

                this.queueManager = queueManager;
+               
+               /* TODO : seems to be true sometimes => find why */ 
+               if (queueManager == null
+                               || queueManager.getQueryManager() == null
+                               || 
queueManager.getQueryManager().getConnection() == null)
+                       return false;

                if 
(queueManager.getQueryManager().getConnection().isLocalSocket()
                    && !noDDA

Modified: trunk/apps/Thaw/src/thaw/plugins/index/DatabaseManager.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/DatabaseManager.java 2007-12-03 
01:08:37 UTC (rev 16210)
+++ trunk/apps/Thaw/src/thaw/plugins/index/DatabaseManager.java 2007-12-03 
01:41:41 UTC (rev 16211)
@@ -267,7 +267,7 @@
                          + "localPath VARCHAR(500) NULL,"
                          + "mime VARCHAR(50) NULL,"
                          + "size BIGINT NOT NULL,"
-                         + "category INTEGER NULL," // This field is a mistake.
+                         + "category INTEGER NULL," // TODO : This field is 
unused, to remove ?
                          + "indexParent INTEGER NOT NULL,"
                          + "toDelete BOOLEAN DEFAULT FALSE NOT NULL,"
                          + "dontDelete BOOLEAN DEFAULT FALSE NOT NULL,"
@@ -624,6 +624,23 @@
                                        indexHandler = new 
IndexParser(index).getIndexHandler();

                                        indexHandler.startDocument();
+                               } else {
+                                       /* returned null because it already 
exists in the db ? */
+                                       /* if yes, we will just update the 
private key */
+
+                                       String publicKey = 
attrs.getValue("publicKey");
+                                       String privateKey = 
attrs.getValue("privateKey");
+                                       
+                                       if (privateKey == null || 
"".equals(privateKey)) {
+                                               return;
+                                       }
+                                       
+                                       int id = Index.isAlreadyKnown(db, 
publicKey, true);
+                                       
+                                       if (id < 0)
+                                               return;
+                                       else
+                                               Index.setPrivateKey(db, id, 
privateKey);
                                }

                                return;

Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Index.java   2007-12-03 01:08:37 UTC 
(rev 16210)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java   2007-12-03 01:41:41 UTC 
(rev 16211)
@@ -81,10 +81,7 @@
        private boolean successful = true;


-       /**
-        * @deprecated Just don't use it !
-        */
-       public Index() {
+       private Index() {
                db = null;
        }

@@ -548,13 +545,15 @@
                }
        }

-
        public void setPrivateKey(String privateKey) {
+               this.privateKey = privateKey;
+               setPrivateKey(db, id, privateKey);
+       }
+
+       public static void setPrivateKey(Hsqldb db, int indexId, String 
privateKey) {
                if (privateKey != null && !FreenetURIHelper.isAKey(privateKey))
                        privateKey = null;

-               this.privateKey = privateKey;
-
                synchronized(db.dbLock) {
                        try {
                                PreparedStatement st;
@@ -566,11 +565,11 @@
                                        st.setString(1, privateKey);
                                else
                                        st.setNull(1, Types.VARCHAR);
-                               st.setInt(2, id);
+                               st.setInt(2, indexId);

                                st.execute();
                        } catch(SQLException e) {
-                               Logger.error(this, "Unable to set private Key 
because: "+e.toString());
+                               Logger.error(new Index(), "Unable to set 
private Key because: "+e.toString());
                        }
                }
        }


Reply via email to