* @see Workspace#copy(String, String)
* @see Workspace#copy(String, String, String)
*/
public void copy(DavResource destination, boolean shallow) throws DavException {
if (!exists()) {
throw new DavException(DavServletResponse.SC_NOT_FOUND);
}
// TODO: support shallow and deep copy is required by RFC 2518
if (shallow) {
throw new DavException(DavServletResponse.SC_FORBIDDEN, "Unable to perform shallow copy.");
}
try {
String itemPath = getLocator().getRepositoryPath();
String destItemPath = destination.getLocator().getRepositoryPath();
Workspace workspace = getRepositorySession().getWorkspace();
if (getLocator().isSameWorkspace(destination.getLocator())) {
workspace.copy(itemPath, destItemPath);
} else {
log.error("Copy between workspaces is not yet implemented (src: '" + getHref() + "', dest: '" + destination.getHref() + "')");
throw new DavException(DavServletResponse.SC_NOT_IMPLEMENTED);
}
} catch (PathNotFoundException e) {
// according to RFC 2518, should not occur
throw new DavException(DavServletResponse.SC_NOT_FOUND, e.getMessage());
} catch (RepositoryException e) {
throw new JcrDavException(e);
}
}