/**
   * ファイルデータをストレージに保存します.
   *
   * @param metadata ファイルデータを含むurlTreeメタデータオブジェクト
   * @param ctx urlTreeコンテキストオブジェクト
   */
  @Override
  public void save(UrlTreeMetaData<InputStream> metadata, UrlTreeContext ctx)
      throws BadContentException {

    String localFileName = metadata.getAbsolutePath();

    logger.debug("saving " + localFileName);
    Path f = this.generateFileObj(localFileName);

    InputStream b = metadata.getData();
    // nullの場合は書き換えない。
    if (b == null) {
      return;
    }
    try {
      Path parent = f.getParent();

      // 書き込む場所がなければ親ディレクトリを作成
      if (Files.notExists(parent)) {
        Files.createDirectories(parent);
      }
      Files.copy(b, f, StandardCopyOption.REPLACE_EXISTING);
    } catch (IOException e) {
      throw new GenericResourceException(e);
    }
  }