@Transactional
  @Override
  public void updateMakerCheckerPermissions(final PermissionsCommand command) {
    context.authenticatedUser();

    final Collection<Permission> allPermissions = this.permissionRepository.findAll();

    final Map<String, Boolean> commandPermissions = command.getPermissions();
    for (final String permissionCode : commandPermissions.keySet()) {

      final Permission permission = findPermissionByCode(allPermissions, permissionCode);

      if (permission.getCode().endsWith("_CHECKER")
          || permission.getCode().startsWith("READ_")
          || permission.getGrouping().equalsIgnoreCase("special")) {
        throw new PermissionNotFoundException(permissionCode);
      }

      final boolean isSelected = commandPermissions.get(permissionCode).booleanValue();
      permission.enableMakerChecker(isSelected);

      this.permissionRepository.save(permission);

      // Typical rollback if maker-checker enabled not here - does it make sense to have a maker
      // checker task for enabling maker-checker for other tasks?
    }
  }
  private Permission findPermissionByCode(
      Collection<Permission> allPermissions, String permissionCode) {

    if (allPermissions != null) {
      for (Permission permission : allPermissions) {
        if (permission.hasCode(permissionCode)) {
          return permission;
        }
      }
    }

    throw new PermissionNotFoundException(permissionCode);
  }