Skip to content

Instantly share code, notes, and snippets.

@asilchev
Created November 13, 2014 08:05
Show Gist options
  • Save asilchev/1890bb2d1e0198bdbd36 to your computer and use it in GitHub Desktop.
Save asilchev/1890bb2d1e0198bdbd36 to your computer and use it in GitHub Desktop.
@RequestMapping(value = "/AE_askForCode",
method = RequestMethod.POST,
produces = "application/json; charset=UTF-8")
@ResponseBody
public BaseResponse getCode(@RequestParam(value = "contractId") long contractId) throws UnauthorizedException {
checkUserAuthentication();
String remoteAddress = getIpAddress();
String serial = getSerialNumber();
BaseResponse passMealResponse;
String userId = getUserId();
passMealDBLogger.logRequestCode(userId, contractId, remoteAddress, serial, getPlatform(), getMacAddress());
try {
passMealDBLogger.logOuterAction(PassMealOuterMethodType.SEND_LINKING_TOKEN_BY_CONTRACT_ID, remoteAddress, serial);
SendLinkingTokenByContractId sendLinkingTokenByContractId = new SendLinkingTokenByContractId();
sendLinkingTokenByContractId.setContractId(contractId);
JAXBElement<SendLinkingTokenByContractIdResponse> jaxbElement = (JAXBElement<SendLinkingTokenByContractIdResponse>)
webServiceTemplate.marshalSendAndReceive(sendLinkingTokenByContractId);
SendLinkingTokenByContractIdResponse response = jaxbElement.getValue();
Result returnData = response.getReturn();
if (RESULT_OK.equals(returnData.getResultCode())) {
passMealResponse = new AskForCodeResponse(returnData.getDescription());
} else {
passMealDBLogger.logError(PassMealErrorType.SEND_TOKEN_FAULT_CODE, remoteAddress, serial);
String reason = ERROR_CODE_110.equals(returnData.getResultCode()) ? messageSource.getMessage(ACCOUNT_IS_NOT_FOUND_KEY, null, null) : returnData.getDescription();
passMealResponse = new PassMealResponseFault(reason);
}
} catch (Exception e) {
passMealResponse = getExceptionResponse(e, PassMealMethodName.SEND_TOKEN);
}
return passMealResponse;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment