Search in sources :

Example 31 with IdmNotificationTemplateDto

use of eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto in project CzechIdMng by bcvsolutions.

the class IdmNotificationTemplateController method backup.

@ResponseBody
@RequestMapping(value = "/{backendId}/backup", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('" + NotificationGroupPermission.NOTIFICATIONTEMPLATE_READ + "')")
@ApiOperation(value = "Backup notification template", nickname = "backupNotificationTemplate", response = IdmNotificationTemplateDto.class, tags = { IdmNotificationTemplateController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = NotificationGroupPermission.NOTIFICATIONTEMPLATE_READ, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = NotificationGroupPermission.NOTIFICATIONTEMPLATE_READ, description = "") }) }, notes = "Backup template to directory given in application properties.")
public ResponseEntity<?> backup(@ApiParam(value = "Template's uuid identifier or code.", required = true) @PathVariable @NotNull String backendId) {
    IdmNotificationTemplateDto template = notificationTemplateService.get(backendId);
    if (template == null) {
        throw new ResultCodeException(CoreResultCode.NOT_FOUND, backendId);
    }
    notificationTemplateService.backup(template);
    return new ResponseEntity<>(toResource(template), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 32 with IdmNotificationTemplateDto

use of eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto in project CzechIdMng by bcvsolutions.

the class IdmNotificationTemplateController method redeploy.

@ResponseBody
@RequestMapping(value = "/{backendId}/redeploy", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('" + NotificationGroupPermission.NOTIFICATIONTEMPLATE_UPDATE + "')")
@ApiOperation(value = "Redeploy notification template", nickname = "redeployNotificationTemplate", response = IdmNotificationTemplateDto.class, tags = { IdmNotificationTemplateController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = NotificationGroupPermission.NOTIFICATIONTEMPLATE_UPDATE, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = NotificationGroupPermission.NOTIFICATIONTEMPLATE_UPDATE, description = "") }) }, notes = "Redeploy template. Redeployed will be only templates, that has pattern in resource." + " Before save newly loaded DO will be backup the old template into backup directory.")
public ResponseEntity<?> redeploy(@ApiParam(value = "Template's uuid identifier or code.", required = true) @PathVariable @NotNull String backendId) {
    IdmNotificationTemplateDto template = notificationTemplateService.get(backendId);
    if (template == null) {
        throw new ResultCodeException(CoreResultCode.NOT_FOUND, backendId);
    }
    template = notificationTemplateService.redeploy(template);
    return new ResponseEntity<>(toResource(template), HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) IdmNotificationTemplateDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto) ApiOperation(io.swagger.annotations.ApiOperation) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

IdmNotificationTemplateDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationTemplateDto)32 Test (org.junit.Test)22 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)20 IdmMessageDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto)13 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)11 IdmNotificationLogDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationLogDto)8 IdmNotificationFilter (eu.bcvsolutions.idm.core.notification.api.dto.filter.IdmNotificationFilter)7 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)5 NotificationConfigurationDto (eu.bcvsolutions.idm.core.notification.api.dto.NotificationConfigurationDto)5 Transactional (org.springframework.transaction.annotation.Transactional)5 IOException (java.io.IOException)4 DateTime (org.joda.time.DateTime)3 SysProvisioningBreakConfigDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningBreakConfigDto)2 IdmNotificationDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmNotificationDto)2 AbstractUnitTest (eu.bcvsolutions.idm.test.api.AbstractUnitTest)2 ApiOperation (io.swagger.annotations.ApiOperation)2 File (java.io.File)2 DecimalFormat (java.text.DecimalFormat)2 ResponseEntity (org.springframework.http.ResponseEntity)2 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)2