BUG-47 : unfinished PCEP migration to generated DTOs.
[bgpcep.git] / pcep / impl / src / main / java / org / opendaylight / protocol / pcep / impl / message / PCCreateMessageValidator.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. 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 package org.opendaylight.protocol.pcep.impl.message;
9
10
11 /**
12  * PCCCreateMessage validator. Validates message integrity.
13  */
14 // FIXME: merge with parser
15 class PCCreateMessageValidator {
16
17         // @Override
18         // public List<Message> validate(final List<Object> objects) throws PCEPDeserializerException {
19         // if (objects == null)
20         // throw new IllegalArgumentException("Passed list can't be null.");
21         //
22         // final List<CompositeInstantiationObject> insts = new ArrayList<CompositeInstantiationObject>();
23         //
24         // CompositeInstantiationObject inst;
25         // while (!objects.isEmpty()) {
26         // try {
27         // if ((inst = this.getValidInstantiationObject(objects)) == null)
28         // break;
29         // } catch (final PCEPDocumentedException e) {
30         // return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(e.getError())));
31         // }
32         //
33         // insts.add(inst);
34         // }
35         //
36         // if (insts.isEmpty())
37         // throw new PCEPDeserializerException("At least one CompositeInstantiationObject is mandatory.");
38         //
39         // if (!objects.isEmpty())
40         // throw new PCEPDeserializerException("Unprocessed objects: " + objects);
41         //
42         // return Arrays.asList((Message) new PCCreateMessage(insts));
43         // }
44         //
45         // private CompositeInstantiationObject getValidInstantiationObject(final List<Object> objects) throws
46         // PCEPDocumentedException {
47         // if (objects.get(0) instanceof UnknownObject)
48         // throw new PCEPDocumentedException("Unknown object", ((UnknownObject) objects.get(0)).getError());
49         // if (!(objects.get(0) instanceof EndpointsObject))
50         // return null;
51         //
52         // final EndpointsObject endPoints = ((EndpointsObject) objects.get(0));
53         // objects.remove(0);
54         //
55         // if (objects.get(0) instanceof UnknownObject)
56         // throw new PCEPDocumentedException("Unknown object", ((UnknownObject) objects.get(0)).getError());
57         // if (!(objects.get(0) instanceof LspaObject))
58         // throw new PCEPDocumentedException("LSPA Object must be second.", PCEPErrors.LSPA_MISSING);
59         // final LspaObject lspa = (LspaObject) objects.get(0);
60         // objects.remove(0);
61         //
62         // ExplicitRouteObject ero = null;
63         // BandwidthObject bandwidth = null;
64         // final List<MetricObject> metrics = Lists.newArrayList();
65         //
66         // Object obj;
67         // int state = 1;
68         // while (!objects.isEmpty()) {
69         // obj = objects.get(0);
70         // if (obj instanceof UnknownObject) {
71         // throw new PCEPDocumentedException("Unknown object", ((UnknownObject) obj).getError());
72         // }
73         //
74         // switch (state) {
75         // case 1:
76         // state = 2;
77         // if (obj instanceof ExplicitRouteObject) {
78         // ero = (ExplicitRouteObject) obj;
79         // break;
80         // }
81         // case 2:
82         // state = 3;
83         // if (obj instanceof BandwidthObject) {
84         // bandwidth = (BandwidthObject) obj;
85         // break;
86         // }
87         // case 3:
88         // state = 4;
89         // if (obj instanceof MetricObject) {
90         // metrics.add((MetricObject) obj);
91         // state = 3;
92         // break;
93         // }
94         // }
95         //
96         // if (state == 4)
97         // break;
98         //
99         // objects.remove(0);
100         // }
101         //
102         // return new CompositeInstantiationObject(endPoints, lspa, ero, bandwidth, metrics);
103         // }
104
105 }