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
9 package org.opendaylight.transportpce.servicehandler;
11 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ConnectionType;
12 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.RpcActions;
13 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.sdnc.request.header.SdncRequestHeader;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
18 * Class for checking service sdnc-request-header compliancy.
20 * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange
23 public class ServicehandlerCompliancyCheck {
25 private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerCompliancyCheck.class);
26 /* SdncRequestHeader. */
27 private SdncRequestHeader sndcRequestHeader;
29 private String serviceName;
30 /* Type of connection : service / infrastructure / roadm-line. */
31 private ConnectionType conType;
32 /* type of service : service-create / service-delete ... */
33 private RpcActions action;
34 /* Response message from procedure. */
35 private String message;
38 * ServicehandlerCompliancyCheck class constructor.
40 * @param sdncRequestHeader
49 public ServicehandlerCompliancyCheck(SdncRequestHeader sdncRequestHeader, String serviceName,
50 ConnectionType conType, RpcActions action) {
51 this.sndcRequestHeader = sdncRequestHeader;
52 this.serviceName = serviceName;
53 this.conType = conType;
59 * ServicehandlerCompliancyCheck class constructor.
61 * @param sdncRequestHeader
68 public ServicehandlerCompliancyCheck(SdncRequestHeader sdncRequestHeader, String serviceName, RpcActions action) {
69 this.sndcRequestHeader = sdncRequestHeader;
70 this.serviceName = serviceName;
76 * ServicehandlerCompliancyCheck class constructor.
85 public ServicehandlerCompliancyCheck(String serviceName, ConnectionType conType, RpcActions action) {
86 this.serviceName = serviceName;
87 this.conType = conType;
93 * ServicehandlerCompliancyCheck class constructor.
100 public ServicehandlerCompliancyCheck(String serviceName, RpcActions action) {
101 this.serviceName = serviceName;
102 this.action = action;
107 * Check if a String is not null and not equal to void.
111 * @return true if String ok false if not
113 public Boolean checkString(String value) {
114 Boolean result = false;
115 if (value != null && value.compareTo("") != 0) {
123 * Check Compliancy of Service request.
126 * Boolean to check connection Type
128 * Boolean to check sndcRequestHeader
130 * @return true if String ok false if not
132 public Boolean check(Boolean contype, Boolean sndcRequest) {
133 Boolean result = true;
134 if (!checkString(serviceName)) {
136 message = "Service Name is not set";
138 } else if (contype && conType == null) {
140 message = "Service ConnectionType is not set";
144 if (sndcRequestHeader != null) {
145 RpcActions serviceAction = sndcRequestHeader.getRpcAction();
146 String requestId = sndcRequestHeader.getRequestId();
147 if (!checkString(requestId)) {
149 message = "Service sndcRequestHeader 'request-id' is not set";
151 } else if (serviceAction != null) {
152 if (serviceAction.compareTo(action) != 0) {
154 message = "Service sndcRequestHeader rpc-action '" + serviceAction + "' not equal to '"
155 + action.name() + "'";
160 message = "Service sndc-request-header 'rpc-action' is not set ";
166 message = "Service sndc-request-header is not set ";
173 public String getMessage() {
177 public void setMessage(String message) {
178 this.message = message;