Author: batosai
Date: 2008-08-24 11:35:53 +0000 (Sun, 24 Aug 2008)
New Revision: 22126

Modified:
   trunk/apps/WoT/src/plugins/WoT/IdentityInserter.java
Log:
Logging. Made me found a problem when inserting multiple ownIdentites (bug 
#2532).

Modified: trunk/apps/WoT/src/plugins/WoT/IdentityInserter.java
===================================================================
--- trunk/apps/WoT/src/plugins/WoT/IdentityInserter.java        2008-08-24 
10:44:25 UTC (rev 22125)
+++ trunk/apps/WoT/src/plugins/WoT/IdentityInserter.java        2008-08-24 
11:35:53 UTC (rev 22126)
@@ -42,7 +42,6 @@
        WoT wot;
        ObjectContainer db;
        HighLevelSimpleClient client;
-       OwnIdentity identity;
        String TEMP_DIR = ".";

        boolean isRunning;
@@ -88,8 +87,6 @@

        public void insert(OwnIdentity identity) throws 
TransformerConfigurationException, FileNotFoundException, 
ParserConfigurationException, TransformerException, IOException, 
InsertException, Db4oIOException, DatabaseClosedException, 
InvalidParameterException {

-               this.identity = identity;
-               
                // Create XML file to insert
                File outputFile= identity.exportToXML(db, new File(TEMP_DIR));

@@ -101,6 +98,9 @@

                // Insert
                client.insert(ib, false, "identity.xml", false, 
client.getInsertContext(false), this);
+               
+               // Logging
+               Logger.minor(this, "Started insert of identity '" + 
identity.getNickName() + "'");

                db.store(identity);
        }
@@ -138,11 +138,22 @@
        @Override
        public void onSuccess(BaseClientPutter state) {

+               OwnIdentity identity;
+               try {
+                       identity = 
wot.getOwnIdentityByURI(state.getURI().toString());
+               } catch (Exception e) {
+                       Logger.error(this, "Identity insert failed", e);
+                       return;
+               }
+               
                identity.setEdition(state.getURI().getSuggestedEdition());
                identity.setLastInsert(new Date());

                db.store(identity);
                db.commit();
+               
+               // Logging
+               Logger.minor(this, "Successful insert of identity '" + 
identity.getNickName() + "'");
        }

 }


Reply via email to