2 * Copyright © 2017 Orange, Inc. 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.servicehandler.validation.checks;
10 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ConnectionType;
11 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.RpcActions;
12 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeader;
13 import org.slf4j.Logger;
14 import org.slf4j.LoggerFactory;
17 * Class for checking service sdnc-request-header compliancy.
20 public final class ServicehandlerCompliancyCheck {
22 private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerCompliancyCheck.class);
25 * Check if a String is not null and not equal to void.
29 * @return true if String ok false if not
31 public static boolean checkString(String value) {
32 return ((value != null) && (value.compareTo("") != 0));
36 * Check Compliancy of Service request.
39 * Boolean to check connection Type
41 * Boolean to check sndcRequestHeader
43 * @return true if String ok false if not
45 public static ComplianceCheckResult check(String serviceName, SdncRequestHeader sdncRequestHeader,
46 ConnectionType conType, RpcActions action,
47 Boolean contype, Boolean sndcRequest) {
48 boolean result = true;
50 if (!checkString(serviceName)) {
52 message = "Service Name is not set";
53 } else if (contype && (conType == null)) {
55 message = "Service ConnectionType is not set";
58 if (sdncRequestHeader != null) {
59 RpcActions serviceAction = sdncRequestHeader.getRpcAction();
60 String requestId = sdncRequestHeader.getRequestId();
61 if (!checkString(requestId)) {
63 message = "Service sdncRequestHeader 'request-id' is not set";
65 } else if (serviceAction != null) {
66 if (serviceAction.compareTo(action) != 0) {
68 message = "Service sdncRequestHeader rpc-action '" + serviceAction + "' not equal to '"
69 + action.name() + "'";
73 message = "Service sndc-request-header 'rpc-action' is not set ";
78 message = "Service sndc-request-header is not set ";
82 return new ComplianceCheckResult(result, message);
85 public ServicehandlerCompliancyCheck() {