Package org.jdesktop.wonderland.client.assetmgr.http.WlHttpAssetRepositoryFactory

Examples of org.jdesktop.wonderland.client.assetmgr.http.WlHttpAssetRepositoryFactory.HttpChecksum


     * @inheritDoc()
     */
    public AssetStream openAssetStream(AssetURI assetURI) {
        // If there is no last modified date, then log a warning. We will
        // still fetch whatever asset we find on the server.
        HttpChecksum cs = WlHttpAssetRepositoryFactory.getChecksumFor(checksum);
        if (cs == null) {
            logger.fine("Opening asset stream, no last modified date for " +
                    "asset " + assetURI.toExternalForm());
        }

        // Find out the URL of the asset to download, make sure it is not null
        String urlString = getURL(assetURI);
        if (urlString == null) {
            logger.warning("Unable to get URL for asset " + assetURI.toExternalForm());
            return new WlHttpAssetStream(AssetResponse.ASSET_INVALID, assetURI);
        }

        // Open the URL to the asset stream, giving the last modified date if
        // we have one. We fetch the response back from the server and set
        // whether the asset is already cached or whether we should download
        // it.
        URLConnection urlConnection = null;
        int response;
        String responseChecksum = null;
        try {
            URL url = new URL(urlString);
            urlConnection = url.openConnection();

            // apply the checksum
            if (cs != null) {
                cs.set((HttpURLConnection) urlConnection, checksum);
            }
           
            urlConnection.connect();
            response = ((HttpURLConnection) urlConnection).getResponseCode();
           
            if (cs != null) {
                responseChecksum = cs.get((HttpURLConnection) urlConnection);
            }
           
        } catch (IOException excp) {
            logger.log(Level.WARNING, "Unable to open URL for asset " +
                    urlString, excp);
View Full Code Here

TOP

Related Classes of org.jdesktop.wonderland.client.assetmgr.http.WlHttpAssetRepositoryFactory.HttpChecksum

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.