2 * Copyright (c) 2013 Cisco Systems, Inc. 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
8 package org.opendaylight.protocol.pcep.impl.message;
12 * PCEPReportMessage validator. Validates message integrity.
14 // FIXME: merge with parser
15 class PCEPReportMessageValidator {
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.");
22 // final List<CompositeStateReportObject> report = new ArrayList<CompositeStateReportObject>();
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())));
29 // if (!(objects.get(0) instanceof PCEPLspObject))
30 // return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(PCEPErrors.LSP_MISSING)));
32 // final PCEPLspObject lsp = (PCEPLspObject) objects.get(0);
35 // final List<CompositeRptPathObject> paths = new ArrayList<CompositeRptPathObject>();
37 // if (!objects.isEmpty()) {
39 // CompositeRptPathObject path;
40 // path = this.getValidCompositePath(objects);
41 // while (path != null) {
43 // if (objects.isEmpty())
45 // path = this.getValidCompositePath(objects);
47 // } catch (final PCEPDocumentedException e) {
48 // return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(e.getError())));
52 // report.add(new CompositeStateReportObject(lsp, paths));
55 // if (report.isEmpty())
56 // throw new PCEPDeserializerException("Atleast one CompositeStateReportObject is mandatory.");
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);
65 // return Arrays.asList((Message) new PCEPReportMessage(report));
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))
73 // final PCEPExplicitRouteObject explicitRoute = (PCEPExplicitRouteObject) objects.get(0);
76 // PCEPLspaObject pathLspa = null;
77 // PCEPExistingPathBandwidthObject pathBandwidth = null;
78 // PCEPReportedRouteObject pathRro = null;
79 // final List<PCEPMetricObject> pathMetrics = new ArrayList<PCEPMetricObject>();
83 // while (!objects.isEmpty()) {
84 // obj = objects.get(0);
85 // if (obj instanceof UnknownObject) {
86 // throw new PCEPDocumentedException("Unknown object", ((UnknownObject) obj).getError());
92 // if (obj instanceof PCEPLspaObject) {
93 // pathLspa = (PCEPLspaObject) obj;
98 // if (obj instanceof PCEPExistingPathBandwidthObject) {
99 // pathBandwidth = (PCEPExistingPathBandwidthObject) obj;
105 // if (obj instanceof PCEPReportedRouteObject) {
106 // pathRro = (PCEPReportedRouteObject) obj;
111 // if (obj instanceof PCEPMetricObject) {
112 // pathMetrics.add((PCEPMetricObject) obj);
121 // objects.remove(0);
124 // return new CompositeRptPathObject(explicitRoute, pathLspa, pathBandwidth, pathRro, pathMetrics);