class DBService implements RolesProvider {

    boolean processRole(ObjectStoreConnection con, Role originalRole, String domainName,
            String roleName, Role role, String admin, String auditRef, boolean ignoreDeletes,
            StringBuilder auditDetails) {
        
        // check to see if we need to insert the role or update it
        
        boolean requestSuccess;
        if (originalRole == null) {
            // auditEnabled can only be set with system admin privileges
            role.setAuditEnabled(false);
            requestSuccess = con.insertRole(domainName, role);
        } else {
            // carrying over auditEnabled from original role
            role.setAuditEnabled(originalRole.getAuditEnabled());
            requestSuccess = con.updateRole(domainName, role);
        }
        
        // if we didn't update any roles then we need to return failure
        
        if (!requestSuccess) {
            return false;
        }

        // open our audit record and log our trust field if one is available
        
        auditDetails.append("{\"name\": \"").append(roleName)
            .append("\", \"trust\": \"").append(role.getTrust()).append('\"');
        
        // now we need process our role members depending this is
        // a new insert operation or an update

        List<RoleMember> roleMembers = role.getRoleMembers();
        
        // support older clients which might send members field
        // at this point, we expect either roleMembers or members,
        // and we can't have both
        
        List<String> members = role.getMembers();
        if (members != null && !members.isEmpty()) {
            roleMembers = ZMSUtils.convertMembersToRoleMembers(members);
        }
        
        if (originalRole == null) {
            
            // we are just going to process all members as new inserts

            if (roleMembers != null) {

                for (RoleMember member : roleMembers) {
                    if (!con.insertRoleMember(domainName, roleName, member, admin, auditRef)) {
                        return false;
                    }
                }
                auditLogRoleMembers(auditDetails, "added-members", roleMembers);
            }
        } else {
            processUpdateRoleMembers(con, originalRole, roleMembers, ignoreDeletes,
                    domainName, roleName, admin, auditRef, auditDetails);
        }
        
        auditDetails.append('}');
        return true;
    }

    public  DBService(ObjectStore store, AuditLogger auditLogger, ZMSConfig zmsConfig, AuditReferenceValidator auditReferenceValidator);

}