2 * Copyright © 2017 AT&T and others. All rights reserved.
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
8 package org.opendaylight.transportpce.pce;
10 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRequestInput;
11 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.pce.rev240205.PathComputationRerouteRequestInput;
12 import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory;
16 * Class to check RPCs Compliancy.
18 public final class PceComplianceCheck {
20 private static final Logger LOG = LoggerFactory.getLogger(PceComplianceCheck.class);
22 private PceComplianceCheck() {
26 * Check if a String is not null and not equal to ''.
28 * @param value String value
30 * @return true if String ok
33 public static boolean checkString(String value) {
34 return (value != null) && (value.compareTo("") != 0);
37 public static PceComplianceCheckResult check(PathComputationRequestInput input) {
39 Boolean result = true;
41 LOG.info("New request {} for new service {}",
42 input.getServiceHandlerHeader().getRequestId(), input.getServiceName());
43 if (!checkString(input.getServiceName())) {
45 message = "Service Name is not set";
48 if (!checkString(input.getServiceHandlerHeader().getRequestId())) {
50 message = "ServiceHandlerHeader Request-ID is not set";
57 return new PceComplianceCheckResult(result, message);
60 public static PceComplianceCheckResult check(PathComputationRerouteRequestInput input) {
62 return new PceComplianceCheckResult(false, "");
64 if (input.getEndpoints() == null
65 || input.getEndpoints().getAEndTp() == null
66 || input.getEndpoints().getZEndTp() == null) {
67 String message = "At least one of the termination points is missing";
69 return new PceComplianceCheckResult(false, message);
71 return new PceComplianceCheckResult(true, "");