@RequestMapping(
      value = {"VIEW"},
      params = {"action=browseWai"})
  public ModelAndView browseWai(
      RenderRequest request,
      RenderResponse response,
      @RequestParam(required = false) String dir,
      @RequestParam(required = false) String msg) {
    this.init(request);

    String decodedDir = pathEncodingUtils.decodeDir(dir);

    if (!serverAccess.isInitialized(userParameters)) {
      serverAccess.initializeServices(userParameters);
    }

    ModelMap model;
    if (!(dir == null || dir.length() == 0 || decodedDir.equals(JsTreeFile.ROOT_DRIVE))) {
      if (this.serverAccess.formAuthenticationRequired(decodedDir, userParameters)) {
        ListOrderedMap parentPathes = pathEncodingUtils.getParentsEncPathes(decodedDir, null, null);
        // we want to get the (last-1) key of sortedmap "parentPathes"
        String parentDir = (String) parentPathes.get(parentPathes.size() - 2);
        model = new ModelMap("currentDir", dir);
        model.put("parentDir", parentDir);
        model.put(
            "username",
            this.serverAccess.getUserPassword(decodedDir, userParameters).getUsername());
        model.put(
            "password",
            this.serverAccess.getUserPassword(decodedDir, userParameters).getPassword());
        if (msg != null) model.put("msg", msg);
        return new ModelAndView("authenticationForm-portlet-wai", model);
      }
    }

    model = browse(dir);
    FormCommand command = new FormCommand();
    model.put("command", command);
    if (msg != null) model.put("msg", msg);
    return new ModelAndView("view-portlet-wai", model);
  }
  @RequestMapping("VIEW")
  protected ModelAndView renderView(RenderRequest request, RenderResponse response)
      throws Exception {
    this.init(request);
    final PortletPreferences prefs = request.getPreferences();
    String defaultPortletView = prefs.getValue(PREF_PORTLET_VIEW, STANDARD_VIEW);
    String[] prefsDefaultPathes = prefs.getValues(PREF_DEFAULT_PATH, null);
    if (log.isDebugEnabled()) {
      log.debug(PREF_DEFAULT_PATH + " preference : ");
      for (String prefDefaultPath : prefsDefaultPathes) log.debug("- " + prefDefaultPath);
    }

    boolean showHiddenFiles = "true".equals(prefs.getValue(PREF_SHOW_HIDDEN_FILES, "false"));
    userParameters.setShowHiddenFiles(showHiddenFiles);

    UploadActionType uploadOption =
        UploadActionType.valueOf(
            prefs.getValue(PREF_UPLOAD_ACTION_EXIST_FILE, UploadActionType.OVERRIDE.toString()));
    userParameters.setUploadOption(uploadOption);

    serverAccess.initializeServices(userParameters);

    String defaultPath = serverAccess.getFirstAvailablePath(userParameters, prefsDefaultPathes);
    log.info("defaultPath will be : " + defaultPath);
    defaultPath = pathEncodingUtils.encodeDir(defaultPath);

    if (userAgentInspector.isMobile(request)) {
      return this.browseMobile(request, response, defaultPath);
    } else {
      if (MOBILE_VIEW.equals(defaultPortletView))
        return this.browseMobile(request, response, defaultPath);
      else if (WAI_VIEW.equals(defaultPortletView))
        return this.browseWai(request, response, defaultPath, null);
      else return this.browseStandard(request, response, defaultPath);
    }
  }
  protected void init(PortletRequest request) {

    if (!userParameters.isInitialized()) {
      String clientIpAdress = request.getProperty("REMOTE_ADDR");
      userParameters.init(clientIpAdress);

      Map userInfos = (Map) request.getAttribute(PortletRequest.USER_INFO);
      userParameters.setUserInfos(userInfos);

      List<String> driveNames = serverAccess.getRestrictedDrivesGroupsContext(request);
      userParameters.setDriveNames(driveNames);

      log.info("set SharedUserPortletParameters in application session");
    }
  }