/** * Formats the given jcr property to the enhanced docview syntax. * @param prop the jcr property * @return the formatted string * @throws RepositoryException if a repository error occurs */ public static String format(Property prop) throws RepositoryException { return format(prop, false, false); }
/** * Sort weak reference values alphabetically to ensure consistent ordering. * @param name Property name * @param value Property value * @return Property value with sorted references */ private String sortWeakReferenceValues(String name, String value) { Set<String> refs = new TreeSet<>(); DocViewProperty prop = DocViewProperty.parse(name, value); for (int i = 0; i < prop.values.length; i++) { refs.add(prop.values[i]); } List<Value> values = new ArrayList<>(); for (String ref : refs) { values.add(new MockValue(ref, PropertyType.WEAKREFERENCE)); } try { String sortedValues = DocViewProperty.format(new MockProperty(name, true, values.toArray(new Value[values.size()]))); return sortedValues; } catch (RepositoryException ex) { throw new RuntimeException("Unable to format value for " + name, ex); } }
private String filterMixinsPropertyValue(String value, Set<String> namespacePrefixesActuallyUsed) { if (this.excludeMixins.length == 0 || StringUtils.isBlank(value)) { return value; } DocViewProperty prop = DocViewProperty.parse(MIXINS_PROPERTY, value); List<Value> mixins = new ArrayList<>(); for (int i = 0; i < prop.values.length; i++) { String mixin = prop.values[i]; if (!exclude(mixin, this.excludeMixins)) { String namespacePrefix = StringUtils.substringBefore(mixin, ":"); collectNamespacePrefix(namespacePrefixesActuallyUsed, namespacePrefix); mixins.add(new MockValue(mixin, PropertyType.STRING)); } } if (mixins.isEmpty()) { return null; } try { return DocViewProperty.format(new MockProperty(MIXINS_PROPERTY, true, mixins.toArray(new Value[mixins.size()]))); } catch (RepositoryException ex) { throw new RuntimeException("Unable to format value for " + MIXINS_PROPERTY, ex); } }
return DocViewProperty.format(prop);
boolean sort = qName.equals(NameConstants.JCR_MIXINTYPES); attrs.addAttribute(qName.getNamespaceURI(), qName.getLocalName(), attrName, CDATA_TYPE, DocViewProperty.format(prop, sort, useBinaryReferences));