diff --git a/src/main/java/org/codelibs/fess/helper/LabelTypeHelper.java b/src/main/java/org/codelibs/fess/helper/LabelTypeHelper.java index 3e3f3c8978..9ade4d75ee 100644 --- a/src/main/java/org/codelibs/fess/helper/LabelTypeHelper.java +++ b/src/main/java/org/codelibs/fess/helper/LabelTypeHelper.java @@ -15,6 +15,8 @@ */ package org.codelibs.fess.helper; +import static org.codelibs.core.stream.StreamUtil.stream; + import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -23,6 +25,7 @@ import java.util.Map; import java.util.Set; import java.util.regex.Pattern; +import java.util.stream.Collectors; import javax.annotation.PostConstruct; import javax.annotation.Resource; @@ -38,8 +41,6 @@ public class LabelTypeHelper { private static final Logger logger = LoggerFactory.getLogger(LabelTypeHelper.class); - private static final long serialVersionUID = 1L; - @Resource protected RoleQueryHelper roleQueryHelper; @@ -67,7 +68,7 @@ private void buildLabelTypeItems(final List labelTypeList) { final LabelTypeItem item = new LabelTypeItem(); item.setLabel(labelType.getName()); item.setValue(labelType.getValue()); - item.setRoleValueList(labelType.getRoleValueList()); + item.setPermissions(labelType.getPermissions()); itemList.add(item); } labelTypeItemList = itemList; @@ -82,15 +83,18 @@ public List> getLabelTypeItemList() { final Set roleSet = roleQueryHelper.build(); if (roleSet.isEmpty()) { for (final LabelTypeItem item : labelTypeItemList) { - final Map map = new HashMap<>(2); - map.put(Constants.ITEM_LABEL, item.getLabel()); - map.put(Constants.ITEM_VALUE, item.getValue()); - itemList.add(map); + if (item.getPermissions().length == 0) { + final Map map = new HashMap<>(2); + map.put(Constants.ITEM_LABEL, item.getLabel()); + map.put(Constants.ITEM_VALUE, item.getValue()); + itemList.add(map); + } } } else { for (final LabelTypeItem item : labelTypeItemList) { + final Set permissions = stream(item.getPermissions()).get(stream -> stream.collect(Collectors.toSet())); for (final String roleValue : roleSet) { - if (item.getRoleValueList().contains(roleValue)) { + if (permissions.contains(roleValue)) { final Map map = new HashMap<>(2); map.put(Constants.ITEM_LABEL, item.getLabel()); map.put(Constants.ITEM_VALUE, item.getValue()); @@ -145,7 +149,7 @@ protected static class LabelTypeItem { private String value; - private List roleValueList; + private String[] permissions; public String getLabel() { return label; @@ -163,12 +167,12 @@ public void setValue(final String value) { this.value = value; } - public List getRoleValueList() { - return roleValueList; + public String[] getPermissions() { + return permissions; } - public void setRoleValueList(final List roleValueList) { - this.roleValueList = roleValueList; + public void setPermissions(String[] permissions) { + this.permissions = permissions; } }