Radiation by bosons in a magnetic undulator of finite length