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;
27 import javax.xml.bind.annotation.XmlAttribute;
28 import javax.xml.bind.annotation.XmlElement;
29 import javax.xml.bind.annotation.XmlRootElement;
31 @XmlRootElement(name = "checkresults")
32 public class CheckResults {
34 @XmlElement(name = "checkresult")
35 private List<CheckResult> results;
37 public CheckResults() {
38 results = new ArrayList<>();
41 public List<CheckResult> getResults() {
45 public void addHostCheckResult(String hostname, int state, String output) {
46 CheckResult newResult = new CheckResult();
47 newResult.setType("host");
48 newResult.setHostname(hostname);
49 newResult.setState(state);
50 newResult.setOutput(output);
51 results.add(newResult);
54 public void addServiceCheckResult(String hostname, String servicename, int state, String output) {
55 CheckResult newResult = new CheckResult();
56 newResult.setType("service");
57 newResult.setHostname(hostname);
58 newResult.setServicename(servicename);
59 newResult.setState(state);
60 newResult.setOutput(output);
61 results.add(newResult);
64 public static class CheckResult {
67 private String hostname;
68 private String servicename;
70 private String output;
72 @XmlAttribute(required = true)
73 public String getType() {
77 public void setType(String type) {
81 @XmlElement(required = true)
82 public String getHostname() {
86 public void setHostname(String hostname) {
87 this.hostname = hostname;
90 @XmlElement(required = false)
91 public String getServicename() {
95 public void setServicename(String servicename) {
96 this.servicename = servicename;
99 @XmlElement(required = true)
100 public int getState() {
104 public void setState(int state) {
108 @XmlElement(required = true)
109 public String getOutput() {
113 public void setOutput(String output) {
114 this.output = output;