diff --git a/config/alfresco/public-services-context.xml b/config/alfresco/public-services-context.xml
index fa3f1ae1da..ae91b11748 100644
--- a/config/alfresco/public-services-context.xml
+++ b/config/alfresco/public-services-context.xml
@@ -904,6 +904,8 @@
getAttributes
query
getKeys
+ exists
+ getCount
diff --git a/source/java/org/alfresco/repo/attributes/AttributeServiceImpl.java b/source/java/org/alfresco/repo/attributes/AttributeServiceImpl.java
index d8cc3ece9b..6e70047654 100644
--- a/source/java/org/alfresco/repo/attributes/AttributeServiceImpl.java
+++ b/source/java/org/alfresco/repo/attributes/AttributeServiceImpl.java
@@ -456,5 +456,73 @@ public class AttributeServiceImpl implements AttributeService
List keys = parsePath(path);
setAttribute(keys, index, value);
}
+
+ /* (non-Javadoc)
+ * @see org.alfresco.service.cmr.attributes.AttributeService#exists(java.util.List)
+ */
+ public boolean exists(List keys)
+ {
+ if (keys == null)
+ {
+ throw new AVMBadArgumentException("Null keys list.");
+ }
+ if (keys.size() == 0)
+ {
+ throw new AVMBadArgumentException("Illegal zero length keys list.");
+ }
+ return getAttributeFromPath(keys) != null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.alfresco.service.cmr.attributes.AttributeService#exists(java.lang.String)
+ */
+ public boolean exists(String path)
+ {
+ if (path == null)
+ {
+ throw new AVMBadArgumentException("Null attribute path.");
+ }
+ List keys = parsePath(path);
+ return exists(keys);
+ }
+
+ /* (non-Javadoc)
+ * @see org.alfresco.service.cmr.attributes.AttributeService#getCount(java.util.List)
+ */
+ public int getCount(List keys)
+ {
+ if (keys == null)
+ {
+ throw new AVMBadArgumentException("Null keys list.");
+ }
+ if (keys.size() == 0)
+ {
+ throw new AVMBadArgumentException("Illegal empty keys list.");
+ }
+ Attribute found = getAttributeFromPath(keys);
+ if (found == null)
+ {
+ throw new AVMNotFoundException("Attribute not found: " + keys);
+ }
+ if (found.getType() != Attribute.Type.LIST &&
+ found.getType() != Attribute.Type.MAP)
+ {
+ throw new AVMWrongTypeException("Not a map or list: " + keys);
+ }
+ return found.size();
+ }
+
+ /* (non-Javadoc)
+ * @see org.alfresco.service.cmr.attributes.AttributeService#getCount(java.lang.String)
+ */
+ public int getCount(String path)
+ {
+ if (path == null)
+ {
+ throw new AVMBadArgumentException("Null attribute path.");
+ }
+ List keys = parsePath(path);
+ return getCount(keys);
+ }
}
diff --git a/source/java/org/alfresco/repo/attributes/AttributeServiceTest.java b/source/java/org/alfresco/repo/attributes/AttributeServiceTest.java
index 7fbd1df2c4..7bcae349be 100644
--- a/source/java/org/alfresco/repo/attributes/AttributeServiceTest.java
+++ b/source/java/org/alfresco/repo/attributes/AttributeServiceTest.java
@@ -294,6 +294,9 @@ public class AttributeServiceTest extends TestCase
list.add(new IntAttributeValue(4));
fService.setAttribute("", "dummy", list);
Attribute found = fService.getAttribute("dummy");
+ assertTrue(fService.exists("dummy"));
+ assertFalse(fService.exists("dimmy"));
+ assertEquals(5, fService.getCount("dummy"));
assertNotNull(found);
assertEquals(5, found.size());
Attribute add = new IntAttributeValue(6);
@@ -315,6 +318,7 @@ public class AttributeServiceTest extends TestCase
list.add(subMap);
fService.setAttribute("", "map", map);
assertEquals("donuts", fService.getAttribute("map/list/5/b").getStringValue());
+ assertEquals(3, fService.getCount("map/list/5"));
}
catch (Exception e)
{
diff --git a/source/java/org/alfresco/repo/attributes/AttributeServiceTransportService.java b/source/java/org/alfresco/repo/attributes/AttributeServiceTransportService.java
index c6b25be44b..6503c0f486 100644
--- a/source/java/org/alfresco/repo/attributes/AttributeServiceTransportService.java
+++ b/source/java/org/alfresco/repo/attributes/AttributeServiceTransportService.java
@@ -207,4 +207,40 @@ public class AttributeServiceTransportService implements
fAuthService.validate(ticket);
fService.setAttribute(keys, index, value);
}
+
+ /* (non-Javadoc)
+ * @see org.alfresco.service.cmr.remote.AttributeServiceTransport#exists(java.lang.String, java.util.List)
+ */
+ public boolean exists(String ticket, List keys)
+ {
+ fAuthService.validate(ticket);
+ return fService.exists(keys);
+ }
+
+ /* (non-Javadoc)
+ * @see org.alfresco.service.cmr.remote.AttributeServiceTransport#exists(java.lang.String, java.lang.String)
+ */
+ public boolean exists(String ticket, String path)
+ {
+ fAuthService.validate(ticket);
+ return fService.exists(path);
+ }
+
+ /* (non-Javadoc)
+ * @see org.alfresco.service.cmr.remote.AttributeServiceTransport#getCount(java.lang.String, java.util.List)
+ */
+ public int getCount(String ticket, List keys)
+ {
+ fAuthService.validate(ticket);
+ return fService.getCount(keys);
+ }
+
+ /* (non-Javadoc)
+ * @see org.alfresco.service.cmr.remote.AttributeServiceTransport#getCount(java.lang.String, java.lang.String)
+ */
+ public int getCount(String ticket, String path)
+ {
+ fAuthService.validate(ticket);
+ return fService.getCount(path);
+ }
}
diff --git a/source/java/org/alfresco/repo/remote/AttributeServiceRemote.java b/source/java/org/alfresco/repo/remote/AttributeServiceRemote.java
index 4c50b9e9b1..1cde15bda2 100644
--- a/source/java/org/alfresco/repo/remote/AttributeServiceRemote.java
+++ b/source/java/org/alfresco/repo/remote/AttributeServiceRemote.java
@@ -185,4 +185,36 @@ public class AttributeServiceRemote implements AttributeService
{
fTransport.setAttribute(fTicketHolder.getTicket(), keys, index, value);
}
+
+ /* (non-Javadoc)
+ * @see org.alfresco.service.cmr.attributes.AttributeService#exists(java.util.List)
+ */
+ public boolean exists(List keys)
+ {
+ return fTransport.exists(fTicketHolder.getTicket(), keys);
+ }
+
+ /* (non-Javadoc)
+ * @see org.alfresco.service.cmr.attributes.AttributeService#exists(java.lang.String)
+ */
+ public boolean exists(String path)
+ {
+ return fTransport.exists(fTicketHolder.getTicket(), path);
+ }
+
+ /* (non-Javadoc)
+ * @see org.alfresco.service.cmr.attributes.AttributeService#getCount(java.util.List)
+ */
+ public int getCount(List keys)
+ {
+ return fTransport.getCount(fTicketHolder.getTicket(), keys);
+ }
+
+ /* (non-Javadoc)
+ * @see org.alfresco.service.cmr.attributes.AttributeService#getCount(java.lang.String)
+ */
+ public int getCount(String path)
+ {
+ return fTransport.getCount(fTicketHolder.getTicket(), path);
+ }
}
diff --git a/source/java/org/alfresco/service/cmr/attributes/AttributeService.java b/source/java/org/alfresco/service/cmr/attributes/AttributeService.java
index 770fe628bc..05bb970727 100644
--- a/source/java/org/alfresco/service/cmr/attributes/AttributeService.java
+++ b/source/java/org/alfresco/service/cmr/attributes/AttributeService.java
@@ -236,4 +236,32 @@ public interface AttributeService
* @return A list of all keys at the specified Attribute location
*/
public List getKeys(List keys);
+
+ /**
+ * Get the size of a map or list.
+ * @param keys List of attribute path keys.
+ * @return The size of of the list or map.
+ */
+ public int getCount(List keys);
+
+ /**
+ * Get the size of a map or list.
+ * @param path The path to the map or list.
+ * @return The size of the list or map.
+ */
+ public int getCount(String path);
+
+ /**
+ * Does an attribute exist.
+ * @param keys List of attribute path keys.
+ * @return Whether the attribute exists.
+ */
+ public boolean exists(List keys);
+
+ /**
+ * Does an attribute exist.
+ * @param path The path to the attribute.
+ * @return Whether the attribute exists.
+ */
+ public boolean exists(String path);
}
diff --git a/source/java/org/alfresco/service/cmr/remote/AttributeServiceTransport.java b/source/java/org/alfresco/service/cmr/remote/AttributeServiceTransport.java
index 71b9259b97..bf319f8330 100644
--- a/source/java/org/alfresco/service/cmr/remote/AttributeServiceTransport.java
+++ b/source/java/org/alfresco/service/cmr/remote/AttributeServiceTransport.java
@@ -170,4 +170,32 @@ public interface AttributeServiceTransport
* @return A list of all keys.
*/
public List getKeys(String ticket, List keys);
+
+ /**
+ * Get the size of a map or list.
+ * @param keys List of attribute path keys.
+ * @return The size of of the list or map.
+ */
+ public int getCount(String ticket, List keys);
+
+ /**
+ * Get the size of a map or list.
+ * @param path The path to the map or list.
+ * @return The size of the list or map.
+ */
+ public int getCount(String ticket, String path);
+
+ /**
+ * Does an attribute exist.
+ * @param keys List of attribute path keys.
+ * @return Whether the attribute exists.
+ */
+ public boolean exists(String ticket, List keys);
+
+ /**
+ * Does an attribute exist.
+ * @param path The path to the attribute.
+ * @return Whether the attribute exists.
+ */
+ public boolean exists(String ticket, String path);
}