Skip to content

Commit

Permalink
Merge pull request #117 from peggy-ntt/sftp-mdc
Browse files Browse the repository at this point in the history
sftp mdc
  • Loading branch information
alexjoybc authored Sep 10, 2019
2 parents f1a7a69 + 0c0d2da commit 9324073
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package ca.bc.gov.open.jrccaccess.autoconfigure.plugins.sftp;

import ca.bc.gov.open.jrccaccess.autoconfigure.common.Constants;
import ca.bc.gov.open.jrccaccess.autoconfigure.services.DocumentReadyHandler;
import ca.bc.gov.open.jrccaccess.libs.TransactionInfo;
import ca.bc.gov.open.jrccaccess.libs.services.exceptions.DocumentFilenameMissingException;
import ca.bc.gov.open.jrccaccess.libs.services.exceptions.DocumentMessageException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHeaders;
import org.springframework.stereotype.Component;
Expand Down Expand Up @@ -46,12 +48,17 @@ public void handleMessage(Message<InputStream> message) throws DocumentMessageEx
logger.debug("Attempting to get file name");
String fileName = getFilename(message);
logger.info("Successfully get file name.");
MDC.put(Constants.MDC_KEY_FILENAME, fileName);
TransactionInfo transactionInfo = new TransactionInfo(fileName,"sftp", LocalDateTime.now());
logger.debug("Attempting to handler document content");
this.documentReadyHandler.handle(content, transactionInfo);
logger.info("successfully handled incoming document.");
MDC.clear();
} catch (IOException e) {
throw new DocumentMessageException(MessageFormat.format("Sftp Input Plugin error while reading the file.{0},{1}.",e.getMessage(),e.getCause()));
String logMsg = MessageFormat.format("Sftp Input Plugin error while reading the file.{0},{1}.",e.getMessage(),e.getCause());
logger.error(logMsg);
MDC.clear();
throw new DocumentMessageException(logMsg);
}

}
Expand Down

0 comments on commit 9324073

Please sign in to comment.