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++;
lengths = new long[0]; } else { /* not null propValue */ if (isLengthElement(propValue)) { lengthElements.add((Element) propValue); } else if (propValue instanceof List) { if (isLengthElement(el)) { lengthElements.add((Element) el);
public Element toXml(Document document) { try { return ValueUtil.valueToXml(jcrValue, document); } catch (RepositoryException e) { throw new RuntimeException(e); } } });
public void setStream(InputStream in) throws IOException { if (index == NO_INDEX) { init(in, true); } else { // TODO: improve. jcr-server sends XML for multivalued properties try { Document doc = DomUtil.parseDocument(in); Element prop = DomUtil.getChildElement(doc, JcrRemotingConstants.JCR_VALUES_LN, ItemResourceConstants.NAMESPACE); DavProperty<?> p = DefaultDavProperty.createFromXml(prop); Value[] jcrVs = ValueUtil.valuesFromXml(p.getValue(), PropertyType.BINARY, vf); init(jcrVs[index].getStream(), true); } catch (RepositoryException e) { throw new IOException(e.getMessage()); } catch (SAXException e) { throw new IOException(e.getMessage()); } catch (ParserConfigurationException e) { throw new IOException(e.getMessage()); } } } }
if (lengthsProp != null) { long[] lengths = ValueUtil.lengthsFromXml(lengthsProp.getValue()); QValue[] qValues = new QValue[lengths.length]; for (int i = 0 ; i < lengths.length ; i ++) {
public void setStream(InputStream in) throws IOException { if (index == NO_INDEX) { init(in, true); } else { // TODO: improve. jcr-server sends XML for multivalued properties try { Document doc = DomUtil.parseDocument(in); Element prop = DomUtil.getChildElement(doc, JcrRemotingConstants.JCR_VALUES_LN, ItemResourceConstants.NAMESPACE); DavProperty<?> p = DefaultDavProperty.createFromXml(prop); Value[] jcrVs = ValueUtil.valuesFromXml(p.getValue(), PropertyType.BINARY, vf); init(jcrVs[index].getStream(), true); } catch (RepositoryException e) { throw new IOException(e.getMessage()); } catch (SAXException e) { throw new IOException(e.getMessage()); } catch (ParserConfigurationException e) { throw new IOException(e.getMessage()); } } } }
if (lengthsProp != null) { long[] lengths = ValueUtil.lengthsFromXml(lengthsProp.getValue()); QValue[] qValues = new QValue[lengths.length]; for (int i = 0 ; i < lengths.length ; i ++) {
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++;
} else { DavProperty<?> p = DefaultDavProperty.createFromXml(prop); Value[] jcrVs = ValueUtil.valuesFromXml(p.getValue(), PropertyType.STRING, valueFactory); QValue[] qvs = new QValue[jcrVs.length]; int type = (jcrVs.length > 0) ? jcrVs[0].getType() : PropertyType.STRING;
public Element toXml(Document document) { try { return ValueUtil.valueToXml(jcrValue, document); } catch (RepositoryException e) { throw new RuntimeException(e); } } });
lengths = new long[0]; } else { /* not null propValue */ if (isLengthElement(propValue)) { lengthElements.add((Element) propValue); } else if (propValue instanceof List) { if (isLengthElement(el)) { lengthElements.add((Element) el);
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++;
} else { DavProperty<?> p = DefaultDavProperty.createFromXml(prop); Value[] jcrVs = ValueUtil.valuesFromXml(p.getValue(), PropertyType.STRING, valueFactory); QValue[] qvs = new QValue[jcrVs.length]; int type = (jcrVs.length > 0) ? jcrVs[0].getType() : PropertyType.STRING;
/** * * @param document * @return the xml element */ @Override public Element toXml(Document document) { Element elem = getName().toXml(document); try { for (Value v : jcrValues) { Element xmlValue = ValueUtil.valueToXml(v, document); elem.appendChild(xmlValue); } } catch (RepositoryException e) { log.error("Unexpected Error while converting jcr value to String: " + e.getMessage()); } return elem; } }
lengths = new long[0]; } else { /* not null propValue */ if (isLengthElement(propValue)) { lengthElements.add((Element) propValue); } else if (propValue instanceof List) { if (isLengthElement(el)) { lengthElements.add((Element) el);
Value[] jcrValues = ValueUtil.valuesFromXml(prop.getValue(), type, valueFactory); if (jcrValues == null || jcrValues.length == 0) { throw new RepositoryException("Item with id " + id.toString() + " doesn't represent a valid property."); Value[] jcrValues = ValueUtil.valuesFromXml(prop.getValue(), type, valueFactory); values = new QValue[jcrValues.length]; for (int i = 0; i < jcrValues.length; i++) {
Value[] jcrValues = ValueUtil.valuesFromXml(prop.getValue(), type, valueFactory); if (jcrValues == null || jcrValues.length == 0) { throw new RepositoryException("Item with id " + id.toString() + " doesn't represent a valid property."); Value[] jcrValues = ValueUtil.valuesFromXml(prop.getValue(), type, valueFactory); values = new QValue[jcrValues.length]; for (int i = 0; i < jcrValues.length; i++) {
/** * 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); }