*
* @throws PreconditionViolationException
*/
public void init(String resourcePath, Element principalPropertySearchElm) throws PreconditionViolationException {
if (principalPropertySearchElm.getChildren().size() == 0) {
throw new PreconditionViolationException(
new ViolatedPrecondition("at-least-one-child-element",
WebdavStatus.SC_BAD_REQUEST,
"DAV:principal-property-search element must have at least one child"),
resourcePath
);
}
List propertySearchElmL = principalPropertySearchElm.getChildren(E_PROPERTY_SEARCH, DNSP);
if (propertySearchElmL.size() == 0) {
throw new PreconditionViolationException(
new ViolatedPrecondition("at-least-one-property-search-element",
WebdavStatus.SC_BAD_REQUEST,
"DAV:principal-property-search element must contain at least one DAV:property-search element"),
resourcePath
);
}
Iterator ps = propertySearchElmL.iterator();
this.conditionList = new ArrayList();
while (ps.hasNext()) {
Element propertySearchElm = (Element)ps.next();
Element matchElm = propertySearchElm.getChild(E_MATCH, DNSP);
if (matchElm == null) {
continue;
}
Element propElm = propertySearchElm.getChild(E_PROP, DNSP);
Iterator pElms = propElm.getChildren().iterator();
while (pElms.hasNext()) {
Element pElm = (Element)pElms.next();
Element newpropElm = new Element(E_PROP, DNSP);
newpropElm.addContent(new Element(pElm.getName(), pElm.getNamespace()));
Element propcontainsElm = new Element("propcontains", Namespace.getNamespace("http://jakarta.apache.org/slide/"));
Element literalElm = new Element(Literals.LITERAL, DNSP);
literalElm.addContent(matchElm.getTextTrim());
propcontainsElm.addContent(newpropElm);
propcontainsElm.addContent(literalElm);
conditionList.add(propcontainsElm);
}
}
List propElmL = principalPropertySearchElm.getChildren(E_PROP, DNSP);
if (propElmL.size() > 1) {
throw new PreconditionViolationException(
new ViolatedPrecondition("at-most-one-prop-element",
WebdavStatus.SC_BAD_REQUEST,
"DAV:principal-property-search element must have at most one DAV:prop child"),
resourcePath
);
}
if (propElmL.size() == 1) {
Element propElm = (Element)propElmL.get(0);
try {
this.requestedProperties = new RequestedPropertiesImpl(propElm);
}
catch (PropertyParseException e) {
throw new PreconditionViolationException(
new ViolatedPrecondition("invalid-prop",
WebdavStatus.SC_BAD_REQUEST,
e.getMessage()),
resourcePath
);