Package com.mongodb

Examples of com.mongodb.QueryBuilder$QueryBuilderException


            .getDb()
            .getCollection(DB_NAME),
          MongoThirdParty.class);
   
    // Build the query.
    QueryBuilder queryBuilder = QueryBuilder.start();
   
    // Add the third-party ID to the query.
    queryBuilder.and(ThirdParty.JSON_KEY_ID).is(thirdParty);
   
    // Execute query.
    DBCursor<MongoThirdParty> result = collection.find(queryBuilder.get());
   
    // If multiple authentication tokens were returned, that is a violation
    // of the system.
    if(result.count() > 1) {
      throw
View Full Code Here


            .getDb()
            .getCollection(DB_NAME),
          MongoAuthenticationToken.class);
   
    // Build the query.
    QueryBuilder queryBuilder = QueryBuilder.start();
   
    // Add the authentication token to the query.
    queryBuilder.and(AuthenticationToken.JSON_KEY_TOKEN).is(token);
   
    // Add the expiration timer to ensure that this token has not expired.
    queryBuilder
      .and(MongoAuthenticationToken.JSON_KEY_EXPIRES)
      .greaterThan(System.currentTimeMillis());
   
    // Execute query.
    DBCursor<MongoAuthenticationToken> result =
      collection.find(queryBuilder.get());
   
    // If multiple authentication tokens were returned, that is a violation
    // of the system.
    if(result.count() > 1) {
      throw
View Full Code Here

        if (!revisionIdExists()) {
            throw new RuntimeException("Revision id '" + revisionId + "' is not valid.");
        }

        DBCollection nodeCollection = mongoConnection.getNodeCollection();
        QueryBuilder queryBuilder = QueryBuilder.start(NodeMongo.KEY_PATH).is(path);
        if (revisionId > 0) {
            queryBuilder = queryBuilder.and(NodeMongo.KEY_REVISION_ID).is(revisionId);
        }
        DBObject query = queryBuilder.get();

        DBObject filter = null;
        if (!fetchAll) {
            QueryBuilder filterBuilder = QueryBuilder.start(NodeMongo.KEY_REVISION_ID).is(1);
            filterBuilder.and(NodeMongo.KEY_CHILDREN).is(1);
            filter = filterBuilder.get();
        }

        NodeMongo nodeMongo = (NodeMongo) nodeCollection.findOne(query, filter);

        return nodeMongo;
View Full Code Here

    }

    private DBCursor performQuery(Pattern pattern) {
        DBCollection nodeCollection = mongoConnection.getNodeCollection();

        QueryBuilder qb = QueryBuilder.start(NodeMongo.KEY_PATH).regex(pattern);
        if (revisionId != null) {
            qb = qb.and(NodeMongo.KEY_REVISION_ID).lessThanEquals(MongoUtil.toMongoRepresentation(revisionId));
        }

        DBObject query = qb.get();

        LOG.debug(String.format("Executing query: %s", query));

        DBCursor dbCursor = nodeCollection.find(query);
View Full Code Here

        }
    }

    public static void assertNodesExist(String parentPath, Node expected) {
        DBCollection nodeCollection = mongoConnection.getNodeCollection();
        QueryBuilder qb = QueryBuilder.start(NodeMongo.KEY_PATH).is(expected.getPath()).and(NodeMongo.KEY_REVISION_ID)
                .is(MongoUtil.toMongoRepresentation(expected.getRevisionId()));
        Map<String, Object> properties = expected.getProperties();
        if (properties != null) {
            for (Map.Entry<String, Object> entry : properties.entrySet()) {
                qb.and(NodeMongo.KEY_PROPERTIES + "." + entry.getKey()).is(entry.getValue());
            }
        }

        DBObject query = qb.get();

        NodeMongo nodeMongo = (NodeMongo) nodeCollection.findOne(query);
        Assert.assertNotNull(nodeMongo);

        Set<Node> children = expected.getChildren();
View Full Code Here

        }
        List<R> results = new ArrayList<R>();
        for (Map.Entry<JacksonCollectionKey, List<Object>> entry : collectionsToIds
                .entrySet()) {
            for (R result : this.<R, RK> getReferenceCollection(entry.getKey())
                    .find(new QueryBuilder().put("_id").in(entry.getValue())
                            .get(), fields)) {
                results.add(result);
            }
        }
        return results;
View Full Code Here

        dropObsoleteChangeSetExecutionIndices();
        ensureChangeSetExecutionIndex();
    }

    private void addTypeToUntypedRecords() {
        DBObject q = new QueryBuilder().put("type").exists(false).get();
        BasicDBObject o = new BasicDBObject("$set", new BasicDBObject("type", RecordType.changeSetExecution.name()));
        getMongeezCollection().update(q, o, false, true, WriteConcern.SAFE);
    }
View Full Code Here

        BasicDBObject o = new BasicDBObject("$set", new BasicDBObject("type", RecordType.changeSetExecution.name()));
        getMongeezCollection().update(q, o, false, true, WriteConcern.SAFE);
    }

    private void loadConfigurationRecord() {
        DBObject q = new QueryBuilder().put("type").is(RecordType.configuration.name()).get();
        DBObject configRecord = getMongeezCollection().findOne(q);
        if (configRecord == null) {
            if (getMongeezCollection().count() > 0L) {
                // We have pre-existing records, so don't assume that they support the latest features
                configRecord =
View Full Code Here

        }), cursor);
    }

    @Override
    public boolean acquireRecoveryLock(int clusterId) {
        QueryBuilder query =
                start().and(
                        start(Document.ID).is(Integer.toString(clusterId)).get(),
                        start(ClusterNodeInfo.REV_RECOVERY_LOCK).notEquals(RecoverLockState.ACQUIRED.name()).get()
                );

        DBObject returnFields = new BasicDBObject();
        returnFields.put("_id", 1);

        BasicDBObject setUpdates = new BasicDBObject();
        setUpdates.append(ClusterNodeInfo.REV_RECOVERY_LOCK, RecoverLockState.ACQUIRED.name());

        BasicDBObject update = new BasicDBObject();
        update.append("$set", setUpdates);

        DBObject oldNode = getClusterNodeCollection().findAndModify(query.get(), returnFields,
                null /*sort*/, false /*remove*/, update, false /*returnNew*/,
                false /*upsert*/);

        return oldNode != null;
    }
View Full Code Here

        return oldNode != null;
    }

    @Override
    public boolean isRecoveryNeeded(long currentTime) {
        QueryBuilder query =
                start(ClusterNodeInfo.STATE).is(ClusterNodeInfo.ClusterNodeState.ACTIVE.name())
                .put(ClusterNodeInfo.LEASE_END_KEY).lessThan(currentTime)
                .put(ClusterNodeInfo.REV_RECOVERY_LOCK).notEquals(RecoverLockState.ACQUIRED.name());

        return getClusterNodeCollection().findOne(query.get()) != null;
    }
View Full Code Here

TOP

Related Classes of com.mongodb.QueryBuilder$QueryBuilderException

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.