add gnpy results to pce:path-computation-request
[transportpce.git] / pce / src / main / java / org / opendaylight / transportpce / pce / PceComplianceCheck.java
1 /*
2  * Copyright © 2017 AT&T 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 package org.opendaylight.transportpce.pce;
9
10 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev190624.PathComputationRequestInput;
11 import org.slf4j.Logger;
12 import org.slf4j.LoggerFactory;
13
14 /*
15  * Class to check RPCs Compliancy.
16  */
17 public final class PceComplianceCheck {
18
19     private static final Logger LOG = LoggerFactory.getLogger(PceComplianceCheck.class);
20
21     private PceComplianceCheck() {
22     }
23
24     /*
25      * Check if a String is not
26      * null and not equal to ''.
27      *
28      * @param value String value
29      * @return  true  if String ok
30      *          false if not
31      */
32     public static boolean checkString(String value) {
33         return ((value != null) && (value.compareTo("") != 0));
34     }
35
36     public static PceComplianceCheckResult check(PathComputationRequestInput input) {
37         String message = "";
38         Boolean result = true;
39         if (input != null) {
40             if (!checkString(input.getServiceName())) {
41                 result = false;
42                 message = "Service Name is not set";
43                 LOG.debug(message);
44             } else {
45                 if (!checkString(input.getServiceHandlerHeader().getRequestId())) {
46                     result = false;
47                     message = "ServiceHandlerHeader Request-ID  is not set";
48                     LOG.debug(message);
49                 }
50             }
51         } else {
52             result = false;
53         }
54         return new PceComplianceCheckResult(result, message);
55     }
56
57 }
58