Revision 34003 branches/v2_0_0_prep/extensions/org.gvsig.installer/org.gvsig.installer.lib/org.gvsig.installer.lib.impl/src/main/java/org/gvsig/installer/lib/impl/DefaultInstallerProviderServices.java

View differences:

DefaultInstallerProviderServices.java
127 127
        decompress.readInstallInfo(is, installerInfos, zipEntriesMap);
128 128
    }
129 129

  
130
    public File downloadFile(URL bundleURL) throws IOException {
131
        URLConnection connection = bundleURL.openConnection();
130
    public File downloadFile(URL bundleURL, String defaultFileName)
131
        throws IOException {
132

  
133
        URL downloadURL = bundleURL;
134

  
135
        // check if the URL ends with '/' and append the file name
136
        if (defaultFileName != null) {
137
            String urlStr = bundleURL.toString();
138
            if (urlStr.endsWith("/")) {
139
                urlStr = urlStr.concat(defaultFileName);
140
                downloadURL = new URL(urlStr);
141
            }
142
        }
143

  
144
        URLConnection connection = downloadURL.openConnection();
132 145
        String fileName = getFileName(connection);
133 146

  
134 147
        if (LOG.isDebugEnabled()) {
135 148
            Date date = new Date(connection.getLastModified());
136 149
            LOG.debug(
137 150
                "Downloading file {} from URL {}, with last modified date: {}",
138
                new Object[] { fileName, bundleURL, date });
151
                new Object[] { fileName, downloadURL, date });
139 152
        }
140 153

  
141 154
        String fileNamePrefix = fileName;
......
147 160
        }
148 161

  
149 162
        BufferedInputStream bis =
150
            new BufferedInputStream(bundleURL.openStream());
163
            new BufferedInputStream(downloadURL.openStream());
151 164

  
152 165
        File localFile = File.createTempFile(fileNamePrefix, fileNameSuffix);
153 166
        BufferedOutputStream bos =

Also available in: Unified diff