Examples of MongoException


Examples of com.mongodb.MongoException

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

Examples of com.mongodb.MongoException

                // number of bytes to the stream
                generator.close();
            } catch (JsonMappingException e) {
                throw new MongoJsonMappingException(e);
            } catch (IOException e) {
                throw new MongoException("Error writing object out", e);
            }
            return stream.getCount();
        } else {
            return defaultDBEncoder.writeObject(buf, object);
        }
View Full Code Here

Examples of com.mongodb.MongoException

            try {
                return jsonDeserializer
                        .deserialize(new BsonObjectTraversingParser(null, dbId,
                                objectMapper), null);
            } catch (IOException e) {
                throw new MongoException("Error deserializing ID", e);
            }
        }
View Full Code Here

Examples of com.mongodb.MongoException

        public D toDbId(K id) {
            BsonObjectGenerator generator = new BsonObjectGenerator();
            try {
                jsonSerializer.serialize(id, generator, null);
            } catch (IOException e) {
                throw new MongoException("Error serializing ID", e);
            }
            return (D) generator.getValue();
        }
View Full Code Here

Examples of com.mongodb.MongoException

            } else {
                if (mongo.getDB("admin").authenticate(user, password.toCharArray())) {
                    logger.debug("Successfully authenticated to MongoDB database (" + dbName +
                            ") as admin " + user);
                } else {
                    throw new MongoException("Unable to authenticate to MongoDB using " +
                            user + "@" + dbName + " or " + user + "@admin.");
                }
            }
        } else {
            logger.debug("Create the morphia datastore WITHOUT credentials");
View Full Code Here

Examples of com.mongodb.MongoException

     * @return The saved object
     * @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

     * @return The saved ID
     * @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");
        }
        return jacksonDBCollection.convertFromDbId(dbObjects[0].get("_id"));
View Full Code Here

Examples of com.mongodb.MongoException

     * @return The underlying DBObject
     * @throws MongoException If no objects were saved
     */
    public DBObject getDbObject() {
        if (dbObjects.length == 0) {
            throw new MongoException("No objects to return");
        }
        return dbObjects[0];
    }
View Full Code Here

Examples of com.mongodb.MongoException

        label = in;
        setStringFieldValue(Item.errorIn, in);
        setStringFieldValue(Item.errorMsg, exception.getMessage());
        String code = "?";
        if (exception instanceof MongoException) {
            MongoException me = (MongoException) exception;
            code = String.valueOf(me.getCode());
        }

        setStringFieldValue(Item.errorCode, code);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        PrintWriter pw = new PrintWriter(baos);
View Full Code Here

Examples of com.mongodb.MongoException

                // The generator buffers everything so that it can write the number of bytes to the stream
                generator.close();
            } catch (JsonMappingException e) {
                throw new MongoJsonMappingException(e);
            } catch (IOException e) {
                throw new MongoException("Error writing object out", e);
            }
            return stream.getCount();
        } else {
            return defaultDBEncoder.writeObject(buf, object);
        }
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.