use of eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto in project CzechIdMng by bcvsolutions.
the class NotificationTemplateBackupBulkActionIntegrationTest method processBulkActionByIds.
@Test
public void processBulkActionByIds() throws IOException {
IdmNotificationTemplateDto template = templateService.getByCode(TEST_TEMPLATE);
Set<UUID> templates = new HashSet<UUID>();
templates.add(template.getId());
template.setSubject(CHANGED_TEST_DESC);
IdmNotificationTemplateDto templateOne = templateService.save(template);
assertEquals(templateOne.getSubject(), CHANGED_TEST_DESC);
IdmBulkActionDto bulkAction = this.findBulkAction(IdmNotificationTemplate.class, NotificationTemplateBackupBulkAction.NAME);
bulkAction.setIdentifiers(templates);
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 1l, null, null);
testBackupFileContent(templateOne, loggedUser.getUsername());
// test attachment is created for LRT
IdmLongRunningTaskDto task = longRunningTaskManager.getLongRunningTask(processAction.getLongRunningTaskId());
List<IdmAttachmentDto> attachments = attachmentManager.getAttachments(task, null).getContent();
Assert.assertEquals(1, attachments.size());
try (InputStream attachmentData = attachmentManager.getAttachmentData(attachments.get(0).getId())) {
Assert.assertNotNull(attachmentData);
// save
File zipFile = attachmentManager.createTempFile();
Files.copy(attachmentData, zipFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
// and extract file
Path zipFolder = attachmentManager.createTempDirectory(null);
ZipUtils.extract(zipFile, zipFolder.toString());
//
File[] listFiles = zipFolder.toFile().listFiles();
Assert.assertEquals(1, listFiles.length);
Assert.assertEquals(String.format("%s.xml", templateOne.getCode()), listFiles[0].getName());
}
}
use of eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto in project CzechIdMng by bcvsolutions.
the class NotificationTemplateRedeployBulkActionIntegrationTest method prevalidationBulkActionByIds.
@Test
public void prevalidationBulkActionByIds() {
IdmNotificationTemplateDto template1 = templateService.getByCode(TEST_TEMPLATE);
IdmBulkActionDto bulkAction = this.findBulkAction(IdmNotificationTemplate.class, NotificationTemplateRedeployBulkAction.NAME);
bulkAction.getIdentifiers().add(template1.getId());
// None info results
ResultModels resultModels = bulkActionManager.prevalidate(bulkAction);
List<ResultModel> results = resultModels.getInfos();
Assert.assertEquals(2, results.size());
Assert.assertTrue(results.stream().anyMatch(n -> n.getStatusEnum().equals(CoreResultCode.BACKUP_FOLDER_FOUND.toString())));
Assert.assertTrue(results.stream().anyMatch(n -> n.getStatusEnum().equals(CoreResultCode.DEPLOY_TEMPLATE_FOLDER_FOUND.toString())));
}
use of eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto in project CzechIdMng by bcvsolutions.
the class NotificationTemplateDeleteBulkActionIntegrationTest method processBulkActionByIds.
@Test
public void processBulkActionByIds() {
templateService.init();
IdmNotificationTemplateDto template1 = templateService.getByCode(TEST_TEMPLATE);
IdmNotificationTemplateDto template2 = templateService.getByCode(TEST_TEMPLATE_TWO);
template1.setUnmodifiable(false);
template2.setUnmodifiable(false);
template1 = templateService.save(template1);
template2 = templateService.save(template2);
Set<UUID> templates = new HashSet<UUID>();
templates.add(template1.getId());
templates.add(template2.getId());
IdmBulkActionDto bulkAction = this.findBulkAction(IdmNotificationTemplate.class, NotificationTemplateDeleteBulkAction.NAME);
bulkAction.setIdentifiers(templates);
IdmBulkActionDto processAction = bulkActionManager.processAction(bulkAction);
checkResultLrt(processAction, 2l, null, null);
for (UUID id : templates) {
IdmNotificationTemplateDto templateDto = templateService.get(id);
assertNull(templateDto);
}
}
use of eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto in project CzechIdMng by bcvsolutions.
the class DefaultSysProvisioningBreakConfigService method getGlobalBreakConfiguration.
@Override
public SysProvisioningBreakConfigDto getGlobalBreakConfiguration(ProvisioningEventType eventType) {
SysProvisioningBreakConfigDto globalConfig = new SysProvisioningBreakConfigDto();
Boolean disable = provisioningBreakConfiguration.getDisabled(eventType);
if (disable == null) {
// global provisioning break configuration isn't set
return null;
}
globalConfig.setDisabled(disable);
globalConfig.setDisableLimit(provisioningBreakConfiguration.getDisableLimit(eventType));
globalConfig.setGlobalConfiguration(Boolean.TRUE);
//
IdmNotificationTemplateDto disabledTemplate = provisioningBreakConfiguration.getDisableTemplate(eventType);
if (disabledTemplate != null) {
globalConfig.setDisableTemplate(disabledTemplate.getId());
globalConfig.setDisableTemplateEmbedded(disabledTemplate);
}
//
IdmNotificationTemplateDto warningTemplate = provisioningBreakConfiguration.getWarningTemplate(eventType);
if (warningTemplate != null) {
globalConfig.setWarningTemplate(warningTemplate.getId());
globalConfig.setWarningTemplateEmbedded(warningTemplate);
}
//
globalConfig.setOperationType(eventType);
globalConfig.setPeriod(provisioningBreakConfiguration.getPeriod(eventType));
// global provisioning break hasn't system id, don't save global config
globalConfig.setSystem(null);
globalConfig.setWarningLimit(provisioningBreakConfiguration.getWarningLimit(eventType));
globalConfig.setTrimmed(true);
return globalConfig;
}
use of eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmNotificationTemplateService method toDto.
@Override
protected IdmNotificationTemplateDto toDto(IdmNotificationTemplateType type, IdmNotificationTemplateDto template) {
if (template == null) {
template = new IdmNotificationTemplateDto();
}
//
if (type == null) {
return template;
}
// transform type to DTO
template.setCode(type.getCode());
template.setName(type.getName());
template.setBodyHtml(type.getBodyHtml());
template.setBodyText(type.getBodyText());
template.setModule(type.getModuleId());
template.setSubject(type.getSubject());
template.setUnmodifiable(type.isSystemTemplate());
template.setParameter(type.getParameter());
template.setSender(type.getSender());
return template;
}
Aggregations