protected final Action newUpdateAction() {
return new Action() {
@Override
protected Object doAction(Object... params) {
Policy policy = (Policy) params[0];
String policyId = (String) params[1];
/**
* Some validation
*/
for(Key key : policy.getProperties()){
if(key.getName() == null || key.getName().isEmpty())
throw new IllegalArgumentException("All properties must have a name");
}
if(LOG.isDebugEnabled()) {
LOG.debug("Updating Policy:", policyId);
}
if(policy.getId() == null || policy.getId().equals(""))
policy.setId(policyId);
else if(policy.getId().equals(policyId) == false)
throw new InvalidParameterException("Policy ID mismatch");
com.alu.e3.data.model.Policy policyDataModel = BeanConverterUtil.toDataModel(policy);
dataManager.updatePolicy(policyDataModel);