protected SharedFileInfo resolveFileSpec(File fileSpec) throws DBException
 {
  SharedFiles queryService = getQueryService();
  SharedFileInfo fileInfo;
  Cursor<SharedFileInfo> fileRecords = null;
  log().info("Applying " + queryService.getEffectiveFilterSpec());
  fileRecords = queryService.listAllFilesRelatedToPath(fileSpec);
  fileInfo = fileRecords.next();
  if (null == fileInfo)
   throw new IllegalArgumentException("File with name '" + getNameOption()
     + "' not found on the shared medium");
  setFileId(fileInfo.getId());
  StringBuilder conflictingNumbers = null;
  for (SharedFileInfo conflictingRecord; null != (conflictingRecord = fileRecords.next());)
  {
   if (null == conflictingNumbers)
   {
    conflictingNumbers = new StringBuilder(45);
    conflictingNumbers.append(getFileId());
   }
   conflictingNumbers.append(", ");
   if (35 <= conflictingNumbers.length())
   {
    conflictingNumbers.append("etc.");
    break;
   }
   conflictingNumbers.append(conflictingRecord.getId());
  }
  if (null != conflictingNumbers)
   throw new IllegalArgumentException("Name '" + getNameOption()
    + "' matches multiple files (##" + conflictingNumbers + "). Please use the --"
    + Syntax.FILE_ID_OPTION + " option to resolve this ambiguity.");
  if (null != fileRecords)
  {
   try
   {
    fileRecords.close();
   }
   catch (Exception e)
   {
    log().log(Level.WARNING, "Close failed for " + fileRecords, e);
   }
  }
  return fileInfo;
 }