protected Product processProduct(Product existingProduct) throws IOException {
    initInput();
    Document dom = readDom();

    this.product =
        existingProduct == null ? DimapProductHelpers.createProduct(dom) : existingProduct;
    this.product.setProductReader(this);

    if (existingProduct == null) {
      readTiePointGrids(dom);
    }

    bindBandsToFiles(dom);
    if (existingProduct == null) {
      readVectorData(ImageManager.DEFAULT_IMAGE_CRS, true);

      // read GCPs and pins from DOM (old-style)
      DimapProductHelpers.addGcps(dom, this.product);
      DimapProductHelpers.addPins(dom, this.product);

      initGeoCodings(dom);
      readVectorData(ImageManager.getModelCrs(product.getGeoCoding()), false);
      DimapProductHelpers.addMaskUsages(dom, this.product);
    }
    this.product.setProductReader(this);
    this.product.setFileLocation(inputFile);
    this.product.setModified(false);
    return this.product;
  }
 private void addBandsToProduct(TiffFileInfo tiffInfo, Product product) throws IOException {
   final ImageReadParam readParam = imageReader.getDefaultReadParam();
   TIFFRenderedImage baseImage =
       (TIFFRenderedImage) imageReader.readAsRenderedImage(FIRST_IMAGE, readParam);
   SampleModel sampleModel = baseImage.getSampleModel();
   final int numBands = sampleModel.getNumBands();
   final int productDataType = ImageManager.getProductDataType(sampleModel.getDataType());
   bandMap = new HashMap<>(numBands);
   for (int i = 0; i < numBands; i++) {
     final String bandName = String.format("band_%d", i + 1);
     final Band band = product.addBand(bandName, productDataType);
     if (tiffInfo.containsField(BaselineTIFFTagSet.TAG_COLOR_MAP)
         && baseImage.getColorModel() instanceof IndexColorModel) {
       band.setImageInfo(createIndexedImageInfo(product, baseImage, band));
     }
     bandMap.put(band, i);
   }
 }