Changed roles matching renderer code
* Logic moved from controller to entity. * Protected List<ConfigurationRolesLDAP> to avoid modifications outsite the entity. FEA: ItEr75S06LdapAuhenticationItEr74S09
This commit is contained in:
parent
cb1e604dc6
commit
9d6c1407af
2 changed files with 28 additions and 43 deletions
|
|
@ -20,6 +20,7 @@
|
|||
package org.navalplanner.business.common.entities;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -166,12 +167,30 @@ public class LDAPConfiguration extends BaseEntity {
|
|||
}
|
||||
|
||||
public List<ConfigurationRolesLDAP> getConfigurationRolesLdap() {
|
||||
return configurationRolesLdap;
|
||||
return Collections.unmodifiableList(configurationRolesLdap);
|
||||
}
|
||||
|
||||
public void setConfigurationRolesLdap(
|
||||
List<ConfigurationRolesLDAP> configurationRolesLdap) {
|
||||
this.configurationRolesLdap = configurationRolesLdap;
|
||||
String roleLibreplan, List<String> rolesLdap) {
|
||||
removeConfigurationRolesLdapForRoleLibreplan(roleLibreplan);
|
||||
|
||||
for (String roleLdap : rolesLdap) {
|
||||
ConfigurationRolesLDAP configuration = new ConfigurationRolesLDAP();
|
||||
configuration.setRoleLibreplan(roleLibreplan);
|
||||
configuration.setRoleLdap(roleLdap);
|
||||
configurationRolesLdap.add(configuration);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeConfigurationRolesLdapForRoleLibreplan(
|
||||
String roleLibreplan) {
|
||||
List<ConfigurationRolesLDAP> toRemove = new ArrayList<ConfigurationRolesLDAP>();
|
||||
for (ConfigurationRolesLDAP each : configurationRolesLdap) {
|
||||
if (each.getRoleLibreplan().equals(roleLibreplan)) {
|
||||
toRemove.add(each);
|
||||
}
|
||||
}
|
||||
configurationRolesLdap.removeAll(toRemove);
|
||||
}
|
||||
|
||||
public Map<String, List<String>> getMapMatchingRoles() {
|
||||
|
|
@ -197,4 +216,5 @@ public class LDAPConfiguration extends BaseEntity {
|
|||
public void setMapMatchingRoles(Map<String, List<String>> mapMatchingRoles) {
|
||||
this.mapMatchingRoles = mapMatchingRoles;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,6 @@ import org.apache.commons.logging.Log;
|
|||
import org.apache.commons.logging.LogFactory;
|
||||
import org.navalplanner.business.calendars.entities.BaseCalendar;
|
||||
import org.navalplanner.business.common.entities.Configuration;
|
||||
import org.navalplanner.business.common.entities.ConfigurationRolesLDAP;
|
||||
import org.navalplanner.business.common.entities.EntityNameEnum;
|
||||
import org.navalplanner.business.common.entities.EntitySequence;
|
||||
import org.navalplanner.business.common.entities.LDAPConfiguration;
|
||||
|
|
@ -838,46 +837,12 @@ public class ConfigurationController extends GenericForwardComposer {
|
|||
}, new Util.Setter<String>() {
|
||||
@Override
|
||||
public void set(String value) {
|
||||
Map<String, List<String>> mapRoles = configurationModel
|
||||
configurationModel
|
||||
.getLdapConfiguration()
|
||||
.getMapMatchingRoles();
|
||||
mapRoles.put(role.name(),
|
||||
Arrays
|
||||
.asList(StringUtils.split(value)));
|
||||
// Add the list of roles to the configuration
|
||||
// getting the values from map
|
||||
List<ConfigurationRolesLDAP> oldRoles = configurationModel
|
||||
.getLdapConfiguration()
|
||||
.getConfigurationRolesLdap();
|
||||
List<ConfigurationRolesLDAP> newRoles = new ArrayList<ConfigurationRolesLDAP>();
|
||||
for (String roleLdap : mapRoles.get(role.name())) {
|
||||
ConfigurationRolesLDAP configurationRoleLdap = new ConfigurationRolesLDAP();
|
||||
configurationRoleLdap.setRoleLdap(roleLdap);
|
||||
configurationRoleLdap.setRoleLibreplan(role
|
||||
.name());
|
||||
newRoles.add(configurationRoleLdap);
|
||||
}
|
||||
for (ConfigurationRolesLDAP oldRole : oldRoles) {
|
||||
boolean isRoleAdded = false;
|
||||
if (oldRole.getRoleLibreplan().equals(
|
||||
role.name()))
|
||||
isRoleAdded = true;
|
||||
for (ConfigurationRolesLDAP addedRole : newRoles) {
|
||||
if (addedRole.getRoleLibreplan()
|
||||
.equals(oldRole
|
||||
.getRoleLibreplan())
|
||||
&& addedRole.getRoleLdap()
|
||||
.equals(oldRole
|
||||
.getRoleLdap())) {
|
||||
isRoleAdded = true;
|
||||
}
|
||||
}
|
||||
if (!isRoleAdded)
|
||||
newRoles.add(oldRole);
|
||||
}
|
||||
configurationModel.getLdapConfiguration()
|
||||
.setConfigurationRolesLdap(newRoles);
|
||||
|
||||
.setConfigurationRolesLdap(
|
||||
role.name(),
|
||||
Arrays.asList(StringUtils
|
||||
.split(value, ";")));
|
||||
}
|
||||
});
|
||||
textbox.setWidth("300px");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue