}
public void deleteOwner(Owner owner) {
List<Override> overrides = overrideService.findByServiceAndAddress(owner.getService(), Constants.ANYHOST_VALUE);
if (overrides == null || overrides.size() == 0) {
Override override = new Override();
override.setAddress(Constants.ANYHOST_VALUE);
override.setService(owner.getService());
override.setEnabled(true);
override.setParams("owner=" + owner.getUsername());
overrideService.saveOverride(override);
} else {
for(Override override : overrides){
Map<String, String> params = StringUtils.parseQueryString(override.getParams());
String usernames = params.get("owner");
if (usernames != null && usernames.length() > 0) {
if (usernames.equals(owner.getUsername())) {
params.remove("owner");
} else {
usernames = usernames.replace(owner.getUsername() + ",", "").replace("," + owner.getUsername(), "");
params.put("owner", usernames);
}
if (params.size() > 0) {
override.setParams(StringUtils.toQueryString(params));
overrideService.updateOverride(override);
} else {
overrideService.deleteOverride(override.getId());
}
}
}
}
}