/** * 查找需要拦截的所有url规则 * * @return */ public List<String> getAllInterceptorUrls() throws DaoException, SystemException, ServiceException { List<String> markUrls = Lists.newArrayList(); // 查找所有资源 // List<Resource> resources = this.findBy("NEI_status",StatusState.delete.getValue()); List<Resource> resources = this.getAll(); for (Resource resource : resources) { if (StringUtils.isNotBlank(resource.getMarkUrl())) { markUrls.add(resource.getMarkUrl()); } } return markUrls; }
/** * Resource转TreeNode * * @param resource 资源 * @param resourceType 资源类型 * @param isCascade 是否级联 * @return * @throws DaoException * @throws SystemException * @throws ServiceException */ private TreeNode resourceToTreeNode(Resource resource, Integer resourceType, boolean isCascade) throws DaoException, SystemException, ServiceException { if (resourceType != null) { if (!resourceType.equals(resource.getType())) { return null; } } TreeNode treeNode = new TreeNode(resource.getId().toString(), resource.getName(), resource.getIconCls()); // 自定义属性 url Map<String, Object> attributes = Maps.newHashMap(); attributes.put("url", resource.getUrl()); attributes.put("markUrl", resource.getMarkUrl()); attributes.put("code", resource.getCode()); attributes.put("type", resource.getType()); treeNode.setAttributes(attributes); if (isCascade) { List<TreeNode> childrenTreeNodes = Lists.newArrayList(); for (Resource subResource : resource.getSubResources()) { TreeNode node = resourceToTreeNode(subResource, resourceType, isCascade); if (node != null) { childrenTreeNodes.add(node); } } treeNode.setChildren(childrenTreeNodes); } return treeNode; }