Cases like this are one of the reasons I'm scared to travel some places. (I don't own firearms, so not this problem specifically, but I'm afraid of not knowing some obscure law.)
I don't think any one person even could read and understand every law on the books for an entire country.
I definitely think the guy should have read the State Department's warning, though, and checked all the pockets of his bag before using it.
Still, I think 12 years is way too harsh if no nefarious intent can be shown.