Source:
public void createNewItem(final String userId, final String authId, final String itemId, final School.ItemType itemType, final String parentId, final Authenticator authChecker) throws DatabaseAccessException, AuthenticationException { final School.ItemType parentType = getParentItemType(itemType); if (!parentType.equals(itemType)) { final AuthenticationResponder responder = authChecker.checkAuthentication(getParentItemType(itemType), parentId, authId, 0, Authentication.AuthType.newBuilder().setCheckingAdmin(true).build()); if (!responder.hasModeratorPermission()) { throw new AuthenticationException("User does not have permission to insert new items for id: " + parentId, AuthenticationException.INVALID_PERMISSION); } } final BasicDBObject insertQuery = createItemInsertQuery(userId, itemId, itemType); if (!parentType.equals(itemType)) { copyParentDetails(insertQuery, itemId, itemType, parentId); } if (itemType.equals(School.ItemType.COURSE)) { final String groupId = createNewGroup(userId, itemId); final List<String> groupList = new ArrayList<>(); groupList.add(groupId); insertQuery.append(DatabaseStringConstants.USER_LIST, groupList); } if (itemType.equals(School.ItemType.BANK_PROBLEM)) { final String groupId = createNewGroup(userId, itemId); final List<String> groupList = new ArrayList<>(); groupList.add(groupId); insertQuery.append(DatabaseStringConstants.USER_LIST, groupList); if (parentId != null) { insertUserIntoGroup(parentId, groupId, true); } } final DBCollection collection = database.getCollection(getCollectionFromType(itemType)); collection.insert(insertQuery); }

Target:
public void createNewItem(final String userId, final String authId, final String itemId, final School.ItemType itemType, final String parentId, final Authenticator authChecker) throws DatabaseAccessException, AuthenticationException { final School.ItemType parentType = getParentItemType(itemType); if (!parentType.equals(itemType)) { final AuthenticationResponder responder = authChecker.checkAuthentication(getParentItemType(itemType), parentId, authId, 0, Authentication.AuthType.newBuilder().setCheckingAdmin(true).build()); if (!responder.hasModeratorPermission()) { throw new AuthenticationException("User does not have permission to insert new items for id: " + parentId, AuthenticationException.INVALID_PERMISSION); } } final BasicDBObject insertQuery = createItemInsertQuery(userId, itemId, itemType); if (!parentType.equals(itemType)) { copyParentDetails(insertQuery, itemId, itemType, parentId); } if (itemType.equals(School.ItemType.COURSE)) { final String groupId = createNewGroup(userId, itemId); final List<String> groupList = new ArrayList<>(); groupList.add(groupId); insertQuery.append(DatabaseStringConstants.USER_LIST, groupList); } else if (itemType.equals(School.ItemType.BANK_PROBLEM)) { final String groupId = createNewGroup(userId, itemId); final List<String> groupList = Lists.newArrayList(groupId); insertQuery.append(DatabaseStringConstants.USER_LIST, groupList); if (parentId != null) { insertUserIntoGroup(parentId, groupId, true); } } final DBCollection collection = database.getCollection(getCollectionFromType(itemType)); collection.insert(insertQuery); }