Search in sources :

Example 71 with DefaultResultModel

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

the class IdmMessageDtoUnitTest method testModelOveloadLevel.

@Test
public void testModelOveloadLevel() {
    ResultModel model = new DefaultResultModel(CoreResultCode.INTERNAL_SERVER_ERROR);
    IdmMessageDto message = new IdmMessageDto.Builder().setModel(model).setLevel(NotificationLevel.SUCCESS).build();
    Assert.assertEquals(NotificationLevel.SUCCESS, message.getLevel());
}
Also used : DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) IdmMessageDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) ResultModel(eu.bcvsolutions.idm.core.api.dto.ResultModel) AbstractUnitTest(eu.bcvsolutions.idm.test.api.AbstractUnitTest) Test(org.junit.Test)

Example 72 with DefaultResultModel

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

the class IdmMessageDtoUnitTest method testModelError.

@Test
public void testModelError() {
    ResultModel model = new DefaultResultModel(CoreResultCode.INTERNAL_SERVER_ERROR);
    IdmMessageDto message = new IdmMessageDto.Builder().setModel(model).build();
    Assert.assertEquals(model.getStatusEnum(), message.getSubject());
    Assert.assertEquals(model.getMessage(), message.getTextMessage());
    Assert.assertEquals(model.getMessage(), message.getHtmlMessage());
    Assert.assertEquals(NotificationLevel.ERROR, message.getLevel());
}
Also used : DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) IdmMessageDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) ResultModel(eu.bcvsolutions.idm.core.api.dto.ResultModel) AbstractUnitTest(eu.bcvsolutions.idm.test.api.AbstractUnitTest) Test(org.junit.Test)

Example 73 with DefaultResultModel

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

the class DisabledProvisioningSystemProcessor method process.

@Override
public EventResult<AccAccountDto> process(EntityEvent<AccAccountDto> event) {
    AccAccountDto account = event.getContent();
    // 
    SysSystemDto system = DtoUtils.getEmbedded(account, AccAccount_.system, (SysSystemDto) null);
    if (system == null) {
        system = systemService.get(account.getSystem());
    }
    boolean isDryRun = getBooleanProperty(ProvisioningService.DRY_RUN_PROPERTY_NAME, event.getProperties());
    boolean closed = false;
    if (system.isDisabledProvisioning() && !isDryRun) {
        ResultModel resultModel = new DefaultResultModel(AccResultCode.PROVISIONING_SYSTEM_DISABLED_PROVISIONING, ImmutableMap.of("name", account.getRealUid(), "system", system.getName()));
        LOG.info(resultModel.toString());
        // 
        closed = true;
    }
    // 
    return new DefaultEventResult<>(event, this, closed);
}
Also used : DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) ResultModel(eu.bcvsolutions.idm.core.api.dto.ResultModel) AccAccountDto(eu.bcvsolutions.idm.acc.dto.AccAccountDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto)

Example 74 with DefaultResultModel

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

the class ProvisioningBreakProcessor method blockOperation.

/**
 * Method block this operation and send message to topic.
 *
 * @param provisioningOperation
 * @return
 */
private SysProvisioningOperationDto blockOperation(SysProvisioningOperationDto provisioningOperation, SysSystemDto system) {
    String uid = provisioningOperationService.getByProvisioningOperation(provisioningOperation).getUid();
    ResultModel resultModel = new DefaultResultModel(AccResultCode.PROVISIONING_SYSTEM_BLOCKED, ImmutableMap.of("name", uid, "system", system.getName()));
    provisioningOperation.setResult(new OperationResult.Builder(OperationState.BLOCKED).setModel(resultModel).build());
    // 
    provisioningOperation = provisioningOperationService.saveOperation(provisioningOperation);
    // 
    // send also to provisioning topic (websocket)
    notificationManager.send(AccModuleDescriptor.TOPIC_PROVISIONING, new IdmMessageDto.Builder().setModel(resultModel).build());
    return provisioningOperation;
}
Also used : DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) IdmMessageDto(eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) ResultModel(eu.bcvsolutions.idm.core.api.dto.ResultModel) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult)

Example 75 with DefaultResultModel

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

the class DefaultEntityEventManager method init.

/**
 * Cancel all previously ran events
 */
