public CreditRequest getCreditRequest() { if (creditRequest == null) { if (FacesContext.getCurrentInstance().isPostback()) { creditRequest = new CreditRequest(); creditRequest.setMoney(new Money()); creditRequest.setDuration(new Duration()); } else { String requestId = FacesContext.getCurrentInstance() .getExternalContext() .getRequestParameterMap() .get("requestId"); if (requestId == null) { throw new IllegalStateException("no credit request id set to update"); } try { creditRequest = contractManagement.getContract(requestId); if (creditRequest.getState() != CreditRequestState.Offer) { throw new IllegalStateException("try to update credit request not in offer state"); } } catch (Exception e) { e.printStackTrace(); } } } return creditRequest; }
public void updateCreditRequest() { LOG.info("updateCreditRequest"); getCreditRequest().setState(CreditRequestState.Update); LOG.info(Data.encodeToXml(creditRequest)); String requestId = creditApprovalProcess.process(creditRequest); creditRequest = contractManagement.getContract(requestId); }