2 * Copyright (c) 2015 CableLabs 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.controller.packetcable.provider.validation.impl.validators.qos;
11 import org.opendaylight.controller.packetcable.provider.validation.impl.validators.AbstractValidator;
12 import org.opendaylight.yang.gen.v1.urn.packetcable.rev170224.pcmm.qos.traffic.profile.TrafficProfile;
13 import org.opendaylight.yang.gen.v1.urn.packetcable.rev170224.pcmm.qos.traffic.profile.traffic.profile.TrafficProfileChoice;
14 import org.opendaylight.yang.gen.v1.urn.packetcable.rev170224.pcmm.qos.traffic.profile.traffic.profile.traffic.profile.choice.FlowSpecChoice;
15 import org.opendaylight.yang.gen.v1.urn.packetcable.rev170224.pcmm.qos.traffic.profile.traffic.profile.traffic.profile.choice.ServiceClassNameChoice;
16 import org.opendaylight.yang.gen.v1.urn.packetcable.rev170224.pcmm.qos.traffic.profile.traffic.profile.traffic.profile.choice.RtpChoice;
17 import org.opendaylight.yang.gen.v1.urn.packetcable.rev170224.pcmm.qos.traffic.profile.traffic.profile.traffic.profile.choice.UgsChoice;
18 import org.opendaylight.yang.gen.v1.urn.packetcable.rev170224.pcmm.flow.spec.profile.FlowSpecProfile;
19 import org.opendaylight.yang.gen.v1.urn.packetcable.rev170224.pcmm.serviceclass.name.profile.ServiceClassNameProfile;
24 public class TrafficProfileValidator extends AbstractValidator<TrafficProfile> {
26 private static final String FS = "flow-spec-profile";
27 private static final String SCN = "service-class-name";
28 private static final String SCP = "service-class-name-profile";
29 private static final String UGS = "ugs-profile";
30 private static final String RTP = "rtp-profile";
33 protected void doValidate(final TrafficProfile trafficProfile, final Extent extent) {
34 if (trafficProfile == null) {
35 getErrorMessages().add("traffic-profile must exist");
38 if (trafficProfile.getTrafficProfileChoice() instanceof ServiceClassNameChoice) {
39 mustExist(((ServiceClassNameChoice)trafficProfile.getTrafficProfileChoice()).getServiceClassNameProfile(), SCP);
40 mustExist(((ServiceClassNameChoice)trafficProfile.getTrafficProfileChoice()).getServiceClassNameProfile().getServiceClassName(), SCN);
41 } else if (trafficProfile.getTrafficProfileChoice() instanceof FlowSpecChoice) {
42 mustExist(((FlowSpecChoice)trafficProfile.getTrafficProfileChoice()).getFlowSpecProfile(), SCP);
43 } else if (trafficProfile.getTrafficProfileChoice() instanceof RtpChoice) {
44 mustExist(((RtpChoice)trafficProfile.getTrafficProfileChoice()).getRtpProfile(), RTP);
45 } else if (trafficProfile.getTrafficProfileChoice() instanceof UgsChoice) {
46 mustExist(((UgsChoice)trafficProfile.getTrafficProfileChoice()).getUgsProfile(), UGS);
48 getErrorMessages().add("Unknown traffic profile");