public MessageSet validate(
     final User searcher,
     final FunctionOperand functionOperand,
     final TerminalClause terminalClause) {
   final MessageSet messageSet;
   I18nHelper i18n = getI18n();
   if (functionOperand.getArgs().size() == 0 && searcher == null) {
     messageSet = new MessageSetImpl();
     messageSet.addErrorMessage(
         i18n.getText("jira.jql.function.anonymous.disallowed", getFunctionName()));
   } else {
     MessageSet messages = validateNumberOfArgs(functionOperand, i18n);
     if (!messages.hasAnyErrors()) {
       if (functionOperand.getArgs().size() == 1) {
         final String username = functionOperand.getArgs().get(0);
         if (userUtil.getUserObject(username) == null) {
           messages.addErrorMessage(
               i18n.getText(getUserNotFoundMessageKey(), functionOperand.getName(), username));
         }
       }
     }
     return messages;
   }
   return messageSet;
 }
  public MessageSet validateBackupProjectImportableSystemLevel(
      final JiraServiceContext jiraServiceContext,
      final BackupProject backupProject,
      final BackupSystemInformation backupSystemInformation) {
    validateJiraServiceContext(jiraServiceContext);
    // No need to check if backupProject has null members, we will never create backup project like
    // that.
    Null.not("backupSystemInformation", backupSystemInformation);

    final MessageSet messageSet = new MessageSetImpl();
    final I18nHelper i18n = jiraServiceContext.getI18nBean();

    // Need to provide a backupProject
    if (backupProject == null) {
      messageSet.addErrorMessage(getText(i18n, "admin.error.project.import.null.project"));
      jiraServiceContext
          .getErrorCollection()
          .addErrorMessage(getText(i18n, "admin.error.project.import.null.project"));
      return messageSet;
    }

    // The user must have the system administrator permission to perform a project import
    if (!userHasSysAdminPermission(jiraServiceContext.getUser())) {
      messageSet.addErrorMessage(getText(i18n, "admin.errors.project.import.must.be.admin"));
    } else {
      // Verify that if the backup projects custom field plugins exist that they are of the right
      // version in this JIRA instance
      // NOTE: warnings, such as the plugin not existing or the custom field being not importable or
      // out of context
      // are not checked here, that is handled by the next phase of the import.
      validateCustomFieldPluginVersions(
          backupProject, backupSystemInformation.getPluginVersions(), messageSet, i18n);

      final String projectKey = backupProject.getProject().getKey();
      final Project existingProject = projectManager.getProjectObjByKey(projectKey);
      if (existingProject == null) {
        // It does not really make sense to warn that we will create a project for them if there are
        // already errors.
        if (!messageSet.hasAnyErrors()) {
          messageSet.addWarningMessage(
              getText(i18n, "admin.warning.project.import.no.existing.project", projectKey));
        }
      } else {
        // We need to make sure that the project does not contain issues, versions, components,
        // etc...
        validateExistingProjectHasValidStateForImport(
            backupProject, backupSystemInformation, existingProject, i18n, messageSet);
      }
    }

    // Copy the errors into the service context error collection
    jiraServiceContext.getErrorCollection().addErrorMessages(messageSet.getErrorMessages());
    return messageSet;
  }