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

#128 - Adding intuit_tid to FMSException & utilizing in code while th… #153

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,16 @@ public AuthenticationException(Throwable throwable) {
public AuthenticationException(String errorMessage, Throwable throwable) {
super(errorMessage, throwable);
}

/**
* Constructor AuthenticationException
*
* @param errorMessage the error message
* @param throwable the throwable
* @param intuit_tid the transaction id
*/
public AuthenticationException(String errorMessage, Throwable throwable, String intuit_tid) {
super(errorMessage, throwable, intuit_tid);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,16 @@ public AuthorizationException(Throwable throwable) {
public AuthorizationException(String errorMessage, Throwable throwable) {
super(errorMessage, throwable);
}

/**
* Constructor AuthorizationException
*
* @param errorMessage the error message
* @param throwable the throwable
* @param intuit_tid the transaction id
*/
public AuthorizationException(String errorMessage, Throwable throwable, String intuit_tid) {
super(errorMessage, throwable, intuit_tid);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,15 @@ public BadRequestException(Throwable throwable) {
public BadRequestException(String errorMessage, Throwable throwable) {
super(errorMessage, throwable);
}

/**
* Constructor BasRequestException
*
* @param errorMessage the error message
* @param throwable the throwable
* @param intuit_tid the transaction id
*/
public BadRequestException(String errorMessage, Throwable throwable, String intuit_tid) {
super(errorMessage, throwable, intuit_tid);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,17 @@ public CompressionException(Throwable throwable) {
public CompressionException(String errorMessage, Throwable e) {
super(errorMessage, e);
}

/**
* Constructor CompressionException
*
* @param errorMessage
* the error message
* @param e
* the throwable object
* @param intuit_tid the transaction id
*/
public CompressionException(String errorMessage, Throwable e, String intuit_tid) {
super(errorMessage, e, intuit_tid);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,15 @@ public ConfigurationException(Throwable throwable) {
public ConfigurationException(String errorMessage, Throwable throwable) {
super(errorMessage, throwable);
}

/**
* Constructor ConfigurationException
*
* @param errorMessage the error message
* @param throwable the throwable
* @param intuit_tid the transaction id
*/
public ConfigurationException(String errorMessage, Throwable throwable, String intuit_tid) {
super(errorMessage, throwable, intuit_tid);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,41 @@ public FMSException(Throwable throwable) {
super(throwable);
this.throwable = throwable;
}

/**
* Constructor FMSException
*
* @param errorList the list of errors
* @param intuit_tid the transaction id
*/
public FMSException(List<Error> errorList, String intuit_tid) {
super(getString(errorList));
this.errorList = errorList;
this.intuit_tid = intuit_tid;
}

/**
* Constructor FMSException
*
* @param errorMessage the error message
* @param intuit_tid the transaction id
*/
public FMSException(String errorMessage, String intuit_tid) {
super(errorMessage);
this.intuit_tid = intuit_tid;
}

/**
* Constructor FMSException
*
* @param throwable the throwable
* @param intuit_tid the transaction id
*/
public FMSException(Throwable throwable, String intuit_tid) {
super(throwable);
this.throwable = throwable;
this.intuit_tid = intuit_tid;
}

/**
* Constructor FMSException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,15 @@ public InternalServiceException(Throwable throwable) {
public InternalServiceException(String errorMessage, Throwable throwable) {
super(errorMessage, throwable);
}

/**
* Constructor for InternalServiceException
*
* @param errorMessage the error message
* @param throwable the throwable
* @param intuit_tid the transaction id
*/
public InternalServiceException(String errorMessage, Throwable throwable, String intuit_tid) {
super(errorMessage, throwable, intuit_tid);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,15 @@ public InvalidRequestException(Throwable throwable) {
public InvalidRequestException(String errorMessage, Throwable throwable) {
super(errorMessage, throwable);
}

/**
* Constructor InvalidRequestException
*
* @param errorMessage the error message
* @param throwable the throwable
* @param intuit_tid the transaction id
*/
public InvalidRequestException(String errorMessage, Throwable throwable, String intuit_tid) {
super(errorMessage, throwable, intuit_tid);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,15 @@ public InvalidTokenException(Throwable throwable) {
public InvalidTokenException(String errorMessage, Throwable throwable) {
super(errorMessage, throwable);
}

/**
* Constructor InvalidTokenException
*
* @param errorMessage the error message
* @param throwable the throwable
* @param intuit_tid the transaction id
*/
public InvalidTokenException(String errorMessage, Throwable throwable, String intuit_tid) {
super(errorMessage, throwable, intuit_tid);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,15 @@ public SerializationException(Throwable throwable) {
public SerializationException(String errorMessage, Throwable throwable) {
super(errorMessage, throwable);
}

/**
* Constructor SerializationException
*
* @param errorMessage the error message
* @param throwable the throwable
* @param intuit_tid the transaction id
*/
public SerializationException(String errorMessage, Throwable throwable, String intuit_tid) {
super(errorMessage, throwable, intuit_tid);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,16 @@ public ServiceException(Throwable throwable) {
public ServiceException(String errorMessage, Throwable throwable) {
super(errorMessage, throwable);
}

/**
* Constructor ServiceException
*
* @param errorMessage the error message
* @param throwable the throwable
* @param intuit_tid the transaction id
*/
public ServiceException(String errorMessage, Throwable throwable, String intuit_tid) {
super(errorMessage, throwable, intuit_tid);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,15 @@ public ServiceUnavailableException(Throwable throwable) {
public ServiceUnavailableException(String errorMessage, Throwable throwable) {
super(errorMessage, throwable);
}

/**
* Constructor ServiceUnavailableException
*
* @param errorMessage the error message
* @param throwable the throwable
* @param intuit_tid the transaction id
*/
public ServiceUnavailableException(String errorMessage, Throwable throwable, String intuit_tid) {
super(errorMessage, throwable, intuit_tid);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,16 @@ public ValidationException(Throwable throwable) {
public ValidationException(String errorMessage, Throwable throwable) {
super(errorMessage, throwable);
}

/**
* Constructor ValidationException
*
* @param errorMessage the error message
* @param throwable the throwable
* @param intuit_tid the transaction id
*/
public ValidationException(String errorMessage, Throwable throwable, String intuit_tid) {
super(errorMessage, throwable, intuit_tid);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public void execute(IntuitMessage intuitMessage) throws FMSException {
}
} else if (isDownload(intuitMessage.getRequestElements().getAction())) {
LOG.debug("CallbackHandlerInterceptor setting downloadedFile...");
callbackMessage.setDownloadedFile(getDownloadedFile(intuitMessage.getResponseElements().getDecompressedData()));
callbackMessage.setDownloadedFile(getDownloadedFile(intuitMessage.getResponseElements().getDecompressedData(), intuitMessage.getRequestElements().getRequestHeaders().get(RequestElements.HEADER_INTUIT_TID)));
} else if (isDownloadPDF(intuitMessage.getRequestElements().getRequestParameters())) {
LOG.debug("CallbackHandlerInterceptor setting binary content for PDF...");
callbackMessage.setDownloadedFile(intuitMessage.getResponseElements().getResponseBytes());
Expand Down Expand Up @@ -303,16 +303,17 @@ private boolean isDownloadPDF(Map<String, String> requestHeaders) {
* Method to get the input stream from the download URL returned from service
*
* @param response the download URL string
* @param intuit_tid
* @return InputStream the downloaded file
* @throws FMSException
*/
private InputStream getDownloadedFile(String response) throws FMSException {
private InputStream getDownloadedFile(String response, String intuit_tid) throws FMSException {
if (response != null) {
try {
URL url = new URL(response);
return url.openStream();
} catch (Exception e) {
throw new FMSException("Exception while downloading the file from URL.", e);
throw new FMSException("Exception while downloading the file from URL.", e, intuit_tid);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ public void execute(IntuitMessage intuitMessage) throws FMSException {
decompressedData = new String(bytes.toByteArray());
} catch (IllegalStateException e) {
LOG.error("IllegalStateException while get the content from HttpResponse.", e);
throw new FMSException(e);
throw new FMSException(e, intuitMessage.getRequestElements().getRequestHeaders().get(RequestElements.HEADER_INTUIT_TID));
} catch (Exception e) {
LOG.error("IOException in DecompressInterceptor.", e);
throw new FMSException(e);
throw new FMSException(e, intuitMessage.getRequestElements().getRequestHeaders().get(RequestElements.HEADER_INTUIT_TID));
}
}
}
Expand All @@ -90,10 +90,10 @@ public void execute(IntuitMessage intuitMessage) throws FMSException {
}
} catch (IllegalStateException e) {
LOG.error("IllegalStateException while get the content from HttpResponse.", e);
throw new FMSException(e);
throw new FMSException(e, intuitMessage.getRequestElements().getRequestHeaders().get(RequestElements.HEADER_INTUIT_TID));
} catch (Exception e) {
LOG.error("IOException in DecompressInterceptor.", e);
throw new FMSException(e);
throw new FMSException(e, intuitMessage.getRequestElements().getRequestHeaders().get(RequestElements.HEADER_INTUIT_TID));
} finally {
if (br != null) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public void execute(IntuitMessage intuitMessage) throws FMSException {
LOG.info("Invalid Content Type" + serializeFormat);
LOG.debug("Decompressed Data" + responseElements.getDecompressedData());
LOG.error("Decompressed Data" + responseElements.getDecompressedData());
throw new FMSException(responseElements.getDecompressedData());
throw new FMSException(responseElements.getDecompressedData(), intuitMessage.getRequestElements().getRequestHeaders().get(RequestElements.HEADER_INTUIT_TID));

}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void execute(IntuitMessage intuitMessage) throws FMSException {
try {
uri = new URI(intuitRequest.getRequestParameters().get(RequestElements.REQ_PARAM_RESOURCE_URL));
} catch (URISyntaxException e) {
throw new FMSException("URISyntaxException", e);
throw new FMSException("URISyntaxException", e, intuitMessage.getRequestElements().getRequestHeaders().get(RequestElements.HEADER_INTUIT_TID));
}

String methodtype = intuitRequest.getRequestParameters().get(RequestElements.REQ_PARAM_METHOD_TYPE);
Expand All @@ -136,7 +136,7 @@ public void execute(IntuitMessage intuitMessage) throws FMSException {
try {
entity = new StringEntity(intuitRequest.getPostString());
} catch (UnsupportedEncodingException e) {
throw new FMSException("UnsupportedEncodingException", e);
throw new FMSException("UnsupportedEncodingException", e, intuitMessage.getRequestElements().getRequestHeaders().get(RequestElements.HEADER_INTUIT_TID));
}
((HttpPost) httpRequest).setEntity(entity);
}
Expand All @@ -163,7 +163,7 @@ public void execute(IntuitMessage intuitMessage) throws FMSException {
} catch (ClientProtocolException e) {
throw new ConfigurationException("Error in Http Protocol definition", e);
} catch (IOException e) {
throw new FMSException(e);
throw new FMSException(e, intuitMessage.getRequestElements().getRequestHeaders().get(RequestElements.HEADER_INTUIT_TID));
} finally {
if (httpResponse != null) {
try {
Expand Down Expand Up @@ -365,10 +365,10 @@ private void setResponseElements(IntuitMessage intuitMessage, HttpResponse httpR
responseElements.setResponseContent(getCopyOfResponseContent(httpResponse.getEntity().getContent()));
} catch (IllegalStateException e) {
LOG.error("IllegalStateException while get the content from HttpRespose.", e);
throw new FMSException(e);
throw new FMSException(e, intuitMessage.getRequestElements().getRequestHeaders().get(RequestElements.HEADER_INTUIT_TID));
} catch (Exception e) {
LOG.error("IOException in HTTPClientConnectionInterceptor while reading the entity from HttpResponse.", e);
throw new FMSException(e);
throw new FMSException(e, intuitMessage.getRequestElements().getRequestHeaders().get(RequestElements.HEADER_INTUIT_TID));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ public void execute(IntuitMessage intuitMessage) throws FMSException {
setResponseElements(intuitMessage, httpUrlConnection);

} catch (URISyntaxException e) {
throw new FMSException("URISyntaxException", e);
throw new FMSException("URISyntaxException", e, intuitMessage.getRequestElements().getRequestHeaders().get(RequestElements.HEADER_INTUIT_TID));
} catch (IOException e) {
throw new FMSException("IO Exception", e);
throw new FMSException("IO Exception", e, intuitMessage.getRequestElements().getRequestHeaders().get(RequestElements.HEADER_INTUIT_TID));
} catch(Throwable e){
throw new FMSException("Unexpected expection", e);
throw new FMSException("Unexpected expection", e, intuitMessage.getRequestElements().getRequestHeaders().get(RequestElements.HEADER_INTUIT_TID));
}
finally{
// Make sure to always disconnect.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void execute(IntuitMessage intuitMessage) throws FMSException {
throw new AuthorizationException(fault.getError());
} else {
//not able to recognize the type of exception
throw new FMSException(fault.getError());
throw new FMSException(fault.getError(), intuitMessage.getRequestElements().getRequestHeaders().get(RequestElements.HEADER_INTUIT_TID));
}
} else if (intuitResponse == null) {
//intuitResponse is null means that message received contains error as message
Expand Down