Skip to content

Commit

Permalink
Merge pull request #894 from sheiksalahudeen/release-2.1
Browse files Browse the repository at this point in the history
Handled Exception while doing batch export.
  • Loading branch information
sheiksalahudeen authored Sep 27, 2016
2 parents 28d0d7f + c5f1668 commit e878595
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public class BatchExportFailureReportProcessor extends OleNGReportProcessor {

@Override
public void process(Object object, String directoryToWrite) throws Exception {
OleNGBatchExportResponse oleNGBatchDeleteResponse = (OleNGBatchExportResponse) object;
List<ExportFailureResponse> exportFailureResponses = oleNGBatchDeleteResponse.getExportFailureResponses();
OleNGBatchExportResponse oleNGBatchExportResponse = (OleNGBatchExportResponse) object;
List<ExportFailureResponse> exportFailureResponses = oleNGBatchExportResponse.getExportFailureResponses();
if (CollectionUtils.isNotEmpty(exportFailureResponses)) {
String exportFailureMessages = new ObjectMapper().defaultPrettyPrintingWriter().writeValueAsString(exportFailureResponses);
logMessage(directoryToWrite, "BatchExport-FailureMessages", "txt", exportFailureMessages, false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ public Object doInTransaction(TransactionStatus status) {
}
});
} catch (Exception ex) {
throw ex;
ex.printStackTrace();
batchExportHandler.addBatchExportFailureResponseToExchange(ex, null, batchProcessTxObject.getExchangeObjectForBatchExport());
} finally {
this.transactionManager = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,10 +149,9 @@ private void prepareBatchExportResponse(List<Future> futures, BatchExportHandler
batchProcessTxObject.getBatchJobDetails().setTotalRecordsProcessed(String.valueOf(originalResponse.getNoOfSuccessRecords() + originalResponse.getNoOfFailureRecords()));
batchExportHandler.updateBatchJob(batchProcessTxObject.getBatchJobDetails());
}
} catch (InterruptedException e) {
e.printStackTrace();
} catch (ExecutionException e) {
} catch (Exception e) {
e.printStackTrace();
batchExportHandler.addBatchExportFailureResponseToExchange(e, null, batchProcessTxObject.getExchangeObjectForBatchExport());
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,30 @@ public class BatchExportHandler extends BatchExportUtil {
private ExportDao exportDao = (ExportDao) SpringContext.getBean("exportDao");

public void processExport(BatchProcessTxObject batchProcessTxObject, OleNGBatchExportResponse oleNGBatchExportResponse) {
String exportScope = batchProcessTxObject.getBatchProcessProfile().getExportScope();
if (StringUtils.isNotBlank(exportScope)) {
switch (exportScope) {
case OleNGConstants.FULL_EXPORT:
processFullExport(batchProcessTxObject, oleNGBatchExportResponse);
break;
case OleNGConstants.FULL_EXCEPT_STAFF_ONLY:
processFullExceptStaffOnly(batchProcessTxObject, oleNGBatchExportResponse);
break;
case OleNGConstants.INCREMENTAL:
processIncremental(batchProcessTxObject, oleNGBatchExportResponse);
break;
case OleNGConstants.INCREMENTAL_EXCEPT_STAFF_ONLY:
processIncrementalExceptStaffOnly(batchProcessTxObject, oleNGBatchExportResponse);
break;
case OleNGConstants.FILTER:
processFilterExport(batchProcessTxObject, oleNGBatchExportResponse);
break;
try {
String exportScope = batchProcessTxObject.getBatchProcessProfile().getExportScope();
if (StringUtils.isNotBlank(exportScope)) {
switch (exportScope) {
case OleNGConstants.FULL_EXPORT:
processFullExport(batchProcessTxObject, oleNGBatchExportResponse);
break;
case OleNGConstants.FULL_EXCEPT_STAFF_ONLY:
processFullExceptStaffOnly(batchProcessTxObject, oleNGBatchExportResponse);
break;
case OleNGConstants.INCREMENTAL:
processIncremental(batchProcessTxObject, oleNGBatchExportResponse);
break;
case OleNGConstants.INCREMENTAL_EXCEPT_STAFF_ONLY:
processIncrementalExceptStaffOnly(batchProcessTxObject, oleNGBatchExportResponse);
break;
case OleNGConstants.FILTER:
processFilterExport(batchProcessTxObject, oleNGBatchExportResponse);
break;
}
}
} catch (Exception e) {
e.printStackTrace();
addBatchExportFailureResponseToExchange(e, null, batchProcessTxObject.getExchangeObjectForBatchExport());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,6 @@ public String getSourceMatchPoint(BatchProfileMatchPoint batchProfileMatchPoint)
}





public void addBatchExportFailureResponseToExchange(Exception exception, String bibId, Exchange exchange) {
String message = exception.toString();
List<ExportFailureResponse> exportFailureResponses = (List<ExportFailureResponse>) exchange.get(OleNGConstants.FAILURE_RESPONSE);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package org.kuali.ole.spring.batch.processor;

import org.apache.commons.collections.CollectionUtils;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import org.kuali.ole.constants.OleNGConstants;
import org.kuali.ole.docstore.common.pojo.RecordDetails;
import org.kuali.ole.docstore.common.response.BatchProcessFailureResponse;
import org.kuali.ole.docstore.common.response.ExportFailureResponse;
import org.kuali.ole.docstore.common.response.OleNGBatchExportResponse;
import org.kuali.ole.docstore.common.response.OleNgBatchResponse;
import org.kuali.ole.oleng.batch.process.model.BatchJobDetails;
Expand All @@ -18,6 +20,7 @@

import java.io.File;
import java.sql.Timestamp;
import java.util.List;
import java.util.Map;

/**
Expand All @@ -40,6 +43,10 @@ public JSONObject processBatch(File inputFileDirectoryPath, String fileType, Str
batchProcessProfile = fetchBatchProcessProfile(profileId);
batchProcessTxObject = buildBatchProcessTxObject(inputFileDirectoryPath, fileType, batchProcessProfile, reportDirectoryName, batchJobDetails);
batchExportHandler.processExport(batchProcessTxObject, oleNGBatchExportResponse);
List<ExportFailureResponse> exportFailureResponses = (List<ExportFailureResponse>) batchProcessTxObject.getExchangeObjectForBatchExport().get(OleNGConstants.FAILURE_RESPONSE);
if(CollectionUtils.isNotEmpty(exportFailureResponses)) {
oleNGBatchExportResponse.setExportFailureResponses(exportFailureResponses);
}
generateBatchReport(inputFileDirectoryPath, batchJobDetails, oleNGBatchExportResponse);
jsonResponse.put(OleNGConstants.STATUS, true);
} catch (Exception e) {
Expand Down

0 comments on commit e878595

Please sign in to comment.