CSW code for backend- still need to check

to see if it works on the database, but at least the pieces are present
(there might be a few bugs).