{
try
{
SystemConfigManager systemConfigManager = (SystemConfigManager) SpringTools.getBean(SystemConfigManager.ID);
PermissionManager permissionManager = (PermissionManager) SpringTools.getBean(PermissionManager.ID);
ModelResponse res = req.createResponse();
boolean byGroups = NumberTools.toBool(req.getParameter("byGroups"), false);
readConfig(req);
int itemsPerRow = 3;
if ("toolBar".equals(style))
{
itemsPerRow = 16;
}
String currentItem = (String) UserTools.getContextObject(req, "aktera.currentMenuItem");
if (currentItem == null && UserTools.currentUserIsInGroup(req, "admin"))
{
currentItem = (String) systemConfigManager.get("system", "startMenuItemAdmin");
}
if (currentItem == null && UserTools.currentUserIsInGroup(req, "manager"))
{
currentItem = (String) systemConfigManager.get("system", "startMenuItemManager");
}
if (currentItem == null && UserTools.getCurrentUserId(req) != null)
{
currentItem = (String) systemConfigManager.get("system", "startMenuItem");
}
Output outFunctions = res.createOutput("functions");
if (! byGroups)
{
outFunctions.setAttribute("style", style == null ? "none" : style);
res.add(outFunctions);
}
String title = getConfiguration().getChild("title").getValue("functions");
outFunctions.setAttribute("title", title);
String bundle = getConfiguration().getChild("bundle").getValue("Aktera");
outFunctions.setAttribute("bundle", bundle);
Map<String, List<Command>> tmpMenuGroups = new Hashtable();
int num = 0;
for (Iterator i = functions.iterator(); i.hasNext();)
{
FunctionItem item = (FunctionItem) i.next();
if (item.feature != null && ! LicenseTools.getLicenseInfo().hasFeature(item.feature))
{
continue;
}
if (item.check != null && ! CheckerTools.check(item.check, req, new Properties()))
{
continue;
}
if (item.role != null && ! UserTools.currentUserIsInGroup(req, "admin")
&& ! UserTools.currentUserIsInGroup(req, item.role))
{
continue;
}
if (item.permission != null)
{
boolean hasPermission = false;
for (String p : item.permission.split("\\|"))
{
if (permissionManager.hasPermission(UserTools.getCurrentUserName(req), p))
{
hasPermission = true;
break;
}