Source:
private Map<QuestionGroupDto, List<QuestionDto>> fetchQuestionMap( boolean usingPublishedForm, String surveyId, String serverBaseUrl, String apiKey, String s3FormDir, List<QuestionGroupDto> groupList) throws Exception { Map<QuestionGroupDto, List<QuestionDto>> questionMap = null; if (!usingPublishedForm) { questionMap = loadAllQuestions(surveyId, performGeoRollup, serverBaseUrl, apiKey); loadQuestionOptions(surveyId, serverBaseUrl, questionMap, apiKey); } else { String fileName = s3FormDir + "/" + surveyId + ".zip"; String formXml = null; try { final URL url = new URL(fileName); final URLConnection conn = url.openConnection(); final BufferedInputStream deviceZipFileInputStream = new BufferedInputStream(conn.getInputStream()); final ZipInputStream formFileStream = new ZipInputStream(deviceZipFileInputStream); formXml = ZipUtil.unZipFile(surveyId + ".xml", formFileStream); } catch (IOException e) { log.error("Error getting form XML file: " + e.getMessage(), e); return null; } SurveyDto formDto = PublishedForm.parse(formXml).toDto(); questionMap = new HashMap<>(); rollupOrder = new ArrayList<QuestionDto>(); boolean anyQuestionsWithoutVariableNames = false; for (QuestionGroupDto qgd : formDto.getQuestionGroupList()) { List<QuestionDto> qList = new ArrayList<>(); for (QuestionDto dto : qgd.getQuestionMap().values()) { qList.add(dto); if (dto.getVariableName() == null) { anyQuestionsWithoutVariableNames = true; } if (performGeoRollup) { for (int i = 0; i < ROLLUP_QUESTIONS.length; i++) { if (ROLLUP_QUESTIONS[i].equalsIgnoreCase(dto.getText())) { rollupOrder.add(dto); } } } } questionMap.put(qgd, qList); groupList.add(qgd); } if (variableNamesInHeaders && anyQuestionsWithoutVariableNames) { loadVariableNames(surveyId, serverBaseUrl, questionMap, apiKey); } } return questionMap; }

Target:
private Map<QuestionGroupDto, List<QuestionDto>> fetchQuestionMap( boolean usingPublishedForm, String surveyId, String serverBaseUrl, String apiKey, String s3FormDir, List<QuestionGroupDto> groupList) throws Exception { Map<QuestionGroupDto, List<QuestionDto>> questionMap = null; if (!usingPublishedForm) { questionMap = loadAllQuestions(surveyId, performGeoRollup, serverBaseUrl, apiKey); loadQuestionOptions(surveyId, serverBaseUrl, questionMap, apiKey); } else { String fileName = s3FormDir + "/" + surveyId + ".zip"; String formXml = null; final URL url = new URL(fileName); log.debug("Getting form XML from " + url); final URLConnection conn = url.openConnection(); final BufferedInputStream deviceZipFileInputStream = new BufferedInputStream(conn.getInputStream()); final ZipInputStream formFileStream = new ZipInputStream(deviceZipFileInputStream); formXml = ZipUtil.unZipFile(surveyId + ".xml", formFileStream); SurveyDto formDto = PublishedForm.parse(formXml).toDto(); questionMap = new HashMap<>(); rollupOrder = new ArrayList<QuestionDto>(); boolean anyQuestionsWithoutVariableNames = false; for (QuestionGroupDto qgd : formDto.getQuestionGroupList()) { List<QuestionDto> qList = new ArrayList<>(); for (QuestionDto dto : qgd.getQuestionMap().values()) { qList.add(dto); if (dto.getVariableName() == null) { anyQuestionsWithoutVariableNames = true; } if (performGeoRollup) { for (int i = 0; i < ROLLUP_QUESTIONS.length; i++) { if (ROLLUP_QUESTIONS[i].equalsIgnoreCase(dto.getText())) { rollupOrder.add(dto); } } } } questionMap.put(qgd, qList); groupList.add(qgd); } if (variableNamesInHeaders && anyQuestionsWithoutVariableNames) { loadVariableNames(surveyId, serverBaseUrl, questionMap, apiKey); } } return questionMap; }