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;
}
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;
}
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;
}
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;
}
Aggregations