/** * Gets a field * * @param name field name * @return The value */ public Object getField(String name) { return writeResult.getField(name); }
/** * Gets a field * * @param name field name * @return The value */ public Object getField(String name) { return writeResult.getField(name); }
/** * updating the entire properties object at the same time, with force flag * to allow overwriting of updates * from other instances of the state * * @param force * @throws UpdateConflictException * | will not throw anything when $force flag is true */ private synchronized boolean updateProperties(final boolean force) throws UpdateConflictException { final Long now = System.nanoTime(); /* write to database */ final WriteResult result = (force) ? collection.update("{_id: #}", getId()).with("{$set: {properties: #, timestamp: #}}", properties, now) : collection.update("{_id: #, timestamp: #}", getId(), timestamp).with( "{$set: {properties: #, timestamp: #}}", properties, now); /* check results */ final Boolean updatedExisting = (Boolean) result .getField("updatedExisting"); if (result.getN() == 0 && result.getError() == null) { throw new UpdateConflictException(timestamp); } else if (result.getN() != 1) { throw new MongoException(result.getError()+ " <--- "+properties); } timestamp = now; return updatedExisting; }