throw new DavException(DavServletResponse.SC_LOCKED);
}
if (!exists()) {
throw new DavException(DavServletResponse.SC_NOT_FOUND);
}
MultiStatusResponse msr = new MultiStatusResponse(getHref(), null);
boolean success = true;
// loop over List and remember all properties and propertyNames
// that have successfully been altered
List successList = new ArrayList();
Iterator it = changeList.iterator();
while (it.hasNext()) {
Object propEntry = it.next();
if (propEntry instanceof DavPropertyName) {
DavPropertyName propName = (DavPropertyName)propEntry;
try {
removeJcrProperty(propName);
successList.add(propName);
} catch (RepositoryException e) {
msr.add(propName, new JcrDavException(e).getErrorCode());
success = false;
}
} else if (propEntry instanceof DavProperty) {
DavProperty prop = (DavProperty)propEntry;
try {
setJcrProperty(prop);
successList.add(prop);
} catch (RepositoryException e) {
msr.add(prop.getName(), new JcrDavException(e).getErrorCode());
success = false;
}
} else {
throw new IllegalArgumentException("unknown object in change list: " + propEntry.getClass().getName());
}
}
try {
if (success) {
// save all changes together (reverted in case this fails)
node.save();
} else {
// set/remove of at least a single prop failed: undo modifications.
node.refresh(false);
}
/* loop over list of properties/names that were successfully altered
and them to the multistatus response respecting the resulte of the
complete action. in case of failure set the status to 'failed-dependency'
in order to indicate, that altering those names/properties would
have succeeded, if no other error occured.*/
it = successList.iterator();
while (it.hasNext()) {
Object o = it.next();
int status = (success) ? DavServletResponse.SC_OK : DavServletResponse.SC_FAILED_DEPENDENCY;
if (o instanceof DavProperty) {
msr.add(((DavProperty) o).getName(), status);
} else {
msr.add((DavPropertyName) o, status);
}
}
return msr;
} catch (RepositoryException e) {
// revert any changes made so far an throw exception