Skip to content

Commit 0ce89a4

Browse files
committed
fixed multi value restrictions
1 parent 3caccd0 commit 0ce89a4

File tree

1 file changed

+12
-4
lines changed
  • app/aem/actions.main/src/main/java/com/cognifide/apm/main/permissions

1 file changed

+12
-4
lines changed

app/aem/actions.main/src/main/java/com/cognifide/apm/main/permissions/Restrictions.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ private void addRestriction(ValueFactory valueFactory, Map<String, Value> result
9494
if (REP_GLOB_PROPERTY.equals(key)) {
9595
result.put(key, normalizeGlob(valueFactory));
9696
} else {
97-
result.put(key, valueFactory.createValue(value, PropertyType.NAME));
97+
result.put(key, valueFactory.createValue(value, determinePropertyType(key)));
9898
}
9999
}
100100
}
@@ -126,18 +126,26 @@ public Map<String, Value[]> getMultiValueRestrictions(ValueFactory valueFactory)
126126

127127
private void addRestrictions(ValueFactory valueFactory, Map<String, Value[]> result, String key, List<String> names) throws ValueFormatException {
128128
if (names != null && !names.isEmpty()) {
129-
result.put(key, createRestrictions(valueFactory, names));
129+
result.put(key, createRestrictions(valueFactory, names, determinePropertyType(key)));
130130
}
131131
}
132132

133-
private Value[] createRestrictions(ValueFactory valueFactory, List<String> names) throws ValueFormatException {
133+
private Value[] createRestrictions(ValueFactory valueFactory, List<String> names, int propertyType) throws ValueFormatException {
134134
Value[] values = new Value[names.size()];
135135
for (int index = 0; index < names.size(); index++) {
136-
values[index] = valueFactory.createValue(names.get(index), PropertyType.NAME);
136+
values[index] = valueFactory.createValue(names.get(index), propertyType);
137137
}
138138
return values;
139139
}
140140

141+
private int determinePropertyType(String key) {
142+
if (StringUtils.equalsAny(key, REP_NT_NAMES_PROPERTY, REP_ITEM_NAMES_PROPERTY)) {
143+
return PropertyType.NAME;
144+
} else {
145+
return PropertyType.STRING;
146+
}
147+
}
148+
141149
private boolean isMultivalue(Map.Entry<String, Object> entry) {
142150
boolean result;
143151
if (REP_GLOB_PROPERTY.equals(entry.getKey())) {

0 commit comments

Comments
 (0)