]> git.argeo.org Git - lgpl/argeo-commons.git/commitdiff
Add a command to get node property type as cnd like string
authorBruno Sinou <bsinou@argeo.org>
Tue, 6 Sep 2011 10:14:57 +0000 (10:14 +0000)
committerBruno Sinou <bsinou@argeo.org>
Tue, 6 Sep 2011 10:14:57 +0000 (10:14 +0000)
git-svn-id: https://svn.argeo.org/commons/trunk@4727 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc

server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/JcrUtils.java

index 19a3f7703b8677b3584324d26e3cec5a28940745..f62196cafe3663de56e1e2ce544832c02ad40fce 100644 (file)
@@ -941,4 +941,31 @@ public class JcrUtils implements ArgeoJcrConstants {
                        throw new ArgeoException("Cannot update last modified", e);
                }
        }
+
+       /**
+        * Returns a String representing the short version (see <a
+        * href="http://jackrabbit.apache.org/node-type-notation.html"> Node type
+        * Notation </a> attributes grammar) of the main business attributes of this
+        * property definition
+        * 
+        * @param prop
+        */
+       public static String getPropertyDefinitionAsString(Property prop) {
+               StringBuffer sbuf = new StringBuffer();
+               try {
+                       if (prop.getDefinition().isAutoCreated())
+                               sbuf.append("a");
+                       if (prop.getDefinition().isMandatory())
+                               sbuf.append("m");
+                       if (prop.getDefinition().isProtected())
+                               sbuf.append("p");
+                       if (prop.getDefinition().isMultiple())
+                               sbuf.append("*");
+               } catch (RepositoryException re) {
+                       throw new ArgeoException(
+                                       "unexpected error while getting property definition as String",
+                                       re);
+               }
+               return sbuf.toString();
+       }
 }