Author: jflesch
Date: 2007-08-08 18:50:10 +0000 (Wed, 08 Aug 2007)
New Revision: 14532
Modified:
trunk/apps/Thaw/src/thaw/plugins/index/AutoRefresh.java
trunk/apps/Thaw/src/thaw/plugins/index/Index.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexFolder.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java
trunk/apps/Thaw/src/thaw/plugins/index/IndexTreeNode.java
Log:
Only write in italic the names of the indexes where the private key is published
Modified: trunk/apps/Thaw/src/thaw/plugins/index/AutoRefresh.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/AutoRefresh.java 2007-08-08
18:27:27 UTC (rev 14531)
+++ trunk/apps/Thaw/src/thaw/plugins/index/AutoRefresh.java 2007-08-08
18:50:10 UTC (rev 14532)
@@ -93,7 +93,10 @@
ResultSet results;
int ret;
- st = c.prepareStatement("SELECT id, originalName,
displayName, publicKey, privateKey, author, positionInTree, revision,
insertionDate "+
+ st = c.prepareStatement("SELECT id, originalName,
displayName, "+
+ " publicKey, privateKey,
publishPrivateKey, "+
+ " author, positionInTree,
revision, "+
+ " insertionDate "+
"FROM indexes ORDER by RAND()
LIMIT 1");
results = st.executeQuery();
@@ -117,6 +120,7 @@
null,
results.getString("publicKey"),
results.getInt("revision"),
results.getString("privateKey"),
+
results.getBoolean("publishPrivateKey"),
results.getString("displayName"),
results.getDate("insertionDate"),
false, false);
Modified: trunk/apps/Thaw/src/thaw/plugins/index/Index.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-08-08 18:27:27 UTC
(rev 14531)
+++ trunk/apps/Thaw/src/thaw/plugins/index/Index.java 2007-08-08 18:50:10 UTC
(rev 14532)
@@ -67,6 +67,7 @@
private String displayName = null;
private boolean hasChanged = false;
private boolean newComment = false;
+ private boolean publishPrivateKey = false;
private java.sql.Date date = null;
/* loaded only if asked explictly */
@@ -101,12 +102,13 @@
* Use it when you can have these infos easily ; else let the index do
the job
*/
public Index(Hsqldb db, Config config, int id, TreeNode parentNode,
- String publicKey, int rev, String privateKey, String
displayName,
- java.sql.Date insertionDate,
+ String publicKey, int rev, String privateKey, boolean
publishPrivateKey,
+ String displayName, java.sql.Date insertionDate,
boolean hasChanged, boolean newComment) {
this(db, config, id);
this.parentNode = parentNode;
this.privateKey = privateKey;
+ this.publishPrivateKey = publishPrivateKey;
this.publicKey = publicKey;
this.rev = rev;
this.displayName = displayName;
@@ -352,7 +354,16 @@
synchronized(db.dbLock) {
try {
PreparedStatement st =
-
db.getConnection().prepareStatement("SELECT publicKey, revision, privateKey,
displayName, newRev, newComment, insertionDate FROM indexes WHERE id = ? LIMIT
1");
+
db.getConnection().prepareStatement("SELECT publicKey, "+
+ "
revision, "+
+ "
privateKey, "+
+ "
publishPrivateKey, "+
+ "
displayName, "+
+ "
newRev, "+
+ "
newComment, "+
+ "
insertionDate "+
+
"FROM indexes "+
+
"WHERE id = ? LIMIT 1");
st.setInt(1, id);
@@ -361,6 +372,7 @@
if (set.next()) {
publicKey = set.getString("publicKey");
privateKey =
set.getString("privateKey");
+ publishPrivateKey =
set.getBoolean("publishPrivateKey");
rev = set.getInt("revision");
displayName =
set.getString("displayName");
hasChanged = set.getBoolean("newRev");
@@ -425,31 +437,16 @@
public boolean publishPrivateKey() {
- try {
-
- synchronized(db.dbLock) {
- PreparedStatement st
- =
db.getConnection().prepareStatement("SELECT publishPrivateKey FROM indexes
WHERE id = ? LIMIT 1");
-
- st.setInt(1, id);
-
- ResultSet set = st.executeQuery();
-
- if (!set.next()) {
- Logger.error(this, "Unable to get
publishPrivateKey value => not found !");
- }
-
- return set.getBoolean("publishPrivateKey");
- }
-
- } catch(SQLException e){
- Logger.error(this, "Unable to get publishPrivateKey
value because: "+e.toString());
+ if (publicKey == null) {
+ Logger.debug(this, "getPrivateKey() => loadData()");
+ loadData();
}
- return false;
+ return publishPrivateKey;
}
public void setPublishPrivateKey(boolean val) {
+
try {
synchronized(db.dbLock) {
PreparedStatement st =
@@ -461,6 +458,8 @@
st.execute();
}
+ publishPrivateKey = val;
+
} catch(SQLException e){
Logger.error(this, "Unable to set publishPrivateKey
value because: "+e.toString());
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexFolder.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexFolder.java 2007-08-08
18:27:27 UTC (rev 14531)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexFolder.java 2007-08-08
18:50:10 UTC (rev 14532)
@@ -89,6 +89,7 @@
n = new Index(db, config,
set.getInt("id"), this,
set.getString("publicKey"),
set.getInt("revision"),
set.getString("privateKey"),
+
set.getBoolean("publishPrivateKey"),
set.getString("displayName"),
set.getDate("insertionDate"),
set.getBoolean("newRev"),
set.getBoolean("newComment"));
@@ -131,26 +132,40 @@
PreparedStatement st;
if (id >= 0) {
- st =
db.getConnection().prepareStatement("SELECT id, name, positionInTree FROM
indexFolders "
-
+ "WHERE parent = ? "
-
+"ORDER BY positionInTree");
+ st =
db.getConnection().prepareStatement("SELECT id, name, positionInTree "+
+
" FROM indexFolders "+
+
"WHERE parent = ? "+
+
"ORDER BY positionInTree");
st.setInt(1, id);
} else {
- st =
db.getConnection().prepareStatement("SELECT id, positionInTree, name FROM
indexFolders "
-
+ "WHERE parent IS NULL "
-
+"ORDER BY positionInTree");
+ st =
db.getConnection().prepareStatement("SELECT id, positionInTree, name "+
+
"FROM indexFolders "+
+
"WHERE parent IS NULL "+
+
"ORDER BY positionInTree");
}
addToVector(v, st.executeQuery(), true);
if (id >= 0) {
- st =
db.getConnection().prepareStatement("SELECT id, positionInTree, displayName,
publicKey, privateKey, revision, newRev, newComment, insertionDate FROM indexes
"
-
+ "WHERE parent = ? ORDER BY positionInTree");
+ st =
db.getConnection().prepareStatement("SELECT id, positionInTree, "+
+
" displayName, publicKey, "+
+
" privateKey, publishPrivateKey, "+
+
" revision, newRev, newComment, "+
+
" insertionDate "+
+
"FROM indexes "+
+
"WHERE parent = ? "+
+
"ORDER BY positionInTree");
st.setInt(1, id);
} else {
- st =
db.getConnection().prepareStatement("SELECT id, positionInTree, displayName,
publicKey, privateKey, revision, newRev, newComment, insertionDate FROM indexes
"
-
+ "WHERE parent IS NULL ORDER BY positionInTree");
+ st =
db.getConnection().prepareStatement("SELECT id, positionInTree, "+
+
" displayName, publicKey, "+
+
" privateKey, publishPrivateKey, "+
+
" revision, newRev, newComment, "+
+
" insertionDate "+
+
"FROM indexes "+
+
"WHERE parent IS NULL "+
+
"ORDER BY positionInTree");
}
addToVector(v, st.executeQuery(), false);
@@ -1441,4 +1456,7 @@
return null;
}
+ public boolean publishPrivateKey() {
+ return false;
+ }
}
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
2007-08-08 18:27:27 UTC (rev 14531)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexManagementHelper.java
2007-08-08 18:50:10 UTC (rev 14532)
@@ -248,12 +248,14 @@
index = new Index(db,
getIndexBrowserPanel().getConfig(),
id,
(TreeNode)getTarget(),
-
sskGenerator.getPublicKey(), 0, sskGenerator.getPrivateKey(),
+
sskGenerator.getPublicKey(), 0,
+
sskGenerator.getPrivateKey(), false,
name, null,
false, false);
} catch(SQLException e) {
- Logger.error(new
IndexManagementHelper(), "Error while creating index: "+e.toString());
+ Logger.error(new
IndexManagementHelper(),
+ "Error while creating
index: "+ e.toString());
return;
}
}
@@ -447,7 +449,8 @@
index = new Index(db, indexBrowser.getConfig(),
id, parent,
- publicKey, revision,
privateKey,
+ publicKey, revision,
+ privateKey, false,
name, null, false, false);
} catch(SQLException e) {
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java 2007-08-08
18:27:27 UTC (rev 14531)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexTree.java 2007-08-08
18:50:10 UTC (rev 14532)
@@ -778,13 +778,13 @@
if (o instanceof IndexTreeNode) {
/* Remember that for the index category,
this kind of query is recursive */
- boolean modifiable =
((IndexTreeNode)o).isModifiable();
boolean hasChanged =
((IndexTreeNode)o).hasChanged();
boolean newComment =
((IndexTreeNode)o).hasNewComment();
+ boolean publishPrivateKey =
((IndexTreeNode)o).publishPrivateKey();
int style = Font.PLAIN;
- if (modifiable)
+ if (publishPrivateKey)
style |= Font.ITALIC;
if (hasChanged)
style |= Font.BOLD;
Modified: trunk/apps/Thaw/src/thaw/plugins/index/IndexTreeNode.java
===================================================================
--- trunk/apps/Thaw/src/thaw/plugins/index/IndexTreeNode.java 2007-08-08
18:27:27 UTC (rev 14531)
+++ trunk/apps/Thaw/src/thaw/plugins/index/IndexTreeNode.java 2007-08-08
18:50:10 UTC (rev 14532)
@@ -43,6 +43,7 @@
public String getPrivateKey();
public boolean isModifiable();
+ public boolean publishPrivateKey();
public boolean hasChanged();
public boolean hasNewComment();