Skip to content

Commit

Permalink
Merge pull request #526 from iostream04/sb-11246
Browse files Browse the repository at this point in the history
SB-11246 : adding all the duplicate dailcode in error message
  • Loading branch information
rahul-tarento authored Mar 22, 2019
2 parents a09ce71 + 7152693 commit e50f853
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
Expand Down Expand Up @@ -590,6 +591,7 @@ private Map<String, Object> readAndValidateCSV(InputStream inputStream) throws I
List<CSVRecord> csvRecords = csvFileParser.getRecords();
validateCSV(csvRecords);
Set<String> dialCodes = new HashSet<>();
Set<String> duplicateDialCodes = new LinkedHashSet<>();
Map<String, List<String>> dialCodeIdentifierMap = new HashMap<>();
Set<String> topics = new HashSet<>();
StringBuilder exceptionMsgs = new StringBuilder();
Expand All @@ -614,10 +616,7 @@ private Map<String, Object> readAndValidateCSV(InputStream inputStream) throws I
dialCodeList = new ArrayList<String>(Arrays.asList(dialCode.split(",")));
for (String dCode : dialCodeList) {
if (!dialCodes.add(dCode.trim())) {
throwClientErrorException(
ResponseCode.errorDduplicateDialCodeEntry,
MessageFormat.format(
ResponseCode.errorDduplicateDialCodeEntry.getErrorMessage(), dialCode));
duplicateDialCodes.add(dCode.trim());
}
}
}
Expand Down Expand Up @@ -654,6 +653,13 @@ private Map<String, Object> readAndValidateCSV(InputStream inputStream) throws I
rows.add(map);
}
}
if (CollectionUtils.isNotEmpty(duplicateDialCodes)) {
throwClientErrorException(
ResponseCode.errorDduplicateDialCodeEntry,
MessageFormat.format(
ResponseCode.errorDduplicateDialCodeEntry.getErrorMessage(),
StringUtils.join(duplicateDialCodes, ",")));
}
if (StringUtils.isNotBlank(exceptionMsgs.toString())) {
ProjectCommonException.throwClientErrorException(
ResponseCode.customClientError, exceptionMsgs.toString());
Expand Down

0 comments on commit e50f853

Please sign in to comment.