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 * PCCCreateMessage validator. Validates message integrity.
14 // FIXME: merge with parser
15 class PCCreateMessageValidator {
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<CompositeInstantiationObject> insts = new ArrayList<CompositeInstantiationObject>();
24 // CompositeInstantiationObject inst;
25 // while (!objects.isEmpty()) {
27 // if ((inst = this.getValidInstantiationObject(objects)) == null)
29 // } catch (final PCEPDocumentedException e) {
30 // return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(e.getError())));
36 // if (insts.isEmpty())
37 // throw new PCEPDeserializerException("At least one CompositeInstantiationObject is mandatory.");
39 // if (!objects.isEmpty())
40 // throw new PCEPDeserializerException("Unprocessed objects: " + objects);
42 // return Arrays.asList((Message) new PCCreateMessage(insts));
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))
52 // final EndpointsObject endPoints = ((EndpointsObject) objects.get(0));
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);
62 // ExplicitRouteObject ero = null;
63 // BandwidthObject bandwidth = null;
64 // final List<MetricObject> metrics = Lists.newArrayList();
68 // while (!objects.isEmpty()) {
69 // obj = objects.get(0);
70 // if (obj instanceof UnknownObject) {
71 // throw new PCEPDocumentedException("Unknown object", ((UnknownObject) obj).getError());
77 // if (obj instanceof ExplicitRouteObject) {
78 // ero = (ExplicitRouteObject) obj;
83 // if (obj instanceof BandwidthObject) {
84 // bandwidth = (BandwidthObject) obj;
89 // if (obj instanceof MetricObject) {
90 // metrics.add((MetricObject) obj);
102 // return new CompositeInstantiationObject(endPoints, lspa, ero, bandwidth, metrics);