Validate session id in query service resource and metastore resource

Changes -
1. Added checkSessionId method and checkQuery method
2. Calling checkSessionId for all endpoints that need a session id in both query and metastore resource.