public void addConfigurations()

in src/main/java/org/apache/sling/maven/bundlesupport/fsresource/FsMountHelper.java [89:127]


    public void addConfigurations(final URI targetUrl, Collection<FsResourceConfiguration> cfgs)
            throws MojoExecutionException {
        final Map<String, FsResourceConfiguration> oldConfigs = getCurrentConfigurations(targetUrl);

        for (FsResourceConfiguration cfg : cfgs) {
            log.debug("Found mapping " + cfg.getFsRootPath() + " to " + cfg.getResourceRootPath());

            // check if this is already configured
            boolean found = false;
            final Iterator<Map.Entry<String, FsResourceConfiguration>> entryIterator =
                    oldConfigs.entrySet().iterator();
            while (!found && entryIterator.hasNext()) {
                final Map.Entry<String, FsResourceConfiguration> current = entryIterator.next();
                final FsResourceConfiguration oldcfg = current.getValue();
                log.debug("Comparing " + oldcfg.getFsRootPath() + " with " + oldcfg);
                if (Objects.equals(oldcfg.getFsRootPath(), cfg.getFsRootPath())) {
                    if (cfg.equals(oldcfg)) {
                        log.info("Using existing configuration for " + cfg.getFsRootPath() + " mounted at "
                                + cfg.getResourceRootPath());
                        found = true;
                    } else {
                        // remove old config
                        log.info("Removing old configuration for " + oldcfg);
                        removeConfiguration(targetUrl, current.getKey());
                    }
                    entryIterator.remove();
                }
            }
            if (!found) {
                log.debug("Adding new configuration for " + cfg.getFsRootPath() + " mounted at "
                        + cfg.getResourceRootPath());
                addConfiguration(targetUrl, cfg);
                log.info("Added new configuration for resource path " + cfg.getResourceRootPath() + " to server");
            }
        }

        // finally remove old configs
        removeConfigurations(targetUrl, oldConfigs);
    }