String locationBarcode = json.getString("locationBarcode");
try {
String newLocation = LimsUtils.lookupLocation(locationBarcode);
if (newLocation != null) {
User user = securityManager.getUserByLoginName(SecurityContextHolder.getContext().getAuthentication().getName());
Sample sample = requestManager.getSampleById(sampleId);
String oldLocation = sample.getLocationBarcode();
sample.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());
sample.getNotes().add(note);
requestManager.saveSampleNote(sample, note);
requestManager.saveSample(sample);