Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2017-11-29 06:33:45 +0000
committerAlexander Kurtakov2017-11-29 06:33:45 +0000
commit9f7c3d67025c6ae4ea91e8f80d661664fa2cd57c (patch)
treee087b8a9b58bd613d39c6ce71bd1c2861c771c99
parentb9da092b743547b0b32643e1904c8695e5a209e6 (diff)
downloadeclipse.platform-9f7c3d67025c6ae4ea91e8f80d661664fa2cd57c.tar.gz
eclipse.platform-9f7c3d67025c6ae4ea91e8f80d661664fa2cd57c.tar.xz
eclipse.platform-9f7c3d67025c6ae4ea91e8f80d661664fa2cd57c.zip
Bug 527783 - Entries in error log: org.eclipse.update.configurator -I20171130-2100I20171130-2000I20171129-2000
Could not install bundle... Remove update.configurator reconciling code. P2 disables it by default so no use of it now. Change-Id: I4821d8547362e1a51a4d7d7988769598c539ec60 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/ConfigurationActivator.java335
-rw-r--r--update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/PlatformConfiguration.java156
2 files changed, 19 insertions, 472 deletions
diff --git a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/ConfigurationActivator.java b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/ConfigurationActivator.java
index 5abb77473..1648dded3 100644
--- a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/ConfigurationActivator.java
+++ b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/ConfigurationActivator.java
@@ -10,20 +10,26 @@
*******************************************************************************/
package org.eclipse.update.internal.configurator;
-import java.io.*;
-import java.net.*;
-import java.util.*;
-
-import org.eclipse.core.runtime.*;
-import org.eclipse.osgi.framework.log.*;
-import org.eclipse.osgi.service.datalocation.*;
-import org.eclipse.osgi.service.debug.*;
-import org.eclipse.osgi.util.ManifestElement;
+import java.io.DataInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+
+import org.eclipse.core.runtime.IBundleGroup;
+import org.eclipse.core.runtime.IBundleGroupProvider;
+import org.eclipse.osgi.framework.log.FrameworkLog;
+import org.eclipse.osgi.service.datalocation.Location;
+import org.eclipse.osgi.service.debug.DebugOptions;
import org.eclipse.osgi.util.NLS;
-import org.eclipse.update.configurator.*;
-import org.osgi.framework.*;
-import org.osgi.service.packageadmin.*;
-import org.osgi.service.startlevel.*;
+import org.eclipse.update.configurator.IPlatformConfiguration;
+import org.eclipse.update.configurator.IPlatformConfigurationFactory;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.InvalidSyntaxException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.ServiceRegistration;
public class ConfigurationActivator implements BundleActivator, IBundleGroupProvider, IConfigurationConstants {
@@ -31,7 +37,6 @@ public class ConfigurationActivator implements BundleActivator, IBundleGroupProv
public static final String LAST_CONFIG_STAMP = "last.config.stamp"; //$NON-NLS-1$
public static final String NAME_SPACE = "org.eclipse.update"; //$NON-NLS-1$
public static final String UPDATE_PREFIX = "update@"; //$NON-NLS-1$
- private static final String INITIAL_PREFIX = "initial@"; //$NON-NLS-1$
// debug options
public static String OPTION_DEBUG = PI_CONFIGURATOR + "/debug"; //$NON-NLS-1$
@@ -81,20 +86,9 @@ public class ConfigurationActivator implements BundleActivator, IBundleGroupProv
Utils.debug("Starting update configurator..."); //$NON-NLS-1$
- if (isReconciling())
- installBundles();
registerBundleGroupProvider();
}
- /**
- * Returns whether the update configurator should be doing its own reconciling work
- */
- public static boolean isReconciling() {
- String reconcile = context.getProperty("org.eclipse.update.reconcile"); //$NON-NLS-1$
- return reconcile == null || reconcile.equalsIgnoreCase("true"); //$NON-NLS-1$
-
- }
-
private void registerBundleGroupProvider() {
final String serviceName = IBundleGroupProvider.class.getName();
try {
@@ -169,232 +163,6 @@ public class ConfigurationActivator implements BundleActivator, IBundleGroupProv
Utils.shutdown();
}
- public boolean installBundles() {
- Utils.debug("Installing bundles..."); //$NON-NLS-1$
- ServiceReference<StartLevel> reference = context.getServiceReference(StartLevel.class);
- int startLevel = 4;
- String defaultStartLevel = context.getProperty("osgi.bundles.defaultStartLevel"); //$NON-NLS-1$
- if (defaultStartLevel != null) {
- try {
- startLevel = Integer.parseInt(defaultStartLevel);
- } catch (NumberFormatException e1) {
- startLevel = 4;
- }
- }
- if (startLevel < 1)
- startLevel = 4;
-
- StartLevel start = null;
- if (reference != null)
- start = context.getService(reference);
- try {
- // Get the list of cached bundles and compare with the ones to be installed.
- // Uninstall all the cached bundles that do not appear on the new list
- Bundle[] cachedBundles = context.getBundles();
- URL[] plugins = configuration.getPluginPath();
-
- // starts the list of bundles to refresh with all currently unresolved bundles (see bug 50680)
- List<Bundle> toRefresh = getUnresolvedBundles();
-
- Bundle[] bundlesToUninstall = getBundlesToUninstall(cachedBundles, plugins);
- for (int i = 0; i < bundlesToUninstall.length; i++) {
- try {
- if (DEBUG)
- Utils.debug("Uninstalling " + bundlesToUninstall[i].getLocation()); //$NON-NLS-1$
- // include every bundle being uninstalled in the list of bundles to refresh (see bug 82393)
- toRefresh.add(bundlesToUninstall[i]);
- bundlesToUninstall[i].uninstall();
- } catch (Exception e) {
- Utils.log(NLS.bind(Messages.ConfigurationActivator_uninstallBundle, (new String[] {bundlesToUninstall[i].getLocation()})));
- }
- }
-
- // Get the urls to install
- String[] bundlesToInstall = getBundlesToInstall(cachedBundles, plugins);
- ArrayList<Bundle> lazyActivationBundles = new ArrayList<>(bundlesToInstall.length);
- for (int i = 0; i < bundlesToInstall.length; i++) {
- try {
- if (DEBUG)
- Utils.debug("Installing " + bundlesToInstall[i]); //$NON-NLS-1$
- URL bundleURL = new URL("reference:file:" + bundlesToInstall[i]); //$NON-NLS-1$
- //Bundle target = context.installBundle(bundlesToInstall[i]);
- Bundle target = context.installBundle(UPDATE_PREFIX + bundlesToInstall[i], bundleURL.openStream());
- // any new bundle should be refreshed as well
- toRefresh.add(target);
- if (start != null)
- start.setBundleStartLevel(target, startLevel);
- // check the bundle manifest to see if it defines a lazy activation policy
- if (hasLazyActivationPolicy(target))
- lazyActivationBundles.add(target);
- } catch (Exception e) {
- if (!Utils.isAutomaticallyStartedBundle(bundlesToInstall[i]))
- Utils.log(NLS.bind(Messages.ConfigurationActivator_installBundle, (new String[] {bundlesToInstall[i]})) + " " + e.getMessage()); //$NON-NLS-1$
- }
- }
- context.ungetService(reference);
- removeInitialBundles(toRefresh, cachedBundles);
- refreshPackages(toRefresh.toArray(new Bundle[toRefresh.size()]));
- // after resolving all the bundles; activate the bundles that have a lazy activation policy
- for (Iterator<Bundle> activateBundles = lazyActivationBundles.iterator(); activateBundles.hasNext();) {
- Bundle toActivate = activateBundles.next();
- try {
- // use the START_ACTIVATION_POLICY option so this is not an eager activation.
- toActivate.start(Bundle.START_ACTIVATION_POLICY);
- } catch (BundleException e) {
- if ((toActivate.getState() & Bundle.RESOLVED) != 0)
- // only log errors if the bundle is resolved
- Utils.log(NLS.bind(Messages.ConfigurationActivator_installBundle, (new String[] {toActivate.getLocation()})) + " " + e.getMessage()); //$NON-NLS-1$
- }
- }
- // keep track of the last config successfully processed
- writePlatformConfigurationTimeStamp();
- return true;
- } catch (Exception e) {
- return false;
- }
- }
-
- private static boolean hasLazyActivationPolicy(Bundle target) {
- // check the bundle manifest to see if it defines a lazy activation policy
- Dictionary<String, String> headers = target.getHeaders(""); //$NON-NLS-1$
- // first check to see if this is a fragment bundle
- String fragmentHost = headers.get(Constants.FRAGMENT_HOST);
- if (fragmentHost != null)
- return false; // do not activate fragment bundles
- // look for the OSGi defined Bundle-ActivationPolicy header
- String activationPolicy = headers.get(Constants.BUNDLE_ACTIVATIONPOLICY);
- try {
- if (activationPolicy != null) {
- ManifestElement[] elements = ManifestElement.parseHeader(Constants.BUNDLE_ACTIVATIONPOLICY, activationPolicy);
- if (elements != null && elements.length > 0) {
- // if the value is "lazy" then it has a lazy activation policy
- if (Constants.ACTIVATION_LAZY.equals(elements[0].getValue()))
- return true;
- }
- } else {
- // check for Eclipse specific lazy start headers "Eclipse-LazyStart" and "Eclipse-AutoStart"
- String eclipseLazyStart = headers.get("Eclipse-LazyStart"); //$NON-NLS-1$
- if (eclipseLazyStart == null)
- eclipseLazyStart = headers.get("Eclipse-AutoStart"); //$NON-NLS-1$
- ManifestElement[] elements = ManifestElement.parseHeader("Eclipse-LazyStart", eclipseLazyStart); //$NON-NLS-1$
- if (elements != null && elements.length > 0) {
- // if the value is true then it is lazy activated
- if ("true".equals(elements[0].getValue())) //$NON-NLS-1$
- return true;
- // otherwise it is only lazy activated if it defines an exceptions directive.
- else if (elements[0].getDirective("exceptions") != null) //$NON-NLS-1$
- return true;
- }
- }
- } catch (BundleException be) {
- // ignore this
- }
- return false;
- }
-
- private void removeInitialBundles(List<Bundle> bundles, Bundle[] cachedBundles) {
- String[] initialSymbolicNames = getInitialSymbolicNames(cachedBundles);
- Iterator<Bundle> iter = bundles.iterator();
- while (iter.hasNext()) {
- Bundle bundle = iter.next();
- String symbolicName = bundle.getSymbolicName();
- for (int i = 0; i < initialSymbolicNames.length; i++) {
- if (initialSymbolicNames[i].equals(symbolicName)) {
- iter.remove();
- break;
- }
- }
- }
- }
-
- private String[] getInitialSymbolicNames(Bundle[] cachedBundles) {
- ArrayList<String> initial = new ArrayList<>();
- for (int i = 0; i < cachedBundles.length; i++) {
- Bundle bundle = cachedBundles[i];
- if (bundle.getLocation().startsWith(INITIAL_PREFIX)) {
- String symbolicName = bundle.getSymbolicName();
- if (symbolicName != null)
- initial.add(symbolicName);
- }
- }
- return initial.toArray(new String[initial.size()]);
- }
-
- private List<Bundle> getUnresolvedBundles() {
- Bundle[] allBundles = context.getBundles();
- List<Bundle> unresolved = new ArrayList<>();
- for (int i = 0; i < allBundles.length; i++)
- if (allBundles[i].getState() == Bundle.INSTALLED)
- unresolved.add(allBundles[i]);
- return unresolved;
- }
-
- private String[] getBundlesToInstall(Bundle[] cachedBundles, URL[] newPlugins) {
- // First, create a map of the cached bundles, for faster lookup
- HashSet<String> cachedBundlesSet = new HashSet<>(cachedBundles.length);
- int offset = UPDATE_PREFIX.length();
- for (int i = 0; i < cachedBundles.length; i++) {
- if (cachedBundles[i].getBundleId() == 0)
- continue; // skip the system bundle
- String bundleLocation = cachedBundles[i].getLocation();
- // Ignore bundles not installed by us
- if (!bundleLocation.startsWith(UPDATE_PREFIX))
- continue;
-
- bundleLocation = bundleLocation.substring(offset);
- cachedBundlesSet.add(bundleLocation);
- // On windows, we will be doing case insensitive search as well, so lower it now
- if (Utils.isWindows)
- cachedBundlesSet.add(bundleLocation.toLowerCase());
- }
-
- ArrayList<String> bundlesToInstall = new ArrayList<>(newPlugins.length);
- for (int i = 0; i < newPlugins.length; i++) {
- String location = Utils.makeRelative(Utils.getInstallURL(), newPlugins[i]).getFile();
- // check if already installed
- if (cachedBundlesSet.contains(location))
- continue;
- if (Utils.isWindows && cachedBundlesSet.contains(location.toLowerCase()))
- continue;
-
- bundlesToInstall.add(location);
- }
- return bundlesToInstall.toArray(new String[bundlesToInstall.size()]);
- }
-
- private Bundle[] getBundlesToUninstall(Bundle[] cachedBundles, URL[] newPlugins) {
- // First, create a map for faster lookups
- HashSet<String> newPluginsSet = new HashSet<>(newPlugins.length);
- for (int i = 0; i < newPlugins.length; i++) {
-
- String pluginLocation = Utils.makeRelative(Utils.getInstallURL(), newPlugins[i]).getFile();
- newPluginsSet.add(pluginLocation);
- // On windows, we will be doing case insensitive search as well, so lower it now
- if (Utils.isWindows)
- newPluginsSet.add(pluginLocation.toLowerCase());
- }
-
- ArrayList<Bundle> bundlesToUninstall = new ArrayList<>();
- int offset = UPDATE_PREFIX.length();
- for (int i = 0; i < cachedBundles.length; i++) {
- if (cachedBundles[i].getBundleId() == 0)
- continue; // skip the system bundle
- String cachedBundleLocation = cachedBundles[i].getLocation();
- // Only worry about bundles we installed
- if (!cachedBundleLocation.startsWith(UPDATE_PREFIX))
- continue;
- cachedBundleLocation = cachedBundleLocation.substring(offset);
-
- if (newPluginsSet.contains(cachedBundleLocation))
- continue;
- if (Utils.isWindows && newPluginsSet.contains(cachedBundleLocation.toLowerCase()))
- continue;
-
- bundlesToUninstall.add(cachedBundles[i]);
- }
- return bundlesToUninstall.toArray(new Bundle[bundlesToUninstall.size()]);
- }
-
/**
* Creates and starts the platform configuration.
* @return the just started platform configuration
@@ -412,71 +180,6 @@ public class ConfigurationActivator implements BundleActivator, IBundleGroupProv
}
- /**
- * Do PackageAdmin.refreshPackages() in a synchronous way. After installing
- * all the requested bundles we need to do a refresh and want to ensure that
- * everything is done before returning.
- * @param bundles
- */
- private void refreshPackages(Bundle[] bundles) {
- if (bundles.length == 0)
- return;
- ServiceReference<PackageAdmin> packageAdminRef = context.getServiceReference(PackageAdmin.class);
- PackageAdmin packageAdmin = null;
- if (packageAdminRef != null) {
- packageAdmin = context.getService(packageAdminRef);
- if (packageAdmin == null)
- return;
- }
- // TODO this is such a hack it is silly. There are still cases for race conditions etc
- // but this should allow for some progress...
- // (patch from John A.)
- final boolean[] flag = new boolean[] {false};
- FrameworkListener listener = event -> {
- if (event.getType() == FrameworkEvent.PACKAGES_REFRESHED)
- synchronized (flag) {
- flag[0] = true;
- flag.notifyAll();
- }
- };
- context.addFrameworkListener(listener);
- packageAdmin.refreshPackages(bundles);
- synchronized (flag) {
- while (!flag[0]) {
- try {
- flag.wait();
- } catch (InterruptedException e) {
- }
- }
- }
- context.removeFrameworkListener(listener);
- context.ungetService(packageAdminRef);
- }
-
- private void writePlatformConfigurationTimeStamp() {
- DataOutputStream stream = null;
- try {
- if (configLocation.isReadOnly())
- return;
-
- String configArea = configLocation.getURL().getFile();
- lastTimeStamp = configuration.getChangeStamp();
- lastStateTimeStamp = Utils.getStateStamp();
- stream = new DataOutputStream(new FileOutputStream(configArea + File.separator + NAME_SPACE + File.separator + LAST_CONFIG_STAMP));
- stream.writeLong(lastTimeStamp);
- stream.writeLong(lastStateTimeStamp);
- } catch (Exception e) {
- Utils.log(e.getLocalizedMessage());
- } finally {
- if (stream != null)
- try {
- stream.close();
- } catch (IOException e1) {
- Utils.log(e1.getLocalizedMessage());
- }
- }
- }
-
private void loadOptions() {
// all this is only to get the application args
DebugOptions service = null;
diff --git a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/PlatformConfiguration.java b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/PlatformConfiguration.java
index 5eff1c691..610d4f895 100644
--- a/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/PlatformConfiguration.java
+++ b/update/org.eclipse.update.configurator/src/org/eclipse/update/internal/configurator/PlatformConfiguration.java
@@ -14,7 +14,6 @@ package org.eclipse.update.internal.configurator;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileFilter;
-import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
@@ -28,7 +27,6 @@ import java.net.URLConnection;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Date;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
@@ -66,7 +64,6 @@ public class PlatformConfiguration implements IPlatformConfiguration, IConfigura
private Configuration config;
private URL configLocation;
- private HashMap<URL, SiteEntry> externalLinkSites; // used to restore prior link site state
private long changeStamp;
private long featuresChangeStamp;
private boolean featuresChangeStampIsValid;
@@ -77,26 +74,20 @@ public class PlatformConfiguration implements IPlatformConfiguration, IConfigura
private Locker lock = null;
private static int defaultPolicy = DEFAULT_POLICY_TYPE;
- private static final String ECLIPSE = "eclipse"; //$NON-NLS-1$
private static final String CONFIG_HISTORY = "history"; //$NON-NLS-1$
private static final String PLATFORM_XML = "platform.xml"; //$NON-NLS-1$
private static final String CONFIG_NAME = ConfigurationActivator.NAME_SPACE + "/" + PLATFORM_XML; //$NON-NLS-1$
private static final String CONFIG_INI = "config.ini"; //NON-NLS-1$ //$NON-NLS-1$
private static final String CONFIG_FILE_LOCK_SUFFIX = ".lock"; //$NON-NLS-1$
private static final String CONFIG_FILE_TEMP_SUFFIX = ".tmp"; //$NON-NLS-1$
- private static final String LINKS = "links"; //$NON-NLS-1$
private static final String[] BOOTSTRAP_PLUGINS = {};
private static final String DEFAULT_FEATURE_APPLICATION = "org.eclipse.ui.ide.workbench"; //$NON-NLS-1$
- private static final String LINK_PATH = "path"; //$NON-NLS-1$
- private static final String LINK_READ = "r"; //$NON-NLS-1$
- private static final String LINK_READ_WRITE = "rw"; //$NON-NLS-1$
private static URL installURL;
private PlatformConfiguration(Location platformConfigLocation) throws CoreException, IOException {
- this.externalLinkSites = new HashMap<>();
this.config = null;
// initialize configuration
@@ -104,19 +95,6 @@ public class PlatformConfiguration implements IPlatformConfiguration, IConfigura
if (config != null)
setDefaultPolicy();
- // Detect external links. These are "soft link" to additional sites. The link
- // files are usually provided by external installation programs. They are located
- // relative to this configuration URL.
- // Note: don't do it for self hosting or if update reconciler is disabled
- if (ConfigurationActivator.isReconciling()) {
- if (!isTransient())
- configureExternalLinks();
-
- // Validate sites in the configuration. Causes any sites that do not exist to
- // be removed from the configuration
- validateSites();
- }
-
// compute differences between configuration and actual content of the sites
// (base sites and link sites)
// Note: when the config is transient (generated by PDE, etc.) we don't reconcile
@@ -139,7 +117,6 @@ public class PlatformConfiguration implements IPlatformConfiguration, IConfigura
}
PlatformConfiguration(URL url) throws Exception {
- this.externalLinkSites = new HashMap<>();
URL installLocation = Utils.getInstallURL();
// Retrieve install location with respect to given url if possible
try {
@@ -153,7 +130,6 @@ public class PlatformConfiguration implements IPlatformConfiguration, IConfigura
}
public PlatformConfiguration(URL url, URL installLocation) throws Exception {
- this.externalLinkSites = new HashMap<>();
initialize(url, installLocation);
}
@@ -825,138 +801,6 @@ public class PlatformConfiguration implements IPlatformConfiguration, IConfigura
return pluginsChangeStamp;
}
- private void configureExternalLinks() {
- URL linkURL = getInstallURL();
- if (!supportsDetection(linkURL, config.getInstallURL()))
- return;
-
- try {
- linkURL = new URL(linkURL, LINKS + "/"); //$NON-NLS-1$
- } catch (MalformedURLException e) {
- // skip bad links ...
- Utils.debug("Unable to obtain link URL"); //$NON-NLS-1$
- return;
- }
-
- File linkDir = new File(linkURL.getFile());
- File[] links = linkDir.listFiles();
- if (links == null || links.length == 0) {
- Utils.debug("No links detected in " + linkURL.toExternalForm()); //$NON-NLS-1$
- return;
- }
-
- for (int i = 0; i < links.length; i++) {
- if (links[i].isDirectory())
- continue;
- Utils.debug("Link file " + links[i].getAbsolutePath()); //$NON-NLS-1$
- Properties props = new Properties();
- FileInputStream is = null;
- try {
- is = new FileInputStream(links[i]);
- props.load(is);
- configureExternalLinkSite(links[i], props);
- } catch (IOException e) {
- // skip bad links ...
- Utils.debug(" unable to load link file " + e); //$NON-NLS-1$
- continue;
- } finally {
- if (is != null) {
- try {
- is.close();
- } catch (IOException e) {
- // ignore ...
- }
- }
- }
- }
- }
-
- private void configureExternalLinkSite(File linkFile, Properties props) {
- String path = props.getProperty(LINK_PATH);
- if (path == null) {
- Utils.debug(" no path definition"); //$NON-NLS-1$
- return;
- }
-
- String link;
- boolean updateable = true;
- URL siteURL;
-
- // parse out link information
- if (path.startsWith(LINK_READ + " ")) { //$NON-NLS-1$
- updateable = false;
- link = path.substring(2).trim();
- } else if (path.startsWith(LINK_READ_WRITE + " ")) { //$NON-NLS-1$
- link = path.substring(3).trim();
- } else {
- link = path.trim();
- }
-
- // make sure we have a valid link specification
- try {
- File siteFile = new File(link);
- siteFile = new File(siteFile, ECLIPSE);
- siteURL = siteFile.toURL();
- if (findConfiguredSite(siteURL, true) != null)
- // linked site is already known
- return;
- } catch (MalformedURLException e) {
- // ignore bad links ...
- Utils.debug(" bad URL " + e); //$NON-NLS-1$
- return;
- }
-
- // process the link
- SiteEntry linkSite = externalLinkSites.get(siteURL);
- if (linkSite == null) {
- // this is a link to a new target so create site for it
- ISitePolicy linkSitePolicy = createSitePolicy(getDefaultPolicy(), DEFAULT_POLICY_LIST);
- linkSite = (SiteEntry) createSiteEntry(siteURL, linkSitePolicy);
- }
- // update site entry if needed
- linkSite.setUpdateable(updateable);
- linkSite.setLinkFileName(linkFile.getAbsolutePath());
-
- // configure the new site
- // NOTE: duplicates are not replaced (first one in wins)
- configureSite(linkSite);
- // there are changes in the config
- config.setDirty(true);
- Utils.debug(" " + (updateable ? "R/W -> " : "R/O -> ") + siteURL.toString()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- private void validateSites() {
-
- // check to see if all sites are valid. Remove any sites that do not exist.
- SiteEntry[] list = config.getSites();
- for (int i = 0; i < list.length; i++) {
- URL siteURL = list[i].getResolvedURL();
- if (!supportsDetection(siteURL, config.getInstallURL()))
- continue;
-
- File siteRoot = new File(siteURL.getFile().replace('/', File.separatorChar));
- if (!siteRoot.exists()) {
- unconfigureSite(list[i]);
- Utils.debug("Site " + siteURL + " does not exist ... removing from configuration"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // If multiple paths are defined in the same link file
- // or if the path changes, the old site will still be kept.
- // A better algorithm could be implemented by keeping track
- // of the previous content of the link file.
- // TODO do the above
- String linkName = list[i].getLinkFileName();
- if (linkName != null) {
- File linkFile = new File(linkName);
- if (!linkFile.exists()) {
- unconfigureSite(list[i]);
- config.setDirty(true);
- Utils.debug("Site " + siteURL + " is no longer linked ... removing from configuration"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
- }
-
private void linkInitializedState(Configuration sharedConfig, Location sharedConfigLocation, Location newConfigLocation) {
try {
URL newConfigIniURL = new URL(newConfigLocation.getURL(), CONFIG_INI);

Back to the top