Skip to content

Commit

Permalink
Merge pull request #34 from le-yams/v8.2
Browse files Browse the repository at this point in the history
merge V8.2 branch
  • Loading branch information
le-yams committed Jul 1, 2015
2 parents 0408d81 + 1cd26d4 commit 95fa202
Show file tree
Hide file tree
Showing 90 changed files with 2,962 additions and 1,064 deletions.
17 changes: 11 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.netbeans.modules</groupId>
<artifactId>nbmongo</artifactId>
<version>8.1.0</version>
<version>8.2.0-SNAPSHOT</version>
<packaging>nbm</packaging>

<name>NBMongo</name>
Expand Down Expand Up @@ -160,16 +160,21 @@
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>2.13.0</version>
<version>3.0.2</version>
<type>jar</type>
</dependency>


<!-- ##### Other Dependencies ##### -->
<dependency>
<groupId>com.github.jsonj</groupId>
<artifactId>jsonj</artifactId>
<version>0.8</version>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>com.cedarsoftware</groupId>
<artifactId>json-io</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>com.mytdev</groupId>
Expand All @@ -184,7 +189,7 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.14.8</version>
<version>1.16.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
19 changes: 18 additions & 1 deletion src/main/java/org/netbeans/modules/mongodb/CollectionInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Objects;
import lombok.Getter;
import lombok.NonNull;
import org.netbeans.modules.mongodb.util.SystemCollectionPredicate;
import org.openide.util.Lookup;

/**
Expand All @@ -46,6 +47,10 @@ public CollectionInfo(@NonNull String name, @NonNull Lookup lookup) {
this.lookup = lookup;
}

public boolean isSystemCollection() {
return SystemCollectionPredicate.get().eval(name);
}

@Override
public boolean equals(Object object) {
if (object == null) {
Expand Down Expand Up @@ -79,6 +84,18 @@ public String toString() {

@Override
public int compareTo(CollectionInfo o) {
return name.compareToIgnoreCase(o.name);
int sysCol = isSystemCollection() ? 1 : 0;
sysCol |= o.isSystemCollection() ? 2 : 0;
switch (sysCol) {
case 1:
return -1;
case 2:
return 1;
case 0: // FALL THROUGH
case 3:
return name.compareToIgnoreCase(o.name);
default:
throw new AssertionError();
}
}
}
92 changes: 0 additions & 92 deletions src/main/java/org/netbeans/modules/mongodb/CollectionStats.java

This file was deleted.

95 changes: 0 additions & 95 deletions src/main/java/org/netbeans/modules/mongodb/DatabaseStats.java

This file was deleted.

13 changes: 7 additions & 6 deletions src/main/java/org/netbeans/modules/mongodb/Index.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
*/
package org.netbeans.modules.mongodb;

import com.mongodb.DBObject;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
Expand All @@ -29,6 +28,7 @@
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.bson.Document;

/**
* POJO that contains the data of an index.
Expand Down Expand Up @@ -87,12 +87,13 @@ public void propertyChange(PropertyChangeEvent evt) {
}
};

public Index(DBObject indexInfo) {
name = (String) indexInfo.get("name");
nameSpace = (String) indexInfo.get("ns");
final DBObject keyObj = (DBObject)indexInfo.get("key");
for(String keyObjProperty: keyObj.keySet())
public Index(Document indexInfo) {
name = indexInfo.getString("name");
nameSpace = indexInfo.getString("ns");
final Document keyObj = indexInfo.get("key", Document.class);
for(String keyObjProperty: keyObj.keySet()) {
keys.add(new Key(keyObjProperty, Integer.valueOf(1).equals(keyObj.get(keyObjProperty))));
}
sparse = Boolean.TRUE.equals(indexInfo.get("sparse"));
unique = Boolean.TRUE.equals(indexInfo.get("unique"));
dropDuplicates = Boolean.TRUE.equals(indexInfo.get("dropDups"));
Expand Down
13 changes: 1 addition & 12 deletions src/main/java/org/netbeans/modules/mongodb/MongoConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import com.mongodb.MongoClient;
import com.mongodb.MongoException;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
import lombok.Getter;
Expand Down Expand Up @@ -64,7 +63,7 @@ public void run() {
final ConnectionInfo connection = getLookup().lookup(ConnectionInfo.class);
try {
client = new MongoClient(connection.getMongoURI());
client.getDatabaseNames(); // ensure connection works
client.listDatabaseNames();
fireConnectionStateChanged(ConnectionState.CONNECTED);
} catch (MongoException ex) {
DialogDisplayer.getDefault().notify(
Expand All @@ -76,16 +75,6 @@ public void run() {
if (client != null) {
client.close();
}
} catch (UnknownHostException ex) {
DialogDisplayer.getDefault().notify(
new NotifyDescriptor.Message(
"unknown server: " + ex.getLocalizedMessage(),
NotifyDescriptor.ERROR_MESSAGE));
MongoClient client = MongoConnection.this.client;
MongoConnection.this.client = null;
if (client != null) {
client.close();
}
}
}
}, Bundle.waitWhileConnecting());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@
*/
package org.netbeans.modules.mongodb;

import com.mongodb.DBObject;
import com.mongodb.MongoException;
import com.mongodb.util.JSON;
import org.bson.Document;

/**
* Unwrapps a MongoException message.
Expand All @@ -34,10 +33,10 @@ public MongoExceptionUnwrapper(Exception ex) {
if(ex instanceof MongoException) {
String msgValue = ex.getMessage();
try {
DBObject jsonMsg = (DBObject) JSON.parse(ex.getMessage());
msgValue = (String) jsonMsg.get("err");
Document document = Document.parse(ex.getMessage());
msgValue = document.getString("err");
if(msgValue == null || msgValue.isEmpty()) {
msgValue = (String) jsonMsg.get("errmsg");
msgValue = document.getString("errmsg");
}
} catch(Exception ignored) { }
message = msgValue;
Expand Down
Loading

0 comments on commit 95fa202

Please sign in to comment.