Added response data to operational datastore, refactored data validation
[packetcable.git] / packetcable-policy-server / src / main / java / org / opendaylight / controller / packetcable / provider / validation / impl / validators / qos / classifier / ClassifierValidator.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.classifier;
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.yang.gen.v1.urn.packetcable.rev151026.pcmm.qos.classifier.Classifier;
14
15 /**
16  * @author rvail
17  */
18 public class ClassifierValidator extends AbstractValidator<Classifier> {
19
20     private static final String SRC_IP = "classifer.srcIp";
21     private static final String SRC_PORT = "classifer.srcPort";
22
23     private static final String DST_IP = "classifer.dstIp";
24     private static final String DST_PORT = "classifer.dstPort";
25
26     private static final String TOS_BYTE = "classifer.tos-byte";
27     private static final String TOS_MASK = "classifer.tos-mask";
28
29     private static final String PROTOCOL = "classifer.protocol";
30
31     @Override
32     public void validate(final Classifier classifier, final Extent extent) throws ValidationException {
33
34         if (classifier == null) {
35             throw new ValidationException("classifer must exist");
36         }
37
38         mustExist(classifier.getSrcIp(), SRC_IP);
39         mustExist(classifier.getSrcPort(), SRC_PORT);
40
41         mustExist(classifier.getDstIp(), DST_IP);
42         mustExist(classifier.getDstPort(), DST_PORT);
43
44         mustExist(classifier.getTosByte(), TOS_BYTE);
45         mustExist(classifier.getTosMask(), TOS_MASK);
46
47         mustExist(classifier.getProtocol(), PROTOCOL);
48
49         throwErrorsIfNeeded();
50     }
51 }