BUG-47 : unfinished PCEP migration to generated DTOs.
[bgpcep.git] / pcep / impl / src / main / java / org / opendaylight / protocol / pcep / impl / message / PCEPUpdateRequestMessageValidator.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 import java.util.List;
11
12 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
14 import org.slf4j.Logger;
15 import org.slf4j.LoggerFactory;
16
17 /**
18  * PCEPUpdateRequestMessage validator. Validates message integrity.
19  */
20 // FIXME: merge with parser
21 class PCEPUpdateRequestMessageValidator {
22
23         private static final Logger logger = LoggerFactory.getLogger(PCEPUpdateRequestMessageValidator.class);
24
25         public List<Message> validate(final List<Object> objects) throws PCEPDeserializerException {
26                 if (objects == null)
27                         throw new IllegalArgumentException("Passed list can't be null.");
28
29                 // final List<CompositeUpdateRequestObject> updateRequests = new ArrayList<CompositeUpdateRequestObject>();
30                 //
31                 // while (!objects.isEmpty()) {
32                 // if (objects.get(0) instanceof UnknownObject) {
33                 // logger.warn("Unknown object found (should be Lsp) - {}.", objects.get(0));
34                 // return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(((UnknownObject)
35                 // objects.get(0)).getError())));
36                 // }
37                 // if (!(objects.get(0) instanceof PCEPLspObject))
38                 // return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(PCEPErrors.LSP_MISSING)));
39                 //
40                 // final PCEPLspObject lsp = (PCEPLspObject) objects.get(0);
41                 // objects.remove(0);
42                 //
43                 // final List<CompositeUpdPathObject> paths = new ArrayList<CompositeUpdPathObject>();
44                 //
45                 // if (!objects.isEmpty()) {
46                 // try {
47                 // CompositeUpdPathObject path;
48                 // path = this.getValidCompositePath(objects);
49                 // while (path != null) {
50                 // paths.add(path);
51                 // if (objects.isEmpty())
52                 // break;
53                 // path = this.getValidCompositePath(objects);
54                 // }
55                 // } catch (final PCEPDocumentedException e) {
56                 // logger.warn("Serializing failed: {}.", e);
57                 // return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(e.getError())));
58                 // }
59                 // }
60                 //
61                 // updateRequests.add(new CompositeUpdateRequestObject(lsp, paths));
62                 // }
63                 //
64                 // if (updateRequests.isEmpty())
65                 // return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(PCEPErrors.LSP_MISSING)));
66                 //
67                 // if (!objects.isEmpty())
68                 // throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
69                 //
70                 // return Arrays.asList((Message) new PCEPUpdateRequestMessage(updateRequests));
71                 return null;
72         }
73
74         // private CompositeUpdPathObject getValidCompositePath(final List<Object> objects) throws PCEPDocumentedException {
75         // if (!(objects.get(0) instanceof PCEPExplicitRouteObject))
76         // return null;
77         //
78         // if (objects.get(0) instanceof UnknownObject)
79         // throw new PCEPDocumentedException("Unknown object", ((UnknownObject) objects.get(0)).getError());
80         // final PCEPExplicitRouteObject explicitRoute = (PCEPExplicitRouteObject) objects.get(0);
81         // objects.remove(0);
82         //
83         // PCEPLspaObject pathLspa = null;
84         // PCEPRequestedPathBandwidthObject pathBandwidth = null;
85         // final List<PCEPMetricObject> pathMetrics = new ArrayList<PCEPMetricObject>();
86         //
87         // Object obj;
88         // int state = 1;
89         // while (!objects.isEmpty()) {
90         // obj = objects.get(0);
91         // if (obj instanceof UnknownObject) {
92         // throw new PCEPDocumentedException("Unknown object", ((UnknownObject) obj).getError());
93         // }
94         //
95         // switch (state) {
96         // case 1:
97         // state = 2;
98         // if (obj instanceof PCEPLspaObject) {
99         // pathLspa = (PCEPLspaObject) obj;
100         // break;
101         // }
102         // case 2:
103         // state = 3;
104         // if (obj instanceof PCEPRequestedPathBandwidthObject) {
105         // pathBandwidth = (PCEPRequestedPathBandwidthObject) obj;
106         // break;
107         // }
108         // case 3:
109         // state = 4;
110         // if (obj instanceof PCEPMetricObject) {
111         // pathMetrics.add((PCEPMetricObject) obj);
112         // state = 3;
113         // break;
114         // }
115         // }
116         //
117         // if (state == 4)
118         // break;
119         //
120         // objects.remove(0);
121         // }
122         //
123         // return new CompositeUpdPathObject(explicitRoute, pathLspa, pathBandwidth, pathMetrics);
124         // }
125
126 }