@Override
public void init() {
    LOG.info("Cancel unprocessed events - event was interrupt during instance restart");
    // 
    String instanceId = eventConfiguration.getAsynchronousInstanceId();
    entityEventService.findByState(instanceId, OperationState.RUNNING).forEach(event -> {
        LOG.info("Cancel unprocessed event [{}] - event was interrupt during instance [{}] restart", event.getId(), instanceId);
        // 
        // cancel event
        ResultModel resultModel = new DefaultResultModel(CoreResultCode.EVENT_CANCELED_BY_RESTART, ImmutableMap.of("eventId", event.getId(), "eventType", event.getEventType(), "ownerId", String.valueOf(event.getOwnerId()), "instanceId", event.getInstanceId()));
        OperationResultDto result = new OperationResultDto.Builder(OperationState.CANCELED).setModel(resultModel).build();
        event.setResult(result);
        entityEventService.saveInternal(event);
        // 
        // cancel event states
        IdmEntityStateFilter filter = new IdmEntityStateFilter();
        filter.setEventId(event.getId());
        List<IdmEntityStateDto> states = entityStateManager.findStates(filter, null).getContent();
        states.stream().filter(state -> {
            return OperationState.RUNNING == state.getResult().getState();
        }).forEach(state -> {
            state.setResult(result);
            entityStateManager.saveState(null, state);
        });
    });
    // 
    cacheManager.evictCache(TRANSACTION_EVENT_CACHE_NAME);
}
Also used : IdmEntityStateDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto) Auditable(eu.bcvsolutions.idm.core.api.domain.Auditable) DefaultEventContext(eu.bcvsolutions.idm.core.api.event.DefaultEventContext) DtoUtils(eu.bcvsolutions.idm.core.api.utils.DtoUtils) IdmEntityEventDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityEventDto) ZonedDateTime(java.time.ZonedDateTime) Autowired(org.springframework.beans.factory.annotation.Autowired) ConfigurationService(eu.bcvsolutions.idm.core.api.service.ConfigurationService) StringUtils(org.apache.commons.lang3.StringUtils) SecurityService(eu.bcvsolutions.idm.core.security.api.service.SecurityService) CoreEvent(eu.bcvsolutions.idm.core.api.event.CoreEvent) Map(java.util.Map) ApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher) LongRunningTaskEventType(eu.bcvsolutions.idm.core.scheduler.api.event.LongRunningTaskEvent.LongRunningTaskEventType) Sort(org.springframework.data.domain.Sort) EntityEventProcessorFilter(eu.bcvsolutions.idm.core.api.dto.filter.EntityEventProcessorFilter) Set(java.util.Set) PageRequest(org.springframework.data.domain.PageRequest) Page(org.springframework.data.domain.Page) Serializable(java.io.Serializable) CreatedComparator(eu.bcvsolutions.idm.core.api.domain.comparator.CreatedComparator) EventType(eu.bcvsolutions.idm.core.api.event.EventType) Lazy(org.springframework.context.annotation.Lazy) AnnotationAwareOrderComparator(org.springframework.core.annotation.AnnotationAwareOrderComparator) Callable(java.util.concurrent.Callable) ValueWrapper(eu.bcvsolutions.idm.core.api.config.cache.domain.ValueWrapper) EntityEventProcessor(eu.bcvsolutions.idm.core.api.event.EntityEventProcessor) Scheduled(org.springframework.scheduling.annotation.Scheduled) TransactionContext(eu.bcvsolutions.idm.core.api.domain.TransactionContext) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) AbstractDto(eu.bcvsolutions.idm.core.api.dto.AbstractDto) Lists(com.google.common.collect.Lists) LookupService(eu.bcvsolutions.idm.core.api.service.LookupService) IdmAuthorityUtils(eu.bcvsolutions.idm.core.security.api.utils.IdmAuthorityUtils) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) EventResult(eu.bcvsolutions.idm.core.api.event.EventResult) SchedulerConfiguration(eu.bcvsolutions.idm.core.scheduler.api.config.SchedulerConfiguration) IdmCacheManager(eu.bcvsolutions.idm.core.api.service.IdmCacheManager) OperationState(eu.bcvsolutions.idm.core.api.domain.OperationState) LongRunningTaskExecutor(eu.bcvsolutions.idm.core.scheduler.api.service.LongRunningTaskExecutor) EventContext(eu.bcvsolutions.idm.core.api.event.EventContext) HttpStatus(org.springframework.http.HttpStatus) EmptyEntityEventProcessor(eu.bcvsolutions.idm.core.api.event.EmptyEntityEventProcessor) IdmEntityEventService(eu.bcvsolutions.idm.core.api.service.IdmEntityEventService) IdmLongRunningTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto) CoreResultCode(eu.bcvsolutions.idm.core.api.domain.CoreResultCode) CoreEventType(eu.bcvsolutions.idm.core.api.event.CoreEvent.CoreEventType) BaseDto(eu.bcvsolutions.idm.core.api.dto.BaseDto) EventContentDeletedException(eu.bcvsolutions.idm.core.api.exception.EventContentDeletedException) LongRunningTaskEvent(eu.bcvsolutions.idm.core.scheduler.api.event.LongRunningTaskEvent) EntityEventManager(eu.bcvsolutions.idm.core.api.service.EntityEventManager) AutowireHelper(eu.bcvsolutions.idm.core.api.utils.AutowireHelper) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) BasePermission(eu.bcvsolutions.idm.core.security.api.domain.BasePermission) TransactionContextHolder(eu.bcvsolutions.idm.core.api.domain.TransactionContextHolder) Pageable(org.springframework.data.domain.Pageable) Objects(com.google.common.base.Objects) ImmutableMap(com.google.common.collect.ImmutableMap) AbstractEntity(eu.bcvsolutions.idm.core.api.entity.AbstractEntity) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) IdmEntityStateFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityStateFilter) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) PriorityType(eu.bcvsolutions.idm.core.api.domain.PriorityType) IdmEntityStateDto(eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto) List(java.util.List) EventConfiguration(eu.bcvsolutions.idm.core.api.config.domain.EventConfiguration) ExceptionProcessable(eu.bcvsolutions.idm.core.security.api.service.ExceptionProcessable) ExceptionUtils(eu.bcvsolutions.idm.core.api.utils.ExceptionUtils) Entry(java.util.Map.Entry) Identifiable(eu.bcvsolutions.idm.core.api.domain.Identifiable) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) EntityEventProcessorDto(eu.bcvsolutions.idm.core.api.dto.EntityEventProcessorDto) IdmJwtAuthentication(eu.bcvsolutions.idm.core.security.api.domain.IdmJwtAuthentication) HashSet(java.util.HashSet) ModelMapper(org.modelmapper.ModelMapper) RejectedExecutionException(java.util.concurrent.RejectedExecutionException) EntityStateManager(eu.bcvsolutions.idm.core.api.service.EntityStateManager) ReadDtoService(eu.bcvsolutions.idm.core.api.service.ReadDtoService) Propagation(org.springframework.transaction.annotation.Propagation) OperationResultDto(eu.bcvsolutions.idm.core.api.dto.OperationResultDto) Direction(org.springframework.data.domain.Sort.Direction) EntityEvent(eu.bcvsolutions.idm.core.api.event.EntityEvent) EntityEventLock(eu.bcvsolutions.idm.core.api.event.EntityEventLock) EntityEventType(eu.bcvsolutions.idm.core.api.event.EntityEventEvent.EntityEventType) TransactionalEventListener(org.springframework.transaction.event.TransactionalEventListener) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmEntityEventFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityEventFilter) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) EnabledEvaluator(eu.bcvsolutions.idm.core.security.api.service.EnabledEvaluator) ApplicationContext(org.springframework.context.ApplicationContext) AsyncEntityEventProcessor(eu.bcvsolutions.idm.core.api.event.AsyncEntityEventProcessor) ConfigurationMap(eu.bcvsolutions.idm.core.api.domain.ConfigurationMap) Comparator(java.util.Comparator) Collections(java.util.Collections) ResultModel(eu.bcvsolutions.idm.core.api.dto.ResultModel) Transactional(org.springframework.transaction.annotation.Transactional) Assert(org.springframework.util.Assert) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) OperationResultDto(eu.bcvsolutions.idm.core.api.dto.OperationResultDto) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) ResultModel(eu.bcvsolutions.idm.core.api.dto.ResultModel) IdmEntityStateFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmEntityStateFilter)

Aggregations

DefaultResultModel (eu.bcvsolutions.idm.core.api.dto.DefaultResultModel)104 ResultModel (eu.bcvsolutions.idm.core.api.dto.ResultModel)52 UUID (java.util.UUID)48 OperationResultDto (eu.bcvsolutions.idm.core.api.dto.OperationResultDto)40 OperationResult (eu.bcvsolutions.idm.core.api.entity.OperationResult)35 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)25 IdmEntityStateDto (eu.bcvsolutions.idm.core.api.dto.IdmEntityStateDto)24 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)21 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)19 HashMap (java.util.HashMap)19 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)18 OperationState (eu.bcvsolutions.idm.core.api.domain.OperationState)16 IdmRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleRequestDto)16 Autowired (org.springframework.beans.factory.annotation.Autowired)16 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)15 List (java.util.List)15 IdmConceptRoleRequestDto (eu.bcvsolutions.idm.core.api.dto.IdmConceptRoleRequestDto)14 Set (java.util.Set)14 ImmutableMap (com.google.common.collect.ImmutableMap)13 CoreResultCode (eu.bcvsolutions.idm.core.api.domain.CoreResultCode)13