/**
   * Handles a request for navigation data, for example for the top navigation menu, left-side
   * navigation or breadcrumb bar.
   *
   * @param request The request.
   * @param entityId The name of the entity.
   * @param navType Navigation type.
   * @return The name of the entity view that should be rendered for this request.
   * @throws NavigationProviderException If an error occurs so that the navigation data cannot be
   *     retrieved.
   * @throws java.lang.Exception if any.
   */
  @RequestMapping(
      method = RequestMethod.GET,
      value = DefaultsMvcData.CoreAreaConstants.NAVIGATION_ACTION_NAME + "/{entityId}")
  public String handleGetNavigation(
      HttpServletRequest request, @PathVariable String entityId, @RequestParam String navType)
      throws Exception {
    LOG.trace("handleGetNavigation:, entityId={}", entityId);

    EntityModel entity = getEntityFromRequest(request, entityId);

    final String requestPath = webRequestContext.getRequestPath();
    final Localization localization = webRequestContext.getLocalization();

    NavigationLinks navigationLinks;
    switch (navType) {
      case NAV_TYPE_TOP:
        navigationLinks = navigationProvider.getTopNavigationLinks(requestPath, localization);
        break;

      case NAV_TYPE_LEFT:
        navigationLinks = navigationProvider.getContextNavigationLinks(requestPath, localization);
        break;

      case NAV_TYPE_BREADCRUMB:
        navigationLinks =
            navigationProvider.getBreadcrumbNavigationLinks(requestPath, localization);
        break;

      default:
        LOG.warn("Unsupported navigation type: {}", navType);
        navigationLinks = null;
        break;
    }

    final ViewModel enrichedEntity = enrichModel(entity, request);
    entity = enrichedEntity instanceof EntityModel ? (EntityModel) enrichedEntity : navigationLinks;
    request.setAttribute(ENTITY_MODEL, entity);

    if (navigationLinks != null) {
      navigationLinks.setXpmMetadata(entity.getXpmMetadata());
      navigationLinks.setXpmPropertyMetadata(entity.getXpmPropertyMetadata());
      request.setAttribute(ENTITY_MODEL, navigationLinks);
    }

    final MvcData mvcData = entity.getMvcData();
    LOG.trace("Entity MvcData: {}", mvcData);
    return resolveView(mvcData, "Entity", request);
  }