throw new DavException(DavServletResponse.SC_LOCKED);
}
if (!exists()) {
throw new DavException(DavServletResponse.SC_NOT_FOUND);
}
MultiStatusResponse msr = new MultiStatusResponse(getHref(), null);
try {
Map<? extends PropEntry, ?> failures = config.getPropertyManager().alterProperties(getPropertyImportContext(changeList), isCollection());
if (failures.isEmpty()) {
// 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 result 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.*/
for (PropEntry propEntry : changeList) {
int statusCode;
if (failures.containsKey(propEntry)) {
Object error = failures.get(propEntry);
statusCode = (error instanceof RepositoryException)
? new JcrDavException((RepositoryException) error).getErrorCode()
: DavServletResponse.SC_INTERNAL_SERVER_ERROR;
} else {
statusCode = (failures.isEmpty()) ? DavServletResponse.SC_OK : DavServletResponse.SC_FAILED_DEPENDENCY;
}
if (propEntry instanceof DavProperty) {
msr.add(((DavProperty<?>) propEntry).getName(), statusCode);
} else {
msr.add((DavPropertyName) propEntry, statusCode);
}
}
return msr;
} catch (RepositoryException e) {
// revert any changes made so far an throw exception