diff --git a/config/alfresco/avm-console-context.xml b/config/alfresco/avm-console-context.xml
index 45189e6e3d..c0dcafbb6b 100644
--- a/config/alfresco/avm-console-context.xml
+++ b/config/alfresco/avm-console-context.xml
@@ -157,6 +157,12 @@
+
+
+
+
+
+
@@ -192,6 +198,9 @@
+
+
+
diff --git a/config/alfresco/avm-test-context.xml b/config/alfresco/avm-test-context.xml
index ec00d24439..263d9163b8 100644
--- a/config/alfresco/avm-test-context.xml
+++ b/config/alfresco/avm-test-context.xml
@@ -130,6 +130,12 @@
+
+
+
+
+
+
@@ -164,6 +170,9 @@
+
+
+
diff --git a/source/java/org/alfresco/repo/avm/AVMContext.java b/source/java/org/alfresco/repo/avm/AVMContext.java
index c7d8487e84..7ccc6cd59a 100644
--- a/source/java/org/alfresco/repo/avm/AVMContext.java
+++ b/source/java/org/alfresco/repo/avm/AVMContext.java
@@ -75,6 +75,11 @@ public class AVMContext
*/
public AVMNodePropertyDAO fAVMNodePropertyDAO;
+ /**
+ * The AVMStorePropertyDAO
+ */
+ public AVMStorePropertyDAO fAVMStorePropertyDAO;
+
/**
* @param nodeDAO the fAVMNodeDAO to set
*/
@@ -159,4 +164,9 @@ public class AVMContext
{
fAVMNodePropertyDAO = avmNodePropertyDAO;
}
+
+ public void setAvmStorePropertyDAO(AVMStorePropertyDAO avmStorePropertyDAO)
+ {
+ fAVMStorePropertyDAO = avmStorePropertyDAO;
+ }
}
diff --git a/source/java/org/alfresco/repo/avm/AVMRepository.java b/source/java/org/alfresco/repo/avm/AVMRepository.java
index 7af981963d..7924036ebe 100644
--- a/source/java/org/alfresco/repo/avm/AVMRepository.java
+++ b/source/java/org/alfresco/repo/avm/AVMRepository.java
@@ -871,12 +871,12 @@ class AVMRepository
* @param name The name of the property.
* @param value The value of the property.
*/
- public void setProperty(String path, QName name, PropertyValue value)
+ public void setNodeProperty(String path, QName name, PropertyValue value)
{
fLookupCount.set(1);
String [] pathParts = SplitPath(path);
AVMStore store = getAVMStoreByName(pathParts[0], true);
- store.setProperty(pathParts[1], name, value);
+ store.setNodeProperty(pathParts[1], name, value);
}
/**
@@ -884,12 +884,12 @@ class AVMRepository
* @param path The path to the node.
* @param properties The Map of QNames to PropertyValues.
*/
- public void setProperties(String path, Map properties)
+ public void setNodeProperties(String path, Map properties)
{
fLookupCount.set(1);
String [] pathParts = SplitPath(path);
AVMStore store = getAVMStoreByName(pathParts[0], true);
- store.setProperties(pathParts[1], properties);
+ store.setNodeProperties(pathParts[1], properties);
}
/**
@@ -899,12 +899,12 @@ class AVMRepository
* @param name The name of the property.
* @return The PropertyValue or null if it does not exist.
*/
- public PropertyValue getProperty(int version, String path, QName name)
+ public PropertyValue getNodeProperty(int version, String path, QName name)
{
fLookupCount.set(1);
String [] pathParts = SplitPath(path);
AVMStore store = getAVMStoreByName(pathParts[0], false);
- return store.getProperty(version, pathParts[1], name);
+ return store.getNodeProperty(version, pathParts[1], name);
}
/**
@@ -913,12 +913,12 @@ class AVMRepository
* @param path The path to the node.
* @return A Map of QNames to PropertyValues.
*/
- public Map getProperties(int version, String path)
+ public Map getNodeProperties(int version, String path)
{
fLookupCount.set(1);
String [] pathParts = SplitPath(path);
AVMStore store = getAVMStoreByName(pathParts[0], false);
- return store.getProperties(version, pathParts[1]);
+ return store.getNodeProperties(version, pathParts[1]);
}
/**
@@ -926,12 +926,64 @@ class AVMRepository
* @param path The path to the node.
* @param name The name of the property.
*/
- public void deleteProperty(String path, QName name)
+ public void deleteNodeProperty(String path, QName name)
{
fLookupCount.set(1);
String [] pathParts = SplitPath(path);
AVMStore store = getAVMStoreByName(pathParts[0], true);
- store.deleteProperty(pathParts[1], name);
+ store.deleteNodeProperty(pathParts[1], name);
+ }
+
+ /**
+ * Set a property on a store. Overwrites if property exists.
+ * @param store The AVMStore.
+ * @param name The QName.
+ * @param value The PropertyValue to set.
+ */
+ public void setStoreProperty(String store, QName name, PropertyValue value)
+ {
+ getAVMStoreByName(store, true).setProperty(name, value);
+ }
+
+ /**
+ * Set a group of properties on a store. Overwrites any properties that exist.
+ * @param store The AVMStore.
+ * @param props The properties to set.
+ */
+ public void setStoreProperties(String store, Map props)
+ {
+ getAVMStoreByName(store, true).setProperties(props);
+ }
+
+ /**
+ * Get a property from a store.
+ * @param store The name of the store.
+ * @param name The property
+ * @return The property value or null if non-existent.
+ */
+ public PropertyValue getStoreProperty(String store, QName name)
+ {
+ return getAVMStoreByName(store, false).getProperty(name);
+ }
+
+ /**
+ * Get all the properties for a store.
+ * @param store The name of the Store.
+ * @return A Map of all the properties.
+ */
+ public Map getStoreProperties(String store)
+ {
+ return getAVMStoreByName(store, false).getProperties();
+ }
+
+ /**
+ * Delete a property from a store.
+ * @param store The name of the store.
+ * @param name The name of the property.
+ */
+ public void deleteStoreProperty(String store, QName name)
+ {
+ getAVMStoreByName(store, true).deleteProperty(name);
}
/**
diff --git a/source/java/org/alfresco/repo/avm/AVMService.java b/source/java/org/alfresco/repo/avm/AVMService.java
index 4d7dea7eae..4d2c6072aa 100644
--- a/source/java/org/alfresco/repo/avm/AVMService.java
+++ b/source/java/org/alfresco/repo/avm/AVMService.java
@@ -317,14 +317,14 @@ public interface AVMService
* @param name The QName of the property.
* @param value The property to set.
*/
- public void setProperty(String path, QName name, PropertyValue value);
+ public void setNodeProperty(String path, QName name, PropertyValue value);
/**
* Set a collection of properties on a node.
* @param path The path to the node.
* @param properties The Map of properties to set.
*/
- public void setProperties(String path, Map properties);
+ public void setNodeProperties(String path, Map properties);
/**
* Get a property of a node by QName.
@@ -333,7 +333,7 @@ public interface AVMService
* @param name The QName.
* @return The PropertyValue or null if it doesn't exist.
*/
- public PropertyValue getProperty(int version, String path, QName name);
+ public PropertyValue getNodeProperty(int version, String path, QName name);
/**
* Get all the properties associated with a node.
@@ -341,12 +341,49 @@ public interface AVMService
* @param path The path to the node.
* @return A Map of QNames to PropertyValues.
*/
- public Map getProperties(int version, String path);
+ public Map getNodeProperties(int version, String path);
/**
* Delete a property.
* @param path The path to the node.
* @param name The QName of the property to delete.
*/
- public void deleteProperty(String path, QName name);
+ public void deleteNodeProperty(String path, QName name);
+
+ /**
+ * Set a property on a store. If the property exists it will be overwritten.
+ * @param store The store to set the property on.
+ * @param name The name of the property.
+ * @param value The value of the property.
+ */
+ public void setStoreProperty(String store, QName name, PropertyValue value);
+
+ /**
+ * Set a group of properties on a store. Existing properties will be overwritten.
+ * @param store The name of the store.
+ * @param props A Map of the properties to set.
+ */
+ public void setStoreProperties(String store, Map props);
+
+ /**
+ * Get a property from a store.
+ * @param store The name of the store.
+ * @param name The name of the property.
+ * @return A PropertyValue or null if non-existent.
+ */
+ public PropertyValue getStoreProperty(String store, QName name);
+
+ /**
+ * Get all the properties associated with a store.
+ * @param store The name of the store.
+ * @return A Map of the stores properties.
+ */
+ public Map getStoreProperties(String store);
+
+ /**
+ * Delete a property on a store by name.
+ * @param store The name of the store.
+ * @param name The name of the property to delete.
+ */
+ public void deleteStoreProperty(String store, QName name);
}
diff --git a/source/java/org/alfresco/repo/avm/AVMServiceImpl.java b/source/java/org/alfresco/repo/avm/AVMServiceImpl.java
index 9692323c7f..ce75e0135f 100644
--- a/source/java/org/alfresco/repo/avm/AVMServiceImpl.java
+++ b/source/java/org/alfresco/repo/avm/AVMServiceImpl.java
@@ -1037,7 +1037,7 @@ public class AVMServiceImpl implements AVMService
* @param name The QName of the property.
* @param value The property to set.
*/
- public void setProperty(final String path, final QName name, final PropertyValue value)
+ public void setNodeProperty(final String path, final QName name, final PropertyValue value)
{
if (path == null || name == null || value == null)
{
@@ -1047,7 +1047,7 @@ public class AVMServiceImpl implements AVMService
{
public void perform()
{
- fAVMRepository.setProperty(path, name, value);
+ fAVMRepository.setNodeProperty(path, name, value);
}
}
TxnCallback doit = new TxnCallback();
@@ -1059,7 +1059,7 @@ public class AVMServiceImpl implements AVMService
* @param path The path to the node.
* @param properties The Map of properties to set.
*/
- public void setProperties(final String path, final Map properties)
+ public void setNodeProperties(final String path, final Map properties)
{
if (path == null || properties == null)
{
@@ -1069,7 +1069,7 @@ public class AVMServiceImpl implements AVMService
{
public void perform()
{
- fAVMRepository.setProperties(path, properties);
+ fAVMRepository.setNodeProperties(path, properties);
}
}
TxnCallback doit = new TxnCallback();
@@ -1083,7 +1083,7 @@ public class AVMServiceImpl implements AVMService
* @param name The QName.
* @return The PropertyValue or null if it doesn't exist.
*/
- public PropertyValue getProperty(final int version, final String path, final QName name)
+ public PropertyValue getNodeProperty(final int version, final String path, final QName name)
{
if (path == null || name == null)
{
@@ -1095,7 +1095,7 @@ public class AVMServiceImpl implements AVMService
public void perform()
{
- value = fAVMRepository.getProperty(version, path, name);
+ value = fAVMRepository.getNodeProperty(version, path, name);
}
}
TxnCallback doit = new TxnCallback();
@@ -1109,7 +1109,7 @@ public class AVMServiceImpl implements AVMService
* @param path The path to the node.
* @return A List of AVMNodeProperties.
*/
- public Map getProperties(final int version, final String path)
+ public Map getNodeProperties(final int version, final String path)
{
if (path == null)
{
@@ -1121,7 +1121,7 @@ public class AVMServiceImpl implements AVMService
public void perform()
{
- properties = fAVMRepository.getProperties(version, path);
+ properties = fAVMRepository.getNodeProperties(version, path);
}
}
TxnCallback doit = new TxnCallback();
@@ -1134,7 +1134,7 @@ public class AVMServiceImpl implements AVMService
* @param path The path to the node.
* @param name The QName of the property to delete.
*/
- public void deleteProperty(final String path, final QName name)
+ public void deleteNodeProperty(final String path, final QName name)
{
if (path == null || name == null)
{
@@ -1144,7 +1144,125 @@ public class AVMServiceImpl implements AVMService
{
public void perform()
{
- fAVMRepository.deleteProperty(path, name);
+ fAVMRepository.deleteNodeProperty(path, name);
+ }
+ }
+ TxnCallback doit = new TxnCallback();
+ fTransaction.perform(doit, true);
+ }
+
+ /**
+ * Set a property on a store. If the property exists it will be overwritten.
+ * @param store The store to set the property on.
+ * @param name The name of the property.
+ * @param value The value of the property.
+ */
+ public void setStoreProperty(final String store, final QName name, final PropertyValue value)
+ {
+ if (store == null || name == null || value == null)
+ {
+ throw new AVMBadArgumentException("Illegal null argument.");
+ }
+ class TxnCallback implements RetryingTransactionCallback
+ {
+ public void perform()
+ {
+ fAVMRepository.setStoreProperty(store, name, value);
+ }
+ }
+ TxnCallback doit = new TxnCallback();
+ fTransaction.perform(doit, true);
+ }
+
+ /**
+ * Set a group of properties on a store. Existing properties will be overwritten.
+ * @param store The name of the store.
+ * @param props A Map of the properties to set.
+ */
+ public void setStoreProperties(final String store, final Map props)
+ {
+ if (store == null || props == null)
+ {
+ throw new AVMBadArgumentException("Illegal null argument.");
+ }
+ class TxnCallback implements RetryingTransactionCallback
+ {
+ public void perform()
+ {
+ fAVMRepository.setStoreProperties(store, props);
+ }
+ }
+ TxnCallback doit = new TxnCallback();
+ fTransaction.perform(doit, true);
+ }
+
+ /**
+ * Get a property from a store.
+ * @param store The name of the store.
+ * @param name The name of the property.
+ * @return A PropertyValue or null if non-existent.
+ */
+ public PropertyValue getStoreProperty(final String store, final QName name)
+ {
+ if (store == null || name == null)
+ {
+ throw new AVMBadArgumentException("Illegal null argument.");
+ }
+ class TxnCallback implements RetryingTransactionCallback
+ {
+ public PropertyValue value;
+
+ public void perform()
+ {
+ value = fAVMRepository.getStoreProperty(store, name);
+ }
+ }
+ TxnCallback doit = new TxnCallback();
+ fTransaction.perform(doit, false);
+ return doit.value;
+ }
+
+ /**
+ * Get all the properties associated with a store.
+ * @param store The name of the store.
+ * @return A Map of the stores properties.
+ */
+ public Map getStoreProperties(final String store)
+ {
+ if (store == null)
+ {
+ throw new AVMBadArgumentException("Null store name.");
+ }
+ class TxnCallback implements RetryingTransactionCallback
+ {
+ public Map props;
+
+ public void perform()
+ {
+ props = fAVMRepository.getStoreProperties(store);
+ }
+ }
+ TxnCallback doit = new TxnCallback();
+ fTransaction.perform(doit, false);
+ return doit.props;
+ }
+
+ /**
+ * Delete a property on a store by name.
+ * @param store The name of the store.
+ * @param name The name of the property to delete.
+ */
+ public void deleteStoreProperty(final String store, final QName name)
+ {
+ if (store == null || name == null)
+ {
+ throw new AVMBadArgumentException("Invalid null argument.");
+ }
+ class TxnCallback implements RetryingTransactionCallback
+ {
+ public void perform()
+ {
+ fAVMRepository.deleteStoreProperty(store, name);
}
}
TxnCallback doit = new TxnCallback();
diff --git a/source/java/org/alfresco/repo/avm/AVMServiceTest.java b/source/java/org/alfresco/repo/avm/AVMServiceTest.java
index 24b55f6203..60d270d02e 100644
--- a/source/java/org/alfresco/repo/avm/AVMServiceTest.java
+++ b/source/java/org/alfresco/repo/avm/AVMServiceTest.java
@@ -2032,11 +2032,11 @@ public class AVMServiceTest extends AVMServiceTestBase
setupBasicTree();
QName name = QName.createQName("silly.uri", "SillyProperty");
PropertyValue value = new PropertyValue(name, "Silly Property Value");
- fService.setProperty("main:/a/b/c/foo", name, value);
+ fService.setNodeProperty("main:/a/b/c/foo", name, value);
fService.createSnapshot("main");
- PropertyValue returned = fService.getProperty(-1, "main:/a/b/c/foo", name);
+ PropertyValue returned = fService.getNodeProperty(-1, "main:/a/b/c/foo", name);
assertEquals(value.toString(), returned.toString());
- Map props = fService.getProperties(-1, "main:/a/b/c/foo");
+ Map props = fService.getNodeProperties(-1, "main:/a/b/c/foo");
assertEquals(1, props.size());
assertEquals(value.toString(), props.get(name).toString());
props = new HashMap();
@@ -2049,16 +2049,16 @@ public class AVMServiceTest extends AVMServiceTestBase
QName n3 = QName.createQName("silly.uri", "Prop3");
PropertyValue p3 = new PropertyValue(null, 42);
props.put(n3, p3);
- fService.setProperties("main:/a/b/c/bar", props);
+ fService.setNodeProperties("main:/a/b/c/bar", props);
fService.createSnapshot("main");
- props = fService.getProperties(-1, "main:/a/b/c/bar");
+ props = fService.getNodeProperties(-1, "main:/a/b/c/bar");
assertEquals(3, props.size());
assertEquals(p1.toString(), props.get(n1).toString());
assertEquals(p2.toString(), props.get(n2).toString());
assertEquals(p3.toString(), props.get(n3).toString());
- fService.deleteProperty("main:/a/b/c/bar", n1);
+ fService.deleteNodeProperty("main:/a/b/c/bar", n1);
fService.createSnapshot("main");
- props = fService.getProperties(-1, "main:/a/b/c/bar");
+ props = fService.getNodeProperties(-1, "main:/a/b/c/bar");
assertEquals(2, props.size());
assertEquals(p2.toString(), props.get(n2).toString());
assertEquals(p3.toString(), props.get(n3).toString());
@@ -2068,4 +2068,43 @@ public class AVMServiceTest extends AVMServiceTestBase
e.printStackTrace(System.err);
}
}
+
+ /**
+ * Test properties on stores.
+ */
+ public void testStoreProperties()
+ {
+ try
+ {
+ QName name = QName.createQName("silly.uri", "SillyProperty");
+ PropertyValue value = new PropertyValue(name, "Silly Property Value");
+ fService.setStoreProperty("main", name, value);
+ PropertyValue found = fService.getStoreProperty("main", name);
+ assertEquals(value.toString(), found.toString());
+ Map props = new HashMap();
+ QName n1 = QName.createQName("silly.uri", "Prop1");
+ PropertyValue p1 = new PropertyValue(null, new Date(System.currentTimeMillis()));
+ props.put(n1, p1);
+ QName n2 = QName.createQName("silly.uri", "Prop2");
+ PropertyValue p2 = new PropertyValue(null, "A String Property.");
+ props.put(n2, p2);
+ QName n3 = QName.createQName("silly.uri", "Prop3");
+ PropertyValue p3 = new PropertyValue(null, 42);
+ props.put(n3, p3);
+ fService.setStoreProperties("main", props);
+ props = fService.getStoreProperties("main");
+ assertEquals(4, props.size());
+ assertEquals(p1.toString(), props.get(n1).toString());
+ assertEquals(p2.toString(), props.get(n2).toString());
+ assertEquals(p3.toString(), props.get(n3).toString());
+ fService.deleteStoreProperty("main", name);
+ props = fService.getStoreProperties("main");
+ assertEquals(3, props.size());
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.err);
+ fail();
+ }
+ }
}
diff --git a/source/java/org/alfresco/repo/avm/AVMStore.java b/source/java/org/alfresco/repo/avm/AVMStore.java
index 0c0e6bef76..8dc2cafb41 100644
--- a/source/java/org/alfresco/repo/avm/AVMStore.java
+++ b/source/java/org/alfresco/repo/avm/AVMStore.java
@@ -274,14 +274,14 @@ public interface AVMStore
* @param name The name of the property.
* @param value The value to set.
*/
- public void setProperty(String path, QName name, PropertyValue value);
+ public void setNodeProperty(String path, QName name, PropertyValue value);
/**
* Set a collection of properties on a node.
* @param path The path to the node.
* @param properties The Map of QNames to PropertyValues.
*/
- public void setProperties(String path, Map properties);
+ public void setNodeProperties(String path, Map properties);
/**
* Get a property by name.
@@ -290,14 +290,14 @@ public interface AVMStore
* @param name The name of the property.
* @return A PropertyValue or null if not found.
*/
- public PropertyValue getProperty(int version, String path, QName name);
+ public PropertyValue getNodeProperty(int version, String path, QName name);
/**
* Delete a single property from a node.
* @param path The path to the node.
* @param name The name of the property.
*/
- public void deleteProperty(String path, QName name);
+ public void deleteNodeProperty(String path, QName name);
/**
* Get all the properties associated with a node.
@@ -305,5 +305,37 @@ public interface AVMStore
* @param path The path to the node.
* @return A Map of QNames to PropertyValues.
*/
- public Map getProperties(int version, String path);
+ public Map getNodeProperties(int version, String path);
+
+ /**
+ * Set a property on this store. Replaces if property already exists.
+ * @param name The QName of the property.
+ * @param value The actual PropertyValue.
+ */
+ public void setProperty(QName name, PropertyValue value);
+
+ /**
+ * Set a group of properties on this store. Replaces any property that exists.
+ * @param properties A Map of QNames to PropertyValues to set.
+ */
+ public void setProperties(Map properties);
+
+ /**
+ * Get a property by name.
+ * @param name The QName of the property to fetch.
+ * @return The PropertyValue or null if non-existent.
+ */
+ public PropertyValue getProperty(QName name);
+
+ /**
+ * Get all the properties associated with this node.
+ * @return A Map of the properties.
+ */
+ public Map getProperties();
+
+ /**
+ * Delete a property.
+ * @param name The name of the property to delete.
+ */
+ public void deleteProperty(QName name);
}
\ No newline at end of file
diff --git a/source/java/org/alfresco/repo/avm/AVMStoreImpl.java b/source/java/org/alfresco/repo/avm/AVMStoreImpl.java
index ed65fc2ba9..c1892ba9b0 100644
--- a/source/java/org/alfresco/repo/avm/AVMStoreImpl.java
+++ b/source/java/org/alfresco/repo/avm/AVMStoreImpl.java
@@ -24,6 +24,7 @@ import java.io.RandomAccessFile;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
@@ -833,7 +834,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
* @param name The name of the property.
* @param value The value to set.
*/
- public void setProperty(String path, QName name, PropertyValue value)
+ public void setNodeProperty(String path, QName name, PropertyValue value)
{
Lookup lPath = lookup(-1, path, true);
AVMNode node = lPath.getCurrentNode();
@@ -845,7 +846,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
* @param path The path to the node.
* @param properties The Map of QNames to PropertyValues.
*/
- public void setProperties(String path, Map properties)
+ public void setNodeProperties(String path, Map properties)
{
Lookup lPath = lookup(-1, path, true);
AVMNode node = lPath.getCurrentNode();
@@ -859,7 +860,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
* @param name The name of the property.
* @return A PropertyValue or null if not found.
*/
- public PropertyValue getProperty(int version, String path, QName name)
+ public PropertyValue getNodeProperty(int version, String path, QName name)
{
Lookup lPath = lookup(version, path, false);
AVMNode node = lPath.getCurrentNode();
@@ -872,7 +873,7 @@ public class AVMStoreImpl implements AVMStore, Serializable
* @param path The path to the node.
* @return A Map of QNames to PropertyValues.
*/
- public Map getProperties(int version, String path)
+ public Map getNodeProperties(int version, String path)
{
Lookup lPath = lookup(version, path, false);
AVMNode node = lPath.getCurrentNode();
@@ -884,10 +885,71 @@ public class AVMStoreImpl implements AVMStore, Serializable
* @param path The path to the node.
* @param name The name of the property.
*/
- public void deleteProperty(String path, QName name)
+ public void deleteNodeProperty(String path, QName name)
{
Lookup lPath = lookup(-1, path, true);
AVMNode node = lPath.getCurrentNode();
node.deleteProperty(name);
}
+
+ /**
+ * Set a property on this store. Replaces if property already exists.
+ * @param name The QName of the property.
+ * @param value The actual PropertyValue.
+ */
+ public void setProperty(QName name, PropertyValue value)
+ {
+ AVMStoreProperty prop = new AVMStorePropertyImpl();
+ prop.setStore(this);
+ prop.setName(name);
+ prop.setValue(value);
+ AVMContext.fgInstance.fAVMStorePropertyDAO.save(prop);
+ }
+
+ /**
+ * Set a group of properties on this store. Replaces any property that exists.
+ * @param properties A Map of QNames to PropertyValues to set.
+ */
+ public void setProperties(Map properties)
+ {
+ for (QName name : properties.keySet())
+ {
+ setProperty(name, properties.get(name));
+ }
+ }
+
+ /**
+ * Get a property by name.
+ * @param name The QName of the property to fetch.
+ * @return The PropertyValue or null if non-existent.
+ */
+ public PropertyValue getProperty(QName name)
+ {
+ return AVMContext.fgInstance.fAVMStorePropertyDAO.get(this, name).getValue();
+ }
+
+ /**
+ * Get all the properties associated with this node.
+ * @return A Map of the properties.
+ */
+ public Map getProperties()
+ {
+ List props =
+ AVMContext.fgInstance.fAVMStorePropertyDAO.get(this);
+ Map retVal = new HashMap();
+ for (AVMStoreProperty prop : props)
+ {
+ retVal.put(prop.getName(), prop.getValue());
+ }
+ return retVal;
+ }
+
+ /**
+ * Delete a property.
+ * @param name The name of the property to delete.
+ */
+ public void deleteProperty(QName name)
+ {
+ AVMContext.fgInstance.fAVMStorePropertyDAO.delete(this, name);
+ }
}
diff --git a/source/java/org/alfresco/repo/avm/AVMStoreProperty.java b/source/java/org/alfresco/repo/avm/AVMStoreProperty.java
new file mode 100644
index 0000000000..7e437a1be6
--- /dev/null
+++ b/source/java/org/alfresco/repo/avm/AVMStoreProperty.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2006 Alfresco, Inc.
+ *
+ * Licensed under the Mozilla Public License version 1.1
+ * with a permitted attribution clause. You may obtain a
+ * copy of the License at
+ *
+ * http://www.alfresco.org/legal/license.txt
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ */
+
+package org.alfresco.repo.avm;
+
+import org.alfresco.repo.domain.PropertyValue;
+import org.alfresco.service.namespace.QName;
+
+/**
+ * Arbitrary properties associated with AVMStores.
+ * @author britt
+ */
+public interface AVMStoreProperty
+{
+ /**
+ * Set the AVMStore.
+ * @param store The AVMStore to set.
+ */
+ public void setStore(AVMStore store);
+
+ /**
+ * Get the AVMStore.
+ * @return The AVMStore this property belongs to.
+ */
+ public AVMStore getStore();
+
+ /**
+ * Set the name of the property.
+ * @param name The QName for the property.
+ */
+ public void setName(QName name);
+
+ /**
+ * Get the name of this property.
+ * @return The QName of this property.
+ */
+ public QName getName();
+
+ /**
+ * Set the actual property value.
+ * @param value The PropertyValue to set.
+ */
+ public void setValue(PropertyValue value);
+
+ /**
+ * Get the actual property value.
+ * @return The actual PropertyValue.
+ */
+ public PropertyValue getValue();
+}
diff --git a/source/java/org/alfresco/repo/avm/AVMStorePropertyDAO.java b/source/java/org/alfresco/repo/avm/AVMStorePropertyDAO.java
new file mode 100644
index 0000000000..0b3acd9715
--- /dev/null
+++ b/source/java/org/alfresco/repo/avm/AVMStorePropertyDAO.java
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 2006 Alfresco, Inc.
+ *
+ * Licensed under the Mozilla Public License version 1.1
+ * with a permitted attribution clause. You may obtain a
+ * copy of the License at
+ *
+ * http://www.alfresco.org/legal/license.txt
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ */
+
+package org.alfresco.repo.avm;
+
+import java.util.List;
+
+import org.alfresco.service.namespace.QName;
+
+/**
+ * The DAO interface for AVMStoreProperties.
+ * @author britt
+ */
+public interface AVMStorePropertyDAO
+{
+ /**
+ * Persist a property.
+ * @param prop The AVMStoreProperty to persist.
+ */
+ public void save(AVMStoreProperty prop);
+
+ /**
+ * Get a property by store and name.
+ * @param store The AVMStore.
+ * @param name The QName of the property.
+ * @return The given AVMStoreProperty or null if not found.
+ */
+ public AVMStoreProperty get(AVMStore store, QName name);
+
+ /**
+ * Get all the properties associated with a store.
+ * @param store The AVMStore whose properties should be fetched.
+ * @return A List of properties associated with the store.
+ */
+ public List get(AVMStore store);
+
+ /**
+ * Update a modified property.
+ * @param prop The AVMStoreProperty to update.
+ */
+ public void update(AVMStoreProperty prop);
+
+ /**
+ * Delete a property from a store by name.
+ * @param store The AVMStore to delete from.
+ * @param name The name of the property.
+ */
+ public void delete(AVMStore store, QName name);
+
+ /**
+ * Delete all properties associated with a store.
+ * @param store The AVMStore whose properties are to be deleted.
+ */
+ public void delete(AVMStore store);
+}
diff --git a/source/java/org/alfresco/repo/avm/AVMStorePropertyImpl.java b/source/java/org/alfresco/repo/avm/AVMStorePropertyImpl.java
new file mode 100644
index 0000000000..fe6ea8c7d0
--- /dev/null
+++ b/source/java/org/alfresco/repo/avm/AVMStorePropertyImpl.java
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2006 Alfresco, Inc.
+ *
+ * Licensed under the Mozilla Public License version 1.1
+ * with a permitted attribution clause. You may obtain a
+ * copy of the License at
+ *
+ * http://www.alfresco.org/legal/license.txt
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+ * either express or implied. See the License for the specific
+ * language governing permissions and limitations under the
+ * License.
+ */
+
+package org.alfresco.repo.avm;
+
+import java.io.Serializable;
+
+import org.alfresco.repo.domain.PropertyValue;
+import org.alfresco.service.namespace.QName;
+
+/**
+ * Simple bean to hold properties attached to AVMStores.
+ * @author britt
+ */
+public class AVMStorePropertyImpl implements AVMStoreProperty, Serializable
+{
+ private static final long serialVersionUID = -5419606158990318723L;
+
+ /**
+ * The store that owns this property.
+ */
+ private AVMStore fStore;
+
+ /**
+ * The name of the property.
+ */
+ private QName fName;
+
+ /**
+ * The actual PropertyValue.
+ */
+ private PropertyValue fValue;
+
+ public AVMStorePropertyImpl()
+ {
+ }
+
+ /**
+ * Get the name of the property.
+ * @return The QName for the property.
+ */
+ public QName getName()
+ {
+ return fName;
+ }
+
+ /**
+ * Set the name of the property.
+ * @param name The QName of the property.
+ */
+ public void setName(QName name)
+ {
+ fName = name;
+ }
+
+ /**
+ * Get the store this property belongs to.
+ * @return The AVMStore that owns this.
+ */
+ public AVMStore getStore()
+ {
+ return fStore;
+ }
+
+ /**
+ * Set the store that this property belongs to.
+ * @param store The AVMStore.
+ */
+ public void setStore(AVMStore store)
+ {
+ fStore = store;
+ }
+
+ /**
+ * Get the actual property value.
+ * @return A PropertyValue object.
+ */
+ public PropertyValue getValue()
+ {
+ return fValue;
+ }
+
+ /**
+ * Set the actual property value.
+ * @param value The PropertyValue to set.
+ */
+ public void setValue(PropertyValue value)
+ {
+ fValue = value;
+ }
+}
+
diff --git a/source/java/org/alfresco/repo/avm/hibernate/AVM.hbm.xml b/source/java/org/alfresco/repo/avm/hibernate/AVM.hbm.xml
index f6fda12fd3..462b7e64da 100644
--- a/source/java/org/alfresco/repo/avm/hibernate/AVM.hbm.xml
+++ b/source/java/org/alfresco/repo/avm/hibernate/AVM.hbm.xml
@@ -197,6 +197,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
get(AVMStore store)
+ {
+ Query query =
+ getSession().createQuery("from AVMStorePropertyImpl asp where asp.store = :store");
+ query.setEntity("store", store);
+ return (List)query.list();
+ }
+
+ /**
+ * Update a modified property.
+ * @param prop The AVMStoreProperty to update.
+ */
+ public void update(AVMStoreProperty prop)
+ {
+ // This is a no op for hibernate.
+ }
+
+ /**
+ * Delete a property from a store by name.
+ * @param store The AVMStore to delete from.
+ * @param name The name of the property.
+ */
+ public void delete(AVMStore store, QName name)
+ {
+ Query delete =
+ getSession().createQuery("delete from AVMStorePropertyImpl asp " +
+ "where asp.store = :store and asp.name = :name");
+ delete.setEntity("store", store);
+ delete.setParameter("name", name);
+ delete.executeUpdate();
+ }
+
+ /**
+ * Delete all properties associated with a store.
+ * @param store The AVMStore whose properties are to be deleted.
+ */
+ public void delete(AVMStore store)
+ {
+ Query delete =
+ getSession().createQuery("delete from AVMStorePropertyImpl asp where asp.store = :store");
+ delete.setEntity("store", store);
+ delete.executeUpdate();
+ }
+}