public FileSystemDTO updateFileSystemAvailability(
     String dirPath, String availability, String availabilityOfExternalRetrievable)
     throws Exception {
   String fsGroupID = getFileSystemGroupID();
   FileSystemMgt2 fsMgt = fileSystemMgt();
   return fsMgt.updateFileSystemAvailability(fsGroupID, dirPath, Availability.toInt(availability))
       ? fsMgt.updateAvailabilityForStudyOnFileSystem(
           fsGroupID,
           dirPath,
           Availability.toInt(availabilityOfExternalRetrievable),
           updateStudiesBatchSize)
       : fsMgt.getFileSystemOfGroup(fsGroupID, dirPath);
 }
 private boolean switchFileSystem(FileSystemMgt2 fsMgt, FileSystemDTO fsDTO) throws Exception {
   synchronized (switchFileSystemMonitor) {
     if (!updateStorageFileSystem(fsMgt)) {
       return selectStorageFileSystem() != null;
     }
     if (storageFileSystem == null || fsDTO == null) {
       log.info("Storage filesystem not set! No RW filesystem configured or no space left!");
       return false;
     } else if (storageFileSystem.getPk() != fsDTO.getPk()) {
       log.info(
           "Storage file system has already been switched from "
               + fsDTO
               + " to "
               + storageFileSystem
               + " by another thread.");
       return true;
     }
     FileSystemDTO tmp = storageFileSystem;
     String next;
     while ((next = tmp.getNext()) != null && !next.equals(storageFileSystem.getDirectoryPath())) {
       tmp = fsMgt.getFileSystemOfGroup(getFileSystemGroupID(), next);
       if (minFreeDiskSpaceRatio > 0) {
         minFreeDiskSpace = calcFreeDiskSpace(tmp);
       }
       if (tmp.getStatus() == FileSystemStatus.RW
           && tmp.getAvailability() == Availability.toInt(getDefAvailability())
           && checkFreeDiskSpace(tmp)) {
         storageFileSystem = fsMgt.updateFileSystemStatus(tmp.getPk(), FileSystemStatus.DEF_RW);
         log.info("Switch storage file system from " + fsDTO + " to " + storageFileSystem);
         sendJMXNotification(new StorageFileSystemSwitched(fsDTO, storageFileSystem));
         return true;
       }
     }
     return false;
   }
 }
 public void setDefAvailability(String availability) {
   this.defAvailability = Availability.toInt(availability);
 }