Examples of MongoException


Examples of com.mongodb.MongoException

     * @param password the (optional) password to use.
     * @throws MongoException in case the connection or authentication failed.
     */
    private void connectToDB(MongoDB mongoDB, String userName, String password) throws MongoException {
        if (!mongoDB.connect(userName, password)) {
            throw new MongoException("Failed to connect to MongoDB! Authentication failed!");
        }

        DBCollection collection = mongoDB.getCollection();
        if (collection == null) {
            throw new MongoException("Failed to connect to MongoDB! No collection returned!");
        }

        collection.ensureIndex(new BasicDBObject(NAME, 1).append("unique", true));
    }
View Full Code Here

Examples of com.mongodb.MongoException

     * @throws MongoException in case no connection to MongoDB exists.
     */
    private DBCollection getCollection() {
        MongoDB mongoDB = m_mongoDbRef.get();
        if (mongoDB == null) {
            throw new MongoException("No connection to MongoDB?!");
        }
        return mongoDB.getCollection();
    }
View Full Code Here

Examples of com.mongodb.MongoException

     * @throws MongoException in case the requested member was not found (or any other MongoDB exception).
     */
    final Role findExistingMember(String name) {
        Role result = m_roleProvider.getRole(name);
        if (result == null) {
            throw new MongoException("No such role: " + name);
        }
        return result;
    }
View Full Code Here

Examples of com.mongodb.MongoException

            objectMapper.writeValue(generator, object);
        } catch (JsonMappingException e) {
            throw new MongoJsonMappingException(e);
        } catch (IOException e) {
            // This shouldn't happen
            throw new MongoException(
                    "Unknown error occurred converting BSON to object", e);
        }
        return generator.getDBObject();
    }
View Full Code Here

Examples of com.mongodb.MongoException

                objectMapper.writerWithView(view).writeValue(generator, object);
            } catch (JsonMappingException e) {
                throw new MongoJsonMappingException(e);
            } catch (IOException e) {
                // This shouldn't happen
                throw new MongoException(
                        "Unknown error occurred converting BSON to object", e);
            }
            return generator.getDBObject();
        }
    }
View Full Code Here

Examples of com.mongodb.MongoException

                    this, dbObject, objectMapper), type);
        } catch (JsonMappingException e) {
            throw new MongoJsonMappingException(e);
        } catch (IOException e) {
            // This shouldn't happen
            throw new MongoException(
                    "Unknown error occurred converting BSON to object", e);
        }
    }
View Full Code Here

Examples of com.mongodb.MongoException

                    dbObject, objectMapper), clazz);
        } catch (JsonMappingException e) {
            throw new MongoJsonMappingException(e);
        } catch (IOException e) {
            // This shouldn't happen
            throw new MongoException(
                    "Unknown error occurred converting BSON to object", e);
        }
    }
View Full Code Here

Examples of com.mongodb.MongoException

        executed = true;
    }

    private void checkExecuted() {
        if (executed) {
            throw new MongoException(
                    "Cannot modify query after it's been executed");
        }
    }
View Full Code Here

Examples of com.mongodb.MongoException

     * @throws MongoException
     *             If no objects were saved
     */
    public T getSavedObject() {
        if (dbObjects.length == 0) {
            throw new MongoException("No objects to return");
        }
        return getSavedObjects().get(0);
    }
View Full Code Here

Examples of com.mongodb.MongoException

     * @throws MongoException
     *             If no objects were saved
     */
    public K getSavedId() {
        if (dbObjects.length == 0) {
            throw new MongoException("No objects to return");
        }
        if (dbObjects[0] instanceof JacksonDBObject) {
            throw new UnsupportedOperationException(
                    "Generated _id retrieval not supported when using stream serialization");
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.