class KewTypeBoServiceImpl implements KewTypeRepositoryService {

    @Override
    public void updateKewType(KewTypeDefinition kewType) {
        if (kewType == null) {
            throw new RiceIllegalArgumentException("kewType is null");
        }
        final String idKey = kewType.getId();
        final KewTypeBo existing = dataObjectService.find(KewTypeBo.class, idKey);
        if (existing == null) {
            throw new RiceIllegalStateException("The KEW type does not exist: " + kewType);
        }
        final KewTypeDefinition toUpdate;
        if (!existing.getId().equals(kewType.getId())){
            final KewTypeDefinition.Builder builder = KewTypeDefinition.Builder.create(kewType);
            builder.setId(existing.getId());
            toUpdate = builder.build();
        } else {
            toUpdate = kewType;
        }

        dataObjectService.save(KewTypeBo.from(toUpdate));
    }

}