code: @Override
      public int getJobInstanceCount(String jobName) throws NoSuchJobException, JobSecurityException {
  
          int jobInstanceCount = 0;
  
          if (authService == null || authService.isAdmin() || authService.isMonitor()) {
              // Do an unfiltered query if no app security, or if the user is admin or monitor
              jobInstanceCount = getPersistenceManagerService().getJobInstanceCount(jobName);
          } else if (authService.isSubmitter()) {
              jobInstanceCount = getPersistenceManagerService().getJobInstanceCount(jobName, batchSecurityHelper.getRunAsUser());
          } else {
              throw new JobSecurityException("Current user " + authService.getRunAsUser() + " is not authorized to perform batch operations");
          }
  
          // Debate on mailing list if we should be reqiured to distinguish between 0 count and NoSuchJobException.
          if (jobInstanceCount == 0) {
              validateJobName(jobName);
          }
  
          return jobInstanceCount;
      }
docs: {@inheritDoc}