use of org.apache.jackrabbit.server.io.ImportContext in project jackrabbit by apache.
the class DavResourceImpl method addMember.
/**
* Adds a new member to this resource.
*
* @see DavResource#addMember(DavResource, org.apache.jackrabbit.webdav.io.InputContext)
*/
public void addMember(DavResource member, InputContext inputContext) throws DavException {
if (!exists()) {
throw new DavException(DavServletResponse.SC_CONFLICT);
}
if (isLocked(this) || isLocked(member)) {
throw new DavException(DavServletResponse.SC_LOCKED);
}
try {
// item or if the new resource would be filtered out
if (isFilteredResource(member) || node.getDefinition().isProtected()) {
log.debug("Forbidden to add member: " + member.getDisplayName());
throw new DavException(DavServletResponse.SC_FORBIDDEN);
}
String memberName = Text.getName(member.getLocator().getRepositoryPath());
ImportContext ctx = getImportContext(inputContext, memberName);
if (!config.getIOManager().importContent(ctx, member)) {
// any changes should have been reverted in the importer
throw new DavException(DavServletResponse.SC_UNSUPPORTED_MEDIA_TYPE);
}
// persist changes after successful import
node.save();
} catch (RepositoryException e) {
log.error("Error while importing resource: " + e.toString());
throw new JcrDavException(e);
} catch (IOException e) {
log.error("Error while importing resource: " + e.toString());
throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
}
}
Aggregations