/*
   * used to restrict modifying operations to office that are either the users
   * office or lower (child) in the office hierarchy
   */
  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;
  }