From a0c5ef0d3f8c263780c919787f1a62a124b552a8 Mon Sep 17 00:00:00 2001 From: Bruno Sinou Date: Tue, 6 Sep 2011 10:14:57 +0000 Subject: [PATCH] Add a command to get node property type as cnd like string git-svn-id: https://svn.argeo.org/commons/trunk@4727 4cfe0d0a-d680-48aa-b62c-e0a02a3f76cc --- .../src/main/java/org/argeo/jcr/JcrUtils.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/JcrUtils.java b/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/JcrUtils.java index 19a3f7703..f62196caf 100644 --- a/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/JcrUtils.java +++ b/server/runtime/org.argeo.server.jcr/src/main/java/org/argeo/jcr/JcrUtils.java @@ -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 Node type + * Notation 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(); + } } -- 2.39.2