Search in sources :

Example 1 with FilterSizeExceededException

use of eu.bcvsolutions.idm.core.api.exception.FilterSizeExceededException in project CzechIdMng by bcvsolutions.

the class IdentityChangeContractGuaranteeBulkAction method prevalidate.

/**
 * If no guarantee for selected identities exists,
 * return the info in the result model.
 */
@Override
public ResultModels prevalidate() {
    ResultModels result = new ResultModels();
    IdmBulkActionDto action = getAction();
    try {
        List<UUID> guarantees = getContractGuaranteeIdentities(action);
        if (guarantees.isEmpty()) {
            result.addInfo(new DefaultResultModel(CoreResultCode.BULK_ACTION_NO_CONTRACT_GUARANTEE_EXISTS));
        }
        if (guarantees.size() > 45) {
            // this is because during autocomplete all IDs are put into the URL
            // which has a max length of 2048
            // the user will be shown all identities without the added filtering
            result.addInfo(new DefaultResultModel(CoreResultCode.BULK_ACTION_TOO_MANY_CONTRACT_GUARANTEE_EXIST));
        }
    } catch (FilterSizeExceededException e) {
        result.addInfo(new DefaultResultModel(CoreResultCode.BULK_ACTION_TOO_MANY_USERS_SELECTED, Map.of("maximum", e.getMaximum())));
    }
    return result;
}
Also used : FilterSizeExceededException(eu.bcvsolutions.idm.core.api.exception.FilterSizeExceededException) IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) UUID(java.util.UUID) ResultModels(eu.bcvsolutions.idm.core.api.dto.ResultModels)

Example 2 with FilterSizeExceededException

use of eu.bcvsolutions.idm.core.api.exception.FilterSizeExceededException in project CzechIdMng by bcvsolutions.

the class IdentityChangeContractGuaranteeBulkAction method preprocessBulkAction.

/**
 * Add the form attributes containing forceSearchParameters (filter) with
 * users who are the guarantees of the selected users.
 */
@Override
public IdmBulkActionDto preprocessBulkAction(IdmBulkActionDto bulkAction) {
    IdmFormAttributeDto oldGuarantee = getGuaranteeAttribute(PROPERTY_OLD_GUARANTEE, true, false);
    IdmFormAttributeDto newGuarantee = getGuaranteeAttribute(PROPERTY_NEW_GUARANTEE, false, false);
    try {
        // try to filter the users
        List<UUID> guaranteeIdentityIds = getContractGuaranteeIdentities(bulkAction);
        if (guaranteeIdentityIds.isEmpty()) {
            // add random id to show empty select box
            guaranteeIdentityIds.add(UUID.randomUUID());
        }
        IdmIdentityFilter identityFilter = new IdmIdentityFilter();
        if (guaranteeIdentityIds.size() <= 45) {
            // this is because during autocomplete all IDs are put into the URL
            // which has a max length of 2048
            // the user will be shown all identities without the added filtering
            identityFilter.setIds(guaranteeIdentityIds);
        }
        oldGuarantee.setForceSearchParameters(identityFilter);
    } catch (FilterSizeExceededException e) {
        LOG.error(e.getLocalizedMessage(), e);
    }
    bulkAction.setFormAttributes(Lists.newArrayList(oldGuarantee, newGuarantee));
    return bulkAction;
}
Also used : FilterSizeExceededException(eu.bcvsolutions.idm.core.api.exception.FilterSizeExceededException) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) UUID(java.util.UUID)

Example 3 with FilterSizeExceededException

use of eu.bcvsolutions.idm.core.api.exception.FilterSizeExceededException in project CzechIdMng by bcvsolutions.

the class IdentityRemoveContractGuaranteeBulkAction method prevalidate.

/**
 * If no guarantee for selected identities exists,
 * return the info in the result model.
 */
@Override
public ResultModels prevalidate() {
    ResultModels result = new ResultModels();
    IdmBulkActionDto action = getAction();
    try {
        List<UUID> guarantees = getContractGuaranteeIdentities(action);
        if (guarantees.isEmpty()) {
            result.addInfo(new DefaultResultModel(CoreResultCode.BULK_ACTION_NO_CONTRACT_GUARANTEE_EXISTS));
        }
        if (guarantees.size() > 45) {
            // this is because during autocomplete all IDs are put into the URL
            // which has a max length of 2048
            // the user will be shown all identities without the added filtering
            result.addInfo(new DefaultResultModel(CoreResultCode.BULK_ACTION_TOO_MANY_CONTRACT_GUARANTEE_EXIST));
        }
    } catch (FilterSizeExceededException e) {
        result.addInfo(new DefaultResultModel(CoreResultCode.BULK_ACTION_TOO_MANY_USERS_SELECTED, Map.of("maximum", e.getMaximum())));
    }
    return result;
}
Also used : FilterSizeExceededException(eu.bcvsolutions.idm.core.api.exception.FilterSizeExceededException) IdmBulkActionDto(eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto) DefaultResultModel(eu.bcvsolutions.idm.core.api.dto.DefaultResultModel) UUID(java.util.UUID) ResultModels(eu.bcvsolutions.idm.core.api.dto.ResultModels)

Example 4 with FilterSizeExceededException

use of eu.bcvsolutions.idm.core.api.exception.FilterSizeExceededException in project CzechIdMng by bcvsolutions.

the class IdentityRemoveContractGuaranteeBulkAction method preprocessBulkAction.

/**
 * Add the form attributes containing forceSearchParameters (filter) with
 * users who are the guarantees of the selected users.
 */
@Override
public IdmBulkActionDto preprocessBulkAction(IdmBulkActionDto bulkAction) {
    IdmFormAttributeDto oldGuarantee = getGuaranteeAttribute(PROPERTY_OLD_GUARANTEE, true, true);
    try {
        // try to filter the users
        List<UUID> guaranteeIdentityIds = getContractGuaranteeIdentities(bulkAction);
        if (guaranteeIdentityIds.isEmpty()) {
            // add random id to show empty select box
            guaranteeIdentityIds.add(UUID.randomUUID());
        }
        IdmIdentityFilter identityFilter = new IdmIdentityFilter();
        if (guaranteeIdentityIds.size() <= 45) {
            // this is because during autocomplete all IDs are put into the URL
            // which has a max length of 2048
            // the user will be shown all identities without the added filtering
            identityFilter.setIds(guaranteeIdentityIds);
        }
        oldGuarantee.setForceSearchParameters(identityFilter);
    } catch (FilterSizeExceededException e) {
        LOG.error(e.getLocalizedMessage(), e);
    }
    bulkAction.setFormAttributes(Lists.newArrayList(oldGuarantee));
    return bulkAction;
}
Also used : FilterSizeExceededException(eu.bcvsolutions.idm.core.api.exception.FilterSizeExceededException) IdmFormAttributeDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto) IdmIdentityFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter) UUID(java.util.UUID)

Aggregations

FilterSizeExceededException (eu.bcvsolutions.idm.core.api.exception.FilterSizeExceededException)4 UUID (java.util.UUID)4 IdmBulkActionDto (eu.bcvsolutions.idm.core.api.bulk.action.dto.IdmBulkActionDto)2 DefaultResultModel (eu.bcvsolutions.idm.core.api.dto.DefaultResultModel)2 ResultModels (eu.bcvsolutions.idm.core.api.dto.ResultModels)2 IdmIdentityFilter (eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityFilter)2 IdmFormAttributeDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormAttributeDto)2