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.ServiceEndpoint;
12 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.ServiceFormat;
13 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.endpoint.RxDirection;
14 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.endpoint.TxDirection;
15 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.lgx.Lgx;
16 import org.opendaylight.yang.gen.v1.http.org.openroadm.common.service.types.rev161014.service.port.Port;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
21 * Class for checking missing info on Tx/Rx for A/Z end.
23 * @author Martial Coulibaly ( martial.coulibaly@gfi.com ) on behalf of Orange
25 public class ServicehandlerTxRxCheck {
27 private static final Logger LOG = LoggerFactory.getLogger(ServicehandlerTxRxCheck.class);
28 /** ServiceEndpoint. */
29 private ServiceEndpoint serviceEnd;
30 /** Response message from procedure. */
31 private String message;
32 /** type serviceEndpoint : serviceAEnd / serviceZEnd. */
33 private String service = null;
36 * ServicehandlerTxRxCheck class constructor.
41 * Integer to define ServiceAEND/ZEND
43 public ServicehandlerTxRxCheck(ServiceEndpoint endPoint, int value) {
44 this.serviceEnd = endPoint;
47 service = MyEndpoint.forValue(value).name();
52 * Check if a String is not null and not equal to ''.
56 * @return true if String ok false if not
58 public Boolean checkString(String value) {
59 Boolean result = false;
60 if (value != null && value.compareTo("") != 0) {
68 * check if Port info is compliant.
72 * @return true if String ok false if not
74 public Boolean checkPort(Port port) {
75 Boolean result = false;
77 String portDeviceName = port.getPortDeviceName();
78 String portType = port.getPortType();
79 String portName = port.getPortName();
80 String portRack = port.getPortRack();
81 String portShelf = port.getPortShelf();
83 if (checkString(portDeviceName) && checkString(portType) && checkString(portName) && checkString(portRack)
84 && checkString(portShelf)) {
93 * Check if lgx info is compliant.
97 * @return true if String ok false if not
99 public Boolean checkLgx(Lgx lgx) {
100 Boolean result = false;
102 String lgxDeviceName = lgx.getLgxDeviceName();
103 String lgxPortName = lgx.getLgxPortName();
104 String lgxPortRack = lgx.getLgxPortRack();
105 String lgxPortShelf = lgx.getLgxPortShelf();
106 if (checkString(lgxDeviceName) && checkString(lgxPortName) && checkString(lgxPortRack)
107 && checkString(lgxPortShelf)) {
115 * Check if Tx/Rx Direction complaincy info.
122 * @return <code>true</code> if check is ok <code>false</code> else
124 public boolean checkTxOrRxInfo(TxDirection txDirection, RxDirection rxDirection) {
125 Boolean result = true;
126 if (txDirection != null) {
127 if (!checkPort(txDirection.getPort())) {
129 message = "Service TxDirection Port is not correctly set";
130 } else if (!checkLgx(txDirection.getLgx())) {
132 message = "Service TxDirection Lgx is not correctly set";
133 } else if (rxDirection != null) {
134 if (!checkPort(rxDirection.getPort())) {
136 message = "Service RxDirection Port is not correctly set";
137 } else if (!checkLgx(rxDirection.getLgx())) {
139 message = "Service RxDirection Lgx is not correctly set";
143 message = "Service RxDirection is not correctly set";
147 message = "Service TxDirection is not correctly set";
153 * Check Compliancy of Service TxRx info.
155 * @return true if String ok false if not
157 public Boolean check() {
158 Boolean result = true;
159 if (serviceEnd != null) {
160 Long serviceRate = serviceEnd.getServiceRate();
161 ServiceFormat serviceformat = serviceEnd.getServiceFormat();
162 String clli = serviceEnd.getClli();
163 if (serviceRate != null && serviceRate <= 0) {
165 message = "Service " + service + " rate is not set";
167 } else if (serviceformat == null) {
169 message = "Service " + service + " format is not set";
171 } else if (!checkString(clli)) {
173 message = "Service" + service + " clli format is not set";
176 if (!checkTxOrRxInfo(serviceEnd.getTxDirection(), serviceEnd.getRxDirection())) {
182 message = service + " is not set";
189 public static void main(String[] args) {
193 public String getMessage() {
197 public void setMessage(String message) {
198 this.message = message;