@Override
  public FileSystemEntryDTO getDirectory(String absPath, FlagsDTO flagsDTO)
      throws FileErrorException {
    File basePath = new File(path);

    File directory = new File(basePath, absPath);
    ensureLocalRoot(basePath, directory);

    if (!flagsDTO.isCreate()) {
      if (!directory.exists()) {
        throw new FileErrorException(FileError.INVALID_STATE_ERR);
      }
    } else {
      if (!directory.exists()) {
        directory.mkdir();
        if (logger.isLoggable(Level.INFO)) {
          logger.log(Level.INFO, "created directory: '" + absPath + "'");
        }
      }
    }

    FileSystemEntryDTO dto = new FileSystemEntryDTO();

    dto.setFile(false);
    dto.setFullPath(absPath);
    dto.setName(directory.getName());
    return dto;
  }
  @Override
  public FileSystemEntryDTO getFile(String absPath, FlagsDTO flagsDTO) throws FileErrorException {
    File basePath = new File(path);

    File file = new File(basePath, absPath);

    ensureLocalRoot(basePath, file);

    if (flagsDTO.isCreate()) {
      if (!file.exists()) {
        try {
          file.createNewFile();
        } catch (IOException e) {
          throw new FileErrorException(FileError.INVALID_MODIFICATION_ERR);
        }
      }
    }

    if (!file.exists()) {
      throw new FileErrorException(FileError.NOT_FOUND_ERR);
    }

    FileSystemEntryDTO dto = new FileSystemEntryDTO();
    dto.setFile(true);
    dto.setFullPath(absPath);
    dto.setName(file.getName());

    return dto;
  }