Integrability of an inhomogeneous nonlinear Schroedinger equation in Bose–Einstein condensates and fiber optics