Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into HEAD
Browse files Browse the repository at this point in the history
  • Loading branch information
Rudi Wijaya committed Apr 28, 2014
2 parents 4dc2e37 + 065a33b commit b107913
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 24 deletions.
26 changes: 13 additions & 13 deletions context.xml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<contexts>


<context id="adapter_mongodb" title="MongoDB Data Adapter">
<description>MongoDB is an open source document-oriented database system developed and supported by 10gen. It is part of the NoSQL family of database systems. Instead of storing data in tables as is done in a &quot;classical&quot; relational database, MongoDB stores structured data as JSON-like documents with dynamic schemas (MongoDB calls the format BSON), making the integration of data in certain types of applications easier and faster.</description>
<topic href="html/mongodb.html" label="MongoDB Data Adapter"/>
</context>
<context id="query_mongo" title="Dataset and query dialog">
<description>From this dialog you can change the dataset query, define new parameters or change the adapter used to retrive the data.</description>
<topic href="http://docs.mongodb.org/manual/" label="The MongoDB Manual"/>
<topic href="http://docs.mongodb.org/manual/core/read-operations/" label="Read Operations Reference"/>
<?xml version="1.0" encoding="UTF-8"?>
<contexts>


<context id="adapter_mongodb" title="MongoDB Data Adapter">
<description>MongoDB is an open source document-oriented database system developed and supported by 10gen. It is part of the NoSQL family of database systems. Instead of storing data in tables as is done in a &quot;classical&quot; relational database, MongoDB stores structured data as JSON-like documents with dynamic schemas (MongoDB calls the format BSON), making the integration of data in certain types of applications easier and faster.</description>
<topic href="html/mongodb.html" label="MongoDB Data Adapter"/>
</context>
</contexts>
<context id="query_mongo" title="Dataset and query dialog">
<description>From this dialog you can change the dataset query, define new parameters or change the adapter used to retrive the data.</description>
<topic href="http://docs.mongodb.org/manual/" label="The MongoDB Manual"/>
<topic href="http://docs.mongodb.org/manual/core/read-operations/" label="Read Operations Reference"/>
</context>
</contexts>
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<artifactId>com.jaspersoft.studio.data.mongodb</artifactId>
<!--packaging>eclipse-plugin</packaging-->
<packaging>jar</packaging>
<version>5.1.0.soluvas1</version>
<version>5.1.1-SNAPSHOT</version>

<dependencies>
<dependency>
Expand Down
23 changes: 13 additions & 10 deletions src/com/jaspersoft/mongodb/connection/MongoDbConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@
import java.sql.Statement;
import java.sql.Struct;
import java.util.Arrays;
import java.util.List;
import java.util.HashSet;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.Executor;

import net.sf.jasperreports.engine.JRException;
Expand Down Expand Up @@ -66,11 +67,12 @@ public class MongoDbConnection implements Connection {

private static final Logger logger = LoggerFactory.getLogger(MongoDbConnection.class);

protected static final List<Integer> AUTH_ERROR_CODES = Arrays.asList(new Integer[] {
protected static final Set<Integer> AUTH_ERROR_CODES = new HashSet<Integer>(Arrays.asList(new Integer[] {
16550, // not authorized for query on foo.system.namespaces
10057, // unauthorized db:admin ns:admin.system.users lock type:1 client:127.0.0.1
15845 // unauthorized
});
15845, // unauthorized
13 // MongoDB 2.6.0: not authorized on DB to execute command { count: \"system.namespaces\", query: {}, fields: {} }
}));

public MongoDbConnection(String mongoURI, String username, String password)
throws JRException {
Expand All @@ -86,7 +88,7 @@ private void create(String mongoURI) throws JRException {
client = new Mongo(mongoURIObject = new MongoURI(mongoURI));
} catch (Exception e) {
logger.error("Cannot create connection", e);
throw new JRException(e.getMessage());
throw new JRException(e.getMessage(), e);
}
}

Expand All @@ -105,15 +107,16 @@ private void setDatabase() throws JRException {
} catch (Exception e) {
String message = e.getMessage();
if (e instanceof MongoException) {
if (AUTH_ERROR_CODES.contains(((MongoException) e).getCode())) {
final MongoException mongoE = (MongoException) e;
if (AUTH_ERROR_CODES.contains(mongoE.getCode())) {
performaAuthentication = true;
} else {
logger.error("Cannot set database", e);
throw new JRException(message);
logger.error("Cannot set database. Code " + mongoE.getCode() + ": " + mongoE, mongoE);
throw new JRException("Error " + mongoE.getCode() + ": " + mongoE, mongoE);
}
} else {
logger.error("Cannot set database", e);
throw new JRException(message);
logger.error("Cannot set database: " + e, e);
throw new JRException(message, e);
}
}
if (performaAuthentication) {
Expand Down

0 comments on commit b107913

Please sign in to comment.