use of org.apache.commons.collections4.CollectionUtils.isEqualCollection in project commons-collections by apache.
the class AbstractMultiValuedMapTest method testFullMapCompatibility.
@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testFullMapCompatibility() throws Exception {
final MultiValuedMap map = makeFullMap();
final MultiValuedMap map2 = (MultiValuedMap) readExternalFormFromDisk(getCanonicalFullCollectionName(map));
assertEquals("Map is the right size", map.size(), map2.size());
for (final Object key : map.keySet()) {
assertTrue("Map had inequal elements", CollectionUtils.isEqualCollection(map.get(key), map2.get(key)));
if (isRemoveSupported()) {
map2.remove(key);
}
}
if (isRemoveSupported()) {
assertEquals("Map had extra values", 0, map2.size());
}
}
use of org.apache.commons.collections4.CollectionUtils.isEqualCollection in project cuba by cuba-platform.
the class WebDataGrid method applySettings.
@Override
public void applySettings(Element element) {
if (!isSettingsEnabled()) {
return;
}
final Element columnsElem = element.element("columns");
if (columnsElem != null) {
List<Column> modelColumns = getVisibleColumns();
List<String> modelIds = modelColumns.stream().map(String::valueOf).collect(Collectors.toList());
List<String> loadedIds = Dom4j.elements(columnsElem, "columns").stream().map(colElem -> colElem.attributeValue("id")).collect(Collectors.toList());
if (CollectionUtils.isEqualCollection(modelIds, loadedIds)) {
applyColumnSettings(element, modelColumns);
}
}
}
use of org.apache.commons.collections4.CollectionUtils.isEqualCollection in project CzechIdMng by bcvsolutions.
the class ContractSliceSynchronizationExecutor method isGuaranteesSame.
/**
* Check if current contract's slices guarantees are same as in account values
*
* @param dto
* @param newGuarantees
* @return
*/
private boolean isGuaranteesSame(IdmContractSliceDto dto, List<IdmIdentityDto> newGuarantees) {
// Guarantees
IdmContractSliceGuaranteeFilter guaranteeFilter = new IdmContractSliceGuaranteeFilter();
guaranteeFilter.setContractSliceId(dto.getId());
List<IdmContractSliceGuaranteeDto> currentGuarantees = guaranteeService.find(guaranteeFilter, null).getContent();
List<UUID> currentGuranteeIds = currentGuarantees.stream().map(gurrantee -> {
return gurrantee.getGuarantee();
}).collect(Collectors.toList());
List<UUID> newGuranteeIds = newGuarantees.stream().map(gurrantee -> {
return gurrantee.getId();
}).collect(Collectors.toList());
return CollectionUtils.isEqualCollection(currentGuranteeIds, newGuranteeIds);
}
use of org.apache.commons.collections4.CollectionUtils.isEqualCollection in project archiva by apache.
the class DefaultSecurityConfigurationService method updateConfiguration.
@Override
public SecurityConfiguration updateConfiguration(SecurityConfiguration newConfiguration) throws ArchivaRestServiceException {
if (newConfiguration == null) {
throw new ArchivaRestServiceException(ErrorMessage.of(ErrorKeys.MISSING_DATA), 400);
}
try {
RedbackRuntimeConfiguration conf = redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration();
boolean userManagerChanged = !CollectionUtils.isEqualCollection(newConfiguration.getActiveUserManagers(), conf.getUserManagerImpls());
boolean rbacManagerChanged = !CollectionUtils.isEqualCollection(newConfiguration.getActiveRbacManagers(), conf.getRbacManagerImpls());
boolean ldapConfigured = newConfiguration.getActiveUserManagers().stream().anyMatch(um -> um.contains("ldap"));
if (!ldapConfigured) {
ldapConfigured = newConfiguration.getActiveRbacManagers().stream().anyMatch(um -> um.contains("ldap"));
}
updateConfig(newConfiguration, conf);
redbackRuntimeConfigurationAdmin.updateRedbackRuntimeConfiguration(conf);
if (userManagerChanged) {
log.info("user managerImpls changed to {} so reload it", newConfiguration.getActiveUserManagers());
userManager.initialize();
}
if (rbacManagerChanged) {
log.info("rbac manager changed to {} so reload it", newConfiguration.getActiveRbacManagers());
rbacManager.initialize();
roleManager.initialize();
}
if (ldapConfigured) {
try {
ldapConnectionFactory.initialize();
} catch (Exception e) {
log.error("Could not initialize LDAP connection factory: {}", e.getMessage());
throw new ArchivaRestServiceException(ErrorMessage.of(ErrorKeys.LDAP_CF_INIT_FAILED, e.getMessage()));
}
}
Collection<PasswordRule> passwordRules = applicationContext.getBeansOfType(PasswordRule.class).values();
for (PasswordRule passwordRule : passwordRules) {
passwordRule.initialize();
}
Collection<CookieSettings> cookieSettingsList = applicationContext.getBeansOfType(CookieSettings.class).values();
for (CookieSettings cookieSettings : cookieSettingsList) {
cookieSettings.initialize();
}
Collection<Authenticator> authenticators = applicationContext.getBeansOfType(Authenticator.class).values();
for (Authenticator authenticator : authenticators) {
try {
log.debug("Initializing authenticatior " + authenticator.getId());
authenticator.initialize();
} catch (Exception e) {
log.error("Initialization of authenticator failed " + authenticator.getId(), e);
}
}
if (ldapConfigured) {
try {
ldapUserMapper.initialize();
} catch (Exception e) {
throw new ArchivaRestServiceException(ErrorMessage.of(ErrorKeys.LDAP_USER_MAPPER_INIT_FAILED, e.getMessage()));
}
}
} catch (RepositoryAdminException e) {
throw new ArchivaRestServiceException(ErrorMessage.of(REPOSITORY_ADMIN_ERROR, e.getMessage()));
}
try {
return SecurityConfiguration.ofRedbackConfiguration(redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration());
} catch (RepositoryAdminException e) {
log.error("Error while retrieve updated configuration: {}", e.getMessage());
throw new ArchivaRestServiceException(ErrorMessage.of(REPOSITORY_ADMIN_ERROR, e.getMessage()));
}
}
use of org.apache.commons.collections4.CollectionUtils.isEqualCollection in project CzechIdMng by bcvsolutions.
the class ContractSynchronizationExecutor method isGuaranteesSame.
/**
* Check if current contract's guarantees are same as in account values
*
* @param dto
* @param newGuarantees
* @return
*/
private boolean isGuaranteesSame(IdmIdentityContractDto dto, List<IdmIdentityDto> newGuarantees) {
// Guarantees
IdmContractGuaranteeFilter guaranteeFilter = new IdmContractGuaranteeFilter();
guaranteeFilter.setIdentityContractId(dto.getId());
List<IdmContractGuaranteeDto> currentGuarantees = guaranteeService.find(guaranteeFilter, null).getContent();
List<UUID> currentGuranteeIds = currentGuarantees.stream().map(gurrantee -> {
return gurrantee.getGuarantee();
}).collect(Collectors.toList());
List<UUID> newGuranteeIds = newGuarantees.stream().map(gurrantee -> {
return gurrantee.getId();
}).collect(Collectors.toList());
return CollectionUtils.isEqualCollection(currentGuranteeIds, newGuranteeIds);
}
Aggregations