use of se.inera.intyg.common.support.modules.registry.ModuleNotFoundException in project webcert by sklintyg.
the class RouteTest method testTransformationExceptionNotificationVersion2.
@Test
public void testTransformationExceptionNotificationVersion2() throws Exception {
// Given
when(moduleRegistry.getModuleApi(anyString())).thenThrow(new ModuleNotFoundException("Testing checked exception"));
notificationWSClient.expectedMessageCount(0);
notificationWSClientV3.expectedMessageCount(0);
permanentErrorHandlerEndpoint.expectedMessageCount(1);
temporaryErrorHandlerEndpoint.expectedMessageCount(0);
// When
producerTemplate.sendBody(createNotificationMessage(SchemaVersion.VERSION_3, "fk7263"));
// Then
assertIsSatisfied(notificationWSClient);
assertIsSatisfied(notificationWSClientV3);
assertIsSatisfied(permanentErrorHandlerEndpoint);
assertIsSatisfied(temporaryErrorHandlerEndpoint);
}
use of se.inera.intyg.common.support.modules.registry.ModuleNotFoundException in project webcert by sklintyg.
the class CopyUtkastServiceImpl method createReplacementCopy.
@Override
@Transactional("jpaTransactionManager")
public CreateReplacementCopyResponse createReplacementCopy(CreateReplacementCopyRequest replacementRequest) {
String originalIntygId = replacementRequest.getOriginalIntygId();
WebCertUser user = userService.getUser();
LOG.debug("Creating replacement copy of intyg '{}'", originalIntygId);
try {
if (intygService.isRevoked(replacementRequest.getOriginalIntygId(), replacementRequest.getTyp(), replacementRequest.isCoherentJournaling())) {
LOG.debug("Cannot create replacement certificate for id '{}', the certificate is revoked", originalIntygId);
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, "Can not create replacement copy - Original certificate is revoked");
}
verifyNotReplaced(replacementRequest.getOriginalIntygId(), "create replacement");
verifyNotComplementedWithSigned(replacementRequest.getOriginalIntygId(), "create replacement");
CopyUtkastBuilderResponse builderResponse = buildReplacementUtkastBuilderResponse(replacementRequest, originalIntygId);
if (replacementRequest.isDjupintegrerad()) {
checkIntegreradEnhet(builderResponse);
}
Utkast savedUtkast = saveAndNotify(builderResponse, user);
monitoringService.logIntygCopiedReplacement(savedUtkast.getIntygsId(), originalIntygId);
return new CreateReplacementCopyResponse(savedUtkast.getIntygsTyp(), savedUtkast.getIntygsId(), originalIntygId);
} catch (ModuleException | ModuleNotFoundException me) {
LOG.error("Module exception occured when trying to make a copy of " + originalIntygId);
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.MODULE_PROBLEM, me);
}
}
use of se.inera.intyg.common.support.modules.registry.ModuleNotFoundException in project webcert by sklintyg.
the class CopyUtkastServiceImpl method createCompletion.
/*
* (non-Javadoc)
*
* @see
* se.inera.intyg.webcert.web.service.utkast.CopyUtkastService#createCopy(se.inera.intyg.webcert.web.service.utkast.
* dto.
* CreateNewDraftCopyRequest)
*/
@Override
public CreateCompletionCopyResponse createCompletion(CreateCompletionCopyRequest copyRequest) {
String originalIntygId = copyRequest.getOriginalIntygId();
LOG.debug("Creating completion to intyg '{}'", originalIntygId);
WebCertUser user = userService.getUser();
try {
if (intygService.isRevoked(copyRequest.getOriginalIntygId(), copyRequest.getTyp(), false)) {
LOG.debug("Cannot create completion copy of certificate with id '{}', the certificate is revoked", originalIntygId);
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, "Original certificate is revoked");
}
CopyUtkastBuilderResponse builderResponse = buildCompletionUtkastBuilderResponse(copyRequest, originalIntygId, true);
if (copyRequest.isDjupintegrerad()) {
checkIntegreradEnhet(builderResponse);
}
Utkast savedUtkast = saveAndNotify(builderResponse, user);
monitoringService.logIntygCopiedCompletion(savedUtkast.getIntygsId(), originalIntygId);
return new CreateCompletionCopyResponse(savedUtkast.getIntygsTyp(), savedUtkast.getIntygsId(), originalIntygId);
} catch (ModuleException | ModuleNotFoundException me) {
LOG.error("Module exception occured when trying to make a copy of " + originalIntygId);
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.MODULE_PROBLEM, me);
}
}
use of se.inera.intyg.common.support.modules.registry.ModuleNotFoundException in project webcert by sklintyg.
the class CopyUtkastServiceImpl method createRenewalCopy.
/*
* (non-Javadoc)
*
* @see
* se.inera.intyg.webcert.web.service.utkast.CopyUtkastService#createCopy(se.inera.intyg.webcert.web.service.utkast.
* dto.
* CreateRenewalCopyRequest)
*/
@Override
public CreateRenewalCopyResponse createRenewalCopy(CreateRenewalCopyRequest copyRequest) {
String originalIntygId = copyRequest.getOriginalIntygId();
LOG.debug("Creating renewal for intyg '{}'", originalIntygId);
WebCertUser user = userService.getUser();
boolean coherentJournaling = user != null && user.getParameters() != null && user.getParameters().isSjf();
try {
if (intygService.isRevoked(copyRequest.getOriginalIntygId(), copyRequest.getOriginalIntygTyp(), coherentJournaling)) {
LOG.debug("Cannot renew certificate with id '{}', the certificate is revoked", originalIntygId);
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, "Original certificate is revoked");
}
verifyNotReplacedWithSigned(copyRequest.getOriginalIntygId(), "create renewal");
verifyNotComplementedWithSigned(copyRequest.getOriginalIntygId(), "create renewal");
CopyUtkastBuilderResponse builderResponse = buildRenewalUtkastBuilderResponse(copyRequest, originalIntygId, coherentJournaling);
if (copyRequest.isDjupintegrerad()) {
checkIntegreradEnhet(builderResponse);
}
Utkast savedUtkast = saveAndNotify(builderResponse, user);
monitoringService.logIntygCopiedRenewal(savedUtkast.getIntygsId(), originalIntygId);
return new CreateRenewalCopyResponse(savedUtkast.getIntygsTyp(), savedUtkast.getIntygsId(), originalIntygId);
} catch (ModuleException | ModuleNotFoundException me) {
LOG.error("Module exception occured when trying to make a copy of " + originalIntygId);
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.MODULE_PROBLEM, me);
}
}
use of se.inera.intyg.common.support.modules.registry.ModuleNotFoundException in project webcert by sklintyg.
the class UtkastServiceImpl method saveDraft.
@Override
@Transactional("jpaTransactionManager")
public SaveDraftResponse saveDraft(String intygId, long version, String draftAsJson, boolean createPdlLogEvent) {
LOG.debug("Saving and validating utkast '{}'", intygId);
Utkast utkast = utkastRepository.findOne(intygId);
if (utkast == null) {
LOG.warn("Utkast '{}' was not found", intygId);
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.DATA_NOT_FOUND, "The utkast could not be found");
}
// check that the draft hasn't been modified concurrently
if (utkast.getVersion() != version) {
LOG.debug("Utkast '{}' was concurrently modified", intygId);
throw new OptimisticLockException(utkast.getSenastSparadAv().getNamn());
}
// check that the draft is still a draft
if (!isTheDraftStillADraft(utkast.getStatus())) {
LOG.error("Utkast '{}' can not be updated since it is no longer in draft mode", intygId);
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.INVALID_STATE, "This utkast can not be updated since it is no longer in draft mode");
}
String intygType = utkast.getIntygsTyp();
// Keep persisted json for comparsion
String persistedJson = utkast.getModel();
// Update draft with user information
updateUtkastModel(utkast, draftAsJson);
// Is draft valid?
DraftValidation draftValidation = validateDraft(intygId, intygType, draftAsJson);
UtkastStatus utkastStatus = draftValidation.isDraftValid() ? UtkastStatus.DRAFT_COMPLETE : UtkastStatus.DRAFT_INCOMPLETE;
utkast.setStatus(utkastStatus);
// Save the updated draft
utkast = saveDraft(utkast);
LOG.debug("Utkast '{}' updated", utkast.getIntygsId());
if (createPdlLogEvent) {
LogRequest logRequest = LogRequestFactory.createLogRequestFromUtkast(utkast);
logService.logUpdateIntyg(logRequest);
monitoringService.logUtkastEdited(utkast.getIntygsId(), utkast.getIntygsTyp());
}
// Notify stakeholders when a draft has been changed/updated
try {
ModuleApi moduleApi = moduleRegistry.getModuleApi(intygType);
if (moduleApi.shouldNotify(persistedJson, draftAsJson)) {
LOG.debug("*** Detected changes in model, sending notification! ***");
sendNotification(utkast, Event.CHANGED);
}
} catch (ModuleException | ModuleNotFoundException e) {
throw new WebCertServiceException(WebCertServiceErrorCodeEnum.MODULE_PROBLEM, e);
}
// Flush JPA changes, to make sure the version attribute is updated
utkastRepository.flush();
return new SaveDraftResponse(utkast.getVersion(), utkastStatus);
}
Aggregations