BUG-159 : Removed PCEPDocumentedException. 31/2931/1
authorDana Kutenicsova <dkutenic@cisco.com>
Thu, 21 Nov 2013 09:29:52 +0000 (10:29 +0100)
committerDana Kutenicsova <dkutenic@cisco.com>
Thu, 21 Nov 2013 09:30:33 +0000 (10:30 +0100)
Change-Id: Ie8021a2ad659d2653201220b5cb16be0a0702865
Signed-off-by: Dana Kutenicsova <dkutenic@cisco.com>
22 files changed:
pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPDocumentedException.java [deleted file]
pcep/api/src/test/java/org/opendaylight/protocol/pcep/api/APITest.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/AbstractPCEPSessionNegotiator.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPSessionImpl.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/Util.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/AbstractMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPErrorMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPNotificationMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPReplyMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPReportMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPUpdateRequestMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PcinitiateMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPClassTypeObjectParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/object/PCEPOpenObjectParser.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/FiniteStateMachineTest.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/MockPCE.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/PCEPObjectParserTest.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/PCEPValidatorTest.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/PCEPErrorMapping.java [moved from pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPErrorMapping.java with 99% similarity]
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/PCEPErrors.java [moved from pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPErrors.java with 99% similarity]
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/UnknownObject.java [moved from pcep/api/src/main/java/org/opendaylight/protocol/pcep/UnknownObject.java with 97% similarity]
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/pojo/SimpleObjectHandlerRegistry.java

diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPDocumentedException.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPDocumentedException.java
deleted file mode 100644 (file)
index 0b58280..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.protocol.pcep;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.opendaylight.protocol.framework.DocumentedException;
-
-/**
- * There are several errors documented in RFC5440 or in draft, that have
- * specific meaning for the PCE. This exception is used, when any of those
- * errors occurs.
- */
-public class PCEPDocumentedException extends DocumentedException {
-
-       private static final long serialVersionUID = 5146586011100522025L;
-
-       private final PCEPErrors error;
-
-       private static final Logger logger = LoggerFactory.getLogger(PCEPDocumentedException.class);
-
-       /**
-        * Used when an error occured that is described in rfc or draft
-        *
-        * @param message
-        *                      message bound with this exception
-        * @param error
-        *            specific documented error
-        */
-       public PCEPDocumentedException(String message, PCEPErrors error) {
-               super(message);
-               this.error = error;
-               logger.error("Error = " + error, this);
-       }
-
-       /**
-        * Returns specific documented error
-        *
-        * @return documented error
-        */
-       public PCEPErrors getError() {
-               return this.error;
-       }
-}
index 0e0c1267d637c2fb535cefdb2180d835abb773ee..62907a63755c600eb8f93cab758f79b4a6ac5720 100644 (file)
@@ -12,8 +12,6 @@ import static org.junit.Assert.assertTrue;
 
 import org.junit.Test;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.PCEPDocumentedException;
-import org.opendaylight.protocol.pcep.PCEPErrors;
 
 public class APITest {
 
@@ -26,10 +24,4 @@ public class APITest {
                assertEquals("Some error message.", e1.getErrorMessage());
                assertTrue(e1.getCause() instanceof IllegalArgumentException);
        }
-
-       @Test
-       public void testDocumentedException() throws PCEPDocumentedException {
-               final PCEPDocumentedException de = new PCEPDocumentedException("", PCEPErrors.C_BIT_SET);
-               assertEquals(PCEPErrors.C_BIT_SET, de.getError());
-       }
 }
index 6666388a3b78af9bd533550231a785ebd2277f9b..27aa5f44f5a53ab2cb8071d1a0c091e26321750e 100644 (file)
@@ -19,7 +19,7 @@ import java.util.concurrent.TimeoutException;
 import javax.annotation.concurrent.GuardedBy;
 
 import org.opendaylight.protocol.framework.AbstractSessionNegotiator;
-import org.opendaylight.protocol.pcep.PCEPErrors;
+import org.opendaylight.protocol.pcep.spi.PCEPErrors;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Keepalive;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.KeepaliveBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.OpenBuilder;
index d584613d88ecfcc2b47bc9ce0a74cb53f90999b0..17443e6a7f1b258210f930dc63edd6ce7aeda45a 100644 (file)
@@ -25,10 +25,10 @@ import java.util.concurrent.TimeUnit;
 
 import org.opendaylight.protocol.framework.AbstractProtocolSession;
 import org.opendaylight.protocol.pcep.PCEPCloseTermination;
-import org.opendaylight.protocol.pcep.PCEPErrors;
 import org.opendaylight.protocol.pcep.PCEPSession;
 import org.opendaylight.protocol.pcep.PCEPSessionListener;
 import org.opendaylight.protocol.pcep.TerminationReason;
+import org.opendaylight.protocol.pcep.spi.PCEPErrors;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.CloseBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Keepalive;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.KeepaliveBuilder;
index a839e6484018549277818ca11f3e8086b1a497e6..bbe273c0c65b188f3c3e3b694aa093ed1724d705 100644 (file)
@@ -13,9 +13,9 @@ import java.util.List;
 
 import org.opendaylight.protocol.concepts.Ipv4Util;
 import org.opendaylight.protocol.concepts.Ipv6Util;
-import org.opendaylight.protocol.pcep.PCEPErrorMapping;
-import org.opendaylight.protocol.pcep.PCEPErrorMapping.PCEPErrorIdentifier;
-import org.opendaylight.protocol.pcep.PCEPErrors;
+import org.opendaylight.protocol.pcep.spi.PCEPErrorMapping;
+import org.opendaylight.protocol.pcep.spi.PCEPErrors;
+import org.opendaylight.protocol.pcep.spi.PCEPErrorMapping.PCEPErrorIdentifier;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcerrBuilder;
index 83504e04367e4c141869937bdb5cb67b046098aa..42f05bc94bdf22f5ed6768de4ba346285e0f0e3d 100644 (file)
@@ -5,15 +5,14 @@ import java.util.BitSet;
 import java.util.List;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.PCEPDocumentedException;
-import org.opendaylight.protocol.pcep.PCEPErrorMapping;
-import org.opendaylight.protocol.pcep.PCEPErrors;
 import org.opendaylight.protocol.pcep.spi.MessageParser;
 import org.opendaylight.protocol.pcep.spi.MessageSerializer;
 import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
 import org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl;
 import org.opendaylight.protocol.pcep.spi.ObjectParser;
 import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
+import org.opendaylight.protocol.pcep.spi.PCEPErrorMapping;
+import org.opendaylight.protocol.pcep.spi.PCEPErrors;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcerrBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
@@ -23,15 +22,12 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.ErrorObjectBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.PcerrMessageBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.ErrorsBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
 import com.google.common.primitives.UnsignedBytes;
 
 public abstract class AbstractMessageParser implements MessageParser, MessageSerializer {
-       private static final Logger LOG = LoggerFactory.getLogger(AbstractMessageParser.class);
 
        private static final int COMMON_OBJECT_HEADER_LENGTH = 4;
 
@@ -152,8 +148,7 @@ public abstract class AbstractMessageParser implements MessageParser, MessageSer
                                                                                maping.getFromErrorsEnum(e).value).build()).build())).build()).build();
        }
 
