Skip to content

Commit 8f8665e

Browse files
author
Chris Wiechmann
committed
Error-Handling improved
if Custom-Property configuration is invalid.
1 parent 9130979 commit 8f8665e

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

modules/apim-adapter/src/main/java/com/axway/apim/lib/CoreParameters.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static Mode valueOfDefault(String key) {
8282

8383
private Boolean replaceHostInSwagger = true;
8484

85-
private Boolean rollback = false;
85+
private Boolean rollback = true;
8686

8787
private String confDir;
8888

@@ -280,11 +280,12 @@ public void setReplaceHostInSwagger(Boolean replaceHostInSwagger) {
280280
this.replaceHostInSwagger = replaceHostInSwagger;
281281
}
282282

283-
public boolean isRollback() {
283+
public Boolean isRollback() {
284284
return rollback;
285285
}
286286

287-
public void setRollback(boolean rollback) {
287+
public void setRollback(Boolean rollback) {
288+
if(rollback==null) return;
288289
this.rollback = rollback;
289290
}
290291

modules/apis/src/main/java/com/axway/apim/apiimport/APIImportConfigAdapter.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -533,15 +533,19 @@ private void validateCustomProperties(API apiConfig) throws AppException {
533533
if(propType!=null && ( propType.asText().equals("select") || propType.asText().equals("switch") )) {
534534
boolean valueFound = false;
535535
ArrayNode selectOptions = (ArrayNode)configuredProp.get("options");
536+
if(selectOptions==null) {
537+
LOG.warn("Skipping custom property validation, as the custom-property: '" + propertyKey + "' with type: " + propType.asText() + " has no options configured. Please check your custom properties configuration.");
538+
break;
539+
}
536540
for(JsonNode option : selectOptions) {
537541
if(option.at("/value").asText().equals(propertyValue)) {
538542
valueFound = true;
539543
break;
540544
}
541545
}
542546
if(!valueFound) {
543-
ErrorState.getInstance().setError("The value: '" + propertyValue + "' isn't configured for custom property: '" + propertyKey + "'", ErrorCode.CANT_READ_CONFIG_FILE, false);
544-
throw new AppException("The value: '" + propertyValue + "' isn't configured for custom property: '" + propertyKey + "'", ErrorCode.CANT_READ_CONFIG_FILE);
547+
ErrorState.getInstance().setError("The value: '" + propertyValue + "' is not a valid option for custom property: '" + propertyKey + "'", ErrorCode.CANT_READ_CONFIG_FILE, false);
548+
throw new AppException("The value: '" + propertyValue + "' is not a valid option for custom property: '" + propertyKey + "'", ErrorCode.CANT_READ_CONFIG_FILE);
545549
}
546550
}
547551
}

0 commit comments

Comments
 (0)