Package de.bwaldvogel.mongo.exception

Examples of de.bwaldvogel.mongo.exception.MongoServerError


    private BSONObject insertDocuments(final Channel channel, final String collectionName,
            final List<BSONObject> documents) throws MongoServerException {
        clearLastStatus(channel);
        try {
            if (collectionName.startsWith("system.")) {
                throw new MongoServerError(16459, "attempt to insert in system namespace");
            }
            final MongoCollection collection = resolveOrCreateCollection(collectionName);
            int n = collection.insertDocuments(documents);
            assert n == documents.size();
            final BSONObject result = new BasicBSONObject("n", Integer.valueOf(n));
View Full Code Here


    private BSONObject deleteDocuments(final Channel channel, final String collectionName, final BSONObject selector,
            final int limit) throws MongoServerException {
        clearLastStatus(channel);
        try {
            if (collectionName.startsWith("system.")) {
                throw new MongoServerError(12050, "cannot delete from system namespace");
            }
            MongoCollection collection = resolveCollection(collectionName, false);
            int n;
            if (collection == null) {
                n = 0;
View Full Code Here

    private BSONObject updateDocuments(final Channel channel, final String collectionName, final BSONObject selector,
            final BSONObject update, final boolean multi, final boolean upsert) throws MongoServerException {
        clearLastStatus(channel);
        try {
            if (collectionName.startsWith("system.")) {
                throw new MongoServerError(10156, "cannot update system collection");
            }

            MongoCollection collection = resolveOrCreateCollection(collectionName);
            return collection.updateDocuments(selector, update, multi, upsert);
        } catch (MongoServerException e) {
View Full Code Here

    }

    private void putLastError(Channel channel, MongoServerException ex) {
        BSONObject error = new BasicBSONObject();
        if (ex instanceof MongoServerError) {
            MongoServerError err = (MongoServerError) ex;
            error.put("err", err.getMessage());
            error.put("code", Integer.valueOf(err.getCode()));
        } else {
            error.put("err", ex.getMessage());
        }
        // TODO: https://github.com/netty/netty/issues/1810
        // also note:
View Full Code Here

TOP

Related Classes of de.bwaldvogel.mongo.exception.MongoServerError

Copyright © 2018 www.massapicom. 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.