Source:
<code>public COREEnvelopeBatchSubmissionResponse batchSubmitTransaction(COREEnvelopeBatchSubmission msg, AssertionType assertion, NhinTargetSystemType targetSystem, NhincConstants.GATEWAY_API_LEVEL apiLevel) { COREEnvelopeBatchSubmissionResponse response; try { String url = proxyHelper.getUrlFromTargetSystemByGatewayAPILevel(targetSystem, getServiceName(), apiLevel); if (url != null && !url.isEmpty()) { X12LargePayloadUtils.convertFileLocationToDataIfEnabled(msg); ServicePortDescriptor<GenericBatchTransactionPort> portDescriptor = new COREGenericBatchServicePortDescriptor(); CONNECTClient<GenericBatchTransactionPort> client = getCONNECTClientSecured(portDescriptor, assertion, url, targetSystem, getServiceName()); client.enableMtom(); response = (COREEnvelopeBatchSubmissionResponse) client.invokePort(GenericBatchTransactionPort.class, "batchSubmitTransaction", msg); if (response != null && response.getPayload() != null) { X12LargePayloadUtils.convertDataToFileLocationIfEnabled(response); } } else { <START> String targetHCID = null; <END> if (targetSystem != null && targetSystem.getHomeCommunity() != null && targetSystem.getHomeCommunity().getHomeCommunityId() != null) { targetHCID = targetSystem.getHomeCommunity().getHomeCommunityId(); } return X12EntityExceptionBuilder.getInstance().createErrorResponse(msg, targetHCID); } } catch (Exception ex) { LOG.error("Error calling batchSubmitTransaction: {}", ex.getLocalizedMessage(), ex); return X12EntityExceptionBuilder.getInstance().createWebServiceErrorResponse(msg, ex.getMessage()); } finally { X12LargePayloadUtils.releaseFileLock(msg); } return response; }</code><technical_language>I duplicate logic in here. Consider HomeCommunityMap.getCommunityIdFromTargetCommunities()</technical_language>

Target:
public COREEnvelopeBatchSubmissionResponse batchSubmitTransaction(COREEnvelopeBatchSubmission msg, AssertionType assertion, NhinTargetSystemType targetSystem, NhincConstants.GATEWAY_API_LEVEL apiLevel) { COREEnvelopeBatchSubmissionResponse response; try { String url = proxyHelper.getUrlFromTargetSystemByGatewayAPILevel(targetSystem, getServiceName(), apiLevel); if (url != null && !url.isEmpty()) { X12LargePayloadUtils.convertFileLocationToDataIfEnabled(msg); ServicePortDescriptor<GenericBatchTransactionPort> portDescriptor = new COREGenericBatchServicePortDescriptor(); CONNECTClient<GenericBatchTransactionPort> client = getCONNECTClientSecured(portDescriptor, assertion, url, targetSystem, getServiceName()); client.enableMtom(); response = (COREEnvelopeBatchSubmissionResponse) client.invokePort(GenericBatchTransactionPort.class, "batchSubmitTransaction", msg); if (response != null && response.getPayload() != null) { X12LargePayloadUtils.convertDataToFileLocationIfEnabled(response); } } else { String targetHCID = HomeCommunityMap.getCommunityIdFromTargetSystem(targetSystem); return X12EntityExceptionBuilder.getInstance().createErrorResponse(msg, targetHCID); } } catch (Exception ex) { LOG.error("Error calling batchSubmitTransaction: {}", ex.getLocalizedMessage(), ex); return X12EntityExceptionBuilder.getInstance().createWebServiceErrorResponse(msg, ex.getMessage()); } finally { X12LargePayloadUtils.releaseFileLock(msg); } return response; }