Thin API Controller

This thins out the API controller, abstracting much of the methodology to the Programme model. Part of a blind alley I pursued trying to fulfil #172 

Eventually we will need to rethink this whole code. It made sense to save JSON to disc when the only output was JSON. Now the output is roughly the same forms of data, but as XML (XCRI-CAP) and JSON much of the code no longer makes sense and causes repetition.