Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

Commit e993fc6

Browse files
author
jamesdotcom
committed
Merge pull request #117 from appirio-tech/dev
admin fee
2 parents 1183d70 + 085bbd9 commit e993fc6

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/java/main/com/topcoder/direct/services/view/action/contest/launch/SaveDraftContestAction.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,31 @@ public boolean evaluate(Object object) {
10031003
ProjectPropertyType.DR_POINTS_PROJECT_PROPERTY_KEY, "0"
10041004
);
10051005
}
1006+
1007+
// guard check if the admin fee is set to a positive double value
1008+
if(softwareCompetition.getProjectHeader().getProperties().containsKey(ProjectPropertyType.ADMIN_FEE_PROJECT_PROPERTY_KEY)) {
1009+
String adminFeeStrValue = softwareCompetition.getProjectHeader().getProperties().get(ProjectPropertyType.ADMIN_FEE_PROJECT_PROPERTY_KEY);
1010+
if(adminFeeStrValue != null && adminFeeStrValue.trim().length() > 0) {
1011+
// try parsing the string value to double value
1012+
try {
1013+
double adminFeeDoubleValue = Double.parseDouble(adminFeeStrValue);
1014+
1015+
if (adminFeeDoubleValue < 0) {
1016+
throw new IllegalArgumentException(
1017+
String.format("The admin fee value [%s] should be positive", adminFeeDoubleValue));
1018+
}
1019+
1020+
if (Double.isNaN(adminFeeDoubleValue)) {
1021+
throw new IllegalArgumentException(
1022+
String.format("The admin fee value [%s] should not be NaN", adminFeeDoubleValue));
1023+
}
1024+
1025+
} catch (NumberFormatException nfe) {
1026+
throw new IllegalArgumentException(
1027+
String.format("The admin fee value [%s] is not a valid number", adminFeeStrValue));
1028+
}
1029+
}
1030+
}
10061031
}
10071032

10081033
/**

0 commit comments

Comments
 (0)