Search in sources :

Example 11 with Codeable

use of eu.bcvsolutions.idm.core.api.domain.Codeable in project CzechIdMng by bcvsolutions.

the class AbstractBulkAction method createPermissionFailedLog.

/**
 * Create failed log for given dto with exception for insufficient permission
 *
 * @param dto
 */
protected void createPermissionFailedLog(DTO dto) {
    String entityCode = "";
    if (dto instanceof Codeable) {
        entityCode = ((Codeable) dto).getCode();
    }
    DefaultResultModel model = new DefaultResultModel(CoreResultCode.BULK_ACTION_INSUFFICIENT_PERMISSION, ImmutableMap.of("bulkAction", this.getAction().getName(), "entityId", dto.getId(), "entityCode", entityCode));
    // 
    this.logItemProcessed(dto, new OperationResult.Builder(OperationState.NOT_EXECUTED).setModel(model).build());
}
Also used : Codeable(eu.bcvsolutions.idm.core.api.domain.Codeable) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult)

Example 12 with Codeable

use of eu.bcvsolutions.idm.core.api.domain.Codeable in project CzechIdMng by bcvsolutions.

the class AbstractBackupBulkAction method processDto.

@Override
@SuppressWarnings("unchecked")
protected OperationResult processDto(DTO dto) {
    try {
        Assert.notNull(dto, "Entity to backup is required!");
        Assert.notNull(dto.getId(), "Id of entity to backup is required!");
        Assert.isTrue(getService() instanceof Recoverable, "Entity service has to implement recoverable interface!");
        Recoverable<DTO> service = (Recoverable<DTO>) getService();
        // call backup
        File backupFile = service.backup(dto);
        // rename to zip folder
        String fileName = dto.getId().toString();
        if (dto instanceof Codeable) {
            fileName = attachmentManager.getValidFileName(((Codeable) dto).getCode());
        }
        File targetFile = new File(zipFolder.toString(), String.format("%s.xml", fileName));
        // and copy file
        FileUtils.copyFile(backupFile, targetFile);
        // 
        return new OperationResult(OperationState.EXECUTED);
    } catch (Exception ex) {
        return new // 
        OperationResult.Builder(// 
        OperationState.EXCEPTION).setCause(// 
        ex).build();
    }
}
Also used : Codeable(eu.bcvsolutions.idm.core.api.domain.Codeable) OperationResult(eu.bcvsolutions.idm.core.api.entity.OperationResult) File(java.io.File) IOException(java.io.IOException) Recoverable(eu.bcvsolutions.idm.core.api.service.Recoverable)

Example 13 with Codeable

use of eu.bcvsolutions.idm.core.api.domain.Codeable in project CzechIdMng by bcvsolutions.

the class DefaultRequestManager method changeRequestState.

/**
 * Change request state
 *
 * @param requestable
 * @param request
 * @param ex
 * @return
 */
private <R extends Requestable> IdmRequestDto changeRequestState(R requestable, IdmRequestDto request, ResultCodeException ex) {
    if (request.getState().isTerminatedState()) {
        // If is request in the terminated state, then we only add result code
        // exception,
        // but don't modify the result state
        request.setResult(// 
        new Builder(request.getResult().getState()).setException(// 
        ex).build());
    } else {
        request = requestService.cancel(request);
        request.setResult(// 
        new Builder(OperationState.CANCELED).setException(// 
        ex).build());
    }
    if (requestable instanceof Codeable && ((Codeable) requestable).getCode() != null) {
        request.setName(((Codeable) requestable).getCode());
    }
    return request;
}
Also used : Codeable(eu.bcvsolutions.idm.core.api.domain.Codeable) Builder(eu.bcvsolutions.idm.core.api.dto.OperationResultDto.Builder)

Example 14 with Codeable

use of eu.bcvsolutions.idm.core.api.domain.Codeable in project CzechIdMng by bcvsolutions.

