Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 262964 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/equinox/internal/p2/core/helpers/AbstractRepositoryManager.java (-7 / +30 lines)
Lines 14-20 Link Here
14
import java.net.*;
14
import java.net.*;
15
import java.util.*;
15
import java.util.*;
16
import org.eclipse.core.runtime.*;
16
import org.eclipse.core.runtime.*;
17
import org.eclipse.core.runtime.preferences.ConfigurationScope;
17
import org.eclipse.core.runtime.preferences.IPreferencesService;
18
import org.eclipse.equinox.internal.p2.core.Activator;
18
import org.eclipse.equinox.internal.p2.core.Activator;
19
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
19
import org.eclipse.equinox.internal.provisional.p2.core.ProvisionException;
20
import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
20
import org.eclipse.equinox.internal.provisional.p2.core.eventbus.IProvisioningEventBus;
Lines 453-459 Link Here
453
	 * Return the preference node which is the root for where we store the repository information.
453
	 * Return the preference node which is the root for where we store the repository information.
454
	 */
454
	 */
455
	private Preferences getPreferences() {
455
	private Preferences getPreferences() {
456
		return new ConfigurationScope().getNode(getBundleId()).node(NODE_REPOSITORIES);
456
		IPreferencesService prefService = (IPreferencesService) ServiceHelper.getService(Activator.getContext(), IPreferencesService.class.getName());
457
458
		try {
459
			return prefService.getRootNode().node("/profile/_SELF_/" + getBundleId() + "/" + NODE_REPOSITORIES); //$NON-NLS-1$ //$NON-NLS-2$
460
		} catch (IllegalArgumentException e) {
461
			return null;
462
		}
457
	}
463
	}
458
464
459
	/**
465
	/**
Lines 689-695 Link Here
689
	 */
695
	 */
690
	private void remember(IRepository repository, String suffix) {
696
	private void remember(IRepository repository, String suffix) {
691
		boolean changed = false;
697
		boolean changed = false;
692
		Preferences node = getPreferences().node(getKey(repository.getLocation()));
698
699
		Preferences node = getPreferences();
700
		// Ensure we retrieved preferences
701
		if (node == null)
702
			return;
703
		node = node.node(getKey(repository.getLocation()));
704
693
		changed |= putValue(node, KEY_URI, repository.getLocation().toString());
705
		changed |= putValue(node, KEY_URI, repository.getLocation().toString());
694
		changed |= putValue(node, KEY_URL, null);
706
		changed |= putValue(node, KEY_URL, null);
695
		changed |= putValue(node, KEY_DESCRIPTION, repository.getDescription());
707
		changed |= putValue(node, KEY_DESCRIPTION, repository.getDescription());
Lines 712-718 Link Here
712
	 */
724
	 */
713
	private boolean remember(RepositoryInfo info, boolean flush) {
725
	private boolean remember(RepositoryInfo info, boolean flush) {
714
		boolean changed = false;
726
		boolean changed = false;
715
		Preferences node = getPreferences().node(getKey(info.location));
727
		Preferences node = getPreferences();
728
		// Ensure we retrieved preferences
729
		if (node == null)
730
			return changed;
731
		node = node.node(getKey(info.location));
716
		changed |= putValue(node, KEY_URI, info.location.toString());
732
		changed |= putValue(node, KEY_URI, info.location.toString());
717
		changed |= putValue(node, KEY_URL, null);
733
		changed |= putValue(node, KEY_URL, null);
718
		changed |= putValue(node, KEY_SYSTEM, Boolean.toString(info.isSystem));
734
		changed |= putValue(node, KEY_SYSTEM, Boolean.toString(info.isSystem));
Lines 763-770 Link Here
763
				Tracing.debug(msg);
779
				Tracing.debug(msg);
764
				new Exception(msg).printStackTrace();
780
				new Exception(msg).printStackTrace();
765
			}
781
			}
766
			getPreferences().node(repoKey).removeNode();
782
			Preferences node = getPreferences();
767
			saveToPreferences();
783
			if (node != null) {
784
				getPreferences().node(repoKey).removeNode();
785
				saveToPreferences();
786
			}
768
			clearNotFound(toRemove);
787
			clearNotFound(toRemove);
769
		} catch (BackingStoreException e) {
788
		} catch (BackingStoreException e) {
770
			log("Error saving preferences", e); //$NON-NLS-1$
789
			log("Error saving preferences", e); //$NON-NLS-1$
Lines 781-786 Link Here
781
	private void restoreFromPreferences() {
800
	private void restoreFromPreferences() {
782
		// restore the list of repositories from the preference store
801
		// restore the list of repositories from the preference store
783
		Preferences node = getPreferences();
802
		Preferences node = getPreferences();
803
		if (node == null)
804
			return;
784
		String[] children;
805
		String[] children;
785
		try {
806
		try {
786
			children = node.childrenNames();
807
			children = node.childrenNames();
Lines 845-851 Link Here
845
	 */
866
	 */
846
	private void saveToPreferences() {
867
	private void saveToPreferences() {
847
		try {
868
		try {
848
			getPreferences().flush();
869
			Preferences node = getPreferences();
870
			if (node != null)
871
				node.flush();
849
		} catch (BackingStoreException e) {
872
		} catch (BackingStoreException e) {
850
			log("Error while saving repositories in preferences", e); //$NON-NLS-1$
873
			log("Error while saving repositories in preferences", e); //$NON-NLS-1$
851
		}
874
		}

Return to bug 262964