Source:
public static boolean mongoUpdateCourseProblem(final Authenticator authenticator, final DB dbs, final String authId, final String problemId, final SrlProblem problem) throws AuthenticationException, DatabaseAccessException { boolean update = false; final DBCollection collection = dbs.getCollection(getCollectionFromType(School.ItemType.COURSE_PROBLEM)); final DBObject cursor = collection.findOne(convertStringToObjectId(problemId)); if (cursor == null) { throw new DatabaseAccessException("Course problem was not found with the following ID: " + problemId); } final BasicDBObject updateObj = new BasicDBObject(); final DBCollection problemCollection = dbs.getCollection(getCollectionFromType(School.ItemType.COURSE_PROBLEM)); final Authentication.AuthType authType = Authentication.AuthType.newBuilder() .setCheckingAdmin(true) .build(); final AuthenticationResponder responder = authenticator .checkAuthentication(School.ItemType.COURSE_PROBLEM, problemId, authId, 0, authType); if (!responder.hasModeratorPermission()) { throw new AuthenticationException("For problem: " + problemId, AuthenticationException.INVALID_PERMISSION); } if (problem.hasName()) { updateObj.append(NAME, problem.getName()); update = true; } if (problem.hasGradeWeight()) { updateObj.append(GRADE_WEIGHT, problem.getGradeWeight()); update = true; } if (problem.hasProblemBankId()) { updateObj.append(PROBLEM_BANK_ID, problem.getProblemBankId()); update = true; } if (update) { problemCollection.update(cursor, new BasicDBObject(SET_COMMAND, updateObj)); UserUpdateHandler.insertUpdates(dbs, ((List) cursor.get(USERS)), problemId, UserUpdateHandler.COURSE_PROBLEM_CLASSIFICATION); } return true; }

Target:
public static boolean mongoUpdateCourseProblem(final Authenticator authenticator, final DB dbs, final String authId, final String problemId, final SrlProblem problem) throws AuthenticationException, DatabaseAccessException { boolean update = false; final DBCollection courseProblemCollection = dbs.getCollection(getCollectionFromType(School.ItemType.COURSE_PROBLEM)); final DBObject cursor = courseProblemCollection.findOne(convertStringToObjectId(problemId)); if (cursor == null) { throw new DatabaseAccessException("Course problem was not found with the following ID: " + problemId); } final BasicDBObject updateObj = new BasicDBObject(); final Authentication.AuthType authType = Authentication.AuthType.newBuilder() .setCheckingAdmin(true) .build(); final AuthenticationResponder responder = authenticator .checkAuthentication(School.ItemType.COURSE_PROBLEM, problemId, authId, 0, authType); if (!responder.hasModeratorPermission()) { throw new AuthenticationException("For problem: " + problemId, AuthenticationException.INVALID_PERMISSION); } if (problem.hasName()) { updateObj.append(NAME, problem.getName()); update = true; } if (problem.hasGradeWeight()) { updateObj.append(GRADE_WEIGHT, problem.getGradeWeight()); update = true; } if (problem.hasProblemBankId()) { updateObj.append(PROBLEM_BANK_ID, problem.getProblemBankId()); update = true; } if (update) { courseProblemCollection.update(cursor, new BasicDBObject(SET_COMMAND, updateObj)); UserUpdateHandler.insertUpdates(dbs, ((List) cursor.get(USERS)), problemId, UserUpdateHandler.COURSE_PROBLEM_CLASSIFICATION); } return true; }