/** * if contains one category (and at least one table is menu object), will return true; * * @param request * @param subSystemId * @return */ private boolean containsViewableChildren(HttpServletRequest request, SubSystem ss) { // Create categories and their tables in hashtable TableManager manager = TableManager.getInstance(); // Iterator tables = manager.getAllTables().iterator(); // Hashtable categories = new Hashtable(50,20); // key:Integer(category id), values :List of // table Integer tableCategoryId; Table table; WebAction action; ArrayList cats = new ArrayList(); Connection conn = null; try { UserWebImpl userWeb = ((UserWebImpl) WebUtils.getSessionContextManager(request.getSession()) .getActor(nds.util.WebKeys.USER)); conn = QueryEngine.getInstance().getConnection(); HashMap webActionEnv = new HashMap(); webActionEnv.put("connection", conn); webActionEnv.put("httpservletrequest", request); webActionEnv.put("userweb", userWeb); List categories = ss.children(); for (int i = 0; i < categories.size(); i++) { Object o = categories.get(i); // TableCategory or WebAction if (o instanceof TableCategory) { TableCategory tc = (TableCategory) o; List children = tc.children(); ArrayList catschild = new ArrayList(); for (int j = 0; j < children.size(); j++) { if (children.get(j) instanceof Table) { table = (Table) children.get(j); if (!table.isMenuObject()) { continue; } try { WebUtils.checkTableQueryPermission(table.getName(), request); } catch (NDSSecurityException e) { continue; } // table is ok for current user to list return true; } else if (children.get(j) instanceof WebAction) { action = (WebAction) children.get(j); if (action.canDisplay(webActionEnv)) return true; } else { throw new NDSRuntimeException( "Unsupported element in TableCategory children:" + children.get(j).getClass()); } } } else if (o instanceof WebAction) { if (((WebAction) o).canDisplay(webActionEnv)) { return true; } } else { throw new NDSException( "Unexpected class in subsystem (id=" + ss.getId() + "), class is " + o.getClass()); } } } catch (Throwable t) { logger.error("Fail to load subsystem tree", t); } finally { try { if (conn != null) conn.close(); } catch (Throwable e) { } } return false; }