if (! super.currentUser.hasServicePrivilege(service)) {
context.put("message", getMessage("HaveNoServicePrivilege", service));
return false;
}
List<Override> overrides = overrideService.findByService(service);
Override allOverride = null;
if (overrides != null && overrides.size() > 0) {
for (Override override: overrides) {
if (override.isDefault()) {
allOverride = override;
break;
}
}
}
if (allOverride != null) {
Map<String, String> map = StringUtils.parseQueryString(allOverride.getParams());
if (mock == null || mock.length() == 0) {
map.remove("mock");
} else {
map.put("mock", URL.encode(mock));
}
if (map.size() > 0) {
allOverride.setParams(StringUtils.toQueryString(map));
allOverride.setEnabled(true);
allOverride.setOperator(operator);
allOverride.setOperatorAddress(operatorAddress);
overrideService.updateOverride(allOverride);
} else {
overrideService.deleteOverride(allOverride.getId());
}
} else if (mock != null && mock.length() > 0) {
Override override = new Override();
override.setService(service);
override.setParams("mock=" + URL.encode(mock));
override.setEnabled(true);
override.setOperator(operator);
override.setOperatorAddress(operatorAddress);
overrideService.saveOverride(override);
}
return true;
}