public Element toXml(Document document) { return NodeTypeUtil.ntNameToXml(ntName, document); } });
public static Collection<String> ntNamesFromXml(Object propValue) { // assume property has be built from xml if (propValue instanceof List) { return retrieveNodeTypeNames(((List<?>)propValue)); } else if (propValue instanceof Element) { List<Element> l = Collections.singletonList((Element) propValue); return retrieveNodeTypeNames(l); } else { // Property value cannot be parsed into node type names. return Collections.emptySet(); } }
public Element toXml(Document document) { try { return ValueUtil.valueToXml(jcrValue, document); } catch (RepositoryException e) { throw new RuntimeException(e); } } });
jcrValues = new Value[0]; } else { /* not null propValue */ if (isValueElement(propValue)) { valueElements.add((Element) propValue); } else if (propValue instanceof List) { if (isValueElement(el)) { valueElements.add((Element) el); int i = 0; for (Element element : valueElements) { jcrValues[i] = getJcrValue(element, defaultType, valueFactory); i++;
public static void parseResultPropertyValue(Object propValue, List<String> columnNames, List<String> selectorNames, List<Value> values, ValueFactory valueFactory) throws ValueFormatException, RepositoryException { if (propValue instanceof List) { for (Object o : ((List<?>) propValue)) { if (o instanceof Element) { parseColumnElement((Element) o, columnNames, selectorNames, values, valueFactory); } } } else if (propValue instanceof Element) { parseColumnElement((Element) propValue, columnNames, selectorNames, values, valueFactory); } else { throw new IllegalArgumentException("SearchResultProperty requires a list of 'dcr:column' xml elements."); } }
@Override public void addProperty(NodeId parentId, Name propertyName, QValue value) throws RepositoryException { checkConsumed(); String uri = getItemUri(parentId, propertyName, sessionInfo); HttpPut request = new HttpPut(uri); request.setHeader(HEADER_CONTENT_TYPE, JcrValueType.contentTypeFromType(value.getType())); request.setEntity(getEntity(value)); requests.add(request); }
/** * Create a new <code>NodeTypeProperty</code> from the specified general * DavProperty object. * * @param property */ public NodeTypeProperty(DavProperty<?> property) { super(property.getName(), property.isInvisibleInAllprop()); if (property instanceof NodeTypeProperty) { nodetypeNames.addAll(((NodeTypeProperty) property).nodetypeNames); } else { nodetypeNames.addAll(NodeTypeUtil.ntNamesFromXml(property.getValue())); } }
/** * Wrap the specified <code>DavProperty</code> in a new <code>ValuesProperty</code>. * * @param property * @param defaultType default type of the values to be deserialized. If however * the {@link #XML_VALUE 'value'} elements provide a {@link #ATTR_VALUE_TYPE 'type'} * attribute, the default value is ignored. * @param valueFactory Factory used to retrieve JCR values from the value * of the given <code>DavProperty</code>. */ public ValuesProperty(DavProperty<?> property, int defaultType, ValueFactory valueFactory) throws RepositoryException, DavException { super(property.getName(), false); if (!(JCR_VALUES.equals(property.getName()) || JCR_VALUE.equals(getName()))) { throw new DavException(DavServletResponse.SC_BAD_REQUEST, "ValuesProperty may only be created with a property that has name="+JCR_VALUES.getName()); } jcrValues = ValueUtil.valuesFromXml(property.getValue(), defaultType, valueFactory); }
/** * Static utility method to convert the type defined by a * {@link javax.jcr.observation.Event JCR event} into an <code>EventType</code> * object. * * @param jcrEventType * @return <code>EventType</code> representation of the given JCR event type. * @throws IllegalArgumentException if the given int does not represent a * valid type constants as defined by {@link Event}.<br> * Valid values are * <ul> * <li>{@link Event#NODE_ADDED}</li> * <li>{@link Event#NODE_REMOVED}</li> * <li>{@link Event#PROPERTY_ADDED}</li> * <li>{@link Event#PROPERTY_REMOVED}</li> * <li>{@link Event#PROPERTY_CHANGED}</li> * <li>{@link Event#NODE_MOVED}</li> * <li>{@link Event#PERSIST}</li> * </ul> */ public static EventType getEventType(int jcrEventType) { String localName = EventUtil.getEventName(jcrEventType); return DefaultEventType.create(localName, NAMESPACE); }
jcrValues = new Value[0]; } else { /* not null propValue */ if (isValueElement(propValue)) { valueElements.add((Element) propValue); } else if (propValue instanceof List) { if (isValueElement(el)) { valueElements.add((Element) el); int i = 0; for (Element element : valueElements) { jcrValues[i] = getJcrValue(element, defaultType, valueFactory); i++;
public Element toXml(Document document) { return NodeTypeUtil.ntNameToXml(ntName, document); } });
public static Collection<String> ntNamesFromXml(Object propValue) { // assume property has be built from xml if (propValue instanceof List) { return retrieveNodeTypeNames(((List<?>)propValue)); } else if (propValue instanceof Element) { List<Element> l = Collections.singletonList((Element) propValue); return retrieveNodeTypeNames(l); } else { // Property value cannot be parsed into node type names. return Collections.emptySet(); } }
public static void parseResultPropertyValue(Object propValue, List<String> columnNames, List<String> selectorNames, List<Value> values, ValueFactory valueFactory) throws ValueFormatException, RepositoryException { if (propValue instanceof List) { for (Object o : ((List<?>) propValue)) { if (o instanceof Element) { parseColumnElement((Element) o, columnNames, selectorNames, values, valueFactory); } } } else if (propValue instanceof Element) { parseColumnElement((Element) propValue, columnNames, selectorNames, values, valueFactory); } else { throw new IllegalArgumentException("SearchResultProperty requires a list of 'dcr:column' xml elements."); } }
@Override public void addProperty(NodeId parentId, Name propertyName, QValue value) throws RepositoryException { checkConsumed(); String uri = getItemUri(parentId, propertyName, sessionInfo); HttpPut request = new HttpPut(uri); request.setHeader(HEADER_CONTENT_TYPE, JcrValueType.contentTypeFromType(value.getType())); request.setEntity(getEntity(value)); requests.add(request); }
public Element toXml(Document document) { try { return ValueUtil.valueToXml(jcrValue, document); } catch (RepositoryException e) { throw new RuntimeException(e); } } });
jcrValues = new Value[0]; } else { /* not null propValue */ if (isValueElement(propValue)) { valueElements.add((Element) propValue); } else if (propValue instanceof List) { if (isValueElement(el)) { valueElements.add((Element) el); int i = 0; for (Element element : valueElements) { jcrValues[i] = getJcrValue(element, defaultType, valueFactory); i++;
/** * @see org.apache.jackrabbit.webdav.xml.XmlSerializable#toXml(Document) */ @Override public Element toXml(Document document) { Element elem = getName().toXml(document); for (String name : getNodeTypeNames()) { elem.appendChild(NodeTypeUtil.ntNameToXml(name, document)); } return elem; } }
public static Collection<String> ntNamesFromXml(Object propValue) { // assume property has be built from xml if (propValue instanceof List) { return retrieveNodeTypeNames(((List<?>)propValue)); } else if (propValue instanceof Element) { List<Element> l = Collections.singletonList((Element) propValue); return retrieveNodeTypeNames(l); } else { // Property value cannot be parsed into node type names. return Collections.emptySet(); } }
public static void parseResultPropertyValue(Object propValue, List<String> columnNames, List<String> selectorNames, List<Value> values, ValueFactory valueFactory) throws ValueFormatException, RepositoryException { if (propValue instanceof List) { for (Object o : ((List<?>) propValue)) { if (o instanceof Element) { parseColumnElement((Element) o, columnNames, selectorNames, values, valueFactory); } } } else if (propValue instanceof Element) { parseColumnElement((Element) propValue, columnNames, selectorNames, values, valueFactory); } else { throw new IllegalArgumentException("SearchResultProperty requires a list of 'dcr:column' xml elements."); } }
@Override public void setValue(PropertyId propertyId, QValue value) throws RepositoryException { checkConsumed(); if (value == null) { // setting property value to 'null' is identical to a removal remove(propertyId); } else { HttpEntity ent = getEntity(value); String uri = getItemUri(propertyId, sessionInfo); // TODO: use PUT in order to avoid the ValuesProperty-PROPPATCH call. // TODO: actually not quite correct for PROPPATCH assert that prop really exists. HttpPut request = new HttpPut(uri); request.setHeader(HEADER_CONTENT_TYPE, JcrValueType.contentTypeFromType(value.getType())); request.setEntity(ent); requests.add(request); } }