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);
}
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));
}
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);
}
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);
}
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;
}
Aggregations