@RequestMapping(value="/{bookmarkId}",method=RequestMethod.DELETE) public ResponseEntity<Bookmark> deleteBookmark(@PathVariable(value="username") String username,@PathVariable(value="bookmarkId") int bookmarkId) throws BookmarkNotFoundException {
  Optional<Bookmark> optional=bookmarksRepository.findByIdAndUserUsername(bookmarkId,username);
  if (optional.isPresent()) {
    bookmarksRepository.delete(optional.get());
    return new ResponseEntity<>(optional.get(),HttpStatus.OK);
  }
 else {
    throw new BookmarkNotFoundException("Bookmark not found. id = " + bookmarkId);
  }
}

@ RequestMapping ( value = "/{bookmarkId}" , method = RequestMethod . DELETE ) public ResponseEntity < Bookmark > deleteBookmark ( @ PathVariable ( value = "username" ) String username , @ PathVariable ( value = "bookmarkId" ) int bookmarkId ) throws BookmarkNotFoundException { Optional < Bookmark > optional = bookmarksRepository . findByIdAndUserUsername ( bookmarkId , username ) ; if ( optional . isPresent ( ) ) { bookmarksRepository . delete ( optional . get ( ) ) ; return new ResponseEntity < > ( optional . get ( ) , HttpStatus . OK ) ; } else { throw new BookmarkNotFoundException ( "Bookmark not found. id = " + bookmarkId ) ; } }
a method to delete a bookmark identified by id .
