How to get the location in OpenMRS

When you log in openmrs, you see location such as Inpatient Ward or Pharmacy or Outpatient Clinic etc. How i can get this location ? Context.getUserContext().getLocation(), Context.getUserContext().getLocationId() does not work.

Is this of help? How to get current location

Or this? How to get a user login location