Search in sources :

Example 6 with ResultModel

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

the class IdmMessageDtoUnitTest method testModelOveloadMessageAndSubject.

@Test
public void testModelOveloadMessageAndSubject() {
    ResultModel model = new DefaultResultModel(CoreResultCode.INTERNAL_SERVER_ERROR);
    IdmMessageDto message = new IdmMessageDto.Builder().setModel(model).setMessage(PARAMETER_TEXT).setSubject(PARAMETER_SUBJECT).build();
    Assert.assertEquals(PARAMETER_SUBJECT, message.getSubject());
    Assert.assertEquals(PARAMETER_TEXT, message.getTextMessage());
    Assert.assertEquals(PARAMETER_TEXT, 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 7 with ResultModel

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

the class IdmMessageDtoUnitTest method testModelSuccess.

@Test
public void testModelSuccess() {
    ResultModel model = new DefaultResultModel(CoreResultCode.ACCEPTED);
    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.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 8 with ResultModel

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

the class IdmMessageDtoUnitTest method testMergeParameters.

@Test
public void testMergeParameters() {
    ResultModel model = new DefaultResultModel(CoreResultCode.INTERNAL_SERVER_ERROR, ImmutableMap.of("one", "one", "two", "two"));
    IdmMessageDto message = new IdmMessageDto.Builder().setModel(model).addParameter("one", "OneUpdated").addParameter("three", "three").build();
    Assert.assertEquals("OneUpdated", message.getParameters().get("one"));
    Assert.assertEquals("two", message.getParameters().get("two"));
    Assert.assertEquals("three", message.getParameters().get("three"));
}
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 9 with ResultModel

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

the class PrepareConnectorObjectProcessor method process.

/**
 * Prepare provisioning operation execution
 */
@Override
public EventResult<SysProvisioningOperationDto> process(EntityEvent<SysProvisioningOperationDto> event) {
    SysProvisioningOperationDto provisioningOperation = event.getContent();
    SysSystemDto system = systemService.get(provisioningOperation.getSystem());
    IcObjectClass objectClass = provisioningOperation.getProvisioningContext().getConnectorObject().getObjectClass();
    SysSystemEntityDto systemEntity = provisioningOperationService.getByProvisioningOperation(provisioningOperation);
    String uid = systemEntity.getUid();
    boolean isWish = systemEntity.isWish();
    LOG.debug("Start preparing attribubes for provisioning operation [{}] for object with uid [{}] and connector object [{}]", provisioningOperation.getOperationType(), uid, objectClass.getType());
    // Find connector identification persisted in system
    if (system.getConnectorKey() == null) {
        throw new ProvisioningException(AccResultCode.CONNECTOR_KEY_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
    }
    // load connector configuration
    IcConnectorConfiguration connectorConfig = systemService.getConnectorConfiguration(system);
    if (connectorConfig == null) {
        throw new ProvisioningException(AccResultCode.CONNECTOR_CONFIGURATION_FOR_SYSTEM_NOT_FOUND, ImmutableMap.of("system", system.getName()));
    }
    // 
    try {
        IcConnectorObject existsConnectorObject = null;
        // call the connector and auto mapping is not allowed.
        if (!(isWish && !provisioningConfiguration.isAllowedAutoMappingOnExistingAccount())) {
            IcUidAttribute uidAttribute = new IcUidAttributeImpl(null, uid, null);
            existsConnectorObject = connectorFacade.readObject(system.getConnectorInstance(), connectorConfig, objectClass, uidAttribute);
        }
        if (existsConnectorObject == null) {
            processCreate(provisioningOperation);
        } else {
            processUpdate(provisioningOperation, connectorConfig, existsConnectorObject);
        }
        // 
        LOG.debug("Preparing attribubes for provisioning operation [{}] for object with uid [{}] and connector object [{}] is sucessfully completed", provisioningOperation.getOperationType(), uid, objectClass.getType());
        // set back to event content
        provisioningOperation = provisioningOperationService.save(provisioningOperation);
        event.setContent(provisioningOperation);
        return new DefaultEventResult<>(event, this);
    } catch (Exception ex) {
        ResultModel resultModel;
        if (ex instanceof ResultCodeException) {
            resultModel = ((ResultCodeException) ex).getError().getError();
        } else {
            resultModel = new DefaultResultModel(AccResultCode.PROVISIONING_PREPARE_ACCOUNT_ATTRIBUTES_FAILED, ImmutableMap.of("name", uid, "system", system.getName(), "operationType", provisioningOperation.getOperationType(), "objectClass", objectClass.getType()));
        }
        LOG.error(resultModel.toString(), ex);
        provisioningOperation.setResult(new OperationResult.Builder(OperationState.EXCEPTION).setModel(resultModel).setCause(ex).build());
        // 
        provisioningOperation = provisioningOperationService.save(provisioningOperation);
        // 
        notificationManager.send(AccModuleDescriptor.TOPIC_PROVISIONING, new IdmMessageDto.Builder().setModel(resultModel).build());
        // set back to event content
        event.setContent(provisioningOperation);
        return new DefaultEventResult<>(event, this, true);
    }
}
Also used : IcConnectorConfiguration(eu.bcvsolutions.idm.ic.api.IcConnectorConfiguration) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) ResultModel(eu.bcvsolutions.idm.core.api.dto.ResultModel) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) IcUidAttributeImpl(eu.bcvsolutions.idm.ic.impl.IcUidAttributeImpl) IcObjectClass(eu.bcvsolutions.idm.ic.api.IcObjectClass) IcConnectorObject(eu.bcvsolutions.idm.ic.api.IcConnectorObject) ProvisioningException(eu.bcvsolutions.idm.acc.exception.ProvisioningException) DefaultEventResult(eu.bcvsolutions.idm.core.api.event.DefaultEventResult) IcUidAttribute(eu.bcvsolutions.idm.ic.api.IcUidAttribute) SysSystemEntityDto(eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto) SysProvisioningOperationDto(eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)

Example 10 with ResultModel

use of eu.bcvsolutions.idm.core.api.dto.ResultModel 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.save(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)

Aggregations

DefaultResultModel (eu.bcvsolutions.idm.core.api.dto.DefaultResultModel)20 ResultModel (eu.bcvsolutions.idm.core.api.dto.ResultModel)20 IdmMessageDto (eu.bcvsolutions.idm.core.notification.api.dto.IdmMessageDto)13 OperationResult (eu.bcvsolutions.idm.core.api.entity.OperationResult)10 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)7 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)6 AbstractUnitTest (eu.bcvsolutions.idm.test.api.AbstractUnitTest)6 Test (org.junit.Test)6 Transactional (org.springframework.transaction.annotation.Transactional)5 SysProvisioningOperationDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningOperationDto)4 IdmLongRunningTaskDto (eu.bcvsolutions.idm.core.scheduler.api.dto.IdmLongRunningTaskDto)3 SysProvisioningBatchDto (eu.bcvsolutions.idm.acc.dto.SysProvisioningBatchDto)2 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)2 PageRequest (org.springframework.data.domain.PageRequest)2 Objects (com.google.common.base.Objects)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Lists (com.google.common.collect.Lists)1 SysSystemEntityDto (eu.bcvsolutions.idm.acc.dto.SysSystemEntityDto)1 ProvisioningException (eu.bcvsolutions.idm.acc.exception.ProvisioningException)1 CoreModuleDescriptor (eu.bcvsolutions.idm.core.CoreModuleDescriptor)1