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

ODK form not found exception handling #39

Merged
merged 2 commits into from
May 31, 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
16 changes: 13 additions & 3 deletions src/main/java/com/uci/transformer/odk/ODKConsumerReactive.java
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ public void accept(XMessage transformedMessage) {
});
} catch (JAXBException e) {
e.printStackTrace();
} catch (NullPointerException e) {
log.error("An error occured : "+e.getMessage() + " at line no : "+ e.getStackTrace()[0].getLineNumber()
+" in class : "+e.getStackTrace()[0].getClassName());
} catch (Exception e) {
e.printStackTrace();
}
Expand Down Expand Up @@ -210,8 +213,10 @@ public Mono<XMessage> transform(XMessage xMessage) throws Exception {
log.info("current form ID:"+formID);
String formPath = getFormPath(formID);
log.info("current form path:"+formPath);

isStartingMessage = xMessage.getPayload().getText().equals(getTransformerMetaDataValue(transformer, "startingMessage"));
if(formPath == null ){
return null;
}
isStartingMessage = xMessage.getPayload().getText() == null ? false : xMessage.getPayload().getText().equals(getTransformerMetaDataValue(transformer, "startingMessage"));
Boolean addOtherOptions = xMessage.getProvider().equals("sunbird") ? true : false;

// Get details of user from database
Expand Down Expand Up @@ -713,7 +718,12 @@ private XMessage getMessageFromResponse(XMessage xMessage, ServiceResponse respo

public static String getFormPath(String formID) {
FormsDao dao = new FormsDao(JsonDB.getInstance().getDB());
return dao.getFormsCursorForFormId(formID).getFormFilePath();
try{
return dao.getFormsCursorForFormId(formID).getFormFilePath();
} catch (NullPointerException ex){
log.info("ODK form not found '"+formID+"'");
return null;
}
}

private Mono<GupshupMessageEntity> appendNewResponse(String formID, XMessage xMessage, ServiceResponse response) {
Expand Down