3e77a4c80846bc2f0cc155f04270f7e56108a9f1
[so.git] / common / src / main / java / org / openecomp / mso / utils / CheckResults.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * OPENECOMP - MSO
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 package org.openecomp.mso.utils;
22
23
24
25 import java.util.ArrayList;
26 import java.util.List;
27
28 import javax.xml.bind.annotation.XmlAttribute;
29 import javax.xml.bind.annotation.XmlElement;
30 import javax.xml.bind.annotation.XmlRootElement;
31
32 @XmlRootElement(name = "checkresults")
33 public class CheckResults {
34
35     @XmlElement(name = "checkresult")
36     private List <CheckResult> results;
37
38     public CheckResults () {
39         results = new ArrayList <CheckResult> ();
40     }
41
42     public List <CheckResult> getResults () {
43         return results;
44     }
45
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);
53     }
54
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);
63     }
64
65     public static class CheckResult {
66
67         private String type;
68         private String hostname;
69         private String servicename;
70         private int state;
71         private String output;
72
73         @XmlAttribute(required = true)
74         public String getType () {
75             return type;
76         }
77
78         public void setType (String type) {
79             this.type = type;
80         }
81
82         @XmlElement(required = true)
83         public String getHostname () {
84             return hostname;
85         }
86
87         public void setHostname (String hostname) {
88             this.hostname = hostname;
89         }
90
91         @XmlElement(required = false)
92         public String getServicename () {
93             return servicename;
94         }
95
96         public void setServicename (String servicename) {
97             this.servicename = servicename;
98         }
99
100         @XmlElement(required = true)
101         public int getState () {
102             return state;
103         }
104
105         public void setState (int state) {
106             this.state = state;
107         }
108
109         @XmlElement(required = true)
110         public String getOutput () {
111             return output;
112         }
113
114         public void setOutput (String output) {
115             this.output = output;
116         }
117     }
118 }