BUG-47 : unfinished PCEP migration to generated DTOs.
[bgpcep.git] / pcep / impl / src / main / java / org / opendaylight / protocol / pcep / impl / message / PCEPReportMessageValidator.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  * PCEPReportMessage validator. Validates message integrity.
13  */
14 // FIXME: merge with parser
15 class PCEPReportMessageValidator {
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<CompositeStateReportObject> report = new ArrayList<CompositeStateReportObject>();
23         //
24         // while (!objects.isEmpty()) {
25         // if (objects.get(0) instanceof UnknownObject)
26         // return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(((UnknownObject)
27         // objects.get(0)).getError())));
28         //
29         // if (!(objects.get(0) instanceof PCEPLspObject))
30         // return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(PCEPErrors.LSP_MISSING)));
31         //
32         // final PCEPLspObject lsp = (PCEPLspObject) objects.get(0);
33         // objects.remove(0);
34         //
35         // final List<CompositeRptPathObject> paths = new ArrayList<CompositeRptPathObject>();
36         //
37         // if (!objects.isEmpty()) {
38         // try {
39         // CompositeRptPathObject path;
40         // path = this.getValidCompositePath(objects);
41         // while (path != null) {
42         // paths.add(path);
43         // if (objects.isEmpty())
44         // break;
45         // path = this.getValidCompositePath(objects);
46         // }
47         // } catch (final PCEPDocumentedException e) {
48         // return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(e.getError())));
49         // }
50         // }
51         //
52         // report.add(new CompositeStateReportObject(lsp, paths));
53         // }
54         //
55         // if (report.isEmpty())
56         // throw new PCEPDeserializerException("Atleast one CompositeStateReportObject is mandatory.");
57         //
58         // if (!objects.isEmpty()) {
59         // if (objects.get(0) instanceof UnknownObject)
60         // return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(((UnknownObject)
61         // objects.get(0)).getError())));
62         // throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
63         // }
64         //
65         // return Arrays.asList((Message) new PCEPReportMessage(report));
66         // }
67         //
68         // private CompositeRptPathObject getValidCompositePath(final List<Object> objects) throws PCEPDocumentedException {
69         // if (objects.get(0) instanceof UnknownObject)
70         // throw new PCEPDocumentedException("Unknown object", ((UnknownObject) objects.get(0)).getError());
71         // if (!(objects.get(0) instanceof PCEPExplicitRouteObject))
72         // return null;
73         // final PCEPExplicitRouteObject explicitRoute = (PCEPExplicitRouteObject) objects.get(0);
74         // objects.remove(0);
75         //
76         // PCEPLspaObject pathLspa = null;
77         // PCEPExistingPathBandwidthObject pathBandwidth = null;
78         // PCEPReportedRouteObject pathRro = null;
79         // final List<PCEPMetricObject> pathMetrics = new ArrayList<PCEPMetricObject>();
80         //
81         // Object obj;
82         // int state = 1;
83         // while (!objects.isEmpty()) {
84         // obj = objects.get(0);
85         // if (obj instanceof UnknownObject) {
86         // throw new PCEPDocumentedException("Unknown object", ((UnknownObject) obj).getError());
87         // }
88         //
89         // switch (state) {
90         // case 1:
91         // state = 2;
92         // if (obj instanceof PCEPLspaObject) {
93         // pathLspa = (PCEPLspaObject) obj;
94         // break;
95         // }
96         // case 2:
97         // state = 3;
98         // if (obj instanceof PCEPExistingPathBandwidthObject) {
99         // pathBandwidth = (PCEPExistingPathBandwidthObject) obj;
100         // break;
101         // }
102         //
103         // case 3:
104         // state = 4;
105         // if (obj instanceof PCEPReportedRouteObject) {
106         // pathRro = (PCEPReportedRouteObject) obj;
107         // break;
108         // }
109         // case 4:
110         // state = 5;
111         // if (obj instanceof PCEPMetricObject) {
112         // pathMetrics.add((PCEPMetricObject) obj);
113         // state = 4;
114         // break;
115         // }
116         // }
117         //
118         // if (state == 5)
119         // break;
120         //
121         // objects.remove(0);
122         // }
123         //
124         // return new CompositeRptPathObject(explicitRoute, pathLspa, pathBandwidth, pathRro, pathMetrics);
125         // }
126 }