2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.onap.so.utils;
25 import java.util.ArrayList;
26 import java.util.List;
28 import javax.xml.bind.annotation.XmlAttribute;
29 import javax.xml.bind.annotation.XmlElement;
30 import javax.xml.bind.annotation.XmlRootElement;
32 @XmlRootElement(name = "checkresults")
33 public class CheckResults {
35 @XmlElement(name = "checkresult")
36 private List <CheckResult> results;
38 public CheckResults () {
39 results = new ArrayList<>();
42 public List <CheckResult> getResults () {
46 public void addHostCheckResult (String hostname, int state, String output) {
47 CheckResult newResult = new CheckResult ();
48 newResult.setType ("host");
49 newResult.setHostname (hostname);
50 newResult.setState (state);
51 newResult.setOutput (output);
52 results.add (newResult);
55 public void addServiceCheckResult (String hostname, String servicename, int state, String output) {
56 CheckResult newResult = new CheckResult ();
57 newResult.setType ("service");
58 newResult.setHostname (hostname);
59 newResult.setServicename (servicename);
60 newResult.setState (state);
61 newResult.setOutput (output);
62 results.add (newResult);
65 public static class CheckResult {
68 private String hostname;
69 private String servicename;
71 private String output;
73 @XmlAttribute(required = true)
74 public String getType () {
78 public void setType (String type) {
82 @XmlElement(required = true)
83 public String getHostname () {
87 public void setHostname (String hostname) {
88 this.hostname = hostname;
91 @XmlElement(required = false)
92 public String getServicename () {
96 public void setServicename (String servicename) {
97 this.servicename = servicename;
100 @XmlElement(required = true)
101 public int getState () {
105 public void setState (int state) {
109 @XmlElement(required = true)
110 public String getOutput () {
114 public void setOutput (String output) {
115 this.output = output;