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.
40 * @param sdncRequestHeader
47 * Boolean to check connection Type
49 * Boolean to check sdncRequestHeader
51 * @return true if String ok false if not
53 public static ComplianceCheckResult check(String serviceName, SdncRequestHeader sdncRequestHeader,
54 ConnectionType conType, RpcActions action,
55 Boolean contype, Boolean sdncRequest) {
56 boolean result = true;
58 if (!checkString(serviceName)) {
60 message = "Service Name (common-id for Temp service) is not set";
61 } else if (contype && (conType == null)) {
63 message = "Service ConnectionType is not set";
66 if (sdncRequestHeader != null) {
67 RpcActions serviceAction = sdncRequestHeader.getRpcAction();
68 String requestId = sdncRequestHeader.getRequestId();
69 if (!checkString(requestId)) {
71 message = "Service sdncRequestHeader 'request-id' is not set";
73 } else if (serviceAction != null) {
74 if (serviceAction.compareTo(action) != 0) {
76 message = "Service sdncRequestHeader rpc-action '" + serviceAction + "' not equal to '"
77 + action.name() + "'";
81 message = "Service sndc-request-header 'rpc-action' is not set ";
86 message = "Service sndc-request-header is not set ";
90 return new ComplianceCheckResult(result, message);
93 private ServicehandlerCompliancyCheck() {