*/
private Office validateUserPriviledgeOnOfficeAndRetrieve(final AppUser currentUser, final Long officeId) {
final Long userOfficeId = currentUser.getOffice().getId();
final Office userOffice = this.officeRepository.findOne(userOfficeId);
if (userOffice == null) { throw new OfficeNotFoundException(userOfficeId); }
if (userOffice.doesNotHaveAnOfficeInHierarchyWithId(officeId)) { throw new NoAuthorizationException(
"User does not have sufficient priviledges to act on the provided office."); }
Office officeToReturn = userOffice;
if (!userOffice.identifiedBy(officeId)) {
officeToReturn = this.officeRepository.findOne(officeId);
if (officeToReturn == null) { throw new OfficeNotFoundException(officeId); }
}
return officeToReturn;
}