public void getMenu(Menu menu, Node node) {
    MenuItem mi;

    Permissions permission =
        SessionUtils.getSession(context)
            .getServiceRegistry()
            .getDocumentFolderService()
            .getPermissions(node);

    mi =
        menu.add(
            Menu.NONE,
            MenuActionItem.MENU_DETAILS,
            Menu.FIRST + MenuActionItem.MENU_DETAILS,
            R.string.action_view_properties);
    mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);

    if (permission.canEdit()) {
      mi =
          menu.add(
              Menu.NONE,
              MenuActionItem.MENU_EDIT,
              Menu.FIRST + MenuActionItem.MENU_EDIT,
              R.string.action_edit_properties);
      mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }

    if (permission.canDelete()) {
      mi =
          menu.add(
              Menu.NONE,
              MenuActionItem.MENU_DELETE_FOLDER,
              Menu.FIRST + MenuActionItem.MENU_DELETE_FOLDER,
              R.string.delete);
      mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_NEVER);
    }
  }
  public static void getMenu(
      AlfrescoSession session, Menu menu, Folder parentFolder, boolean extended) {
    MenuItem mi;

    if (parentFolder == null) {
      return;
    }

    Permissions permission =
        session.getServiceRegistry().getDocumentFolderService().getPermissions(parentFolder);

    if (!extended && parentFolder != null && permission.canAddChildren()) {
      mi =
          menu.add(
              Menu.NONE,
              MenuActionItem.MENU_CREATE_FOLDER,
              Menu.FIRST + MenuActionItem.MENU_CREATE_FOLDER,
              R.string.folder_create);
      mi.setIcon(R.drawable.ic_add_folder);
      mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    if (!extended && parentFolder != null && permission.canAddChildren()) {
      SubMenu devCaptureMenu =
          menu.addSubMenu(
              Menu.NONE,
              MenuActionItem.MENU_DEVICE_CAPTURE,
              Menu.FIRST + MenuActionItem.MENU_DEVICE_CAPTURE,
              R.string.upload);
      devCaptureMenu.setIcon(android.R.drawable.ic_menu_add);
      devCaptureMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

      devCaptureMenu.add(
          Menu.NONE,
          MenuActionItem.MENU_DEVICE_CAPTURE_CAMERA_PHOTO,
          Menu.FIRST + MenuActionItem.MENU_DEVICE_CAPTURE_CAMERA_PHOTO,
          R.string.take_photo);

      if (AndroidVersion.isICSOrAbove()) {
        devCaptureMenu.add(
            Menu.NONE,
            MenuActionItem.MENU_DEVICE_CAPTURE_CAMERA_VIDEO,
            Menu.FIRST + MenuActionItem.MENU_DEVICE_CAPTURE_CAMERA_VIDEO,
            R.string.make_video);
      }

      devCaptureMenu.add(
          Menu.NONE,
          MenuActionItem.MENU_DEVICE_CAPTURE_MIC_AUDIO,
          Menu.FIRST + MenuActionItem.MENU_DEVICE_CAPTURE_MIC_AUDIO,
          R.string.record_audio);
      devCaptureMenu.add(
          Menu.NONE,
          MenuActionItem.MENU_UPLOAD,
          Menu.FIRST + MenuActionItem.MENU_UPLOAD,
          R.string.content_upload);
    }

    if (extended && parentFolder != null && permission.canEdit()) {
      mi =
          menu.add(
              Menu.NONE,
              MenuActionItem.MENU_EDIT,
              Menu.FIRST + MenuActionItem.MENU_EDIT,
              R.string.edit);
      mi.setIcon(R.drawable.ic_edit);
      mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    if (extended && parentFolder != null && permission.canDelete()) {
      mi =
          menu.add(
              Menu.NONE,
              MenuActionItem.MENU_DELETE_FOLDER,
              Menu.FIRST + MenuActionItem.MENU_DELETE_FOLDER,
              R.string.delete);
      mi.setIcon(R.drawable.ic_delete);
      mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    if (!extended && parentFolder != null) {
      mi =
          menu.add(
              Menu.NONE,
              MenuActionItem.MENU_REFRESH,
              Menu.FIRST + MenuActionItem.MENU_REFRESH,
              R.string.refresh);
      mi.setIcon(R.drawable.ic_refresh);
      mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }
  }
  public static void getMenu(
      AlfrescoSession session, Menu menu, Folder parentFolder, boolean actionMode) {
    MenuItem mi;

    if (parentFolder == null) {
      return;
    }
    Permissions permission = null;
    try {
      permission =
          session.getServiceRegistry().getDocumentFolderService().getPermissions(parentFolder);
    } catch (Exception e) {
      return;
    }

    if (!actionMode) {
      mi =
          menu.add(
              Menu.NONE,
              MenuActionItem.MENU_SEARCH_FOLDER,
              Menu.FIRST + MenuActionItem.MENU_SEARCH_FOLDER,
              R.string.search);
      mi.setIcon(R.drawable.ic_search);
      mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    if (!actionMode && permission.canAddChildren()) {
      mi =
          menu.add(
              Menu.NONE,
              MenuActionItem.MENU_CREATE_FOLDER,
              Menu.FIRST + MenuActionItem.MENU_CREATE_FOLDER,
              R.string.folder_create);
      mi.setIcon(R.drawable.ic_add_folder);
      mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

      SubMenu createMenu =
          menu.addSubMenu(
              Menu.NONE,
              MenuActionItem.MENU_DEVICE_CAPTURE,
              Menu.FIRST + MenuActionItem.MENU_DEVICE_CAPTURE,
              R.string.add_menu);
      createMenu.setIcon(android.R.drawable.ic_menu_add);
      createMenu.getItem().setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

      createMenu.add(
          Menu.NONE,
          MenuActionItem.MENU_UPLOAD,
          Menu.FIRST + MenuActionItem.MENU_UPLOAD,
          R.string.upload_title);

      createMenu.add(
          Menu.NONE,
          MenuActionItem.MENU_CREATE_DOCUMENT,
          Menu.FIRST + MenuActionItem.MENU_CREATE_DOCUMENT,
          R.string.create_document);

      createMenu.add(
          Menu.NONE,
          MenuActionItem.MENU_DEVICE_CAPTURE_CAMERA_PHOTO,
          Menu.FIRST + MenuActionItem.MENU_DEVICE_CAPTURE_CAMERA_PHOTO,
          R.string.take_photo);

      if (AndroidVersion.isICSOrAbove()) {
        createMenu.add(
            Menu.NONE,
            MenuActionItem.MENU_DEVICE_CAPTURE_CAMERA_VIDEO,
            Menu.FIRST + MenuActionItem.MENU_DEVICE_CAPTURE_CAMERA_VIDEO,
            R.string.make_video);
      }

      createMenu.add(
          Menu.NONE,
          MenuActionItem.MENU_DEVICE_CAPTURE_MIC_AUDIO,
          Menu.FIRST + MenuActionItem.MENU_DEVICE_CAPTURE_MIC_AUDIO,
          R.string.record_audio);
    }

    if (actionMode) {
      mi =
          menu.add(
              Menu.NONE,
              MenuActionItem.MENU_DETAILS,
              Menu.FIRST + MenuActionItem.MENU_DETAILS,
              R.string.action_view_properties);
      mi.setIcon(R.drawable.ic_details);
      mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    if (actionMode && permission.canEdit()) {
      mi =
          menu.add(
              Menu.NONE,
              MenuActionItem.MENU_EDIT,
              Menu.FIRST + MenuActionItem.MENU_EDIT,
              R.string.edit);
      mi.setIcon(R.drawable.ic_edit);
      mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    if (actionMode && permission.canDelete()) {
      mi =
          menu.add(
              Menu.NONE,
              MenuActionItem.MENU_DELETE,
              Menu.FIRST + MenuActionItem.MENU_DELETE,
              R.string.delete);
      mi.setIcon(R.drawable.ic_delete);
      mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }

    if (!actionMode) {
      mi =
          menu.add(
              Menu.NONE,
              MenuActionItem.MENU_REFRESH,
              Menu.FIRST + MenuActionItem.MENU_REFRESH,
              R.string.refresh);
      mi.setIcon(R.drawable.ic_refresh);
      mi.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
    }
  }