/*
 * oxTrust is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text.
 *
 * Copyright (c) 2014, Gluu
 */

package org.gluu.oxtrust.action;

import static org.jboss.seam.ScopeType.CONVERSATION;

import java.io.Serializable;
import java.util.Date;

import org.gluu.oxtrust.ldap.service.ApplianceService;
import org.gluu.oxtrust.model.GluuAppliance;
import org.gluu.oxtrust.util.OxTrustConstants;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;

/**
 * Action class for health check display
 * 
 * @author Oleksiy Tataryn Date: 11.14.2013
 */
@Scope(CONVERSATION)
@Name("applianceStatusAction")
public class ApplianceStatusAction implements Serializable {

	private static final long serialVersionUID = -7470520478553992898L;

	@In
	private ApplianceService applianceService;

	private String health;

	public String checkHealth() {
		GluuAppliance appliance = applianceService.getAppliance();
		Date lastUpdateDateTime = appliance.getLastUpdate();
		long lastUpdate = 0;
		if (lastUpdateDateTime != null) {
			lastUpdate = lastUpdateDateTime.getTime();
		}

		long currentTime = System.currentTimeMillis();
		long timeSinceLastUpdate = currentTime - lastUpdate;
		if (timeSinceLastUpdate >= 0 && timeSinceLastUpdate < 100) {
			this.setHealth("OK");
		} else {
			this.setHealth("FAIL");
		}

		return OxTrustConstants.RESULT_SUCCESS;
	}

	public String getHealth() {
		return health;
	}

	public void setHealth(String health) {
		this.health = health;
	}

}

@@ -466,16 +466,58 @@
 ons.In;%0A
+import org.jboss.seam.annotations.Logger;%0A
 import o
@@ -588,16 +588,47 @@
 s.Scope;
+%0Aimport org.jboss.seam.log.Log;
 %0A%0A/**%0A *
@@ -902,16 +902,47 @@
 2898L;%0A%0A
+%09@Logger%0A    private Log log;%0A%0A
 %09@In%0A%09pr
@@ -1268,55 +1268,188 @@
 %09%09%7D%0A
-%0A%09%09long currentTime = System.currentTimeMillis(
+%09%09log.debug(%22checkHealth.lastUpdate%22, lastUpdate);%0A%0A%09%09long currentTime = System.currentTimeMillis();%0A%09%09%0A%09%09log.debug(%22lastUpdate: '%7B0%7D', currentTime: '%7B1%7D'%22, lastUpdate, currentTime
 );%0A%09
@@ -1631,16 +1631,67 @@
 L%22);%0A%09%09%7D
+%0A%09%09log.debug(%22Set status '%7B0%7D'%22, this.getHealth());
 %0A%0A%09%09retu

Add more logging info in to status checker