Author: jflesch
Date: 2007-01-27 19:08:10 +0000 (Sat, 27 Jan 2007)
New Revision: 11628
Modified:
trunk/apps/Thaw/src/thaw/core/ConfigWindow.java
trunk/apps/Thaw/src/thaw/core/Logger.java
trunk/apps/Thaw/src/thaw/core/PluginManager.java
trunk/apps/Thaw/src/thaw/plugins/index/File.java
trunk/apps/Thaw/src/thaw/plugins/index/Index.java
Log:
Avoid an useless SQL request each time a file is selected
Modified: trunk/apps/Thaw/src/thaw/core/ConfigWindow.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/ConfigWindow.java 2007-01-27 18:33:43 UTC
(rev 11627)
+++ trunk/apps/Thaw/src/thaw/core/ConfigWindow.java 2007-01-27 19:08:10 UTC
(rev 11628)
@@ -179,8 +179,6 @@
if(e.getSource() == okButton) {
advancedMode =
Boolean.valueOf(core.getConfig().getValue("advancedMode")).booleanValue();
- /* should reinit the whole connection correctly */
- core.getPluginManager().stopPlugins();
Reloader reloader = new Reloader(needConnectionReset);
Thread reload = new Thread(reloader);
@@ -203,7 +201,7 @@
public void run() {
-/* should reinit the whole connection correctly */
+ /* should reinit the whole connection correctly */
core.getPluginManager().stopPlugins();
if (resetConnection && !core.initConnection()) {
Modified: trunk/apps/Thaw/src/thaw/core/Logger.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/Logger.java 2007-01-27 18:33:43 UTC (rev
11627)
+++ trunk/apps/Thaw/src/thaw/core/Logger.java 2007-01-27 19:08:10 UTC (rev
11628)
@@ -10,7 +10,8 @@
public class Logger {
- /* 0 = Errors only
+ /*
+ * 0 = Errors only
* 1 = Errors + warnings
* 2 = Errors + warnings + notices
* 3 = Errors + warnings + notices + infos
@@ -19,8 +20,9 @@
* (or maybe someone having the FCPv2 specs :)
*
* 2 or more is recommanded.
+ * 4 or more is unhealthy
*/
- public final static int LOG_LEVEL = 2;
+ public final static int LOG_LEVEL = 3;
private static Vector logListeners = null;
Modified: trunk/apps/Thaw/src/thaw/core/PluginManager.java
===================================================================
--- trunk/apps/Thaw/src/thaw/core/PluginManager.java 2007-01-27 18:33:43 UTC
(rev 11627)
+++ trunk/apps/Thaw/src/thaw/core/PluginManager.java 2007-01-27 19:08:10 UTC
(rev 11628)
@@ -68,6 +68,7 @@
Vector pluginNames;
if(core.getConfig().getPluginNames().size() == 0) {
+ Logger.notice(this, "Loading default plugin list");
/* Then we load the config with the default plugins */
for(int i = 0 ; i < PluginManager.defaultPlugins.length
; i++) {
core.getConfig().addPlugin(PluginManager.defaultPlugins[i]);
Modified: trunk/apps/Thaw/src/thaw/plugins/index/File.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/File.java 2007-01-27 18:33:43 UTC
(rev 11627)
+++ trunk/apps/Thaw/src/thaw/plugins/index/File.java 2007-01-27 19:08:10 UTC
(rev 11628)
@@ -35,6 +35,9 @@
private int parentId;
+ private Index parent;
+
+
/* if not null, the transfer will be removed when finished */
private FCPQueueManager queueManager = null;
@@ -55,7 +58,21 @@
this.localPath = localPath;
this.mime = mime;
this.size = size;
+ }
+
+ public File(final Hsqldb db, final int id, final String filename,
+ String publicKey, java.io.File localPath,
+ String mime, long size, int parentId, Index parent) {
+ this.db = db;
+ this.id = id;
+ this.filename = filename;
+ this.publicKey = publicKey;
+ this.localPath = localPath;
+ this.mime = mime;
+ this.size = size;
this.parentId = parentId;
+
+ this.parent = parent;
}
@@ -342,6 +359,10 @@
* Note: Do a SQL requests each time
*/
public boolean isModifiable() {
- return (new Index(db, parentId)).isModifiable();
+ if (parent != null) {
+ Logger.debug(this, "isModifiable() => new
Index().isModifiable()");
+ return (new Index(db, parentId)).isModifiable();
+ }
+ return parent.isModifiable();
}
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-01-27 18:33:43 UTC
(rev 11627)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-01-27 19:08:10 UTC
(rev 11628)
@@ -319,7 +319,7 @@
}
public boolean loadData() {
- Logger.info(this, "loadData()");
+ Logger.debug(this, "loadData()");
synchronized(db.dbLock) {
try {
PreparedStatement st =
@@ -349,6 +349,7 @@
public String getPublicKey() {
if (publicKey == null) {
+ Logger.debug(this, "getPublicKey() => loadData()");
loadData();
}
@@ -357,6 +358,7 @@
public int getRevision() {
if (rev < 0) {
+ Logger.debug(this, "getRevision() => loadData()");
loadData();
}
@@ -365,6 +367,7 @@
public String getPrivateKey() {
if (publicKey == null) { /* we rely on the publicKey because
the privateKey is not often availabe */
+ Logger.debug(this, "getPrivateKey() => loadData()");
loadData();
}
@@ -510,6 +513,7 @@
public String toString(boolean withRev) {
if (displayName == null || rev < 0) {
+ Logger.debug(this, "toString() => loadData()");
loadData();
}
@@ -794,7 +798,7 @@
thaw.plugins.index.File file =
new thaw.plugins.index.File(db,
file_id, filename, file_publicKey,
-
localPath, mime, size, id);
+
localPath, mime, size, id, this);
files.add(file);
}
@@ -1045,7 +1049,7 @@
Document xmlDoc;
try {
- Logger.debug(this, "XML parser ready");
+ Logger.info(this, "XML parser ready");
xmlDoc = xmlBuilder.parse(input);
Logger.info(this, "Index parsed");
} catch(final org.xml.sax.SAXException e) {
@@ -1073,8 +1077,10 @@
public void loadHeader(final Element rootEl) {
final Element header =
(Element)rootEl.getElementsByTagName("header").item(0);
- if (publicKey == null)
+ if (publicKey == null) {
+ Logger.debug(this, "getPublicKey() => loadData()");
loadData();
+ }
String pKey = getHeaderElement(header, "privateKey");
if (pKey != null) {
@@ -1386,12 +1392,14 @@
public void forceHasChangedReload() {
+ Logger.debug(this, "forceHasChangedReload() => loadData()");
loadData();
}
public boolean hasChanged() {
if (publicKey == null) {
+ Logger.debug(this, "hasChanged() => loadData()");
loadData();
}