The actual shooting is justified. A guy shooting a police dog will probably shoot at the cop afterwards- and did, according to the article.
If I'm not mistaken, police dogs are trained specifically to disarm subjects, presumably the cop was hoping the dog would take the guy out and prevent gunfire. From the article it's not entirely clear if the cop gave the guy an opportunity to give up the gun peacefully, or what the guy was doing with his gun. Did the cop just stop a random guy on the street because he was carrying a weapon? Perhaps a more peaceful solution could have been found?