class KewTypeBoServiceImpl implements KewTypeRepositoryService {

    @Override
    public KewTypeDefinition createKewType(KewTypeDefinition kewType) {
        if (kewType == null){
            throw new RiceIllegalArgumentException("kewType is null");
        }
        final String nameKey = kewType.getName();
        final String namespaceKey = kewType.getNamespace();
        final KewTypeDefinition existing = getTypeByNameAndNamespace(nameKey, namespaceKey);
        if (existing != null && existing.getName().equals(nameKey) && existing.getNamespace().equals(namespaceKey)){
            throw new RiceIllegalStateException("The KEW Type to create already exists: " + kewType);
        }

        KewTypeBo bo = dataObjectService.save(KewTypeBo.from(kewType));

        return KewTypeBo.to(bo);
    }

}