Package org.bson.types

Examples of org.bson.types.ObjectId


            @RequestParam(value = "firstname") String firstname,
            @RequestParam(value = "lastname") String lastname,
            Model model) {
        System.out.println("ID received: " + id);
        User user = new User();
        user.setId(new ObjectId(id));
        user.setFirstname(firstname);
        user.setLastname(lastname);
        String msg = userService.updateUser(user);
        System.out.println("Message: " + msg);
        return msg;
View Full Code Here


            while (_running) {
                try {
                    for (final String lockName : _locks.keySet()) {
                        final DistributedLock lock = _locks.get(lockName);

                        final ObjectId lockId = lock.getLockId();

                        if (!lock.isLocked() || lockId == null) continue;

                        LockDao.heartbeat(_mongo, lockName, lockId, lock.getOptions(), _svcOptions);
                    }
View Full Code Here

            final long serverTime = getServerTime(pMongo, pSvcOptions);
            final long startTime = System.currentTimeMillis();

            // The doc was not there so we are going to try and insert a new doc.
            if (lockDoc == null) {
                final ObjectId lockId
                = tryInsertNew(pMongo, pLockName, pSvcOptions, pLockOptions,serverTime, startTime);
                if (lockId != null) return lockId;
            }

            if (lockDoc == null) lockDoc = findById(pMongo, pLockName, pSvcOptions);

            // Get the state.
            final LockState lockState = LockState.findByCode(lockDoc.getString(LockDef.STATE.field));

            // If it is unlocked, then try and lock.
            if (lockState.isUnlocked()) {
                final ObjectId lockId
                = tryLockingExisting( pMongo, pLockName, pSvcOptions, pLockOptions, serverTime, startTime);
                if (lockId != null) return lockId;
            }

            final ObjectId lockId = (ObjectId)lockDoc.get(LockDef.LOCK_ID.field);

            // Could not get the lock.
            incrementLockAttemptCount(pMongo, pLockName, lockId, pSvcOptions);

            return null;
View Full Code Here

        final long adjustTime = System.currentTimeMillis() - pStartTime;

        final long serverTime = pServerTime + adjustTime;
        final Date now = new Date(serverTime);

        final ObjectId lockId = ObjectId.get();

        final BasicDBObject query = new BasicDBObject(LockDef.ID.field, pLockName);
        query.put(LockDef.STATE.field, LockState.UNLOCKED.code());

        final BasicDBObject toSet = new BasicDBObject();
View Full Code Here

    {
        final long adjustTime = System.currentTimeMillis() - pStartTime;

        final long serverTime = pServerTime + adjustTime;
        final Date now = new Date(serverTime);
        final ObjectId lockId = ObjectId.get();

        final Thread currentThread = Thread.currentThread();

        final BasicDBObject lockDoc = new BasicDBObject(LockDef.ID.field, pLockName);
        lockDoc.put(LockDef.LIBRARY_VERSION.field, pSvcOptions.getLibVersion());
View Full Code Here

        try {
            while (cur.hasNext()) {

                final BasicDBObject lockDoc = (BasicDBObject)cur.next();

                final ObjectId lockId = (ObjectId)lockDoc.get(LockDef.LOCK_ID.field);
                final String lockName = lockDoc.getString(LockDef.ID.field);

                final long serverTime = getServerTime(pMongo, pSvcOptions);

                final BasicDBObject toSet = new BasicDBObject();
View Full Code Here

     * Try and lock the distributed lock.
     */
    private boolean tryDistributedLock() {
        if (isLocked()) return false;

        final ObjectId lockId = LockDao.lock(_mongo, _name, _svcOptions, _lockOptions);

        if (lockId == null) return false;

        _locked.set(true);
        _lockId = lockId;
View Full Code Here

     */
    @Override
    public boolean tryLock() {
        if (isLocked()) return false;

        final ObjectId lockId = LockDao.lock(_mongo, _name, _svcOptions, _lockOptions);

        if (lockId == null) return false;

        _locked.set(true);
        _lockId = lockId;
View Full Code Here

    }

    public static void testResults (){

       DAOEmployee daoEmployee = DAOEmployee.getInstance();
       Employee employee = daoEmployee.get(new ObjectId("5348c6168c49580b805788c3"));
       DAOSubjectCourse daoSubjectCourse = DAOSubjectCourse.getInstance();
       //daoSubjectCourse.findByTeacher(employee);

    }
View Full Code Here

            return null;
        }
        List<Period> periods = (List<Period>) getWrappedData();

        for(Period period : periods) {
            if(period.getId().equals(new ObjectId(rowKey)))
                return period;
        }

        return null;
    }
View Full Code Here

TOP

Related Classes of org.bson.types.ObjectId

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.