}
private boolean handleDockerContainersRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException {
try {
DockerServer dockerServer = getDockerServer();
DockerContainers dockerContainers = dockerServer.getDockerContainers();
switch (dockerContainers.getStatusCode()) {
case SERVER_ERROR :
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, dockerContainers.getStatusMessage());
return false;
case CONNECTION_REFUSED :
JSONObject jsonObject = new JSONObject();
jsonObject.put(DockerContainers.CONTAINERS, dockerContainers.getStatusMessage());
OrionServlet.writeJSONResponse(request, response, jsonObject);
return true;
case OK :
JSONArray jsonArray = new JSONArray();
for (DockerContainer dockerContainer : dockerContainers.getContainers()) {
jsonObject = new JSONObject();
jsonObject.put(DockerContainer.ID, dockerContainer.getIdShort());
jsonObject.put(DockerContainer.IMAGE, dockerContainer.getImage());
jsonObject.put(DockerContainer.COMMAND, dockerContainer.getCommand());
jsonObject.put(DockerContainer.CREATED, dockerContainer.getCreated());