-       // FIXME: remove PCEPDocumentedException
-       abstract protected Message validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException, PCEPDocumentedException;
+       abstract protected Message validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException;
 
        @Override
        public final Message parseMessage(final byte[] buffer, final List<Message> errors) throws PCEPDeserializerException {
@@ -163,12 +158,6 @@ public abstract class AbstractMessageParser implements MessageParser, MessageSer
                final List<Object> objs = parseObjects(buffer);
 
                // Run validation
-               try {
-                       return validate(objs, errors);
-               } catch (PCEPDocumentedException e) {
-                       LOG.info("Message failed to validate", e);
-                       errors.add(createErrorMsg(e.getError()));
-                       return null;
-               }
+               return validate(objs, errors);
        }
 }
index 94f908815b7bccba41473ece48f6435c6af54b31..c45a23a82d588cde1b0d8be66e467485a6fa3f66 100644 (file)
@@ -12,10 +12,8 @@ import io.netty.buffer.ByteBuf;
 import java.util.List;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.PCEPDocumentedException;
-import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.UnknownObject;
 import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.UnknownObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcerrBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
@@ -75,7 +73,7 @@ public class PCEPErrorMessageParser extends AbstractMessageParser {
        }
 
        @Override
-       protected PcerrMessage validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException, PCEPDocumentedException {
+       protected PcerrMessage validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
                if (objects == null) {
                        throw new IllegalArgumentException("Passed list can't be null.");
                }
@@ -99,9 +97,6 @@ public class PCEPErrorMessageParser extends AbstractMessageParser {
                        objects.remove(0);
                } else if (obj instanceof Rp) {
                        final Rp o = ((Rp) obj);
-                       if (o.isProcessingRule()) {
-                               throw new PCEPDocumentedException("Invalid setting of P flag.", PCEPErrors.P_FLAG_NOT_SET);
-                       }
                        requestParameters.add(new RpsBuilder().setRp(o).build());
                        state = State.RpIn;
                        objects.remove(0);
@@ -127,9 +122,6 @@ public class PCEPErrorMessageParser extends AbstractMessageParser {
                                state = State.Error;
                                if (obj instanceof Rp) {
                                        final Rp o = ((Rp) obj);
-                                       if (o.isProcessingRule()) {
-                                               throw new PCEPDocumentedException("Invalid setting of P flag.", PCEPErrors.P_FLAG_NOT_SET);
-                                       }
                                        requestParameters.add(new RpsBuilder().setRp(o).build());
                                        state = State.RpIn;
                                        break;
index 068e25a91d296de35ca2d3d064dccd4e84b90843..9244baca90113e52334b4d2d12266990fbcc95db 100644 (file)
@@ -9,24 +9,15 @@ package org.opendaylight.protocol.pcep.impl.message;
 
 import io.netty.buffer.ByteBuf;
 
-import java.util.Arrays;
 import java.util.List;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.PCEPDocumentedException;
-import org.opendaylight.protocol.pcep.PCEPErrorMapping;
-import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.UnknownObject;
 import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcerrBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcntfBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.PcntfMessage;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.notification.object.CNotification;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.ErrorObjectBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.PcerrMessageBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.ErrorsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.PcntfMessageBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.Notifications;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.NotificationsBuilder;
@@ -81,26 +72,15 @@ public class PCEPNotificationMessageParser extends AbstractMessageParser {
                        throw new PCEPDeserializerException("Notification message cannot be empty.");
                }
 
-               final PCEPErrorMapping maping = PCEPErrorMapping.getInstance();
-
                final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.Notifications> compositeNotifications = Lists.newArrayList();
 
                while (!objects.isEmpty()) {
                        org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.Notifications comObj;
-                       try {
-                               comObj = getValidNotificationComposite(objects);
-                       } catch (final PCEPDocumentedException e) {
-                               final PcerrMessageBuilder b = new PcerrMessageBuilder();
-                               b.setErrors(Arrays.asList(new ErrorsBuilder().setErrorObject(
-                                               new ErrorObjectBuilder().setType(maping.getFromErrorsEnum(e.getError()).type).setValue(
-                                                               maping.getFromErrorsEnum(e.getError()).value).build()).build()));
-                               return new PcerrBuilder().setPcerrMessage(b.build()).build();
-                       }
+                       comObj = getValidNotificationComposite(objects);
 
                        if (comObj == null) {
                                break;
                        }
-
                        compositeNotifications.add(comObj);
                }
 
@@ -116,7 +96,7 @@ public class PCEPNotificationMessageParser extends AbstractMessageParser {
        }
 
        private static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.Notifications getValidNotificationComposite(
-                       final List<Object> objects) throws PCEPDocumentedException {
+                       final List<Object> objects) {
                final List<Rps> requestParameters = Lists.newArrayList();
                final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.Notifications> notifications = Lists.newArrayList();
                Object obj;
@@ -124,19 +104,11 @@ public class PCEPNotificationMessageParser extends AbstractMessageParser {
                State state = State.Init;
                while (!objects.isEmpty() && !state.equals(State.End)) {
                        obj = objects.get(0);
-
-                       if (obj instanceof UnknownObject) {
-                               throw new PCEPDocumentedException("Unknown object", ((UnknownObject) obj).getError());
-                       }
-
                        switch (state) {
                        case Init:
                                state = State.RpIn;
                                if (obj instanceof Rp) {
                                        final Rp rp = (Rp) obj;
-                                       if (rp.isProcessingRule()) {
-                                               throw new PCEPDocumentedException("Invalid setting of P flag.", PCEPErrors.P_FLAG_NOT_SET);
-                                       }
                                        requestParameters.add(new RpsBuilder().setRp(rp).build());
                                        state = State.Init;
                                        break;
index cdbc59ef3669c4939df2bf5a5fc4cb2bc4f5d408..d501b168eac895c2f3e4974b061daf390a93d6e3 100644 (file)
@@ -11,10 +11,9 @@ import io.netty.buffer.ByteBuf;
 
 import java.util.List;
 
-import org.opendaylight.protocol.pcep.PCEPDocumentedException;
-import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.UnknownObject;
+import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.PCEPErrors;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Pcrep;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcrepBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
@@ -115,17 +114,30 @@ public class PCEPReplyMessageParser extends AbstractMessageParser {
        }
 
        @Override
-       protected Pcrep validate(final List<Object> objects, final List<Message> errors) throws PCEPDocumentedException {
+       protected Pcrep validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
+               if (objects == null) {
+                       throw new IllegalArgumentException("Passed list can't be null.");
+               }
+               if (objects.isEmpty()) {
+                       throw new PCEPDeserializerException("Pcrep message cannot be empty.");
+               }
                final List<Replies> replies = Lists.newArrayList();
                while (!objects.isEmpty()) {
-                       replies.add(this.getValidReply(objects));
+                       final Replies r = this.getValidReply(objects, errors);
+                       if (r != null) {
+                               replies.add(r);
+                       }
+               }
+               if (!objects.isEmpty()) {
+                       throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
                }
                return new PcrepBuilder().setPcrepMessage(new PcrepMessageBuilder().setReplies(replies).build()).build();
        }
 
-       private Replies getValidReply(final List<Object> objects) throws PCEPDocumentedException {
+       private Replies getValidReply(final List<Object> objects, final List<Message> errors) {
                if (!(objects.get(0) instanceof Rp)) {
-                       throw new PCEPDocumentedException("Pcrep message must contain at least one RP object.", PCEPErrors.RP_MISSING);
+                       errors.add(createErrorMsg(PCEPErrors.RP_MISSING));
+                       return null;
                }
                final Rp rp = (Rp) objects.get(0);
                objects.remove(0);
@@ -158,7 +170,7 @@ public class PCEPReplyMessageParser extends AbstractMessageParser {
                return new RepliesBuilder().setRp(rp).setResult(res).build();
        }
 
-       private void parseAttributes(final FailureBuilder builder, final List<Object> objects) throws PCEPDocumentedException {
+       private void parseAttributes(final FailureBuilder builder, final List<Object> objects) {
                final List<Metrics> pathMetrics = Lists.newArrayList();
 
                Object obj;
@@ -197,8 +209,6 @@ public class PCEPReplyMessageParser extends AbstractMessageParser {
                                break;
                        case End:
                                break;
-                       default:
-                               throw new PCEPDocumentedException("Unknown object", ((UnknownObject) obj).getError());
                        }
                        if (!state.equals(State.End)) {
                                objects.remove(0);
@@ -207,7 +217,7 @@ public class PCEPReplyMessageParser extends AbstractMessageParser {
                builder.setMetrics(pathMetrics);
        }
 
-       private void parsePath(final PathsBuilder builder, final List<Object> objects) throws PCEPDocumentedException {
+       private void parsePath(final PathsBuilder builder, final List<Object> objects) {
                final List<Metrics> pathMetrics = Lists.newArrayList();
 
                Object obj;
@@ -252,8 +262,6 @@ public class PCEPReplyMessageParser extends AbstractMessageParser {
                                break;
                        case End:
                                break;
-                       default:
-                               throw new PCEPDocumentedException("Unknown object", ((UnknownObject) obj).getError());
                        }
                        if (!state.equals(State.End)) {
                                objects.remove(0);
index b59ce68bcfc47e14fb7438096c594f98bbef3076..7a3c9221e38c7ceab026f980496b19ccb64ae5c9 100644 (file)
@@ -12,10 +12,8 @@ import io.netty.buffer.ByteBuf;
 import java.util.List;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.PCEPDocumentedException;
-import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.UnknownObject;
 import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.PCEPErrors;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Pcrpt;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcrptBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
@@ -89,7 +87,7 @@ public class PCEPReportMessageParser extends AbstractMessageParser {
        }
 
        @Override
-       public Message validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException, PCEPDocumentedException {
+       public Message validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
                if (objects == null) {
                        throw new IllegalArgumentException("Passed list can't be null.");
                }
@@ -100,22 +98,15 @@ public class PCEPReportMessageParser extends AbstractMessageParser {
                final List<Reports> reports = Lists.newArrayList();
 
                while (!objects.isEmpty()) {
-                       final Reports report = getValidReports(objects);
+                       final Reports report = getValidReports(objects, errors);
                        if (reports != null) {
                                reports.add(report);
                        }
                }
-
-               if (!objects.isEmpty()) {
-                       if (objects.get(0) instanceof UnknownObject) {
-                               throw new PCEPDocumentedException("Unknown object encountered", ((UnknownObject) objects.get(0)).getError());
-                       }
-                       throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
-               }
                return new PcrptBuilder().setPcrptMessage(new PcrptMessageBuilder().setReports(reports).build()).build();
        }
 
-       private Reports getValidReports(final List<Object> objects) throws PCEPDocumentedException {
+       private Reports getValidReports(final List<Object> objects, final List<Message> errors) {
                final ReportsBuilder builder = new ReportsBuilder();
                if (objects.get(0) instanceof Srp) {
                        builder.setSrp((Srp) objects.get(0));
@@ -125,7 +116,8 @@ public class PCEPReportMessageParser extends AbstractMessageParser {
                        builder.setLsp((Lsp) objects.get(0));
                        objects.remove(0);
                } else {
-                       throw new PCEPDocumentedException("LSP object missing", PCEPErrors.LSP_MISSING);
+                       errors.add(createErrorMsg(PCEPErrors.LSP_MISSING));
+                       return null;
                }
                if (!objects.isEmpty()) {
                        final PathBuilder pBuilder = new PathBuilder();
@@ -135,7 +127,7 @@ public class PCEPReportMessageParser extends AbstractMessageParser {
                return builder.build();
        }
 
-       private void parsePath(final List<Object> objects, final PathBuilder builder) throws PCEPDocumentedException {
+       private void parsePath(final List<Object> objects, final PathBuilder builder) {
                final List<Metrics> pathMetrics = Lists.newArrayList();
                Object obj;
                State state = State.Init;
@@ -184,10 +176,6 @@ public class PCEPReportMessageParser extends AbstractMessageParser {
                                break;
                        case End:
                                break;
-                       default:
-                               if (obj instanceof UnknownObject) {
-                                       throw new PCEPDocumentedException("Unknown object", ((UnknownObject) obj).getError());
-                               }
                        }
                        if (!state.equals(State.End)) {
                                objects.remove(0);
index ca0ba404e6281be14ade122f959edc50d5858224..79c7ccd4b4551415edb0c6e30b8e1670299444e7 100644 (file)
@@ -12,10 +12,8 @@ import io.netty.buffer.ByteBuf;
 import java.util.List;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.PCEPDocumentedException;
-import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.UnknownObject;
 import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.PCEPErrors;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Pcupd;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcupdBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
@@ -81,7 +79,7 @@ public class PCEPUpdateRequestMessageParser extends AbstractMessageParser {
        }
 
        @Override
-       protected Message validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException, PCEPDocumentedException {
+       protected Message validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
                if (objects == null) {
                        throw new IllegalArgumentException("Passed list can't be null.");
                }
@@ -92,33 +90,32 @@ public class PCEPUpdateRequestMessageParser extends AbstractMessageParser {
                final List<Updates> updateRequests = Lists.newArrayList();
 
                while (!objects.isEmpty()) {
-                       final Updates update = getValidUpdates(objects);
+                       final Updates update = getValidUpdates(objects, errors);
                        if (update != null) {
                                updateRequests.add(update);
                        }
                }
                if (!objects.isEmpty()) {
-                       if (objects.get(0) instanceof UnknownObject) {
-                               throw new PCEPDocumentedException("Unknown object encountered", ((UnknownObject) objects.get(0)).getError());
-                       }
                        throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
                }
                return new PcupdBuilder().setPcupdMessage(new PcupdMessageBuilder().setUpdates(updateRequests).build()).build();
        }
 
-       private Updates getValidUpdates(final List<Object> objects) throws PCEPDocumentedException {
+       private Updates getValidUpdates(final List<Object> objects, final List<Message> errors) {
                final UpdatesBuilder builder = new UpdatesBuilder();
                if (objects.get(0) instanceof Srp) {
                        builder.setSrp((Srp) objects.get(0));
                        objects.remove(0);
                } else {
-                       throw new PCEPDocumentedException("Srp object missing.", PCEPErrors.SRP_MISSING);
+                       errors.add(createErrorMsg(PCEPErrors.SRP_MISSING));
+                       return null;
                }
                if (objects.get(0) instanceof Lsp) {
                        builder.setLsp((Lsp) objects.get(0));
                        objects.remove(0);
                } else {
-                       throw new PCEPDocumentedException("Lsp object missing.", PCEPErrors.LSP_MISSING);
+                       errors.add(createErrorMsg(PCEPErrors.LSP_MISSING));
+                       return null;
                }
                if (!objects.isEmpty()) {
                        final PathBuilder pBuilder = new PathBuilder();
@@ -126,7 +123,8 @@ public class PCEPUpdateRequestMessageParser extends AbstractMessageParser {
                                pBuilder.setEro((Ero) objects.get(0));
                                objects.remove(0);
                        } else {
-                               throw new PCEPDocumentedException("Ero object missing.", PCEPErrors.ERO_MISSING);
+                               errors.add(createErrorMsg(PCEPErrors.ERO_MISSING));
+                               return null;
                        }
                        parsePath(objects, pBuilder);
                        builder.setPath(pBuilder.build());
@@ -134,7 +132,7 @@ public class PCEPUpdateRequestMessageParser extends AbstractMessageParser {
                return builder.build();
        }
 
-       private void parsePath(final List<Object> objects, final PathBuilder pBuilder) throws PCEPDocumentedException {
+       private void parsePath(final List<Object> objects, final PathBuilder pBuilder) {
                final List<Metrics> pathMetrics = Lists.newArrayList();
                Object obj;
                State state = State.Init;
@@ -171,10 +169,6 @@ public class PCEPUpdateRequestMessageParser extends AbstractMessageParser {
                                break;
                        case End:
                                break;
-                       default:
-                               if (obj instanceof UnknownObject) {
-                                       throw new PCEPDocumentedException("Unknown object", ((UnknownObject) obj).getError());
-                               }
                        }
                        if (!state.equals(State.End)) {
                                objects.remove(0);
index d804f790293c2770984fe79c848377038f1668ee..60fd4cf0aaa4488ad00c5d8ff5648047e0ae5bf7 100644 (file)
@@ -9,15 +9,10 @@ package org.opendaylight.protocol.pcep.impl.message;
 
 import io.netty.buffer.ByteBuf;
 
-import java.util.Arrays;
 import java.util.List;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.PCEPDocumentedException;
-import org.opendaylight.protocol.pcep.PCEPErrorMapping;
-import org.opendaylight.protocol.pcep.UnknownObject;
 import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcerrBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Pcinitiate;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.PcinitiateBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
@@ -32,9 +27,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.typ
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lsp.object.Lsp;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.lspa.object.Lspa;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.metric.object.Metric;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcep.error.object.ErrorObjectBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.PcerrMessageBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcerr.message.pcerr.message.ErrorsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcinitiate.message.PcinitiateMessageBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcinitiate.message.pcinitiate.message.Requests;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcinitiate.message.pcinitiate.message.RequestsBuilder;
@@ -92,21 +84,12 @@ public class PcinitiateMessageParser extends AbstractMessageParser {
                        throw new IllegalArgumentException("Passed list can't be null.");
                }
                final PcinitiateMessageBuilder builder = new PcinitiateMessageBuilder();
-               final PCEPErrorMapping maping = PCEPErrorMapping.getInstance();
                final List<Requests> reqs = Lists.newArrayList();
                Requests req = null;
                while (!objects.isEmpty()) {
-                       try {
-                               req = this.getValidRequest(objects);
-                               if (req == null) {
-                                       break;
-                               }
-                       } catch (final PCEPDocumentedException e) {
-                               final PcerrMessageBuilder b = new PcerrMessageBuilder();
-                               b.setErrors(Arrays.asList(new ErrorsBuilder().setErrorObject(
-                                               new ErrorObjectBuilder().setType(maping.getFromErrorsEnum(e.getError()).type).setValue(
-                                                               maping.getFromErrorsEnum(e.getError()).value).build()).build()));
-                               return new PcerrBuilder().setPcerrMessage(b.build()).build();
+                       req = this.getValidRequest(objects);
+                       if (req == null) {
+                               break;
                        }
                        reqs.add(req);
                }
@@ -114,7 +97,7 @@ public class PcinitiateMessageParser extends AbstractMessageParser {
                return new PcinitiateBuilder().setPcinitiateMessage(builder.build()).build();
        }
 
-       private Requests getValidRequest(final List<Object> objects) throws PCEPDocumentedException {
+       private Requests getValidRequest(final List<Object> objects) {
                final RequestsBuilder builder = new RequestsBuilder();
                builder.setSrp((Srp) objects.get(0));
                objects.remove(0);
@@ -172,8 +155,6 @@ public class PcinitiateMessageParser extends AbstractMessageParser {
                                break;
                        case End:
                                break;
-                       default:
-                               throw new PCEPDocumentedException("Unknown object", ((UnknownObject) obj).getError());
                        }
                        if (!state.equals(State.End)) {
                                objects.remove(0);
index 34fd29873cf79de87a384c9324abd6dc995d3b23..72155f39282c0731c950fb4a6a4c79d3f58776a1 100644 (file)
@@ -8,9 +8,9 @@
 package org.opendaylight.protocol.pcep.impl.object;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.UnknownObject;
+import org.opendaylight.protocol.pcep.spi.PCEPErrors;
 import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.UnknownObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv;
index d15e64eb792d71cbc362b75dfc503b15e18c4d7b..2fa8f3ab11f8cbdd1614bf36f389445f515e61bc 100644 (file)
@@ -9,9 +9,9 @@
 package org.opendaylight.protocol.pcep.impl.object;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.UnknownObject;
+import org.opendaylight.protocol.pcep.spi.PCEPErrors;
 import org.opendaylight.protocol.pcep.spi.TlvHandlerRegistry;
+import org.opendaylight.protocol.pcep.spi.UnknownObject;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;
index faf6163d48b619b889ffe913089663f87884a4e3..56e77c36ce16fb545a7e36e023e72ad9c13c6783 100644 (file)
@@ -32,8 +32,8 @@ import org.mockito.Mock;
 import org.mockito.MockitoAnnotations;
 import org.mockito.invocation.InvocationOnMock;
 import org.mockito.stubbing.Answer;
-import org.opendaylight.protocol.pcep.PCEPErrorMapping;
-import org.opendaylight.protocol.pcep.PCEPErrors;
+import org.opendaylight.protocol.pcep.spi.PCEPErrorMapping;
+import org.opendaylight.protocol.pcep.spi.PCEPErrors;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Keepalive;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.KeepaliveBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Open;
index a3a3c8051fc3d1c5204d5f34da81e5ca0b19487e..ce4e65f0022dc90a0d14559c76203dffd3fa81f8 100644 (file)
@@ -10,10 +10,10 @@ package org.opendaylight.protocol.pcep.impl;
 import java.util.ArrayList;
 import java.util.List;
 
-import org.opendaylight.protocol.pcep.PCEPErrors;
 import org.opendaylight.protocol.pcep.PCEPSession;
 import org.opendaylight.protocol.pcep.PCEPSessionListener;
 import org.opendaylight.protocol.pcep.PCEPTerminationReason;
+import org.opendaylight.protocol.pcep.spi.PCEPErrors;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open;
 import org.slf4j.Logger;
index b80543bfdeba14ff865ca280beca813b75ff5f78..dffc114522e9cf8e7d3e9bf574968cb7eb74f186 100644 (file)
@@ -19,7 +19,6 @@ import org.junit.Test;
 import org.opendaylight.protocol.concepts.Ipv4Util;
 import org.opendaylight.protocol.concepts.Ipv6Util;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.impl.object.PCEPBandwidthObjectParser;
 import org.opendaylight.protocol.pcep.impl.object.PCEPClassTypeObjectParser;
 import org.opendaylight.protocol.pcep.impl.object.PCEPCloseObjectParser;
@@ -123,7 +122,7 @@ public class PCEPObjectParserTest {
        }
 
        @Test
-       public void testOpenObjectWithTLV() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
+       public void testOpenObjectWithTLV() throws PCEPDeserializerException, IOException {
                final PCEPOpenObjectParser parser = new PCEPOpenObjectParser(this.tlvRegistry);
                final byte[] result = ByteArray.fileToBytes("src/test/resources/PCEPOpenObject1.bin");
 
@@ -149,7 +148,7 @@ public class PCEPObjectParserTest {
        }
 
        @Test
-       public void testCloseObject() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
+       public void testCloseObject() throws IOException, PCEPDeserializerException {
                final PCEPCloseObjectParser parser = new PCEPCloseObjectParser(this.tlvRegistry);
                final byte[] result = ByteArray.fileToBytes("src/test/resources/PCEPCloseObject1.bin");
 
@@ -163,7 +162,7 @@ public class PCEPObjectParserTest {
        }
 
        @Test
-       public void testLoadBalancingObject() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
+       public void testLoadBalancingObject() throws IOException, PCEPDeserializerException {
                final PCEPLoadBalancingObjectParser parser = new PCEPLoadBalancingObjectParser(this.tlvRegistry);
                final byte[] result = ByteArray.fileToBytes("src/test/resources/PCEPLoadBalancingObject1.bin");
 
@@ -178,7 +177,7 @@ public class PCEPObjectParserTest {
        }
 
        @Test
-       public void testLspObjectWithTLV() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
+       public void testLspObjectWithTLV() throws IOException, PCEPDeserializerException {
                final PCEPLspObjectParser parser = new PCEPLspObjectParser(this.tlvRegistry);
                final byte[] result = ByteArray.fileToBytes("src/test/resources/PCEPLspObject1WithTLV.bin");
 
@@ -277,7 +276,7 @@ public class PCEPObjectParserTest {
        }
 
        @Test
-       public void testBandwidthObject() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
+       public void testBandwidthObject() throws IOException, PCEPDeserializerException {
                final PCEPBandwidthObjectParser parser = new PCEPBandwidthObjectParser(this.tlvRegistry);
                byte[] result = ByteArray.fileToBytes("src/test/resources/PCEPBandwidthObject1LowerBounds.bin");
 
@@ -298,7 +297,7 @@ public class PCEPObjectParserTest {
        }
 
        @Test
-       public void testEndPointsObjectIPv4() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
+       public void testEndPointsObjectIPv4() throws IOException, PCEPDeserializerException {
                final byte[] srcIPBytes = { (byte) 0xA2, (byte) 0xF5, (byte) 0x11, (byte) 0x0E };
                final byte[] destIPBytes = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
 
@@ -316,7 +315,7 @@ public class PCEPObjectParserTest {
        }
 
        @Test
-       public void testEndPointsObjectIPv6() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
+       public void testEndPointsObjectIPv6() throws IOException, PCEPDeserializerException {
                final byte[] destIPBytes = { (byte) 0x00, (byte) 0x02, (byte) 0x5D, (byte) 0xD2, (byte) 0xFF, (byte) 0xEC, (byte) 0xA1,
                                (byte) 0xB6, (byte) 0x58, (byte) 0x1E, (byte) 0x9F, (byte) 0x50, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, };
                final byte[] srcIPBytes = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
@@ -336,7 +335,7 @@ public class PCEPObjectParserTest {
        }
 
        @Test
-       public void testErrorObjectWithTlv() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
+       public void testErrorObjectWithTlv() throws PCEPDeserializerException, IOException {
                final PCEPErrorObjectParser parser = new PCEPErrorObjectParser(this.tlvRegistry);
                byte[] result = ByteArray.fileToBytes("src/test/resources/PCEPErrorObject1.bin");
 
@@ -360,7 +359,7 @@ public class PCEPObjectParserTest {
        }
 
        @Test
-       public void testLspaObject() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
+       public void testLspaObject() throws IOException, PCEPDeserializerException {
                final PCEPLspaObjectParser parser = new PCEPLspaObjectParser(this.tlvRegistry);
                byte[] result = ByteArray.fileToBytes("src/test/resources/PCEPLspaObject1LowerBounds.bin");
 
@@ -403,7 +402,7 @@ public class PCEPObjectParserTest {
        }
 
        @Test
-       public void testMetricObject() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
+       public void testMetricObject() throws IOException, PCEPDeserializerException {
                final PCEPMetricObjectParser parser = new PCEPMetricObjectParser(this.tlvRegistry);
                byte[] result = ByteArray.fileToBytes("src/test/resources/PCEPMetricObject1LowerBounds.bin");
 
@@ -430,7 +429,7 @@ public class PCEPObjectParserTest {
        }
 
        @Test
-       public void testNoPathObjectWithTlv() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
+       public void testNoPathObjectWithTlv() throws PCEPDeserializerException, IOException {
                final PCEPNoPathObjectParser parser = new PCEPNoPathObjectParser(this.tlvRegistry);
                byte[] result = ByteArray.fileToBytes("src/test/resources/PCEPNoPathObject1WithoutTLV.bin");
 
@@ -458,7 +457,7 @@ public class PCEPObjectParserTest {
        }
 
        @Test
-       public void testNotifyObjectWithTlv() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
+       public void testNotifyObjectWithTlv() throws PCEPDeserializerException, IOException {
                final PCEPNotificationObjectParser parser = new PCEPNotificationObjectParser(this.tlvRegistry);
                byte[] result = ByteArray.fileToBytes("src/test/resources/PCEPNotificationObject2WithoutTlv.bin");
 
@@ -483,7 +482,7 @@ public class PCEPObjectParserTest {
        }
 
        @Test
-       public void testRPObjectWithTlv() throws PCEPDeserializerException, IOException, PCEPDocumentedException {
+       public void testRPObjectWithTlv() throws PCEPDeserializerException, IOException {
                final PCEPRequestParameterObjectParser parser = new PCEPRequestParameterObjectParser(this.tlvRegistry);
                byte[] result = ByteArray.fileToBytes("src/test/resources/PCEPRPObject1.bin");
 
@@ -523,7 +522,7 @@ public class PCEPObjectParserTest {
        }
 
        @Test
-       public void testSvecObject() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
+       public void testSvecObject() throws IOException, PCEPDeserializerException {
                final PCEPSvecObjectParser parser = new PCEPSvecObjectParser(this.tlvRegistry);
                byte[] result = ByteArray.fileToBytes("src/test/resources/PCEPSvecObject2.bin");
 
@@ -563,7 +562,7 @@ public class PCEPObjectParserTest {
        }
 
        @Test
-       public void testClassTypeObject() throws PCEPDeserializerException, PCEPDocumentedException {
+       public void testClassTypeObject() throws PCEPDeserializerException {
                final PCEPClassTypeObjectParser parser = new PCEPClassTypeObjectParser(this.tlvRegistry);
                final byte[] result = new byte[] { 0, 0, 0, (byte) 0x04 };
 
@@ -614,7 +613,7 @@ public class PCEPObjectParserTest {
        }
 
        @Test
-       public void testSrpObject() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
+       public void testSrpObject() throws IOException, PCEPDeserializerException {
                final PCEPSrpObjectParser parser = new PCEPSrpObjectParser(this.tlvRegistry);
                final byte[] result = new byte[] { 0, 0, 0, 0, 0, 0, 0, (byte) 0x01 };
 
@@ -628,7 +627,7 @@ public class PCEPObjectParserTest {
        }
 
        @Test
-       public void testObjectiveFunctionObject() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
+       public void testObjectiveFunctionObject() throws IOException, PCEPDeserializerException {
                final PCEPObjectiveFunctionObjectParser parser = new PCEPObjectiveFunctionObjectParser(this.tlvRegistry);
                final byte[] result = ByteArray.fileToBytes("src/test/resources/PCEPObjectiveFunctionObject.1.bin");
 
@@ -642,7 +641,7 @@ public class PCEPObjectParserTest {
        }
 
        @Test
-       public void testGlobalConstraintsObject() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
+       public void testGlobalConstraintsObject() throws IOException, PCEPDeserializerException {
                final PCEPGlobalConstraintsObjectParser parser = new PCEPGlobalConstraintsObjectParser(this.tlvRegistry);
                final byte[] result = ByteArray.fileToBytes("src/test/resources/PCEPGlobalConstraintsObject.1.bin");
 
index 752ca6b1330526f38abbb3c38c2cc473e0fbd6cf..e2c786bd289550f12582bb8424d997cb47b3a9fc 100644 (file)
@@ -20,7 +20,6 @@ import java.util.List;
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.impl.message.PCEPCloseMessageParser;
 import org.opendaylight.protocol.pcep.impl.message.PCEPErrorMessageParser;
 import org.opendaylight.protocol.pcep.impl.message.PCEPKeepAliveMessageParser;
@@ -263,7 +262,7 @@ public class PCEPValidatorTest {
        }
 
        @Test
-       public void testOpenMsg() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
+       public void testOpenMsg() throws IOException, PCEPDeserializerException {
                final byte[] result = ByteArray.fileToBytes("src/test/resources/PCEPOpenMessage1.bin");
                final PCEPOpenMessageParser parser = new PCEPOpenMessageParser(this.objectRegistry);
                final OpenMessageBuilder builder = new OpenMessageBuilder();
@@ -281,33 +280,34 @@ public class PCEPValidatorTest {
                                tlv1).setLspDbVersion(tlv2).build());
                builder.setOpen(b.build());
 
-               assertEquals(new OpenBuilder().setOpenMessage(builder.build()).build(), parser.parseMessage(result, Collections.<Message>emptyList()));
+               assertEquals(new OpenBuilder().setOpenMessage(builder.build()).build(),
+                               parser.parseMessage(result, Collections.<Message> emptyList()));
                final ByteBuf buf = Unpooled.buffer(result.length);
                parser.serializeMessage(new OpenBuilder().setOpenMessage(builder.build()).build(), buf);
                assertArrayEquals(result, buf.array());
        }
 
        @Test
-       public void testKeepAliveMsg() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
-               final byte[] result = new byte[] { };
+       public void testKeepAliveMsg() throws IOException, PCEPDeserializerException {
+               final byte[] result = new byte[] {};
                final PCEPKeepAliveMessageParser parser = new PCEPKeepAliveMessageParser(this.objectRegistry);
                final KeepaliveBuilder builder = new KeepaliveBuilder().setKeepaliveMessage(new KeepaliveMessageBuilder().build());
 
-               assertEquals(builder.build(), parser.parseMessage(result, Collections.<Message>emptyList()));
+               assertEquals(builder.build(), parser.parseMessage(result, Collections.<Message> emptyList()));
                final ByteBuf buf = Unpooled.buffer(result.length);
                parser.serializeMessage(builder.build(), buf);
                assertArrayEquals(result, buf.array());
        }
 
        @Test
-       public void testCloseMsg() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
+       public void testCloseMsg() throws IOException, PCEPDeserializerException {
                final byte[] result = ByteArray.fileToBytes("src/test/resources/PCEPCloseMessage1.bin");
 
                final PCEPCloseMessageParser parser = new PCEPCloseMessageParser(this.objectRegistry);
                final CloseBuilder builder = new CloseBuilder().setCCloseMessage(new CCloseMessageBuilder().setCClose(
                                new CCloseBuilder().setIgnore(false).setProcessingRule(false).setReason((short) 5).build()).build());
 
-               assertEquals(builder.build(), parser.parseMessage(result, Collections.<Message>emptyList()));
+               assertEquals(builder.build(), parser.parseMessage(result, Collections.<Message> emptyList()));
                final ByteBuf buf = Unpooled.buffer(result.length);
                parser.serializeMessage(builder.build(), buf);
                assertArrayEquals(result, buf.array());
@@ -540,7 +540,7 @@ public class PCEPValidatorTest {
        //
 
        @Test
-       public void testReplyMsg() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
+       public void testReplyMsg() throws IOException, PCEPDeserializerException {
                // only RP
                byte[] result = ByteArray.fileToBytes("src/test/resources/PCRep.1.bin");
 
@@ -554,7 +554,8 @@ public class PCEPValidatorTest {
                replies1.add(rBuilder.build());
                builder.setReplies(replies1);
 
-               assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(result, Collections.<Message>emptyList()));
+               assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(),
+                               parser.parseMessage(result, Collections.<Message> emptyList()));
                ByteBuf buf = Unpooled.buffer(result.length);
                parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
                assertArrayEquals(result, buf.array());
@@ -571,7 +572,8 @@ public class PCEPValidatorTest {
                replies2.add(rBuilder2.build());
                builder.setReplies(replies2);
 
-               assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(result, Collections.<Message>emptyList()));
+               assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(),
+                               parser.parseMessage(result, Collections.<Message> emptyList()));
                buf = Unpooled.buffer(result.length);
                parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
                assertArrayEquals(result, buf.array());
@@ -586,7 +588,8 @@ public class PCEPValidatorTest {
                replies3.add(rBuilder.build());
                builder.setReplies(replies3);
 
-               assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(result, Collections.<Message>emptyList()));
+               assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(),
+                               parser.parseMessage(result, Collections.<Message> emptyList()));
                buf = Unpooled.buffer(result.length);
                parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
                assertArrayEquals(result, buf.array());
@@ -608,14 +611,15 @@ public class PCEPValidatorTest {
                replies4.add(rBuilder.build());
                builder.setReplies(replies4);
 
-               assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(), parser.parseMessage(result, Collections.<Message>emptyList()));
+               assertEquals(new PcrepBuilder().setPcrepMessage(builder.build()).build(),
+                               parser.parseMessage(result, Collections.<Message> emptyList()));
                buf = Unpooled.buffer(result.length);
                parser.serializeMessage(new PcrepBuilder().setPcrepMessage(builder.build()).build(), buf);
                assertArrayEquals(result, buf.array());
        }
 
        @Test
-       public void testUpdMsg() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
+       public void testUpdMsg() throws IOException, PCEPDeserializerException {
                byte[] result = ByteArray.fileToBytes("src/test/resources/PCUpd.2.bin");
 
                final PCEPUpdateRequestMessageParser parser = new PCEPUpdateRequestMessageParser(this.objectRegistry);
@@ -629,7 +633,8 @@ public class PCEPValidatorTest {
                updates.add(new UpdatesBuilder().setSrp(this.srp).setLsp(this.lsp).setPath(pBuilder.build()).build());
                builder.setUpdates(updates);
 
-               assertEquals(new PcupdBuilder().setPcupdMessage(builder.build()).build(), parser.parseMessage(result, Collections.<Message>emptyList()));
+               assertEquals(new PcupdBuilder().setPcupdMessage(builder.build()).build(),
+                               parser.parseMessage(result, Collections.<Message> emptyList()));
                ByteBuf buf = Unpooled.buffer(result.length);
                parser.serializeMessage(new PcupdBuilder().setPcupdMessage(builder.build()).build(), buf);
                assertArrayEquals(result, buf.array());
@@ -644,14 +649,15 @@ public class PCEPValidatorTest {
                updates1.add(new UpdatesBuilder().setSrp(this.srp).setLsp(this.lsp).setPath(pBuilder1.build()).build());
                builder.setUpdates(updates1);
 
-               assertEquals(new PcupdBuilder().setPcupdMessage(builder.build()).build(), parser.parseMessage(result, Collections.<Message>emptyList()));
+               assertEquals(new PcupdBuilder().setPcupdMessage(builder.build()).build(),
+                               parser.parseMessage(result, Collections.<Message> emptyList()));
                buf = Unpooled.buffer(result.length);
                parser.serializeMessage(new PcupdBuilder().setPcupdMessage(builder.build()).build(), buf);
                assertArrayEquals(result, buf.array());
        }
 
        @Test
-       public void testRptMsg() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
+       public void testRptMsg() throws IOException, PCEPDeserializerException {
                byte[] result = ByteArray.fileToBytes("src/test/resources/PCRpt.1.bin");
 
                final PCEPReportMessageParser parser = new PCEPReportMessageParser(this.objectRegistry);
@@ -662,7 +668,8 @@ public class PCEPValidatorTest {
                reports.add(new ReportsBuilder().setLsp(this.lsp).build());
                builder.setReports(reports);
 
-               assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parser.parseMessage(result, Collections.<Message>emptyList()));
+               assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(),
+                               parser.parseMessage(result, Collections.<Message> emptyList()));
                ByteBuf buf = Unpooled.buffer(result.length);
                parser.serializeMessage(new PcrptBuilder().setPcrptMessage(builder.build()).build(), buf);
                assertArrayEquals(result, buf.array());
@@ -673,7 +680,8 @@ public class PCEPValidatorTest {
                reports1.add(new ReportsBuilder().setLsp(this.lsp).setPath(new PathBuilder().setEro(this.ero).setLspa(this.lspa).build()).build());
                builder.setReports(reports1);
 
-               assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parser.parseMessage(result, Collections.<Message>emptyList()));
+               assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(),
+                               parser.parseMessage(result, Collections.<Message> emptyList()));
                buf = Unpooled.buffer(result.length);
                parser.serializeMessage(new PcrptBuilder().setPcrptMessage(builder.build()).build(), buf);
                assertArrayEquals(result, buf.array());
@@ -689,7 +697,8 @@ public class PCEPValidatorTest {
                reports2.add(new ReportsBuilder().setSrp(this.srp).setLsp(this.lsp).setPath(pBuilder.build()).build());
                builder.setReports(reports2);
 
-               assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parser.parseMessage(result, Collections.<Message>emptyList()));
+               assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(),
+                               parser.parseMessage(result, Collections.<Message> emptyList()));
                buf = Unpooled.buffer(result.length);
                parser.serializeMessage(new PcrptBuilder().setPcrptMessage(builder.build()).build(), buf);
                assertArrayEquals(result, buf.array());
@@ -706,14 +715,15 @@ public class PCEPValidatorTest {
                reports3.add(new ReportsBuilder().setSrp(this.srp).setLsp(this.lsp).setPath(pBuilder1.build()).build());
                builder.setReports(reports3);
 
-               assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(), parser.parseMessage(result, Collections.<Message>emptyList()));
+               assertEquals(new PcrptBuilder().setPcrptMessage(builder.build()).build(),
+                               parser.parseMessage(result, Collections.<Message> emptyList()));
                buf = Unpooled.buffer(result.length);
                parser.serializeMessage(new PcrptBuilder().setPcrptMessage(builder.build()).build(), buf);
                assertArrayEquals(result, buf.array());
        }
 
        @Test
-       public void testPcinitMsg() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
+       public void testPcinitMsg() throws IOException, PCEPDeserializerException {
                final byte[] result = ByteArray.fileToBytes("src/test/resources/Pcinit.bin");
 
                final PcinitiateMessageParser parser = new PcinitiateMessageParser(this.objectRegistry);
@@ -731,14 +741,15 @@ public class PCEPValidatorTest {
                reqs.add(rBuilder.build());
                builder.setRequests(reqs);
 
-               assertEquals(new PcinitiateBuilder().setPcinitiateMessage(builder.build()).build(), parser.parseMessage(result, Collections.<Message>emptyList()));
+               assertEquals(new PcinitiateBuilder().setPcinitiateMessage(builder.build()).build(),
+                               parser.parseMessage(result, Collections.<Message> emptyList()));
                final ByteBuf buf = Unpooled.buffer(result.length);
                parser.serializeMessage(new PcinitiateBuilder().setPcinitiateMessage(builder.build()).build(), buf);
                assertArrayEquals(result, buf.array());
        }
 
        @Test
-       public void testNotificationMsg() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
+       public void testNotificationMsg() throws IOException, PCEPDeserializerException {
                final CNotification cn1 = new CNotificationBuilder().setIgnore(false).setProcessingRule(false).setType((short) 1).setValue(
                                (short) 1).build();
 
@@ -773,14 +784,15 @@ public class PCEPValidatorTest {
                nots.add(b.build());
                builder.setNotifications(nots);
 
-               assertEquals(new PcntfBuilder().setPcntfMessage(builder.build()).build(), parser.parseMessage(result, Collections.<Message>emptyList()));
+               assertEquals(new PcntfBuilder().setPcntfMessage(builder.build()).build(),
+                               parser.parseMessage(result, Collections.<Message> emptyList()));
                final ByteBuf buf = Unpooled.buffer(result.length);
                parser.serializeMessage(new PcntfBuilder().setPcntfMessage(builder.build()).build(), buf);
                assertArrayEquals(result, buf.array());
        }
 
        @Test
-       public void testErrorMsg() throws IOException, PCEPDeserializerException, PCEPDocumentedException {
+       public void testErrorMsg() throws IOException, PCEPDeserializerException {
                byte[] result = ByteArray.fileToBytes("src/test/resources/PCErr.3.bin");
 
                final ErrorObject error1 = new ErrorObjectBuilder().setIgnore(false).setProcessingRule(false).setType((short) 3).setValue((short) 1).build();
@@ -794,7 +806,8 @@ public class PCEPValidatorTest {
                builder.setErrors(innerErr);
                builder.setErrorType(new SessionBuilder().setOpen(this.open).build());
 
-               assertEquals(new PcerrBuilder().setPcerrMessage(builder.build()).build(), parser.parseMessage(result, Collections.<Message>emptyList()));
+               assertEquals(new PcerrBuilder().setPcerrMessage(builder.build()).build(),
+                               parser.parseMessage(result, Collections.<Message> emptyList()));
                ByteBuf buf = Unpooled.buffer(result.length);
                parser.serializeMessage(new PcerrBuilder().setPcerrMessage(builder.build()).build(), buf);
                assertArrayEquals(result, buf.array());
@@ -811,7 +824,8 @@ public class PCEPValidatorTest {
                builder.setErrors(innerErr);
                builder.setErrorType(new RequestBuilder().setRps(rps).build());
 
-               assertEquals(new PcerrBuilder().setPcerrMessage(builder.build()).build(), parser.parseMessage(result, Collections.<Message>emptyList()));
+               assertEquals(new PcerrBuilder().setPcerrMessage(builder.build()).build(),
+                               parser.parseMessage(result, Collections.<Message> emptyList()));
                buf = Unpooled.buffer(result.length);
                parser.serializeMessage(new PcerrBuilder().setPcerrMessage(builder.build()).build(), buf);
                assertArrayEquals(result, buf.array());
similarity index 99%
rename from pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPErrorMapping.java
rename to pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/PCEPErrorMapping.java
index ebf31430fa0b299d47c6098dbdc4207d5c94baca..1abda2d13c1e8e49ca17f378ce3a359ead531ea5 100644 (file)
@@ -5,7 +5,7 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-package org.opendaylight.protocol.pcep;
+package org.opendaylight.protocol.pcep.spi;
 
 import java.util.HashMap;
 import java.util.Map;
@@ -15,7 +15,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * Bidirectional mapping of {@link org.opendaylight.protocol.pcep.PCEPErrors PCEPErrors} and
+ * Bidirectional mapping of {@link org.opendaylight.protocol.pcep.spi.PCEPErrors PCEPErrors} and
  * {@link org.opendaylight.protocol.pcep.impl.object.PCEPErrorObjectParser.PCEPErrorIdentifier ErrorIdentifier}
  */
 public final class PCEPErrorMapping {
similarity index 99%
rename from pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPErrors.java
rename to pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/PCEPErrors.java
index b2c1f08537a6fe2cfcae8c356b782f1110ec7a6b..58bd2f2b8404cbfe35cbd6087b1b17a2010d5a14 100644 (file)
@@ -5,7 +5,7 @@
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-package org.opendaylight.protocol.pcep;
+package org.opendaylight.protocol.pcep.spi;
 
 /**
  * Possible errors listed in RFC5440, RFC 5455 and stateful draft.
similarity index 97%
rename from pcep/api/src/main/java/org/opendaylight/protocol/pcep/UnknownObject.java
rename to pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/UnknownObject.java
index 4e19ee420255da53c3f9ee1cd3a4614f3f69b6cb..01949612c06ab959d0b97f66ec7de42f9d622708 100644 (file)
@@ -5,7 +5,7 @@
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
-package org.opendaylight.protocol.pcep;
+package org.opendaylight.protocol.pcep.spi;
 
 import java.util.Arrays;
 import java.util.List;
index 6d7a7121c40e3828d365fc922f2db847bc8d260d..2a3e704ac72f8fc25ddd14b5c30afacae1f8ab51 100644 (file)
@@ -8,10 +8,10 @@
 package org.opendaylight.protocol.pcep.spi.pojo;
 
 import org.opendaylight.protocol.concepts.HandlerRegistry;
-import org.opendaylight.protocol.pcep.UnknownObject;
 import org.opendaylight.protocol.pcep.spi.ObjectHandlerRegistry;
 import org.opendaylight.protocol.pcep.spi.ObjectParser;
 import org.opendaylight.protocol.pcep.spi.ObjectSerializer;
+import org.opendaylight.protocol.pcep.spi.UnknownObject;
 import org.opendaylight.protocol.util.Util;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Object;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.ObjectHeader;