User user = securityManager.getUserByLoginName(SecurityContextHolder.getContext().getAuthentication().getName());
Library library = requestManager.getLibraryById(libraryId);
String oldLocation = library.getLocationBarcode();
library.setLocationBarcode(newLocation);
Note note = new Note();
note.setInternalOnly(true);
note.setText("Location changed from " + oldLocation + " to " + newLocation + " by " + user.getLoginName() + " on " + new Date());
note.setOwner(user);
note.setCreationDate(new Date());
library.getNotes().add(note);
requestManager.saveLibraryNote(library, note);
requestManager.saveLibrary(library);
}
else {