Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change getAllPropertyNames to return empty string/JSON array if type invalid #3548

Merged
merged 6 commits into from
Aug 18, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1176,10 +1176,10 @@ private boolean hasProperty(Token token, String name) {
* @throws ParserException
*/
private String getAllPropertyNames(String type, String delim) throws ParserException {
ArrayList<String> namesList = new ArrayList<String>();
if (type == null || type.length() == 0 || type.equals("*")) {
Map<String, List<TokenProperty>> pmap =
MapTool.getCampaign().getCampaignProperties().getTokenTypeMap();
ArrayList<String> namesList = new ArrayList<String>();

for (Entry<String, List<TokenProperty>> entry : pmap.entrySet()) {
for (TokenProperty tp : entry.getValue()) {
Expand All @@ -1196,14 +1196,11 @@ private String getAllPropertyNames(String type, String delim) throws ParserExcep
} else {
List<TokenProperty> props =
MapTool.getCampaign().getCampaignProperties().getTokenPropertyList(type);
if (props == null) {
throw new ParserException(
I18N.getText(
"macro.function.tokenProperty.unknownPropType", "getAllPropertyNames", type));
}
ArrayList<String> namesList = new ArrayList<String>();
for (TokenProperty tp : props) {
namesList.add(tp.getName());
// If property type not found return an empty string or JSON array
if (props != null) {
for (TokenProperty tp : props) {
namesList.add(tp.getName());
}
}
if ("json".equals(delim)) {
JsonArray jarr = new JsonArray();
Expand Down