/** Visit all files to keep only XML files. */
  @Override
  protected void visit() {
    final ParameterValue<URL> paramUrl =
        (ParameterValue<URL>)
            getSourceConfiguration(getSource()).parameter(URL.getName().getCode());

    if (paramUrl == null || paramUrl.getValue() == null) {
      getLogger().log(Level.WARNING, "Provided File path is not defined.");
      return;
    }

    final URL urlPath = paramUrl.getValue();

    try {
      path = new File(urlPath.toURI());
    } catch (URISyntaxException e) {
      getLogger().log(Level.INFO, "Fails to convert path url to file.");
      path = new File(urlPath.getPath());
    }

    List<File> candidates = new ArrayList<>();

    if (path.isDirectory()) {
      candidates.addAll(
          FileUtilities.scanDirectory(
              path,
              new FileFilter() {
                @Override
                public boolean accept(File pathname) {
                  final String fullName = pathname.getName();
                  final int idx = fullName.lastIndexOf('.');
                  final String extension = fullName.substring(idx + 1);
                  return extension.equalsIgnoreCase("xml");
                }
              }));
    } else {
      candidates.add(path);
    }

    index = new HashMap<>();
    for (final File candidate : candidates) {
      try {
        final MapContext mapContext =
            MapContextIO.readMapContextFile(candidate, "", "", styleBusiness);
        if (mapContext != null) {
          final GenericName name = NamesExt.create(mapContext.getName());
          index.put(name, candidate);
        }
      } catch (JAXBException e) {
        getLogger()
            .log(
                Level.WARNING,
                "Candidate MapContext file can't be read : " + candidate.getAbsolutePath(),
                e);
      }
    }

    super.visit();
  }
 /**
  * Return the raw configuration MapContext.
  *
  * @param key
  * @return
  * @throws JAXBException
  */
 public org.constellation.provider.coveragesgroup.xml.MapContext getRawMapContext(
     final GenericName key) throws JAXBException {
   if (index == null) {
     visit();
   }
   final File mapContextFile = index.get(key);
   return MapContextIO.readRawMapContextFile(mapContextFile);
 }
  /**
   * @param key layer name
   * @param login used if one or more layer of MapContext come from secured map service
   * @param password used if one or more layer of MapContext come from secured map service
   * @return MapContext or null if layer name doesn't exist.
   * @throws JAXBException
   */
  public MapContext getMapContext(final GenericName key, final String login, final String password)
      throws JAXBException {
    if (index == null) {
      visit();
    }

    final File mapContextFile = index.get(key);
    return MapContextIO.readMapContextFile(mapContextFile, login, password, styleBusiness);
  }
  /**
   * Add or update MapContext for a key
   *
   * @param key
   * @param mapContext
   * @throws JAXBException
   * @throws IOException
   */
  public void addRawMapContext(
      final GenericName key, org.constellation.provider.coveragesgroup.xml.MapContext mapContext)
      throws JAXBException, IOException {
    if (index == null) {
      visit();
    }

    File mapContextFile = index.get(key);
    if (mapContextFile == null) {
      mapContextFile = new File(path, key.tip().toString() + ".xml");
    }
    MapContextIO.writeMapContext(mapContextFile, mapContext);
    index.put(key, mapContextFile);
  }