This line is pretty identical to https://github.com/aerogear/aerogear-unifiedpush-server/pull/118/files#diff-c542671dc55a6f1a8db8757bc5775df9R95. Maybe it should be extracted to some method?