private void verifyDeleteShareACLs(List<ShareACL> shareAclList) {
    if (shareAclList == null) {
      return;
    }
    _log.info("Number of share ACL(s) to delete {} ", shareAclList.size());

    for (ShareACL acl : shareAclList) {
      acl.proceedToNextStep();
      _log.info("Verifying ACL {}", acl.toString());

      // Are there same user or group found in other acls. If so, report
      // error
      verifyUserGroup(acl);

      if (!acl.canProceedToNextStep()) {
        break;
      }

      // Verify with existing ACL
      CifsShareACL dbShareAcl = getExistingACL(acl);

      // If same acl exists, allow to modify
      if (dbShareAcl != null) {
        _log.info("Existing ACL found in delete request: {}", dbShareAcl);
        acl.proceedToNextStep();

      } else {
        // If not found, don't allow to proceed further
        if (acl.canProceedToNextStep()) {
          _log.error("No existing ACL found in DB to delete {}", acl);
          acl.cancelNextStep(ShareACLOperationErrorType.ACL_NOT_FOUND);
        }
      }
    }
  }
  private void reportDeleteErrors(CifsShareACLUpdateParams param) {

    String opName = ShareACLOperationType.DELETE.name();
    // Report Add ACL Errors
    ShareACLs shareAcls = param.getAclsToDelete();
    if (shareAcls == null || shareAcls.getShareACLs().size() == 0) return;

    List<ShareACL> shareAclList = shareAcls.getShareACLs();
    for (ShareACL acl : shareAclList) {
      if (!acl.canProceedToNextStep()) {
        ShareACLOperationErrorType error = acl.getErrorType();

        switch (error) {

            /*
             * case SNAPSHOT_EXPORT_SHOULD_BE_READ_ONLY: { throw
             * APIException.badRequests.snapshotExportPermissionReadOnly();
             * }
             */

          case USER_AND_GROUP_PROVIDED:
            {
              throw APIException.badRequests.bothUserAndGroupInACLFound(
                  acl.getUser(), acl.getGroup());
            }

          case USER_OR_GROUP_NOT_PROVIDED:
            {
              throw APIException.badRequests.missingUserOrGroupInACE(opName);
            }

          case MULTIPLE_ACES_WITH_SAME_USER_OR_GROUP:
            {
              String userOrGroup = acl.getUser() == null ? acl.getGroup() : acl.getUser();

              throw APIException.badRequests.multipleACLsWithUserOrGroupFound(opName, userOrGroup);
            }

          case MULTIPLE_DOMAINS_FOUND:
            {
              String domain1 = acl.getDomain();
              String userOrGroup = acl.getUser() == null ? acl.getGroup() : acl.getUser();
              String domain2 = userOrGroup.substring(0, userOrGroup.indexOf("\\"));
              throw APIException.badRequests.multipleDomainsFound(opName, domain1, domain2);
            }

          case ACL_NOT_FOUND:
            {
              throw APIException.badRequests.shareACLNotFoundFound(opName, acl.toString());
            }

          default:
            break;
        }
      }
    }
  }
  private void verifyAddShareACLs(List<ShareACL> shareAclList) {
    if (shareAclList == null) {
      return;
    }
    _log.info("Number of share ACL(s) to add {} ", shareAclList.size());

    for (ShareACL acl : shareAclList) {
      acl.proceedToNextStep();
      _log.info("Verifying ACL {}", acl.toString());

      // Are there same user or group found in other acls. If so, report
      // error
      verifyUserGroup(acl);

      if (!acl.canProceedToNextStep()) {
        break;
      }

      validatePermissions(acl);

      if (!acl.canProceedToNextStep()) {
        break;
      }
      // Verify with existing ACL
      CifsShareACL dbShareAcl = getExistingACL(acl);

      // If same acl exists, don't allow to add again.
      if (dbShareAcl != null) {
        _log.error(
            "Duplicate ACL in add request. User/group in ACL for share already exists: {}",
            dbShareAcl);
        acl.cancelNextStep(ShareACLOperationErrorType.ACL_EXISTS);
        break;
      }
      // If not found proceed for further verifications.
      else {
        if (acl.canProceedToNextStep()) {
          _log.info("No existing ACL found in DB {}", acl);
        }
      }
    }
  }
  private void reportAddErrors(CifsShareACLUpdateParams param) {

    String opName = ShareACLOperationType.ADD.name();
    // Report Add ACL Errors
    ShareACLs shareAcls = param.getAclsToAdd();
    if (shareAcls == null || shareAcls.getShareACLs().size() == 0) return;

    List<ShareACL> shareAclList = shareAcls.getShareACLs();
    for (ShareACL acl : shareAclList) {
      if (!acl.canProceedToNextStep()) {
        ShareACLOperationErrorType error = acl.getErrorType();

        switch (error) {
          case SNAPSHOT_SHARE_SHOULD_BE_READ_ONLY:
            {
              throw APIException.badRequests.snapshotSMBSharePermissionReadOnly();
            }

          case INVALID_PERMISSION:
            {
              if (acl.getPermission() != null) {
                throw APIException.badRequests.invalidPermissionForACL(acl.getPermission());
              } else {
                throw APIException.badRequests.missingValueInACE(opName, REQUEST_PARAM_PERMISSION);
              }
            }

          case USER_AND_GROUP_PROVIDED:
            {
              throw APIException.badRequests.bothUserAndGroupInACLFound(
                  acl.getUser(), acl.getGroup());
            }

          case USER_OR_GROUP_NOT_PROVIDED:
            {
              throw APIException.badRequests.missingUserOrGroupInACE(opName);
            }

          case MULTIPLE_ACES_WITH_SAME_USER_OR_GROUP:
            {
              String userOrGroup = acl.getUser() == null ? acl.getGroup() : acl.getUser();

              throw APIException.badRequests.multipleACLsWithUserOrGroupFound(opName, userOrGroup);
            }

          case MULTIPLE_DOMAINS_FOUND:
            {
              String domain1 = acl.getDomain();
              String userOrGroup = acl.getUser() == null ? acl.getGroup() : acl.getUser();
              String domain2 = userOrGroup.substring(0, userOrGroup.indexOf("\\"));
              throw APIException.badRequests.multipleDomainsFound(opName, domain1, domain2);
            }

          case ACL_EXISTS:
            {
              throw APIException.badRequests.shareACLAlreadyExists(opName, acl.toString());
            }
            // case ACL_NOT_FOUND:
          default:
            break;
        }
      }
    }
  }