the class DefaultRequestManager method makeNiceValue.

private Object makeNiceValue(Object value) {
    if (value == null) {
        return null;
    }
    if (value instanceof Codeable) {
        Codeable codeable = (Codeable) value;
        return codeable.getCode();
    }
    if (value instanceof Niceable) {
        Niceable codeable = (Niceable) value;
        return codeable.getNiceLabel();
    }
    if (value instanceof Identifiable) {
        Identifiable identifiable = (Identifiable) value;
        return identifiable.getId();
    }
    if (value instanceof ConfigurationMap) {
        ConfigurationMap configurationMap = (ConfigurationMap) value;
        Map<String, Serializable> map = configurationMap.toMap();
        return map.toString();
    }
    return value;
}
Also used : Niceable(eu.bcvsolutions.idm.core.api.domain.Niceable) Serializable(java.io.Serializable) Codeable(eu.bcvsolutions.idm.core.api.domain.Codeable) ConfigurationMap(eu.bcvsolutions.idm.core.api.domain.ConfigurationMap) GuardedString(eu.bcvsolutions.idm.core.security.api.domain.GuardedString) Identifiable(eu.bcvsolutions.idm.core.api.domain.Identifiable)

Example 15 with Codeable

use of eu.bcvsolutions.idm.core.api.domain.Codeable in project CzechIdMng by bcvsolutions.

the class DefaultCommonFormServiceIntegrationTest method testCreateForm.

@Test
@Transactional
public void testCreateForm() {
    Codeable owner = getHelper().createIdentity((GuardedString) null);
    IdmFormAttributeDto attribute = createDefinition();
    IdmFormValueDto formValue = new IdmFormValueDto(attribute);
    formValue.setValue("testOne");
    IdmFormDto formOne = new IdmFormDto();
    formOne.setName("test");
    formOne.setFormDefinition(attribute.getFormDefinition());
    formOne.setValues(Lists.newArrayList(formValue));
    formOne.setOwnerCode(owner.getCode());
    // 
    commonFormService.saveForm(owner, formOne);
    formOne = commonFormService.getForms(owner).get(0);
    // 
    Assert.assertNotNull(formOne.getId());
    Assert.assertEquals(owner.getCode(), formOne.getOwnerCode());
    Assert.assertEquals(lookupService.lookupEntity(owner.getClass(), owner.getId()).getClass().getCanonicalName(), formOne.getOwnerType());
    Assert.assertEquals(owner.getId(), formOne.getOwnerId());
    Assert.assertEquals(formValue.getValue(), formOne.getValues().get(0).getValue());
    // 
    commonFormService.deleteForms(owner);
    Assert.assertTrue(commonFormService.getForms(owner).isEmpty());
}
Also used : Codeable(eu.bcvsolutions.idm.core.api.domain.Codeable) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmFormValueDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormValueDto) IdmFormDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Codeable (eu.bcvsolutions.idm.core.api.domain.Codeable)17 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)6 UUID (java.util.UUID)4 SystemEntityType (eu.bcvsolutions.idm.acc.domain.SystemEntityType)3 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)3 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)3 IOException (java.io.IOException)3 Test (org.junit.Test)3 SysSchemaObjectClassDto (eu.bcvsolutions.idm.acc.dto.SysSchemaObjectClassDto)2 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)2 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)2 AuditSearchable (eu.bcvsolutions.idm.core.api.domain.AuditSearchable)2 BaseDto (eu.bcvsolutions.idm.core.api.dto.BaseDto)2 DefaultResultModel (eu.bcvsolutions.idm.core.api.dto.DefaultResultModel)2 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)2 OperationResultDto (eu.bcvsolutions.idm.core.api.dto.OperationResultDto)2 AbstractEntity (eu.bcvsolutions.idm.core.api.entity.AbstractEntity)2 OperationResult (eu.bcvsolutions.idm.core.api.entity.OperationResult)2 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)2 IdmFormDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDto)2