|
Lines 37-72
Link Here
|
| 37 |
/** |
37 |
/** |
| 38 |
* Returns bundles defined by the 'bundles.info' file in the |
38 |
* Returns bundles defined by the 'bundles.info' file in the |
| 39 |
* specified location, or <code>null</code> if none. The "bundles.info" file |
39 |
* specified location, or <code>null</code> if none. The "bundles.info" file |
| 40 |
* is assumed to be at a fixed relative location to the specified file. This |
40 |
* is assumed to be at a fixed location relative to the configuration area URL. |
| 41 |
* method will also look for a "source.info". If available, any source |
41 |
* This method will also look for a "source.info". If available, any source |
| 42 |
* bundles found will also be added to the returned list. |
42 |
* bundles found will also be added to the returned list. If bundle URLs found |
|
|
43 |
* in the bundles.txt are relative, they will be appended to platformHome to |
| 44 |
* make them absolute. |
| 43 |
* |
45 |
* |
| 44 |
* @param platformHome absolute path in the local file system to an installation |
46 |
* @param platformHome absolute path in the local file system to an installation |
|
|
47 |
* @param configurationArea url location of the configuration directory to search for bundles.info and source.info |
| 45 |
* @return URLs of all bundles in the installation or <code>null</code> if not able |
48 |
* @return URLs of all bundles in the installation or <code>null</code> if not able |
| 46 |
* to locate a bundles.info |
49 |
* to locate a bundles.info |
| 47 |
*/ |
50 |
*/ |
| 48 |
public static URL[] readBundlesTxt(String platformHome) { |
51 |
public static URL[] readBundlesTxt(String platformHome, URL configurationArea) { |
| 49 |
|
|
|
| 50 |
Path basePath = new Path(platformHome); |
52 |
Path basePath = new Path(platformHome); |
| 51 |
|
53 |
if (configurationArea == null) { |
| 52 |
File configArea = TargetWeaver.getConfigurationArea(platformHome); |
|
|
| 53 |
File bundlesTxt = new File(configArea, BUNDLE_TXT_PATH); |
| 54 |
List bundles = getBundlesFromFile(bundlesTxt, basePath); |
| 55 |
|
| 56 |
if (bundles == null) { |
| 57 |
return null; |
54 |
return null; |
| 58 |
} |
55 |
} |
|
|
56 |
try { |
| 57 |
URL bundlesTxt = new URL(configurationArea.getProtocol(), configurationArea.getHost(), configurationArea.getFile().concat(BUNDLE_TXT_PATH)); |
| 58 |
List bundles = getBundlesFromFile(bundlesTxt, basePath); |
| 59 |
|
| 60 |
if (bundles == null) { |
| 61 |
return null; |
| 62 |
} |
| 59 |
|
63 |
|
| 60 |
File srcBundlesTxt = new File(configArea, SRC_BUNDLE_TXT_PATH); |
64 |
URL srcBundlesTxt = new URL(configurationArea.getProtocol(), configurationArea.getHost(), configurationArea.getFile().concat(SRC_BUNDLE_TXT_PATH)); |
| 61 |
List srcBundles = getBundlesFromFile(srcBundlesTxt, basePath); |
65 |
List srcBundles = getBundlesFromFile(srcBundlesTxt, basePath); |
| 62 |
|
66 |
|
| 63 |
if (srcBundles == null) { |
67 |
if (srcBundles != null) { |
|
|
68 |
bundles.addAll(srcBundles); |
| 69 |
} |
| 64 |
return (URL[]) bundles.toArray(new URL[bundles.size()]); |
70 |
return (URL[]) bundles.toArray(new URL[bundles.size()]); |
| 65 |
} |
|
|
| 66 |
|
| 67 |
bundles.addAll(srcBundles); |
| 68 |
return (URL[]) bundles.toArray(new URL[bundles.size()]); |
| 69 |
|
71 |
|
|
|
72 |
} catch (MalformedURLException e) { |
| 73 |
PDECore.log(e); |
| 74 |
return null; |
| 75 |
} |
| 70 |
} |
76 |
} |
| 71 |
|
77 |
|
| 72 |
/** |
78 |
/** |
|
Lines 75-97
Link Here
|
| 75 |
* Returns a list of URL locations, one for each bundle entry or <code> |
81 |
* Returns a list of URL locations, one for each bundle entry or <code> |
| 76 |
* null</code> if there is a problem reading the file. |
82 |
* null</code> if there is a problem reading the file. |
| 77 |
* |
83 |
* |
| 78 |
* @param file the file to read |
84 |
* @param file the URL of the file to read |
| 79 |
* @param basePath the path describing the base location of the platform install |
85 |
* @param basePath the path describing the base location of the platform install |
| 80 |
* @return list containing URL locations or <code>null</code> |
86 |
* @return list containing URL locations or <code>null</code> |
| 81 |
*/ |
87 |
*/ |
| 82 |
private static List getBundlesFromFile(File file, Path basePath) { |
88 |
private static List getBundlesFromFile(URL fileURL, Path basePath) { |
| 83 |
if (!file.exists()) { |
|
|
| 84 |
return null; |
| 85 |
} |
| 86 |
URL url = null; |
| 87 |
try { |
| 88 |
url = file.toURL(); |
| 89 |
} catch (MalformedURLException e) { |
| 90 |
return null; |
| 91 |
} |
| 92 |
List bundles = new ArrayList(); |
89 |
List bundles = new ArrayList(); |
| 93 |
try { |
90 |
try { |
| 94 |
BufferedReader r = new BufferedReader(new InputStreamReader(url.openStream())); |
91 |
BufferedReader r = new BufferedReader(new InputStreamReader(fileURL.openStream())); |
| 95 |
|
92 |
|
| 96 |
String line; |
93 |
String line; |
| 97 |
try { |
94 |
try { |
|
Lines 156-163
Link Here
|
| 156 |
} |
153 |
} |
| 157 |
} |
154 |
} |
| 158 |
} catch (MalformedURLException e) { |
155 |
} catch (MalformedURLException e) { |
|
|
156 |
PDECore.log(e); |
| 159 |
return null; |
157 |
return null; |
| 160 |
} catch (IOException e) { |
158 |
} catch (IOException e) { |
|
|
159 |
PDECore.log(e); |
| 161 |
return null; |
160 |
return null; |
| 162 |
} |
161 |
} |
| 163 |
return bundles; |
162 |
return bundles; |