geopackage-sdk/src/main/java/mil/nga/geopackage/factory/GeoPackageManagerImpl.java
@Override
    public boolean importGeoPackage(String name, URL url, boolean override,
                                    GeoPackageProgress progress) {

        boolean success = false;

        HttpURLConnection connection = null;
        try {
            connection = (HttpURLConnection) url.openConnection();
            connection.connect();

            int responseCode = connection.getResponseCode();
            if (responseCode == HttpURLConnection.HTTP_MOVED_PERM
                    || responseCode == HttpURLConnection.HTTP_MOVED_TEMP
                    || responseCode == HttpURLConnection.HTTP_SEE_OTHER) {
                String redirect = connection.getHeaderField("Location");
                connection.disconnect();
                url = new URL(redirect);
                connection = (HttpURLConnection) url.openConnection();
                connection.connect();
            }

            if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
                throw new GeoPackageException("Failed to import GeoPackage "
                        + name + " from URL: '" + url.toString() + "'. HTTP "
                        + connection.getResponseCode() + " "
                        + connection.getResponseMessage());
            }

            int fileLength = connection.getContentLength();
            if (fileLength != -1 && progress != null) {
                progress.setMax(fileLength);
            }

            InputStream geoPackageStream = connection.getInputStream();
            success = importGeoPackage(name, override, geoPackageStream,
                    progress);
        } catch (IOException e) {
            throw new GeoPackageException("Failed to import GeoPackage " + name
                    + " from URL: '" + url.toString() + "'", e);
        } finally {
            if (connection != null) {
                connection.disconnect();
            }
        }

        return success;
    }
@Override
    public boolean importGeoPackage(String name, URL url, boolean override,
                                    GeoPackageProgress progress) {

        boolean success = false;

        HttpURLConnection connection = null;
        try {
            connection = (HttpURLConnection) url.openConnection();
            connection.connect();

            int responseCode = connection.getResponseCode();
            if (responseCode == HttpURLConnection.HTTP_MOVED_PERM
                    || responseCode == HttpURLConnection.HTTP_MOVED_TEMP
                    || responseCode == HttpURLConnection.HTTP_SEE_OTHER) {
                String redirect = connection.getHeaderField("Location");
                connection.disconnect();
                url = new URL(redirect);
                connection = (HttpURLConnection) url.openConnection();
                connection.connect();
            }

            if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
                throw new GeoPackageException("Failed to import GeoPackage "
                        + name + " from URL: '" + url.toString() + "'. HTTP "
                        + connection.getResponseCode() + " "
                        + connection.getResponseMessage());
            }

            int fileLength = connection.getContentLength();
            if (fileLength != -1 && progress != null) {
                progress.setMax(fileLength);
            }

            InputStream geoPackageStream = connection.getInputStream();
            success = importGeoPackage(name, override, geoPackageStream,
                    progress);
        } catch (IOException e) {
            throw new GeoPackageException("Failed to import GeoPackage " + name
                    + " from URL: '" + url.toString() + "'", e);
        } finally {
            if (connection != null) {
                connection.disconnect();
            }
        }

        return success;
    }
@ Override public boolean importGeoPackage ( String name , URL url , boolean override , GeoPackageProgress progress ) { boolean success = false ; HttpURLConnection connection = null ; try { connection = ( HttpURLConnection ) url . openConnection ( ) ; connection . connect ( ) ; int responseCode = connection . getResponseCode ( ) ; if ( responseCode == HttpURLConnection . HTTP_MOVED_PERM || responseCode == HttpURLConnection . HTTP_MOVED_TEMP || responseCode == HttpURLConnection . HTTP_SEE_OTHER ) { String redirect = connection . getHeaderField ( "Location" ) ; connection . disconnect ( ) ; url = new URL ( redirect ) ; connection = ( HttpURLConnection ) url . openConnection ( ) ; connection . connect ( ) ; } if ( connection . getResponseCode ( ) != HttpURLConnection . HTTP_OK ) { throw new GeoPackageException ( "Failed to import GeoPackage " + name + " from URL: '" + url . toString ( ) + "'. HTTP " + connection . getResponseCode ( ) + " " + connection . getResponseMessage ( ) ) ; } int fileLength = connection . getContentLength ( ) ; if ( fileLength != - 1 && progress != null ) { progress . setMax ( fileLength ) ; } InputStream geoPackageStream = connection . getInputStream ( ) ; success = importGeoPackage ( name , override , geoPackageStream , progress ) ; } catch ( IOException e ) { throw new GeoPackageException ( "Failed to import GeoPackage " + name + " from URL: '" + url . toString ( ) + "'" , e ) ; } finally { if ( connection != null ) { connection . disconnect ( ) ; } } return success ; }
{@inheritDoc}
{