ArrayList result = new ArrayList(bundleCount);
long id = -1;
boolean bundleDiscarded = false;
for (int i = 0; i < bundleCount; i++) {
boolean error = false;
BaseData data = null;
try {
id = in.readLong();
if (id != 0) {
data = loadBaseData(id, in);
data.getBundleFile();
StorageHook[] dataStorageHooks = data.getStorageHooks();
for (int j = 0; j < dataStorageHooks.length; j++)
dataStorageHooks[j].validate();
if (Debug.DEBUG && Debug.DEBUG_GENERAL)
Debug.println("BundleData created: " + data); //$NON-NLS-1$
processExtension(data, EXTENSION_INITIALIZE);
result.add(data);
}
} catch (IllegalArgumentException e) {
// may be from data.getBundleFile()
bundleDiscarded = true;
error = true;
} catch (BundleException e) {
// should never happen
bundleDiscarded = true;
error = true;
} catch (IOException e) {
bundleDiscarded = true;
error = true;
if (Debug.DEBUG && Debug.DEBUG_GENERAL) {
Debug.println("Error reading framework metadata: " + e.getMessage()); //$NON-NLS-1$
Debug.printStackTrace(e);
}
}
if (error && data != null) {
BaseStorageHook storageHook = (BaseStorageHook) data.getStorageHook(BaseStorageHook.KEY);
storageHook.delete(true, BaseStorageHook.DEL_BUNDLE_STORE);
}
}
if (bundleDiscarded)
FrameworkProperties.setProperty(EclipseStarter.PROP_REFRESH_BUNDLES, "true"); //$NON-NLS-1$