Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

issue37: db that requires auth does not always display so

  • Loading branch information...
commit 1cf7b086e89faa08a74e78459f1ed8aac45bfc82 1 parent 8e25513
@agirbal authored
View
4 src/org/mongo/jmongob/BaseTreeNode.java
@@ -28,7 +28,7 @@ protected void structureComponentCustom(JComponent old) {
try {
populateChildren();
} catch (Exception e) {
- getLogger().log(Level.WARNING, null, e);
+ getLogger().log(Level.WARNING, e.getMessage(), e);
}
super.structureComponentCustom(old);
getTree().expandNode(this);
@@ -44,7 +44,7 @@ protected void updateComponentCustom(JComponent comp) {
getLogger().log(Level.FINE, "Node " + toString() + " took " + (System.currentTimeMillis() - start));
} catch (MongoException e) {
- if (e.getCode() == 10057)
+ if (e.getCode() == 10057 || e.getMessage().startsWith("unauthorized"))
overlays.add(SwingFast.createIcon("overlay/lock.png", iconGroup));
else
overlays.add(SwingFast.createIcon("overlay/error.png", iconGroup));
View
6 src/org/mongo/jmongob/DbNode.java
@@ -54,10 +54,12 @@ protected void populateChildren() {
@Override
protected void updateNode(List<ImageIcon> overlays) {
label = db.getName();
- // db.getStats is too slow..
+ // db.getStats is too slow.. just do a quick command
// CommandResult res = db.getStats();
-// res.throwOnError();
+ CommandResult res = db.command("getLastError");
+ res.throwOnError();
// label += " (" + res.getInt("objects") + "/" + res.getInt("dataSize") + ")";
+
if (db.isAuthenticated())
overlays.add(SwingFast.createIcon("overlay/unlock.png", iconGroup));
}
View
9 src/org/mongo/jmongob/DbPanel.java
@@ -308,7 +308,8 @@ public void options() {
}
public void authenticate() {
- final DB db = getDbNode().getDb();
+ final DbNode dbNode = getDbNode();
+ final DB db = dbNode.getDb();
final String user = getStringFieldValue(Item.authUser);
final String pass = getStringFieldValue(Item.authPassword);
new DbJob() {
@@ -332,6 +333,12 @@ public String getShortName() {
@Override
public void wrapUp(Object res) {
super.wrapUp(res);
+ if (dbNode.getDb().getName().equals("admin")) {
+ // now we can list dbs, refresh whole mongo
+ dbNode.getMongoNode().structureComponent();
+ } else {
+ dbNode.structureComponent();
+ }
}
}.addJob();
}
View
3  src/org/mongo/jmongob/RouterNode.java
@@ -36,6 +36,9 @@ public RouterNode(ServerAddress addr, Mongo mongo) throws IOException, SAXExcept
protected void populateChildren() {
CommandResult res = mongo.getDB("admin").command("listShards");
BasicDBList shards = (BasicDBList) res.get("shards");
+ if (shards == null)
+ return;
+
for (Object obj : shards) {
try {
DBObject shard = (DBObject) obj;
Please sign in to comment.
Something went wrong with that request. Please try again.