public Response copy ( Session destSession , String sourcePath , String destPath ) { try { Workspace workspace = destSession . getWorkspace ( ) ; workspace . copy ( sourcePath , destPath ) ; // If the source resource was successfully moved // to a pre-existing destination resource. if ( itemExisted ) { return Response . noContent ( ) . build ( ) ; } // If the source resource was successfully moved, // and a new resource was created at the destination. else { if ( uriBuilder != null ) { return Response . created ( uriBuilder . path ( workspace . getName ( ) ) . path ( destPath ) . build ( ) ) . build ( ) ; } // to save compatibility if uribuilder is not provided return Response . status ( HTTPStatus . CREATED ) . build ( ) ; } } catch ( ItemExistsException e ) { return Response . status ( HTTPStatus . METHOD_NOT_ALLOWED ) . entity ( e . getMessage ( ) ) . build ( ) ; } catch ( PathNotFoundException e ) { return Response . status ( HTTPStatus . CONFLICT ) . entity ( e . getMessage ( ) ) . build ( ) ; } catch ( AccessDeniedException e ) { return Response . status ( HTTPStatus . FORBIDDEN ) . entity ( e . getMessage ( ) ) . build ( ) ; } catch ( LockException e ) { return Response . status ( HTTPStatus . LOCKED ) . entity ( e . getMessage ( ) ) . build ( ) ; } catch ( RepositoryException e ) { log . error ( e . getMessage ( ) , e ) ; return Response . serverError ( ) . entity ( e . getMessage ( ) ) . build ( ) ; } }
Webdav COPY method implementation for the same workspace .