Search in sources :

Example 6 with UiMenu

use of org.molgenis.web.UiMenu in project molgenis by molgenis.

the class XmlMolgenisUiMenuTest method getParentMenu.

@Test
public void getParentMenu() {
    assertNull(new XmlMolgenisUiMenu(new MenuType(), permissionService).getParentMenu());
    UiMenu parentMenu = new XmlMolgenisUiMenu(new MenuType(), permissionService);
    assertEquals(new XmlMolgenisUiMenu(new MenuType(), parentMenu, permissionService).getParentMenu(), parentMenu);
}
Also used : UiMenu(org.molgenis.web.UiMenu) Test(org.testng.annotations.Test)

Example 7 with UiMenu

use of org.molgenis.web.UiMenu in project molgenis by molgenis.

the class XmlMolgenisUiMenuTest method getBreadcrumb.

@Test
public void getBreadcrumb() {
    UiMenu menu1 = new XmlMolgenisUiMenu(new MenuType(), permissionService);
    UiMenu menu2 = new XmlMolgenisUiMenu(new MenuType(), menu1, permissionService);
    UiMenu menu3 = new XmlMolgenisUiMenu(new MenuType(), menu2, permissionService);
    assertEquals(menu1.getBreadcrumb(), Arrays.asList(menu1));
    assertEquals(menu2.getBreadcrumb(), Arrays.asList(menu1, menu2));
    assertEquals(menu3.getBreadcrumb(), Arrays.asList(menu1, menu2, menu3));
}
Also used : UiMenu(org.molgenis.web.UiMenu) Test(org.testng.annotations.Test)

Example 8 with UiMenu

use of org.molgenis.web.UiMenu in project molgenis by molgenis.

the class XmlMolgenisUiTest method getMenu.

@Test
public void getMenu() {
    String menuId = "menu1";
    MenuType menuType = new MenuType();
    menuType.setName(menuId);
    when(molgenis.getMenu()).thenReturn(menuType);
    UiMenu menu = xmlMolgenisUi.getMenu();
    assertEquals(menu.getId(), menuId);
}
Also used : UiMenu(org.molgenis.web.UiMenu) Test(org.testng.annotations.Test)

Example 9 with UiMenu

use of org.molgenis.web.UiMenu in project molgenis by molgenis.

the class MolgenisMenuController method forwardMenuDefaultPlugin.

@RequestMapping("/{menuId}")
public String forwardMenuDefaultPlugin(@Valid @NotNull @PathVariable String menuId, Model model) {
    UiMenu menu = molgenisUi.getMenu(menuId);
    if (menu == null)
        throw new RuntimeException("menu with id [" + menuId + "] does not exist");
    model.addAttribute(KEY_MENU_ID, menuId);
    UiMenuItem activeItem = menu.getActiveItem();
    String pluginId = activeItem != null ? activeItem.getId() : VoidPluginController.ID;
    String contextUri = URI + '/' + menuId + '/' + pluginId;
    model.addAttribute(KEY_CONTEXT_URL, contextUri);
    model.addAttribute(KEY_MOLGENIS_VERSION, molgenisVersion);
    model.addAttribute(KEY_MOLGENIS_BUILD_DATE, molgenisBuildData);
    return getForwardPluginUri(pluginId, null);
}
Also used : UiMenuItem(org.molgenis.web.UiMenuItem) UiMenu(org.molgenis.web.UiMenu) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 10 with UiMenu

use of org.molgenis.web.UiMenu in project molgenis by molgenis.

the class MolgenisAccessDecisionVoter method vote.

@Override
public int vote(Authentication authentication, FilterInvocation filterInvocation, Collection<ConfigAttribute> attributes) {
    String requestUrl = filterInvocation.getRequestUrl();
    Matcher pluginMatcher = PATTERN_PLUGINID.matcher(requestUrl);
    if (pluginMatcher.matches()) {
        String pluginId = pluginMatcher.group(1);
        return getMolgenisPermissionService().hasPermission(new PluginIdentity(pluginId), PluginPermission.READ) ? ACCESS_GRANTED : ACCESS_DENIED;
    }
    Matcher menuMatcher = PATTERN_MENUID.matcher(requestUrl);
    if (menuMatcher.matches()) {
        String menuId = menuMatcher.group(1);
        UiMenu menu = getMolgenisUi().getMenu(menuId);
        return menu != null ? ACCESS_GRANTED : ACCESS_DENIED;
    }
    return ACCESS_DENIED;
}
Also used : Matcher(java.util.regex.Matcher) PluginIdentity(org.molgenis.data.plugin.model.PluginIdentity) UiMenu(org.molgenis.web.UiMenu)

Aggregations

UiMenu (org.molgenis.web.UiMenu)11 UiMenuItem (org.molgenis.web.UiMenuItem)5 Test (org.testng.annotations.Test)4 PluginIdentity (org.molgenis.data.plugin.model.PluginIdentity)2 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)2 Matcher (java.util.regex.Matcher)1 UserPermissionEvaluator (org.molgenis.security.core.UserPermissionEvaluator)1 ApplicationContextProvider (org.molgenis.util.ApplicationContextProvider)1 Ui (org.molgenis.web.Ui)1 ApplicationContext (org.springframework.context.ApplicationContext)1 BeforeMethod (org.testng.annotations.BeforeMethod)1