17 package com.nokia.carbide.remoteconnections.interfaces; |
17 package com.nokia.carbide.remoteconnections.interfaces; |
18 |
18 |
19 import java.io.ByteArrayInputStream; |
19 import java.io.ByteArrayInputStream; |
20 import java.io.InputStream; |
20 import java.io.InputStream; |
21 import java.lang.reflect.InvocationTargetException; |
21 import java.lang.reflect.InvocationTargetException; |
|
22 import java.net.URL; |
22 import java.util.ArrayList; |
23 import java.util.ArrayList; |
23 import java.util.Collections; |
24 import java.util.Collections; |
24 import java.util.Comparator; |
25 import java.util.Comparator; |
25 import java.util.HashMap; |
26 import java.util.HashMap; |
26 import java.util.HashSet; |
27 import java.util.HashSet; |
115 String installFileUrl = null; |
116 String installFileUrl = null; |
116 try { |
117 try { |
117 installFileUrl = getInstallFileUrl(runnableContext); |
118 installFileUrl = getInstallFileUrl(runnableContext); |
118 inputStream = getInstallFile(installFileUrl, runnableContext); |
119 inputStream = getInstallFile(installFileUrl, runnableContext); |
119 } catch (Exception e) { |
120 } catch (Exception e) { |
120 RemoteConnectionsActivator.logError(e); |
121 RemoteConnectionsActivator.log("Failed to find package URL " + installFileUrl, e); |
121 } |
122 } |
122 String defaultFileName = null; |
123 String defaultFileName = null; |
123 if (installFileUrl != null) |
124 if (installFileUrl != null) |
124 defaultFileName = new Path(installFileUrl).lastSegment(); |
125 defaultFileName = new Path(installFileUrl).lastSegment(); |
125 return new PackageContents(defaultFileName, inputStream); |
126 return new PackageContents(defaultFileName, inputStream); |
126 } |
127 } |
127 |
128 |
128 private ByteArrayInputStream getInstallFile(String installFileUrl, IRunnableContext runnableContext) throws Exception { |
129 private InputStream getInstallFile(String installFileUrl, IRunnableContext runnableContext) throws Exception { |
|
130 |
|
131 URL url = null; |
|
132 |
|
133 // see if the file is local (Ed's hack for testing...) |
|
134 url = new URL(installFileUrl); |
|
135 if (url.getProtocol().equals("file")) { |
|
136 return url.openStream(); |
|
137 } |
|
138 |
129 GetMethod getMethod = new GetMethod(installFileUrl); |
139 GetMethod getMethod = new GetMethod(installFileUrl); |
130 HttpClient client = new HttpClient(); |
140 HttpClient client = new HttpClient(); |
131 InstallPackages.setProxyData(client, getMethod); |
141 InstallPackages.setProxyData(client, getMethod); |
132 client.getHttpConnectionManager().getParams().setConnectionTimeout(8000); |
142 client.getHttpConnectionManager().getParams().setConnectionTimeout(8000); |
133 int serverStatus = 0; |
143 int serverStatus = 0; |