Package com.volantis.shared.net.url

Examples of com.volantis.shared.net.url.URLContent


        // is no way to specify an operation specific timeout so it uses the
        // default one associated with the manager.
        final URL url = new URL(absoluteURI);
        final URLConfiguration urlConfig =
            URLConfigurationFactory.getURLConfiguration(url, context);
        URLContent content = manager.getURLContent(url, null, urlConfig);

        InputStream connectionInput = null;
        try {
            connectionInput = content.getInputStream();
            StreamSource xslSource = new StreamSource(connectionInput,
                    absoluteURI);
            SAXTransformerFactory factory = getTransformerFactory(isCompilable);
            factory.setErrorListener(this.getCollatingErrorListener());
            return factory.newTemplates(xslSource);
View Full Code Here


        // =====================================================================
        //   Test Expectations
        // =====================================================================

        // Make sure that parameters are passed through properly both ways.
        URLContent content = manager.getURLContent(url, period, null);
        assertSame(urlContentMock, content);
    }
View Full Code Here

        // =====================================================================
        //   Test Expectations
        // =====================================================================
        PipelineURLContentManager manager = new PipelineURLContentManager(
                contentManagerMock);
        URLContent content;

        // Make sure that parameters are passed through properly both ways.
        content = manager.getURLContent(urlAsString, period, null);
        assertSame(urlContentMock, content);
    }
View Full Code Here

                context);

        try {
            final URLConfiguration urlConfiguration =
                URLConfigurationFactory.getURLConfiguration(url, context);
            URLContent content =
                manager.getURLContent(url, timeout, urlConfiguration);

            // InputSource for content that we are trying to include.
            InputSource source = new InputSource(content.getInputStream());

            // Ensure that the systemID property is set for the
            // InputSource. The XMLReader will need this in order to
            // resolve relative URIs
            source.setSystemId(inclusionSystemId);

            // add dependency to the dependency context
            final DependencyContext dependencyContext =
                context.getDependencyContext();
            if (dependencyContext != null &&
                dependencyContext.isTrackingDependencies()) {

                dependencyContext.addDependency(content.getDependency());
            }

            // perform the inclusion
            reader.parse(source);
View Full Code Here

                context);

        try {
            final URLConfiguration urlConfiguration =
                URLConfigurationFactory.getURLConfiguration(url, context);
            URLContent content =
                manager.getURLContent(url, timeout, urlConfiguration);

            // The encoding to use is determined as follows.
            //
            // 1) The document being included specifies an encoding in
            //    the header, otherwise
            // 2) the value of the encoding attribute if one extist,
            //    otherwise
            // 3) UTF-8

            // try to obtain the encoding using approach 1.
            characterEncoding = content.getCharacterEncoding();

            // try to obtain the encoding using approach 2.
            if (null == characterEncoding) {
                characterEncoding = encoding;
            }

            // try to obtain the encoding using approach 3.
            if (null == characterEncoding) {
                characterEncoding = DEFAULT_TEXT_ENCODING;
            }

            InputStream is =
                    new BufferedInputStream(content.getInputStream());
            InputStreamReader reader =
                    new InputStreamReader(is, characterEncoding);

            final int CHUNK_SIZE = 1024;
            final char[] chars = new char[CHUNK_SIZE];
            int charsRead = 0;

            while (-1 != charsRead) {
                // read a chunk of the text into the buffer
                charsRead = reader.read(chars, 0, CHUNK_SIZE);
                if (charsRead > 0) {
                    // pass the characters down the XML pipeline
                    target.characters(chars, 0, charsRead);
                }
            }
            // add dependency to the dependency context
            final DependencyContext dependencyContext =
                context.getDependencyContext();
            if (dependencyContext != null &&
                dependencyContext.isTrackingDependencies()) {

                dependencyContext.addDependency(content.getDependency());
            }
        } catch (UnsupportedEncodingException uee) {
            // get hold of the current locator
            Locator currentLocator =
                    context.getCurrentLocator();
View Full Code Here

    public static InputSource createURLInputSource(
            URL url, URLContentManager manager, URLConfiguration urlConfig)
            throws IOException {

        // Get the content, use the default timeout.
        URLContent content = manager.getURLContent(url, null, urlConfig);

        InputStream inputStream = content.getInputStream();

        InputSource result = new InputSource(inputStream);
        result.setSystemId(url.toExternalForm());

        return result;
View Full Code Here

                              Period timeout,
                              URLConfiguration configuration)
            throws IOException {


        URLContent fileContents = null;


        // If the url is a host based file convert to ftp
        String host = url.getHost().toLowerCase();
        if (LOCAL_HOST.equals(host)) {
View Full Code Here

            new CacheAwareHttpContentRetriever(cache, manager, entry, clock);

        ProviderResult result;
        try {
            // get the content
            final URLContent content =
                contentRetriever.retrieve(url, timeout, httpConfig);
            // store the cache entry state in the result
            final CachedHttpContentState state =
                contentRetriever.getCacheState();
            result =
View Full Code Here

        }
    }

    // javadoc inherited
    public Freshness revalidate(final DependencyContext context) {
        final URLContent content =
            (URLContent) cache.retrieve(cacheKey, objectProvider);
        final Freshness freshness;
        if (!this.equals(content.getDependency())) {
            freshness = Freshness.STALE;
            context.setProperty(cacheKey, content);
        } else {
            freshness = freshness(context);
        }
View Full Code Here

TOP

Related Classes of com.volantis.shared.net.url.URLContent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.