Package org.fao.geonet.monitor.health

Source Code of org.fao.geonet.monitor.health.CswGetCapabilitiesHealthCheck

package org.fao.geonet.monitor.health;

import jeeves.monitor.HealthCheckFactory;
import jeeves.server.context.ServiceContext;
import jeeves.server.local.LocalServiceRequest;
import jeeves.server.sources.ServiceRequest.InputMethod;
import org.fao.geonet.utils.Xml;

import org.fao.geonet.constants.Geonet;
import org.jdom.Element;

import com.yammer.metrics.core.HealthCheck;

/**
* Checks to ensure that the CSW subsystem is accessible and functioning
* <p/>
* User: jeichar
* Date: 3/26/12
* Time: 9:01 AM
*/
public class CswGetCapabilitiesHealthCheck implements HealthCheckFactory {
    public HealthCheck create(final ServiceContext context) {
        return new HealthCheck("Csw GetCapabilities") {
            @Override
            protected Result check() throws Exception {
                try {
          LocalServiceRequest request = LocalServiceRequest.create("local://csw?request=GetCapabilities&service=CSW");
          request.setDebug(false);
          request.setLanguage("eng");
          request.setInputMethod(InputMethod.GET);
          Element result = context.execute(request);

                    if (result.getChild("ServiceIdentification", Geonet.Namespaces.OWS) == null)
                        return Result.unhealthy("Capabilities did not have a 'ServiceIdentification' element as expected.  Xml: " + Xml.getString(result));
                    return Result.healthy();
                } catch (Throwable e) {
                    return Result.unhealthy(e);
                }
            }
        };
    }
}
TOP

Related Classes of org.fao.geonet.monitor.health.CswGetCapabilitiesHealthCheck

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.