public DocumentDTO transformYElement(
      YExportable yExportable, ZipArchive currentZipArchive, String currentXmlPath) {

    DocumentDTO productObject = null;

    if (yExportable instanceof YElement) {
      YElement yElement = (YElement) yExportable;

      MetadataToProtoMetadataParser mtd2prt = new MetadataToProtoMetadataParserImpl();
      DocumentMetadata docMetadata =
          mtd2prt.yelementToDocumentMetadata(
              yElement, currentZipArchive, currentXmlPath, collection);

      if (docMetadata != null) {
        productObject = new DocumentDTO();
        productObject.setKey(docMetadata.getKey());
        // Document and DocumentMetadata should have the same key?
        productObject.setDocumentMetadata(docMetadata);

        List<YContentEntry> contents = yElement.getContents();
        for (YContentEntry content : contents) {
          // get a media path from yElement
          handleContent(productObject, content, currentZipArchive);
        }
      }
    }
    return productObject;
  }
  private void fetchMediaFromZip(
      DocumentDTO docDTO, YContentFile yFile, ZipArchive currentZipArchive, String mediaType) {
    for (String location : yFile.getLocations()) {
      // path to media in yFile contains prefix yadda.pack:/, check and remove it
      String prefix = "yadda.pack:/";
      if (location.startsWith(prefix)) {
        location = location.substring(prefix.length());
        // path to media in zip file contains zip filename, not included in yFile
        List<String> foundPaths = currentZipArchive.filter(".*" + location);
        // foundPaths should contain 1 item
        if (foundPaths.size() > 0) {
          try {
            String foundPath = foundPaths.get(0);
            InputStream mediaIS = currentZipArchive.getFileAsInputStream(foundPath);
            // ... do something with mediaIS
            Media.Builder mediaBuilder = Media.newBuilder();
            mediaBuilder.setKey(docDTO.getKey());
            // Media and Document should have the same key?
            mediaBuilder.setMediaType(mediaType);
            byte[] content = IOUtils.toByteArray(mediaIS);
            mediaBuilder.setContent(ByteString.copyFrom(content));
            mediaBuilder.setSourcePath(currentZipArchive.getZipFilePath() + "#" + foundPath);
            mediaBuilder.setSourceFilesize(content.length);

            docDTO.addMedia(mediaBuilder.build());
            docDTO.addMediaType(mediaType);
            mediaIS.close();

          } catch (IOException ex) {
            logger.error(ex.toString());
          }
        } else {
          logger.error("File path in BWmeta, but not in archive: " + location);
        }
      }
    }
  }