// Path: api/src/main/java/org/openmrs/module/hl7query/AuthenticationErrorObject.java
// public class AuthenticationErrorObject extends LinkedHashMap<String, Object> {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	public AuthenticationErrorObject() {
// 		super();
// 	}
// 
// 	/**
// 	 * Puts a property in this map, and returns the map itself (for chained method calls)
// 	 * 
// 	 * @param key
// 	 * @param value
// 	 * @return
// 	 */
// 	public AuthenticationErrorObject add(String key, Object value) {
// 		put(key, value);
// 		return this;
// 	}
// 
// 	/**
// 	 * Removes a property from the map, and returns the map itself (for chained method calls)
// 	 * 
// 	 * @param key
// 	 * @return
// 	 */
// 	public AuthenticationErrorObject removeProperty(String key) {
// 		remove(key);
// 		return this;
// 	}
// 
// 	/**
// 	 * Creates an instance from the given json string.
// 	 * 
// 	 * @param json
// 	 * @return the simpleObject
// 	 * @throws JsonParseException
// 	 * @throws JsonMappingException
// 	 * @throws IOException
// 	 */
// 	public static AuthenticationErrorObject parseJson(String json) throws JsonParseException, JsonMappingException, IOException {
// 		ObjectMapper objectMapper = new ObjectMapper();
// 		AuthenticationErrorObject object = objectMapper.readValue(json, AuthenticationErrorObject.class);
// 		return object;
// 	}
// }


import org.openmrs.api.context.Context;
import org.openmrs.module.hl7query.AuthenticationErrorObject;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.context.request.WebRequest;
package org.openmrs.module.hl7query.web.controller;

/**
 * The contents of this file are subject to the OpenMRS Public License
 * Version 1.0 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://license.openmrs.org
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 *
 * Copyright (C) OpenMRS, LLC.  All Rights Reserved.
 */


/**
 * Controller that lets a client check the status of their session, and log out. (Authenticating is handled through a filter, and may happen through this or
 * any other resource.
 */
@Controller
@RequestMapping(value = "/module/hl7query/session")
public class Hl7QuerySessionController extends BaseHL7QueryController {

	/**
	 * Tells the user their sessionId, and whether or not they are authenticated.
	 * 
	 * @param request
	 * @return
	 * @should return the session id if the user is authenticated
	 * @should return the session id if the user is not authenticated
	 */
	@RequestMapping(method = RequestMethod.GET)
	@ResponseBody
	public Object get(WebRequest request) {
		return new AuthenticationErrorObject().add("sessionId", request.getSessionId()).add("authenticated", Context.isAuthenticated());
	}

	/**
	 * Logs the client out
	 * @should log the client out
	 */
	@RequestMapping(method = RequestMethod.DELETE)
// Path: api/src/main/java/org/openmrs/module/hl7query/AuthenticationErrorObject.java
// public class AuthenticationErrorObject extends LinkedHashMap<String, Object> {
// 
// 	private static final long serialVersionUID = 1L;
// 
// 	public AuthenticationErrorObject() {
// 		super();
// 	}
// 
// 	/**
// 	 * Puts a property in this map, and returns the map itself (for chained method calls)
// 	 * 
// 	 * @param key
// 	 * @param value
// 	 * @return
// 	 */
// 	public AuthenticationErrorObject add(String key, Object value) {
// 		put(key, value);
// 		return this;
// 	}
// 
// 	/**
// 	 * Removes a property from the map, and returns the map itself (for chained method calls)
// 	 * 
// 	 * @param key
// 	 * @return
// 	 */
// 	public AuthenticationErrorObject removeProperty(String key) {
// 		remove(key);
// 		return this;
// 	}
// 
// 	/**
// 	 * Creates an instance from the given json string.
// 	 * 
// 	 * @param json
// 	 * @return the simpleObject
// 	 * @throws JsonParseException
// 	 * @throws JsonMappingException
// 	 * @throws IOException
// 	 */
// 	public static AuthenticationErrorObject parseJson(String json) throws JsonParseException, JsonMappingException, IOException {
// 		ObjectMapper objectMapper = new ObjectMapper();
// 		AuthenticationErrorObject object = objectMapper.readValue(json, AuthenticationErrorObject.class);
// 		return object;
// 	}
// }


// Path: omod/src/main/java/org/openmrs/module/hl7query/web/controller/Hl7QuerySessionController.java
import org.openmrs.api.context.Context;
import org.openmrs.module.hl7query.AuthenticationErrorObject;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.context.request.WebRequest;

package org.openmrs.module.hl7query.web.controller;

/**
 * The contents of this file are subject to the OpenMRS Public License
 * Version 1.0 (the "License"); you may not use this file except in
 * compliance with the License. You may obtain a copy of the License at
 * http://license.openmrs.org
 *
 * Software distributed under the License is distributed on an "AS IS"
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 * License for the specific language governing rights and limitations
 * under the License.
 *
 * Copyright (C) OpenMRS, LLC.  All Rights Reserved.
 */


/**
 * Controller that lets a client check the status of their session, and log out. (Authenticating is handled through a filter, and may happen through this or
 * any other resource.
 */
@Controller
@RequestMapping(value = "/module/hl7query/session")
public class Hl7QuerySessionController extends BaseHL7QueryController {

	/**
	 * Tells the user their sessionId, and whether or not they are authenticated.
	 * 
	 * @param request
	 * @return
	 * @should return the session id if the user is authenticated
	 * @should return the session id if the user is not authenticated
	 */
	@RequestMapping(method = RequestMethod.GET)
	@ResponseBody
	public Object get(WebRequest request) {
		return new AuthenticationErrorObject().add("sessionId", request.getSessionId()).add("authenticated", Context.isAuthenticated());
	}

	/**
	 * Logs the client out
	 * @should log the client out
	 */
	@RequestMapping(method = RequestMethod.DELETE)
	@ResponseBody