use of org.craftercms.studio.api.v2.service.config.ConfigurationService in project studio by craftercms.
the class UiServiceInternalImpl method getGlobalMenu.
@Override
@SuppressWarnings("unchecked")
public List<MenuItem> getGlobalMenu(Set<String> permissions) throws ServiceLayerException {
if (CollectionUtils.isNotEmpty(permissions)) {
HierarchicalConfiguration menuConfig = getGlobalMenuConfig();
List<MenuItem> menuItems = new ArrayList<>();
// TODO: Move this config to ConfigurationService
List<HierarchicalConfiguration> itemsConfig = menuConfig.configurationsAt(MENU_ITEMS_CONFIG_KEY);
if (CollectionUtils.isNotEmpty(itemsConfig)) {
for (HierarchicalConfiguration itemConfig : itemsConfig) {
String requiredPermission = getRequiredStringProperty(itemConfig, PERMISSION_CONFIG_KEY);
if (requiredPermission.equals(ANY_PERMISSION_WILDCARD) || permissions.contains(requiredPermission)) {
MenuItem item = new MenuItem();
item.setId(getRequiredStringProperty(itemConfig, ID_CONFIG_KEY));
item.setLabel(getRequiredStringProperty(itemConfig, LABEL_CONFIG_KEY));
item.setIcon(getRequiredStringProperty(itemConfig, ICON_CONFIG_KEY));
menuItems.add(item);
}
}
} else {
throw new ConfigurationException("No menu items found in global menu config");
}
return menuItems;
} else {
return null;
}
}
Aggregations