use of gov.cms.ab2d.common.model.PdpClient in project ab2d by CMSgov.
the class PdpClientServiceImpl method updateClientStatus.
private PdpClientDTO updateClientStatus(String contractNumber, boolean enabled) {
PdpClient pdpClient = getClientByContract(contractNumber);
pdpClient.setEnabled(enabled);
PdpClient updatedPdpClient = pdpClientRepository.saveAndFlush(pdpClient);
return mapping.getModelMapper().map(updatedPdpClient, PdpClientDTO.class);
}
use of gov.cms.ab2d.common.model.PdpClient in project ab2d by CMSgov.
the class StatusCommon method doStatus.
public ResponseEntity doStatus(String jobUuid, HttpServletRequest request, String apiPrefix) {
MDC.put(JOB_LOG, jobUuid);
log.info("Request submitted to get job status");
PdpClient pdpClient = pdpClientService.getCurrentClient();
JobPollResult jobPollResult;
try {
jobPollResult = jobClient.poll(pdpClient.isAdmin(), jobUuid, pdpClient.getOrganization(), retryAfterDelay);
} catch (TooFrequentInvocations tfi) {
log.error("Client was polling too frequently");
throw new TooManyRequestsException("You are polling too frequently");
}
HttpHeaders responseHeaders = new HttpHeaders();
switch(jobPollResult.getStatus()) {
case SUCCESSFUL:
return getSuccessResponse(jobPollResult, jobUuid, request, apiPrefix);
case SUBMITTED:
case IN_PROGRESS:
responseHeaders.add(X_PROG, jobPollResult.getProgress() + "% complete");
responseHeaders.add(RETRY_AFTER, Integer.toString(retryAfterDelay));
eventLogger.log(new ApiResponseEvent(MDC.get(ORGANIZATION), jobUuid, HttpStatus.ACCEPTED, "Job in progress", jobPollResult.getProgress() + "% complete", (String) request.getAttribute(REQUEST_ID)));
return new ResponseEntity<>(null, responseHeaders, HttpStatus.ACCEPTED);
case FAILED:
throwFailedResponse("Job failed while processing");
break;
default:
throwFailedResponse("Unknown status of job");
}
throw new JobProcessingException("Unknown error");
}
use of gov.cms.ab2d.common.model.PdpClient in project ab2d by CMSgov.
the class ApiCommon method checkIfCurrentClientCanAddJob.
public void checkIfCurrentClientCanAddJob() {
PdpClient pdpClient = pdpClientService.getCurrentClient();
String organization = pdpClient.getOrganization();
if (jobClient.activeJobs(organization) >= pdpClient.getMaxParallelJobs()) {
String errorMsg = "You already have active export requests in progress. Please wait until they complete before submitting a new one.";
log.error(errorMsg);
throw new TooManyRequestsException(errorMsg, jobClient.getActiveJobIds(organization));
}
}
Aggregations