### Eclipse Workspace Patch 1.0 #P org.eclipse.equinox.frameworkadmin.equinox Index: src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxBundlesState.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.equinox/p2/bundles/org.eclipse.equinox.frameworkadmin.equinox/src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxBundlesState.java,v retrieving revision 1.6 diff -u -r1.6 EquinoxBundlesState.java --- src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxBundlesState.java 3 Apr 2008 16:36:14 -0000 1.6 +++ src/org/eclipse/equinox/internal/frameworkadmin/equinox/EquinoxBundlesState.java 9 Jul 2008 15:35:02 -0000 @@ -402,59 +402,37 @@ return true; } - public BundleInfo convert(BundleDescription toConvert) { + private BundleInfo convertSystemBundle(BundleDescription toConvert) { + // Converting the System Bundle boolean markedAsStarted = false; int sl = BundleInfo.NO_LEVEL; String location = null; - // This algorithm is not sophisticated. - if (toConvert.getBundleId() == 0 && EquinoxConstants.FW_SYMBOLIC_NAME.equals(toConvert.getSymbolicName())) { - // Converting the System Bundle - String symbolicNameTarget = toConvert.getSymbolicName(); - Version versionTarget = toConvert.getVersion(); - try { - File fwJar = manipulator.getLauncherData().getFwJar(); - if (fwJar != null) { - String fwJarLocation = fwJar.toURL().toExternalForm(); - String[] clauses = Utils.getClausesManifestMainAttributes(fwJarLocation, Constants.BUNDLE_SYMBOLICNAME); - String fwJarSymbolicName = Utils.getPathFromClause(clauses[0]); - String fwJarVersionSt = Utils.getManifestMainAttributes(fwJarLocation, Constants.BUNDLE_VERSION); - if (fwJarSymbolicName.equals(symbolicNameTarget) && fwJarVersionSt.equals(versionTarget.toString())) { - location = fwJarLocation; - markedAsStarted = true; - } - } - } catch (MalformedURLException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } catch (FrameworkAdminRuntimeException e1) { - // TODO Auto-generated catch block - e1.printStackTrace(); - } - } else { - location = FileUtils.getEclipseRealLocation(manipulator, toConvert.getLocation()); - BundleInfo[] originalBInfos = manipulator.getConfigData().getBundles(); - // if (DEBUG) - // System.out.println("toConvert=" + location); - boolean found = false; - for (int i = 0; i < originalBInfos.length; i++) { - // if (DEBUG) - // System.out.println("originalBInfos[" + i + "]=" + - // originalBInfos[i].getLocation()); - if (originalBInfos[i].getLocation().equals(location)) { - markedAsStarted = originalBInfos[i].isMarkedAsStarted(); - sl = getStartLevel(originalBInfos[i].getStartLevel()); - found = true; - break; + String symbolicNameTarget = toConvert.getSymbolicName(); + Version versionTarget = toConvert.getVersion(); + try { + File fwJar = manipulator.getLauncherData().getFwJar(); + if (fwJar != null) { + String fwJarLocation = fwJar.toURL().toExternalForm(); + String[] clauses = Utils.getClausesManifestMainAttributes(fwJarLocation, Constants.BUNDLE_SYMBOLICNAME); + String fwJarSymbolicName = Utils.getPathFromClause(clauses[0]); + String fwJarVersionSt = Utils.getManifestMainAttributes(fwJarLocation, Constants.BUNDLE_VERSION); + if (fwJarSymbolicName.equals(symbolicNameTarget) && fwJarVersionSt.equals(versionTarget.toString())) { + location = fwJarLocation; + markedAsStarted = true; } } - if (!found) { - // TODO current equinox impl has no way to get the start level - // info persistently stored. - markedAsStarted = false; - sl = BundleInfo.NO_LEVEL; - } + } catch (MalformedURLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } catch (FrameworkAdminRuntimeException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); } + return createBundleInfo(toConvert, markedAsStarted, sl, location); + } + + private BundleInfo createBundleInfo(BundleDescription toConvert, boolean markedAsStarted, int sl, String location) { BundleInfo result = new BundleInfo(); result.setSymbolicName(toConvert.getSymbolicName()); result.setVersion(toConvert.getVersion().toString()); @@ -467,9 +445,28 @@ } public BundleInfo[] convertState(BundleDescription[] bundles) { + BundleInfo[] originalBInfos = manipulator.getConfigData().getBundles(); + Map bundleInfoMap = new HashMap(); + for (int i = 0; i < originalBInfos.length; i++) { + bundleInfoMap.put(originalBInfos[i].getLocation(), originalBInfos[i]); + } + BundleInfo[] result = new BundleInfo[bundles.length]; for (int i = 0; i < bundles.length; i++) { - result[i] = convert(bundles[i]); + if (bundles[i].getBundleId() == 0 && EquinoxConstants.FW_SYMBOLIC_NAME.equals(bundles[i].getSymbolicName())) { + result[i] = convertSystemBundle(bundles[i]); + continue; + } + + boolean markedAsStarted = false; + int sl = BundleInfo.NO_LEVEL; + String location = FileUtils.getEclipseRealLocation(manipulator, bundles[i].getLocation()); + BundleInfo original = (BundleInfo) bundleInfoMap.get(location); + if (original != null) { + markedAsStarted = original.isMarkedAsStarted(); + sl = getStartLevel(original.getStartLevel()); + } + result[i] = createBundleInfo(bundles[i], markedAsStarted, sl, location); } return result; } @@ -511,7 +508,7 @@ public BundleInfo getSystemBundle() { BundleDescription bundle = this.getSystemBundleDescription(); - return (bundle != null ? convert(bundle) : null); + return (bundle != null ? convertSystemBundle(bundle) : null); } private BundleDescription getSystemBundleDescription() {