From c14f6803a8f461dc405c1dc56193ed39e8efdbb0 Mon Sep 17 00:00:00 2001 From: slewis Date: Sun, 11 May 2008 22:42:42 +0000 Subject: Added getNodes() for IIDStore --- .../org/eclipse/ecf/internal/storage/IDStore.java | 23 ++++++++++++++++++++++ .../src/org/eclipse/ecf/storage/IIDStore.java | 8 ++++++++ 2 files changed, 31 insertions(+) diff --git a/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/internal/storage/IDStore.java b/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/internal/storage/IDStore.java index 100865da1..b3159bc91 100644 --- a/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/internal/storage/IDStore.java +++ b/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/internal/storage/IDStore.java @@ -11,6 +11,8 @@ package org.eclipse.ecf.internal.storage; +import java.util.ArrayList; +import java.util.List; import org.eclipse.ecf.core.identity.*; import org.eclipse.ecf.storage.*; import org.eclipse.equinox.security.storage.*; @@ -22,6 +24,7 @@ public class IDStore implements IIDStore { private static final String idStoreNameSegment = "/ECF/ID Store/"; //$NON-NLS-1$ private static final String NSSEPARATOR = ":"; //$NON-NLS-1$ + private static final ISecurePreferences[] EMPTY_SECUREPREFERENCES = {}; /* (non-Javadoc) * @see org.eclipse.ecf.storage.IIDStore#getNode(org.eclipse.ecf.core.identity.ID) @@ -39,6 +42,26 @@ public class IDStore implements IIDStore { return root.node(path); } + /* (non-Javadoc) + * @see org.eclipse.ecf.storage.IIDStore#getNodes() + */ + public ISecurePreferences[] getNodes() { + final ISecurePreferences root = SecurePreferencesFactory.getDefault(); + if (root == null) + return null; + ISecurePreferences parentNode = root.node(idStoreNameSegment); + if (parentNode == null) + return EMPTY_SECUREPREFERENCES; + String[] childNames = parentNode.childrenNames(); + List result = new ArrayList(); + for (int i = 0; i < childNames.length; i++) { + ISecurePreferences p = parentNode.node(childNames[i]); + if (p != null) + result.add(p); + } + return (ISecurePreferences[]) result.toArray(new ISecurePreferences[] {}); + } + private String getIDAsString(ID id) { final Namespace ns = id.getNamespace(); final INamespaceStoreAdapter nsadapter = (INamespaceStoreAdapter) ns.getAdapter(INamespaceStoreAdapter.class); diff --git a/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/storage/IIDStore.java b/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/storage/IIDStore.java index 30b0d31c0..f35cc6268 100644 --- a/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/storage/IIDStore.java +++ b/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/storage/IIDStore.java @@ -21,6 +21,14 @@ import org.eclipse.equinox.security.storage.ISecurePreferences; */ public interface IIDStore { + /** + * Get {@link ISecurePreferences} for all IDs in ID store. + * + * @return array of ISecurePreferences instances. If number of instances current stored is 0, returns + * empty array. Will not return null. + */ + public ISecurePreferences[] getNodes(); + /** * Get {@link ISecurePreferences} node for a given ID. Clients may use this to either create an {@link ISecurePreferences} * instance for a new {@link ID}, or get an existing one from storage. -- cgit v1.2.3