From 661c6b469d811e252611ae074124b934ca32046b Mon Sep 17 00:00:00 2001 From: Yuriy Artamonov Date: Thu, 12 Feb 2015 11:48:58 +0000 Subject: [PATCH] Include for specific permissions config leads to bug in RoleEditor UI #PL-4840 --- .../cuba/gui/config/PermissionConfig.java | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/modules/gui/src/com/haulmont/cuba/gui/config/PermissionConfig.java b/modules/gui/src/com/haulmont/cuba/gui/config/PermissionConfig.java index 09220389ff..b956109b43 100644 --- a/modules/gui/src/com/haulmont/cuba/gui/config/PermissionConfig.java +++ b/modules/gui/src/com/haulmont/cuba/gui/config/PermissionConfig.java @@ -18,6 +18,7 @@ import com.haulmont.cuba.gui.security.entity.AttributeTarget; import com.haulmont.cuba.gui.security.entity.BasicPermissionTarget; import com.haulmont.cuba.gui.security.entity.MultiplePermissionTarget; import com.haulmont.cuba.gui.security.entity.OperationPermissionTarget; +import org.apache.commons.collections.CollectionUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringEscapeUtils; import org.apache.commons.lang.StringUtils; @@ -236,10 +237,24 @@ public class PermissionConfig { String id = elem.attributeValue("id"); String caption = getMessage("permission-config." + id); if ("category".equals(elem.getName())) { - Node n = new Node<>( - new BasicPermissionTarget("category:" + id, caption, null)); - node.addChild(n); - walkSpecific(elem, n); + Node existingCategory = null; + String categoryPermissionId = "category:" + id; + for (Node subNode : node.getChildren()) { + if (categoryPermissionId.equals(subNode.getData().getId())) { + existingCategory = subNode; + break; + } + } + + Node categoryNode; + if (existingCategory == null) { + categoryNode = new Node<>(new BasicPermissionTarget(categoryPermissionId, caption, null)); + node.addChild(categoryNode); + } else { + categoryNode = existingCategory; + } + + walkSpecific(elem, categoryNode); } else if ("permission".equals(elem.getName())) { Node n = new Node<>( new BasicPermissionTarget("permission:" + id, caption, id));