public InputSource resolveEntity()

in src/main/java/org/apache/commons/configuration2/resolver/CatalogResolver.java [391:419]


    public InputSource resolveEntity(final String publicId, final String systemId) throws SAXException {
        String resolved = getResolver().getResolvedEntity(publicId, systemId);

        if (resolved != null) {
            final String badFilePrefix = "file://";
            final String correctFilePrefix = "file:///";

            // Java 5 has a bug when constructing file URLs
            if (resolved.startsWith(badFilePrefix) && !resolved.startsWith(correctFilePrefix)) {
                resolved = correctFilePrefix + resolved.substring(badFilePrefix.length());
            }

            try {
                final URL url = locate(fs, null, resolved);
                if (url == null) {
                    throw new ConfigurationException("Could not locate " + resolved);
                }
                final InputStream inputStream = fs.getInputStream(url);
                final InputSource inputSource = new InputSource(resolved);
                inputSource.setPublicId(publicId);
                inputSource.setByteStream(inputStream);
                return inputSource;
            } catch (final Exception e) {
                log.warn("Failed to create InputSource for " + resolved, e);
            }
        }

        return null;
    }