Adding support for multiple classifiers per gate
[packetcable.git] / packetcable-policy-server / src / main / java / org / opendaylight / controller / packetcable / provider / validation / impl / validators / qos / GateValidator.java
1 /*
2  * Copyright (c) 2015 CableLabs and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.controller.packetcable.provider.validation.impl.validators.qos;
10
11 import org.opendaylight.controller.packetcable.provider.validation.ValidationException;
12 import org.opendaylight.controller.packetcable.provider.validation.impl.validators.AbstractValidator;
13 import org.opendaylight.controller.packetcable.provider.validation.impl.validators.qos.classifier.ClassifiersValidator;
14 import org.opendaylight.yang.gen.v1.urn.packetcable.rev151101.pcmm.qos.gates.apps.app.subscribers.subscriber.gates.Gate;
15
16 /**
17  * @author rvail
18  */
19 public class GateValidator extends AbstractValidator<Gate> {
20
21     private static final String GATE_ID = "gate.gateId";
22     private static final String GATE_SPEC = "gate.gate-spec";
23     private static final String TRAFFIC_PROFILE = "gate.traffic-profile";
24     private static final String CLASSIFIERS = "gate.classifiers";
25
26 //    private final GateSpecValidatator gateSpecValidatator = new GateSpecValidatator();
27     private final TrafficProfileValidator trafficProfileValidator = new TrafficProfileValidator();
28     private final ClassifiersValidator classifiersValidator = new ClassifiersValidator();
29
30     @Override
31     public void validate(final Gate gate, final Extent extent) throws ValidationException {
32         if (gate == null) {
33             throw new ValidationException("gate must exist");
34         }
35
36         mustExist(gate.getGateId(), GATE_ID);
37
38         // all leafs in GateSpec are optional
39         // mustExist(gate.getGateSpec(), GATE_SPEC);
40
41         // Classifiers
42         mustExist(gate.getClassifiers(), CLASSIFIERS);
43
44         mustExist(gate.getTrafficProfile(), TRAFFIC_PROFILE);
45         if (extent == Extent.NODE_AND_SUBTREE) {
46             validateChild(trafficProfileValidator, gate.getTrafficProfile());
47             validateChild(classifiersValidator, gate.getClassifiers());
48         }
49
50         throwErrorsIfNeeded();
51     }
52 }