public void handlerMenu(
      HttpServletRequest request,
      HttpServletResponse response,
      HttpSession session,
      AdminService admin,
      ExtendedMap formItems,
      ExtendedMap parameters,
      User user,
      Document verticalDoc)
      throws VerticalAdminException, TransformerException, IOException {

    // get resource tree xml
    ResourceFolder root = resourceService.getResourceRoot();
    ResourceXmlCreator xmlCreator = new ResourceXmlCreator();
    xmlCreator.setIncludeFullPath(true);
    xmlCreator.setListFolders(true);
    xmlCreator.setListResources(false);
    XMLDocument resourcesDoc = xmlCreator.createResourceTreeXml(root);

    Cookie cookie = CookieUtil.getCookie(request, "resourcePickerPath");
    if (cookie != null) {
      try {
        String resourcePickerPathBase64AndUrlEncoded = cookie.getValue();
        String resourcePickerPathBase64Encoded =
            UrlPathDecoder.decode(resourcePickerPathBase64AndUrlEncoded);
        String resourcePickerPath =
            new String(Base64Util.decode(resourcePickerPathBase64Encoded), "UTF-8");
        if (resourcePickerPath != null) {
          parameters.put("path", resourcePickerPath);
        }
      } catch (IllegalArgumentException e) {
        LOG.warn("Value in Cookie 'resourcePickerPath' is not base64 encoded ");
      }
    }

    // add popup parameters
    parameters.put("mimetype", formItems.get("mimetype", ""));
    parameters.put("extension", formItems.get("extension", ""));
    parameters.put("fieldname", formItems.get("fieldname"));
    parameters.put("subop", formItems.get("subop", ""));
    parameters.put("sourceKey", formItems.get("sourceKey", ""));
    parameters.put("destinationKey", formItems.get("destinationKey", ""));

    transformXML(
        request,
        response,
        resourcesDoc.getAsDOMDocument(),
        "resource_selector_frame1.xsl",
        parameters);
  }
  public void handlerBrowse(
      HttpServletRequest request,
      HttpServletResponse response,
      HttpSession session,
      AdminService admin,
      ExtendedMap formItems,
      ExtendedMap parameters,
      User user,
      Document verticalDoc)
      throws VerticalAdminException, TransformerException, IOException {

    String path = formItems.getString("path", "/");
    String deploymentPath = DeploymentPathResolver.getAdminDeploymentPath(request);
    String resourcePickerPathBase64Encoded = Base64Util.encode(path.getBytes("UTF-8"));
    String resourcePickerPathBase64EncodedAndUrlEncoded =
        UrlPathEncoder.encode(resourcePickerPathBase64Encoded);
    CookieUtil.setCookie(
        response,
        "resourcePickerPath",
        resourcePickerPathBase64EncodedAndUrlEncoded,
        ContentBaseHandlerServlet.COOKIE_TIMEOUT,
        deploymentPath);

    Document doc;
    if (request.getParameter("searchtext") != null) {
      String searchText = formItems.getString("searchtext", "");
      doc = admin.getResourceTreeXml(path, true, true, -1, true, true).getAsDOMDocument();
      doc = filterResources(doc, searchText);
      parameters.put("searchtext", searchText);
      parameters.put("search", "true");
    } else {
      doc = admin.getResourceTreeXml(path, true, true, 1, false, true).getAsDOMDocument();
    }

    addAccessLevelParameters(user, parameters);

    parameters.put("mimetype", formItems.get("mimetype", ""));
    parameters.put("extension", formItems.get("extension", ""));
    parameters.put("fieldname", formItems.get("fieldname"));
    parameters.put("path", doc.getDocumentElement().getAttribute("root"));
    parameters.put("sortby", formItems.get("sortby", "@name"));
    parameters.put("sortby-direction", formItems.get("sortby-direction", "ascending"));
    parameters.put("reload", formItems.get("reload", false));
    parameters.put("move", formItems.get("move", false));

    transformXML(request, response, doc, "resource_browse.xsl", parameters);
  }