JAL-3949 An attempt at converting to Log4j 2 -- no output achieved!
[jalview.git] / src / jalview / io / vamsas / DatastoreItem.java
index d7db6a6..a1d8380 100644 (file)
@@ -1,38 +1,39 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.5)
- * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
  * Jalview 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 3 of the License, or (at your option) any later version.
- * 
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *  
  * Jalview 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 Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
  */
 package jalview.io.vamsas;
 
-import jalview.bin.Cache;
-import jalview.datamodel.DBRefEntry;
-import jalview.gui.TreePanel;
-import jalview.io.VamsasAppDatastore;
-
 import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.IdentityHashMap;
 import java.util.Vector;
 
-import org.apache.commons.logging.Log;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
 
+import jalview.bin.Cache;
+import jalview.io.VamsasAppDatastore;
+import jalview.util.MessageManager;
 import uk.ac.vamsas.client.IClientDocument;
 import uk.ac.vamsas.client.Vobject;
 import uk.ac.vamsas.client.VorbaId;
-import uk.ac.vamsas.objects.core.DbRef;
 import uk.ac.vamsas.objects.core.Entry;
 import uk.ac.vamsas.objects.core.Provenance;
 import uk.ac.vamsas.objects.core.Seg;
@@ -61,8 +62,7 @@ public abstract class DatastoreItem
   /**
    * shared log instance
    */
-  protected static org.apache.log4j.Logger log = org.apache.log4j.Logger
-          .getLogger(DatastoreItem.class);
+  protected static Logger log = LogManager.getLogger(DatastoreItem.class);
 
   /**
    * note: this is taken verbatim from jalview.io.VamsasAppDatastore
@@ -77,8 +77,8 @@ public abstract class DatastoreItem
     }
     if (Cache.log.isDebugEnabled())
     {
-      Cache.log.debug("Returning null VorbaID binding for jalview object "
-              + jvobj);
+      Cache.log.debug(
+              "Returning null VorbaID binding for jalview object " + jvobj);
     }
     return null;
   }
@@ -96,8 +96,8 @@ public abstract class DatastoreItem
     if (id == null)
     {
       id = cdoc.registerObject(vobj);
-      Cache.log
-              .debug("Registering new object and returning null for getvObj2jv");
+      Cache.log.debug(
+              "Registering new object and returning null for getvObj2jv");
       return null;
     }
     if (vobj2jv.containsKey(vobj.getVorbaId()))
@@ -125,7 +125,8 @@ public abstract class DatastoreItem
       {
         Cache.log.error("Failed to get id for "
                 + (vobj.isRegisterable() ? "registerable"
-                        : "unregisterable") + " object " + vobj);
+                        : "unregisterable")
+                + " object " + vobj);
       }
     }
     if (vobj2jv.containsKey(vobj.getVorbaId())
@@ -133,16 +134,18 @@ public abstract class DatastoreItem
     {
       Cache.log.debug(
               "Warning? Overwriting existing vamsas id binding for "
-                      + vobj.getVorbaId(), new Exception(
-                      "Overwriting vamsas id binding."));
+                      + vobj.getVorbaId(),
+              new Exception(MessageManager.getString(
+                      "exception.overwriting_vamsas_id_binding")));
     }
     else if (jv2vobj.containsKey(jvobj)
             && !((VorbaId) jv2vobj.get(jvobj)).equals(vobj.getVorbaId()))
     {
       Cache.log.debug(
               "Warning? Overwriting existing jalview object binding for "
-                      + jvobj, new Exception(
-                      "Overwriting jalview object binding."));
+                      + jvobj,
+              new Exception(MessageManager.getString(
+                      "exception.overwriting_jalview_id_binding")));
     }
     /*
      * Cache.log.error("Attempt to make conflicting object binding! "+vobj+" id "
@@ -192,15 +195,16 @@ public abstract class DatastoreItem
     Object vobject = jv2vobj.remove(oldjvobject);
     if (vobject == null)
     {
-      throw new Error(
-              "IMPLEMENTATION ERROR: old jalview object is not bound ! ("
-                      + oldjvobject + ")");
+      throw new Error(MessageManager.formatMessage(
+              "error.implementation_error_old_jalview_object_not_bound",
+              new String[]
+              { oldjvobject.toString() }));
     }
     if (newjvobject != null)
     {
       jv2vobj.put(newjvobject, vobject);
       vobj2jv.put(vobject, newjvobject);
-      updateRegistryEntry(newjvobject, (Vobject) vobject);
+      updateRegistryEntry(newjvobject, vobj);
     }
   }
 
@@ -233,9 +237,11 @@ public abstract class DatastoreItem
     tojalview = true;
     if (jvobj != null && !(boundType.isAssignableFrom(jvobj.getClass())))
     {
-      throw new Error("Implementation Error: Vamsas Document Class "
-              + vobj.getClass() + " should bind to a " + boundType
-              + " (found a " + jvobj.getClass() + ")");
+      throw new Error(MessageManager.formatMessage(
+              "error.implementation_error_vamsas_doc_class_should_bind_to_type",
+              new String[]
+              { vobj.getClass().toString(), boundType.toString(),
+                  jvobj.getClass().toString() }));
     }
     dsReg.registerDsObj(this);
   }
@@ -261,9 +267,11 @@ public abstract class DatastoreItem
     vobj = getjv2vObj(jvobj);
     if (vobj != null && !(boundToType.isAssignableFrom(vobj.getClass())))
     {
-      throw new Error("Implementation Error: Jalview Class "
-              + jvobj2.getClass() + " should bind to a " + boundToType
-              + " (found a " + vobj.getClass() + ")");
+      throw new Error(MessageManager.formatMessage(
+              "error.implementation_error_vamsas_doc_class_should_bind_to_type",
+              new String[]
+              { jvobj2.getClass().toString(), boundToType.toString(),
+                  vobj.getClass().toString() }));
     }
     dsReg.registerDsObj(this);
   }
@@ -381,8 +389,8 @@ public abstract class DatastoreItem
   {
     datastore = ds;
     dsReg = ds.getDatastoreRegisty();
-    initDatastoreItem(ds.getProvEntry(), ds.getClientDocument(), ds
-            .getVamsasObjectBinding(), ds.getJvObjectBinding());
+    initDatastoreItem(ds.getProvEntry(), ds.getClientDocument(),
+            ds.getVamsasObjectBinding(), ds.getJvObjectBinding());
   }
 
   private void initDatastoreItem(Entry provEntry, IClientDocument cdoc,
@@ -436,8 +444,7 @@ public abstract class DatastoreItem
       end = start;
       start = t;
     }
-    return new int[]
-    { start, end, pol < 0 ? 1 : 0 };
+    return new int[] { start, end, pol < 0 ? 1 : 0 };
   }
 
   /**
@@ -450,9 +457,9 @@ public abstract class DatastoreItem
     jalview.datamodel.Provenance jprov = new jalview.datamodel.Provenance();
     for (int i = 0; i < prov.getEntryCount(); i++)
     {
-      jprov.addEntry(prov.getEntry(i).getUser(), prov.getEntry(i)
-              .getAction(), prov.getEntry(i).getDate(), prov.getEntry(i)
-              .getId());
+      jprov.addEntry(prov.getEntry(i).getUser(),
+              prov.getEntry(i).getAction(), prov.getEntry(i).getDate(),
+              prov.getEntry(i).getId());
     }
 
     return jprov;