protected final Action newCreateAction() {
return new Action() {
@Override
protected Object doAction(Object... params) {
Policy policy = (Policy) params[0];
if ((policy.getId() == null) || (policy.getId().equals("")))
{
// create the id
policy.setId(UUID.randomUUID().toString());
}
/**
* 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("Creating Policy:", policy.getId());
}
com.alu.e3.data.model.Policy policyDataModel = BeanConverterUtil.toDataModel(policy);
dataManager.addPolicy(policyDataModel);
PolicyResponse response = new PolicyResponse(PolicyResponse.SUCCESS);
response.setId(policy.getId());
return response;
}
};
}