Пример #1
0
  private static int buildMenuList(
      HttpServletRequest request,
      GovernanceArtifactConfiguration configuration,
      List<Menu> menuList,
      String key,
      int menuOrder) {
    String singularLabel = configuration.getSingularLabel();
    String pluralLabel = configuration.getPluralLabel();
    boolean hasNamespace = configuration.hasNamespace();
    String lifecycleAttribute = key + "Lifecycle_lifecycleName";

    lifecycleAttribute =
        BuilLifecycleAttribute(
            configuration, DEFAULT_LIFECYCLE_GENERATOR_CLASS, lifecycleAttribute);

    if (singularLabel == null || pluralLabel == null) {
      log.error(
          "The singular label and plural label have not "
              + "been defined for the artifact type: "
              + key);
    } else {
      int iconSet = configuration.getIconSet();
      if (CarbonUIUtil.isUserAuthorized(
              request, "/permission/admin/manage/resources/govern/" + key + "/add")
          && CarbonUIUtil.isUserAuthorized(request, "/permission/admin/manage/resources/browse")
          && CarbonUIUtil.isUserAuthorized(request, "/permission/admin/manage/resources/ws-api")) {
        Menu addMenu = new Menu();
        addMenu.setId("governance_add_" + key + "_menu");
        addMenu.setI18nKey(singularLabel);
        addMenu.setParentMenu("add_sub_menu");
        if (configuration.getExtension() == null) {
          addMenu.setLink("../generic/add_edit.jsp");
          addMenu.setUrlParameters(
              "key="
                  + key
                  + "&lifecycleAttribute="
                  + lifecycleAttribute
                  + "&breadcrumb="
                  + singularLabel);
        } else {
          addMenu.setLink("../generic/add_content.jsp");
          addMenu.setUrlParameters(
              "key="
                  + key
                  + "&lifecycleAttribute="
                  + lifecycleAttribute
                  + "&breadcrumb="
                  + singularLabel
                  + "&mediaType="
                  + configuration.getMediaType()
                  + "&extension="
                  + configuration.getExtension()
                  + "&singularLabel="
                  + singularLabel
                  + "&pluralLabel="
                  + pluralLabel
                  + "&hasNamespace"
                  + hasNamespace);
        }
        addMenu.setRegion("region3");
        addMenu.setOrder(String.valueOf(menuOrder));
        addMenu.setStyleClass("manage");
        if (iconSet > 0) {
          addMenu.setIcon("../generic/images/add" + iconSet + ".png");
        } else {
          addMenu.setIcon("../images/add.gif");
        }
        addMenu.setAllPermissionsRequired(true);
        addMenu.setRequirePermission(
            new String[] {
              "/permission/admin/manage/resources/govern/" + key + "/add",
              "/permission/admin/manage/resources/browse",
              "/permission/admin/manage/resources/ws-api"
            });
        menuList.add(addMenu);
      }

      if (CarbonUIUtil.isUserAuthorized(
              request, "/permission/admin/manage/resources/govern/" + key + "/list")
          && CarbonUIUtil.isUserAuthorized(request, "/permission/admin/manage/resources/ws-api")) {
        Menu listMenu = new Menu();
        listMenu.setId("governance_list_" + key + "_menu");
        listMenu.setI18nKey(pluralLabel);
        listMenu.setParentMenu("list_sub_menu");
        if (configuration.getExtension() == null) {
          listMenu.setLink("../generic/list.jsp");
          listMenu.setUrlParameters(
              "key="
                  + key
                  + "&breadcrumb="
                  + pluralLabel
                  + "&singularLabel="
                  + singularLabel
                  + "&pluralLabel="
                  + pluralLabel);
        } else {
          listMenu.setLink("../generic/list_content.jsp");
          listMenu.setUrlParameters(
              "key="
                  + key
                  + "&lifecycleAttribute="
                  + lifecycleAttribute
                  + "&breadcrumb="
                  + singularLabel
                  + "&mediaType="
                  + configuration.getMediaType()
                  + "&singularLabel="
                  + singularLabel
                  + "&pluralLabel="
                  + pluralLabel
                  + "&hasNamespace="
                  + hasNamespace);
        }
        listMenu.setRegion("region3");
        listMenu.setOrder(String.valueOf(menuOrder));
        listMenu.setStyleClass("manage");
        if (iconSet > 0) {
          listMenu.setIcon("../generic/images/list" + iconSet + ".png");
        } else {
          listMenu.setIcon("../images/list.gif");
        }
        listMenu.setAllPermissionsRequired(true);
        listMenu.setRequirePermission(
            new String[] {
              "/permission/admin/manage/resources/govern/" + key + "/list",
              "/permission/admin/manage/resources/ws-api"
            });
        menuList.add(listMenu);
      }
      /*if (CarbonUIUtil.isUserAuthorized(request,
              "/permission/admin/configure/governance/" + key + "-ui")) {
          Menu configureMenu = new Menu();
          configureMenu.setId("governance_" + key + "_config_menu");
          configureMenu.setI18nKey(pluralLabel);
          configureMenu.setParentMenu("configure_menu");
          configureMenu.setLink("../generic/configure.jsp");
          configureMenu.setUrlParameters("key=" + key + "&breadcrumb=" + pluralLabel +
                  "&add_edit_region=region3&add_edit_item=governance_add_" + key + "_menu" +
                  "&lifecycleAttribute=" + lifecycleAttribute +
                  "&add_edit_breadcrumb=" + singularLabel + "&singularLabel=" + singularLabel +
                  "&pluralLabel=" + pluralLabel);
          configureMenu.setRegion("region1");
          configureMenu.setOrder("40");
          configureMenu.setStyleClass("manage");
          if (iconSet > 0) {
              configureMenu.setIcon("../generic/images/configure" + iconSet + ".png");
          } else {
              configureMenu.setIcon("../generic/images/services1.gif");
          }
          configureMenu.setRequirePermission(
                  new String[]{"/permission/admin/configure/governance/" + key + "-ui"});
          menuList.add(configureMenu);
      }*/
      menuOrder++;
    }
    return menuOrder;
  }