@Override
    public void validate(IValidatable<String> validatable) {
      String vcName = validatable.getValue();

      final CoverageStoreInfo store = getCatalog().getStore(storeId, CoverageStoreInfo.class);
      List<CoverageInfo> coverages = getCatalog().getCoveragesByCoverageStore(store);
      for (CoverageInfo curr : coverages) {
        CoverageView currvc =
            curr.getMetadata().get(CoverageView.COVERAGE_VIEW, CoverageView.class);
        if (currvc != null) {
          if (coverageInfoId == null || !coverageInfoId.equals(curr.getId())) {
            if (currvc.getName().equals(vcName) && newCoverage) {
              Map<String, Object> map = new HashMap<>();
              map.put("name", vcName);
              map.put("coverageName", curr.getName());
              IValidationError err =
                  new ValidationError("duplicateCoverageViewName")
                      .addKey("duplicateCoverageViewName")
                      .setVariables(map);
              validatable.error(err);
              return;
            }
          }
        }
      }
    }
  public CoverageViewAbstractPage(
      String workspaceName, String storeName, String coverageName, CoverageInfo coverageInfo)
      throws IOException {
    storeId =
        getCatalog().getStoreByName(workspaceName, storeName, CoverageStoreInfo.class).getId();
    Catalog catalog = getCatalog();
    CoverageStoreInfo store = catalog.getStore(storeId, CoverageStoreInfo.class);

    GridCoverage2DReader reader =
        (GridCoverage2DReader) catalog.getResourcePool().getGridCoverageReader(store, null);
    String[] coverageNames = reader.getGridCoverageNames();
    if (availableCoverages == null) {
      availableCoverages = new ArrayList<String>();
    }
    for (String coverage : coverageNames) {
      ImageLayout layout = reader.getImageLayout(coverage);
      SampleModel sampleModel = layout.getSampleModel(null);
      final int numBands = sampleModel.getNumBands();
      if (numBands == 1) {
        // simple syntax for simple case
        availableCoverages.add(coverage);
      } else {
        for (int i = 0; i < numBands; i++) {
          availableCoverages.add(coverage + CoverageView.BAND_SEPARATOR + i);
        }
      }
    }
    Collections.sort(availableCoverages);
    name = COVERAGE_VIEW_NAME;
    if (coverageName != null) {
      newCoverage = false;

      // grab the coverage view
      coverageViewInfo =
          coverageInfo != null
              ? coverageInfo
              : catalog.getResourceByStore(store, coverageName, CoverageInfo.class);
      CoverageView coverageView =
          coverageViewInfo.getMetadata().get(CoverageView.COVERAGE_VIEW, CoverageView.class);
      // the type can be still not saved
      if (coverageViewInfo != null) {
        coverageInfoId = coverageViewInfo.getId();
      }
      if (coverageView == null) {
        throw new IllegalArgumentException(
            "The specified coverage does not have a coverage view attached to it");
      }
      outputBands = new ArrayList<CoverageBand>(coverageView.getCoverageBands());
      name = coverageView.getName();
    } else {
      outputBands = new ArrayList<CoverageBand>();
      newCoverage = true;
      coverageViewInfo = null;
    }
    selectedCoverages = new ArrayList<String>(availableCoverages);

    // build the form and the text area
    Form<CoverageViewAbstractPage> form = new Form<>("form", new CompoundPropertyModel<>(this));
    add(form);

    final TextField<String> nameField = new TextField<>("name");
    nameField.setRequired(true);
    nameField.add(new CoverageViewNameValidator());
    form.add(nameField);

    coverageEditor =
        new CoverageViewEditor(
            "coverages",
            new PropertyModel<>(this, "selectedCoverages"),
            new PropertyModel<>(this, "outputBands"),
            availableCoverages);
    form.add(coverageEditor);

    // save and cancel at the bottom of the page
    form.add(
        new SubmitLink("save") {
          @Override
          public void onSubmit() {
            onSave();
          }
        });
    form.add(
        new Link<Void>("cancel") {

          @Override
          public void onClick() {
            onCancel();
          }
        });
  }