protected Model buildCurrentModel()

in src/main/java/org/apache/sling/commons/log/logback/OsgiAction.java [69:110]


    protected Model buildCurrentModel(
            @NotNull SaxEventInterpretationContext interpretationContext,
            @NotNull String name,
            @NotNull Attributes attributes) {
        OsgiModel osgiModel = new OsgiModel();

        // TO CHECK Should we add the config fragment at end
        final Collection<ConfigSourceInfo> providers = getFragmentProviders();
        for (ConfigSourceInfo cp : providers) {
            InputSource is = cp.getConfigProvider().getConfigSource();

            SaxEventRecorder recorder = null;
            try {
                recorder = populateSaxEventRecorder(is);

                List<SaxEvent> saxEvents = recorder.getSaxEventList();
                if (saxEvents.isEmpty()) {
                    addWarn("Empty sax event list");
                } else {
                    LogConfigManager lcm = (LogConfigManager) getContext().getObject(LogConfigManager.class.getName());
                    JoranConfigurator genericXMLConfigurator = new JoranConfiguratorWrapper(lcm);
                    genericXMLConfigurator.setContext(context);
                    genericXMLConfigurator.getRuleStore().addPathPathMapping(INCLUDED_TAG, CONFIGURATION_TAG);

                    Model modelFromIncludedFile =
                            genericXMLConfigurator.buildModelFromSaxEventList(recorder.getSaxEventList());
                    if (modelFromIncludedFile == null) {
                        addError(ErrorCodes.EMPTY_MODEL_STACK);
                    } else {
                        osgiModel.getSubModels().addAll(modelFromIncludedFile.getSubModels());
                    }
                }

            } catch (JoranException e) {
                addError("Error processing XML data in [" + cp + "]", e);
            } finally {
                Util.close(is);
            }
        }

        return osgiModel;
    }