Carboxylic Acid Derivative Mechanism

Question: 

Provide the major products for the reaction and show the full mechanism.
organic chemistry mechanism