|
Lines 19-24
Link Here
|
| 19 |
import java.io.InputStream; |
19 |
import java.io.InputStream; |
| 20 |
import java.io.OutputStream; |
20 |
import java.io.OutputStream; |
| 21 |
import java.net.Authenticator; |
21 |
import java.net.Authenticator; |
|
|
22 |
import java.net.HttpURLConnection; |
| 22 |
import java.net.URL; |
23 |
import java.net.URL; |
| 23 |
import java.net.URLConnection; |
24 |
import java.net.URLConnection; |
| 24 |
import java.util.Date; |
25 |
import java.util.Date; |
|
Lines 53-59
Link Here
|
| 53 |
String destPath = (String)context.getProperty(IImportHandler.TEMP_DIRECTORY); |
54 |
String destPath = (String)context.getProperty(IImportHandler.TEMP_DIRECTORY); |
| 54 |
final String fileURL = (String)element.getValues().get("file_path"); //$NON-NLS-1$ |
55 |
final String fileURL = (String)element.getValues().get("file_path"); //$NON-NLS-1$ |
| 55 |
|
56 |
|
| 56 |
//**Need to authenticate **// |
57 |
//**Need to authenticate **/// |
| 57 |
monitor.beginTask(element.getAgentName(), IProgressMonitor.UNKNOWN); |
58 |
monitor.beginTask(element.getAgentName(), IProgressMonitor.UNKNOWN); |
| 58 |
monitor.subTask(" "+StringUtil.replace(Messages.getString("LocalDownloadImportHandler.2", locale),"{0}", fileURL)); //$NON-NLS-1$ //$NON-NLS-2$ |
59 |
monitor.subTask(" "+StringUtil.replace(Messages.getString("LocalDownloadImportHandler.2", locale),"{0}", fileURL)); //$NON-NLS-1$ //$NON-NLS-2$ |
| 59 |
Authenticator.setDefault (authenticator); |
60 |
Authenticator.setDefault (authenticator); |
|
Lines 61-68
Link Here
|
| 61 |
File file; |
62 |
File file; |
| 62 |
String key = GLAHelper.getAdapterPathKey(parserInput); |
63 |
String key = GLAHelper.getAdapterPathKey(parserInput); |
| 63 |
try { |
64 |
try { |
| 64 |
|
65 |
|
| 65 |
URLConnection connection = (new URL(fileURL)).openConnection(); |
66 |
URLConnection connection = (new URL(fileURL)).openConnection(); |
|
|
67 |
//fix for bugzilla 206260 |
| 68 |
if(connection instanceof HttpURLConnection) |
| 69 |
{ |
| 70 |
// Redirect a maximum of five times. This is a generally accepted check which makes sure that |
| 71 |
// multiple redirects are supported, but this is not infinite. |
| 72 |
for(int i =0; i < 5;i++) |
| 73 |
{ |
| 74 |
int retCode = ((HttpURLConnection)connection).getResponseCode(); |
| 75 |
if( retCode >= 300 && retCode < 400) |
| 76 |
{ |
| 77 |
String location = connection.getHeaderField("location"); |
| 78 |
connection = (new URL(location)).openConnection(); |
| 79 |
} |
| 80 |
else |
| 81 |
{ |
| 82 |
break; |
| 83 |
} |
| 84 |
} |
| 85 |
} |
| 86 |
//end of fix for bugzilla 206260 |
| 66 |
InputStream inputStream = connection.getInputStream(); |
87 |
InputStream inputStream = connection.getInputStream(); |
| 67 |
SimpleDateFormat format = new SimpleDateFormat("yyyymmddhhMMss"); //$NON-NLS-1$ |
88 |
SimpleDateFormat format = new SimpleDateFormat("yyyymmddhhMMss"); //$NON-NLS-1$ |
| 68 |
|
89 |
|