blob: 9e143b5fb9848fb5476a5390a7cb837b77d4b4fd [file] [log] [blame]
package org.apache.taverna.gis;
import java.net.URI;
import java.util.ArrayList;
import java.util.List;
import com.fasterxml.jackson.databind.JsonNode;
import org.apache.taverna.visit.VisitReport;
import org.apache.taverna.visit.VisitReport.Status;
import org.apache.taverna.workflowmodel.health.HealthCheck;
import org.apache.taverna.workflowmodel.health.HealthChecker;
/**
* Gis <code>HealthChecker</code>.
*/
public class GisActivityHealthChecker implements
HealthChecker<GisActivity> {
public boolean canVisit(Object o) {
// Return True if we can visit the object. We could do
// deeper (but not time consuming) checks here, for instance
// if the health checker only deals with GisActivity where
// a certain configuration option is enabled.
return o instanceof GisActivity;
}
public boolean isTimeConsuming() {
// Return true if the health checker does a network lookup
// or similar time consuming checks, in which case
// it would only be performed when using File->Validate workflow
// or File->Run.
return false;
}
public VisitReport visit(GisActivity activity, List<Object> ancestry) {
JsonNode config = activity.getConfiguration();
// We'll build a list of subreports
List<VisitReport> subReports = new ArrayList<>();
if (!URI.create(config.get("exampleUri").asText()).isAbsolute()) {
// Report Severe problems we know won't work
VisitReport report = new VisitReport(HealthCheck.getInstance(),
activity, "Example URI must be absolute", HealthCheck.INVALID_URL,
Status.SEVERE);
subReports.add(report);
}
if (config.get("exampleString").asText().equals("")) {
// Warning on possible problems
subReports.add(new VisitReport(HealthCheck.getInstance(), activity,
"Example string empty", HealthCheck.NO_CONFIGURATION,
Status.WARNING));
}
// The default explanation here will be used if the subreports list is
// empty
return new VisitReport(HealthCheck.getInstance(), activity,
"Gis service OK", HealthCheck.NO_PROBLEM, subReports);
}
}