Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorslewis2008-05-20 16:32:47 +0000
committerslewis2008-05-20 16:32:47 +0000
commit64a1faa747962cfb652d9e281d00848197982f95 (patch)
tree5572ecf63792e08f43073056ddb56c55e7322e28
parentef3ba11b03e2ed7210475d8beeeedd588635e98b (diff)
downloadorg.eclipse.ecf-64a1faa747962cfb652d9e281d00848197982f95.tar.gz
org.eclipse.ecf-64a1faa747962cfb652d9e281d00848197982f95.tar.xz
org.eclipse.ecf-64a1faa747962cfb652d9e281d00848197982f95.zip
Additions to ContainerStore/ContainerEntry
-rw-r--r--framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/internal/storage/ContainerEntry.java6
-rw-r--r--framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/internal/storage/ContainerStore.java35
-rw-r--r--framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/storage/IContainerStore.java4
-rw-r--r--framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/storage/IStorableContainerAdapter.java7
4 files changed, 47 insertions, 5 deletions
diff --git a/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/internal/storage/ContainerEntry.java b/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/internal/storage/ContainerEntry.java
index ecf018614..f4ed8bebf 100644
--- a/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/internal/storage/ContainerEntry.java
+++ b/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/internal/storage/ContainerEntry.java
@@ -53,7 +53,7 @@ public class ContainerEntry implements IContainerEntry {
} catch (IDCreateException e) {
throw new ContainerCreateException("Could not create ID for container", e); //$NON-NLS-1$
} catch (StorageException e) {
- throw new ContainerCreateException("Could not get factory name", e); //$NON-NLS-1$
+ throw new ContainerCreateException("Exception on restore", e); //$NON-NLS-1$
}
}
@@ -81,6 +81,10 @@ public class ContainerEntry implements IContainerEntry {
return prefs.get(FACTORY_NAME_KEY, ""); //$NON-NLS-1$
}
+ protected void setFactoryName(String factoryName, boolean encrypt) throws StorageException {
+ prefs.put(FACTORY_NAME_KEY, factoryName, encrypt);
+ }
+
/* (non-Javadoc)
* @see org.eclipse.ecf.storage.IContainerEntry#getPreferences()
*/
diff --git a/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/internal/storage/ContainerStore.java b/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/internal/storage/ContainerStore.java
index c9b2a832c..f3be43d3e 100644
--- a/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/internal/storage/ContainerStore.java
+++ b/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/internal/storage/ContainerStore.java
@@ -18,6 +18,7 @@ import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.ecf.core.identity.ID;
import org.eclipse.ecf.storage.*;
import org.eclipse.equinox.security.storage.ISecurePreferences;
+import org.eclipse.equinox.security.storage.StorageException;
/**
*
@@ -62,8 +63,38 @@ public class ContainerStore implements IContainerStore {
Assert.isNotNull(containerID);
IIDEntry idEntry = idStore.store(containerID);
ContainerEntry containerEntry = new ContainerEntry(idEntry);
- containerAdapter.handleStore(containerEntry.getPreferences());
- return containerEntry;
+ try {
+ containerEntry.setFactoryName(containerAdapter.getFactoryName(), containerAdapter.encrypt());
+ containerAdapter.handleStore(containerEntry.getPreferences());
+ return containerEntry;
+ } catch (StorageException e) {
+ // Undo and return null
+ containerEntry.delete();
+ return null;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.storage.IContainerStore#retrieve(org.eclipse.ecf.core.identity.ID)
+ */
+ public IContainerEntry retrieve(ID containerID) {
+ IIDEntry entry = idStore.store(containerID);
+ return retrieve(entry);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ecf.storage.IContainerStore#retrieve(org.eclipse.ecf.storage.IIDEntry)
+ */
+ public IContainerEntry retrieve(IIDEntry idEntry) {
+ Assert.isNotNull(idEntry);
+ ISecurePreferences pref = idEntry.getPreferences();
+ String[] names = pref.childrenNames();
+ IContainerEntry result = null;
+ for (int k = 0; k < names.length; k++) {
+ if (names[k].equals(CONTAINER_NODE_NAME))
+ result = new ContainerEntry(idEntry);
+ }
+ return result;
}
/* (non-Javadoc)
diff --git a/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/storage/IContainerStore.java b/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/storage/IContainerStore.java
index c514339cc..43f005d53 100644
--- a/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/storage/IContainerStore.java
+++ b/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/storage/IContainerStore.java
@@ -12,6 +12,7 @@
package org.eclipse.ecf.storage;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.ecf.core.identity.ID;
/**
* Storage interface for IContainer instances.
@@ -35,4 +36,7 @@ public interface IContainerStore extends IAdaptable {
*/
public IContainerEntry store(IStorableContainerAdapter containerAdapter);
+ public IContainerEntry retrieve(ID containerID);
+
+ public IContainerEntry retrieve(IIDEntry idEntry);
}
diff --git a/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/storage/IStorableContainerAdapter.java b/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/storage/IStorableContainerAdapter.java
index 66efbe3f3..3dedfba26 100644
--- a/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/storage/IStorableContainerAdapter.java
+++ b/framework/bundles/org.eclipse.ecf.storage/src/org/eclipse/ecf/storage/IStorableContainerAdapter.java
@@ -13,16 +13,19 @@ package org.eclipse.ecf.storage;
import org.eclipse.ecf.core.identity.IIdentifiable;
import org.eclipse.equinox.security.storage.ISecurePreferences;
+import org.eclipse.equinox.security.storage.StorageException;
/**
*
*/
public interface IStorableContainerAdapter extends IIdentifiable {
+ public boolean encrypt();
+
public String getFactoryName();
- public void handleStore(ISecurePreferences prefs);
+ public void handleStore(ISecurePreferences prefs) throws StorageException;
- public void handleRestore(ISecurePreferences prefs);
+ public void handleRestore(ISecurePreferences prefs) throws StorageException;
}

Back to the top