Initial commit for ServiceHandler
[transportpce.git] / stubpce / src / main / java / org / opendaylight / transportpce / stubpce / CompliancyCheck.java
1 /*
2  * Copyright © 2017 Orange, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9
10 package org.opendaylight.transportpce.stubpce;
11
12 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.stubpce.rev170426.PathComputationRequestInput;
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
15
16
17 /*
18  * Class to check RPCs Compliancy.
19  * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange
20  *
21  */
22 public class CompliancyCheck {
23     /* Logging. */
24     private static final Logger LOG = LoggerFactory.getLogger(CompliancyCheck.class);
25     /* Response message from procedure. */
26     private String message;
27
28     private PathComputationRequestInput input;
29
30     public CompliancyCheck(PathComputationRequestInput prcInput) {
31         input = prcInput;
32     }
33
34     /*
35      * Check if a String is not
36      * null and not equal to ''.
37      *
38      * @param value String value
39      * @return  true  if String ok
40      *          false if not
41      */
42     public Boolean checkString(String value) {
43         Boolean result = false;
44         if ((value != null) && (value.compareTo("") != 0)) {
45             result = true;
46         }
47         return result;
48
49     }
50
51     public Boolean check() {
52         Boolean result = true;
53         if (input != null) {
54             if (!checkString(input.getServiceName())) {
55                 result = false;
56                 message = "Service Name is not set";
57                 LOG.debug(message);
58             } else {
59                 if (!checkString(input.getServiceHandlerHeader().getRequestId())) {
60                     result = false;
61                     message = "ServiceHandlerHeader Request-ID  is not set";
62                     LOG.debug(message);
63                 }
64             }
65         } else {
66             result = false;
67         }
68         return result;
69     }
70
71     public String getMessage() {
72         return message;
73     }
74
75
76     public void setMessage(String message) {
77         this.message = message;
78     }
79
80 }