use of com.synopsys.integration.alert.api.common.model.exception.AlertException in project hub-alert by blackducksoftware.
the class UpdateEmailService method handleSend.
private void handleSend(Properties javamailProperties, String smtpFrom, String smtpHost, int smtpPort, boolean smtpAuth, String smtpUsername, String smtpPassword, Map<String, Object> templateFields, String emailAddress) throws AlertException {
try {
String alertLogo = alertProperties.createSynopsysLogoPath();
Map<String, String> contentIdsToFilePaths = new HashMap<>();
emailMessagingService.addTemplateImage(templateFields, contentIdsToFilePaths, EmailPropertyKeys.EMAIL_LOGO_IMAGE.getPropertyKey(), alertLogo);
EmailTarget passwordResetEmail = new EmailTarget(emailAddress, TEMPLATE_NAME, templateFields, contentIdsToFilePaths);
emailMessagingService.sendEmailMessage(javamailProperties, smtpFrom, smtpHost, smtpPort, smtpAuth, smtpUsername, smtpPassword, passwordResetEmail);
} catch (Exception genericException) {
throw new AlertException("Problem sending version update email. " + StringUtils.defaultIfBlank(genericException.getMessage(), StringUtils.EMPTY), genericException);
}
}
use of com.synopsys.integration.alert.api.common.model.exception.AlertException in project hub-alert by blackducksoftware.
the class JobConfigActionsTest method deleteServerErrorTest.
@Test
public void deleteServerErrorTest() throws Exception {
Mockito.when(mockedJobAccessor.getJobById(Mockito.any())).thenReturn(Optional.of(distributionJobModel));
Mockito.doThrow(new AlertException("Exception for Alert test")).when(mockedFieldModelProcessor).performBeforeDeleteAction(Mockito.any());
ActionResponse<JobFieldModel> jobFieldModelActionResponse = defaultJobConfigActions.delete(jobId);
assertTrue(jobFieldModelActionResponse.isError());
assertFalse(jobFieldModelActionResponse.hasContent());
assertEquals(HttpStatus.INTERNAL_SERVER_ERROR, jobFieldModelActionResponse.getHttpStatus());
}
use of com.synopsys.integration.alert.api.common.model.exception.AlertException in project hub-alert by blackducksoftware.
the class ProviderSchedulingManager method initializeConfiguredProviders.
private List<ProviderTask> initializeConfiguredProviders(Provider provider, List<ConfigurationModel> providerConfigurations) {
List<ProviderTask> initializedTasks = new ArrayList<>();
for (ConfigurationModel providerConfig : providerConfigurations) {
try {
StatefulProvider statefulProvider = provider.createStatefulProvider(providerConfig);
if (statefulProvider.isConfigEnabled()) {
List<ProviderTask> initializedTasksForConfig = scheduleTasksForProviderConfig(provider, providerConfig);
initializedTasks.addAll(initializedTasksForConfig);
} else {
logger.debug("The provider configuration '{}' was disabled. No tasks will be scheduled for this config.", statefulProvider.getConfigName());
}
} catch (AlertException e) {
logger.error("Something went wrong while attempting to schedule provider tasks", e);
}
}
return initializedTasks;
}
use of com.synopsys.integration.alert.api.common.model.exception.AlertException in project hub-alert by blackducksoftware.
the class CertificateActions method updateWithoutChecks.
@Override
protected ActionResponse<CertificateModel> updateWithoutChecks(Long id, CertificateModel resource) {
try {
Optional<CustomCertificateModel> existingCertificate = certificateAccessor.getCertificate(id);
String logableId = escapeUtil.replaceWithUnderscore(resource.getId());
String loggableAlias = escapeUtil.replaceWithUnderscore(resource.getAlias());
logger.info("Updating certificate with id: {} and alias: {}", logableId, loggableAlias);
if (existingCertificate.isPresent()) {
CertificateModel certificateModel = importCertificate(resource);
return new ActionResponse<>(HttpStatus.NO_CONTENT, certificateModel);
}
logger.error("Certificate with id: {} missing.", logableId);
return new ActionResponse<>(HttpStatus.NOT_FOUND, "Certificate not found.");
} catch (AlertException ex) {
logger.error("Error occurred updating certificate", ex);
return new ActionResponse<>(HttpStatus.INTERNAL_SERVER_ERROR, ex.getMessage());
}
}
use of com.synopsys.integration.alert.api.common.model.exception.AlertException in project hub-alert by blackducksoftware.
the class CertificateActions method deleteWithoutChecks.
@Override
protected ActionResponse<CertificateModel> deleteWithoutChecks(Long id) {
try {
Optional<CustomCertificateModel> certificate = certificateAccessor.getCertificate(id);
if (certificate.isPresent()) {
CustomCertificateModel certificateModel = certificate.get();
logger.info("Delete certificate with id: {} and alias: {}", certificateModel.getNullableId(), certificateModel.getAlias());
trustStoreService.removeCertificate(certificateModel);
certificateAccessor.deleteCertificate(id);
}
} catch (AlertException ex) {
logger.error("Error deleting certificate", ex);
return new ActionResponse<>(HttpStatus.INTERNAL_SERVER_ERROR, String.format("Error deleting certificate: %s", ex.getMessage()));
}
return new ActionResponse<>(HttpStatus.NO_CONTENT);
}
Aggregations