Package com.imaginea.mongodb.exceptions

Examples of com.imaginea.mongodb.exceptions.InvalidMongoCommandException


                @Override
                public Object execute() throws Exception {
                    // Get query
                    int startIndex = query.indexOf("("), endIndex = query.lastIndexOf(")");
                    if (startIndex == -1 || endIndex == -1) {
                        throw new InvalidMongoCommandException(ErrorCodes.INVALID_QUERY, "Invalid query");
                    }
                    String cmdStr = query.substring(0, startIndex);
                    int lastIndexOfDot = cmdStr.lastIndexOf(".");
                    if (lastIndexOfDot + 1 == cmdStr.length()) {
                        // In this case the cmsStr = db.collectionName.
                        throw new InvalidMongoCommandException(ErrorCodes.COMMAND_EMPTY, "Command is empty");
                    }
                    String command = cmdStr.substring(lastIndexOfDot + 1, cmdStr.length());
                    DatabaseService databaseService = new DatabaseServiceImpl(connectionId);
                    int docsLimit = Integer.parseInt(limit);
                    int docsSkip = Integer.parseInt(skip);
View Full Code Here


                int startIndex = query.indexOf("("), endIndex = query.lastIndexOf(")");
                String cmdStr = query.substring(0, startIndex);
                int lastIndexOfDot = cmdStr.lastIndexOf(".");
                if (lastIndexOfDot + 1 == cmdStr.length()) {
                    // In this case the cmsStr = db.gridFSName.
                    throw new InvalidMongoCommandException(ErrorCodes.COMMAND_EMPTY, "Command is empty");
                }
                int firstIndexOfDot = cmdStr.indexOf(".");
                int indexOfDotAtCollectionName = cmdStr.lastIndexOf(".", lastIndexOfDot - 1);
                String bucket = cmdStr.substring(firstIndexOfDot + 1, indexOfDotAtCollectionName);
                String collectionName = cmdStr.substring(indexOfDotAtCollectionName + 1, lastIndexOfDot);
                String command = cmdStr.substring(lastIndexOfDot + 1, cmdStr.length());
                if (firstIndexOfDot != lastIndexOfDot) {
                    // when commands are of the form db.bucketName.find
                } else {
                    throw new InvalidMongoCommandException(ErrorCodes.INVALID_COMMAND, "Invalid command");
                }
                String jsonStr = query.substring(startIndex + 1, endIndex);
                return gridFSService.executeQuery(dbName, bucket, collectionName, command, jsonStr, skip, limit, sortBy);
            }
        });
View Full Code Here

            return executeTotalIndexSize(dbCollection);
        }
        if (command.equals("update")) {
            return executeUpdate(dbCollection, queryStr);
        }
        throw new InvalidMongoCommandException(ErrorCodes.COMMAND_NOT_SUPPORTED, "Command is not yet supported");
    }
View Full Code Here

        String outputCollection = null;

        if (params.get("out") instanceof DBObject) {
            DBObject out = (DBObject) params.get("out");
            if (out.get("sharded") != null) {
                throw new InvalidMongoCommandException(ErrorCodes.COMMAND_NOT_SUPPORTED, "sharded is not yet supported. Please remove it and run again");
            }
            if (out.get("replace") != null) {
                if (out.get("nonAtomic") != null) {
                    throw new InvalidMongoCommandException(ErrorCodes.COMMAND_NOT_SUPPORTED, "nonAtomic is not supported in replace mode. Please remove it and run again");
                }
                outputCollection = (String) out.get("replace");
                outputDb = (String) out.get("db");
                outputType = MapReduceCommand.OutputType.REPLACE;
            } else if (out.get("merge") != null) {
                outputCollection = (String) out.get("merge");
                outputDb = (String) out.get("db");
                outputType = MapReduceCommand.OutputType.INLINE;
            } else if (out.get("reduce") != null) {
                outputCollection = (String) out.get("reduce");
                outputDb = (String) out.get("db");
                outputType = MapReduceCommand.OutputType.INLINE;
            } else if (out.get("inline") != null) {
                outputType = MapReduceCommand.OutputType.INLINE;
                if (out.get("nonAtomic") != null) {
                    throw new InvalidMongoCommandException(ErrorCodes.COMMAND_NOT_SUPPORTED, "nonAtomic is not supported in inline mode. Please remove it and run again");
                }
            }
        } else if (params.get("out") instanceof String) {
            outputCollection = (String) params.get("out");
        }

        DBObject query = (DBObject) params.get("query");
        DBObject sort = (DBObject) params.get("sort");
        int limit = 0;
        if (params.get("limit") != null) {
            limit = (Integer) params.get("limit");
        }
        String finalize = (String) params.get("finalize");
        Map scope = (Map) params.get("scope");
        if (params.get("jsMode") != null) {
            throw new InvalidMongoCommandException(ErrorCodes.COMMAND_NOT_SUPPORTED, "jsMode is not yet supported. Please remove it and run again");
        }
        boolean verbose = true;
        if (params.get("verbose") != null) {
            verbose = (Boolean) params.get("verbose ");
        }
View Full Code Here

        String reconstructedUpdateQuery = "{updateQueryParams:[" + queryStr + "]}";
        DBObject queryObj = (DBObject) JSON.parse(reconstructedUpdateQuery);

        List queryParams = (List) queryObj.get("updateQueryParams");
        if (queryParams.size() < 2) {
            throw new InvalidMongoCommandException(ErrorCodes.COMMAND_ARGUMENTS_NOT_SUFFICIENT, "Requires atleast 2 params");
        }
        DBObject criteria = (DBObject) queryParams.get(0);
        DBObject updateByValuesMap = (DBObject) queryParams.get(1);
        boolean upsert = false, multi = false;
        if (queryParams.size() > 2) {
View Full Code Here

        }
        DBObject sortObj = (DBObject) JSON.parse(sortByStr);
        if (command.equals("runCommand")) {
            return executeCommand(db, queryStr);
        }
        throw new InvalidMongoCommandException(ErrorCodes.COMMAND_NOT_SUPPORTED, "Command is not yet supported");
    }
View Full Code Here

                public Object execute() throws Exception {
                    DocumentService documentService = new DocumentServiceImpl(connectionId);
                    // Get query
                    int startIndex = query.indexOf("("), endIndex = query.lastIndexOf(")");
                    if (startIndex == -1 || endIndex == -1) {
                        throw new InvalidMongoCommandException(ErrorCodes.INVALID_QUERY, "Invalid query");
                    }
                    String cmdStr = query.substring(0, startIndex);
                    int lastIndexOfDot = cmdStr.lastIndexOf(".");
                    if (lastIndexOfDot + 1 == cmdStr.length()) {
                        // In this case the cmsStr = db.collectionName.
                        throw new InvalidMongoCommandException(ErrorCodes.COMMAND_EMPTY, "Command is empty");
                    }
                    String command = cmdStr.substring(lastIndexOfDot + 1, cmdStr.length());
                    String collection = null;
                    int firstIndexOfDot = cmdStr.indexOf(".");
                    if (firstIndexOfDot != lastIndexOfDot) {
View Full Code Here

TOP

Related Classes of com.imaginea.mongodb.exceptions.InvalidMongoCommandException

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.