BUG-47 : removed PCEPMessage interface, switched to generated Message. 15/1715/3
authorDana Kutenicsova <dkutenic@cisco.com>
Mon, 7 Oct 2013 11:14:05 +0000 (13:14 +0200)
committerRobert Varga <rovarga@cisco.com>
Mon, 7 Oct 2013 12:24:57 +0000 (14:24 +0200)
Change-Id: Ida381612f5b71d06a4ba118292786573307c146a
Signed-off-by: Dana Kutenicsova <dkutenic@cisco.com>
54 files changed:
pcep/api/pom.xml
pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPMessage.java [deleted file]
pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSession.java
pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionListener.java
pcep/api/src/main/java/org/opendaylight/protocol/pcep/message/PCCreateMessage.java
pcep/api/src/main/java/org/opendaylight/protocol/pcep/message/PCEPCloseMessage.java
pcep/api/src/main/java/org/opendaylight/protocol/pcep/message/PCEPErrorMessage.java
pcep/api/src/main/java/org/opendaylight/protocol/pcep/message/PCEPKeepAliveMessage.java
pcep/api/src/main/java/org/opendaylight/protocol/pcep/message/PCEPNotificationMessage.java
pcep/api/src/main/java/org/opendaylight/protocol/pcep/message/PCEPOpenMessage.java
pcep/api/src/main/java/org/opendaylight/protocol/pcep/message/PCEPReplyMessage.java
pcep/api/src/main/java/org/opendaylight/protocol/pcep/message/PCEPReportMessage.java
pcep/api/src/main/java/org/opendaylight/protocol/pcep/message/PCEPRequestMessage.java
pcep/api/src/main/java/org/opendaylight/protocol/pcep/message/PCEPUpdateRequestMessage.java
pcep/api/src/test/java/org/opendaylight/protocol/pcep/api/APITest.java
pcep/api/src/test/java/org/opendaylight/protocol/pcep/api/MessagesTest.java [deleted file]
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/AbstractPCEPSessionNegotiator.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/AbstractPCEPSessionNegotiatorFactory.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPDispatcherImpl.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPHandlerFactory.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPMessageFactory.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPMessageValidator.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPSessionImpl.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/RawPCEPMessageFactory.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCCreateMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCCreateMessageValidator.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPCloseMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPCloseMessageValidator.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/PCEPErrorMessageValidator.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPKeepAliveMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPKeepAliveMessageValidator.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/PCEPNotificationMessageValidator.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPOpenMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPOpenMessageValidator.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/PCEPReplyMessageValidator.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/PCEPReportMessageValidator.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPRequestMessageParser.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/message/PCEPRequestMessageValidator.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/PCEPUpdateRequestMessageValidator.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/PCEPValidatorTest.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/ServerSessionMock.java
pcep/impl/src/test/java/org/opendaylight/protocol/pcep/impl/SimpleSessionListener.java
pcep/spi/src/main/java/org/opendaylight/protocol/pcep/spi/RawMessage.java
pcep/testtool/src/main/java/org/opendaylight/protocol/pcep/testtool/SimpleSessionListener.java
pcep/testtool/src/main/java/org/opendaylight/protocol/pcep/testtool/TestingSessionListener.java
pcep/testtool/src/test/java/org/opendaylight/protocol/pcep/testtool/PCCMock.java

index 23d0043c5d38d397f5d972946573fc105e2937c0..1298f5081003aa94064156c3bffbc5dc9b37fcce 100644 (file)
                            org.opendaylight.protocol.pcep.subobject,
                            org.opendaylight.protocol.pcep.tlv,
                            org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.*,
+                           org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.rsvp.rev130820.*,
                            org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.*,
                        </Export-Package>
                        <Import-Package>
diff --git a/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPMessage.java b/pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPMessage.java
deleted file mode 100644 (file)
index 7332958..0000000
+++ /dev/null
@@ -1,89 +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 java.util.List;
-
-/**
- * Basic structure for PCEP Message. Cannot be instantiated directly. Current PCEP version is 1. Each message contains a
- * list of PCEP objects.
- * 
- */
-public abstract class PCEPMessage {
-
-       private static final long serialVersionUID = 4293319459468168384L;
-
-       /**
-        * Current supported version of PCEP.
-        */
-       public static final int PCEP_VERSION = 1;
-
-       private final List<PCEPObject> objects;
-
-       /**
-        * Constructor is protected to prevent direct instantiation, but to allow to call this constructor via super().
-        * 
-        * @param objects
-        */
-       protected PCEPMessage(final List<PCEPObject> objects) {
-               if (objects.contains(null)) {
-                       throw new IllegalArgumentException("Object list contains null element at offset " + objects.indexOf(null));
-               }
-
-               this.objects = objects;
-       }
-
-       /**
-        * Returns list of all objects that the message contains
-        * 
-        * @return list of all objects that the message contains
-        */
-       public List<PCEPObject> getAllObjects() {
-               return this.objects;
-       }
-
-       @Override
-       public int hashCode() {
-               final int prime = 31;
-               int result = 1;
-               result = prime * result + ((this.objects == null) ? 0 : this.objects.hashCode());
-               return result;
-       }
-
-       @Override
-       public boolean equals(final Object obj) {
-               if (this == obj) {
-                       return true;
-               }
-               if (obj == null) {
-                       return false;
-               }
-               if (this.getClass() != obj.getClass()) {
-                       return false;
-               }
-               final PCEPMessage other = (PCEPMessage) obj;
-               if (this.objects == null) {
-                       if (other.objects != null) {
-                               return false;
-                       }
-               } else if (!this.objects.equals(other.objects)) {
-                       return false;
-               }
-               return true;
-       }
-
-       @Override
-       public String toString() {
-               final StringBuilder builder = new StringBuilder();
-               builder.append("PCEPMessage [objects=");
-               builder.append(this.objects);
-               builder.append("]");
-               return builder.toString();
-       }
-
-}
index 0dbeed907ab6081b748068ae1acdaf83ae240433..301354e1a8166215518be9a77b63fcb09c7369f5 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.protocol.pcep;
 
 import org.opendaylight.protocol.framework.ProtocolSession;
 import org.opendaylight.protocol.pcep.object.PCEPCloseObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 
 /**
  * PCEP Session represents the finite state machine in PCEP, including timers and its purpose is to create a PCEP
@@ -16,7 +17,7 @@ import org.opendaylight.protocol.pcep.object.PCEPCloseObject;
  * manually. If the session is up, it has to redirect messages to/from user. Handles also malformed messages and unknown
  * requests.
  */
-public interface PCEPSession extends ProtocolSession<PCEPMessage> {
+public interface PCEPSession extends ProtocolSession<Message> {
 
        /**
         * Sends message from user to PCE/PCC. If the user sends an Open Message, the session returns an error (open message
@@ -25,7 +26,7 @@ public interface PCEPSession extends ProtocolSession<PCEPMessage> {
         * 
         * @param message message to be sent
         */
-       public void sendMessage(PCEPMessage message);
+       public void sendMessage(Message message);
 
        public void close(PCEPCloseObject.Reason reason);
 }
index be42b4372d3f8e1b3509b6dc5426e63dd18f7484..20ff395ed12d4d5cbd2730d626e00f35099c65da 100644 (file)
@@ -8,10 +8,11 @@
 package org.opendaylight.protocol.pcep;
 
 import org.opendaylight.protocol.framework.SessionListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 
 /**
  * Listener that receives session informations from the session.
  */
-public interface PCEPSessionListener extends SessionListener<PCEPMessage, PCEPSession, PCEPTerminationReason> {
+public interface PCEPSessionListener extends SessionListener<Message, PCEPSession, PCEPTerminationReason> {
 
 }
index df64f480d2bb53d7d5edb60a5a2cd1afdb17d425..b12b6bdec0b1e1b2f7d0061a5ab544461f291a01 100644 (file)
@@ -7,60 +7,55 @@
  */
 package org.opendaylight.protocol.pcep.message;
 
-import java.util.ArrayList;
 import java.util.List;
 
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPObject;
 import org.opendaylight.protocol.pcep.object.CompositeInstantiationObject;
 import org.opendaylight.protocol.pcep.object.CompositeStateReportObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+
+import com.google.common.collect.Lists;
 
 /**
- * @see <a href="http://www.ietf.org/id/draft-crabbe-pce-pce-initiated-lsp-00.txt">5.1.  The LSP Create Message</a>
+ * @see <a href="http://www.ietf.org/id/draft-crabbe-pce-pce-initiated-lsp-00.txt">5.1. The LSP Create Message</a>
  */
-public class PCCreateMessage extends PCEPMessage {
-
-       private static final long serialVersionUID = -2407399568579836171L;
+public class PCCreateMessage implements Message {
 
        private final List<CompositeInstantiationObject> lsps;
 
+       private final List<PCEPObject> objects;
+
        /**
         * Constructs {@link PCCreateMessage}.
-        *
-        * @throws IllegalArgumentException
-        *             if there is not even one {@link CompositeInstantiationObject}
-        *             in the list.
-        *
-        * @param lsps
-        *            List<CompositeInstantiationObject>. Can't be empty or null.
+        * 
+        * @throws IllegalArgumentException if there is not even one {@link CompositeInstantiationObject} in the list.
+        * 
+        * @param lsps List<CompositeInstantiationObject>. Can't be empty or null.
         */
        public PCCreateMessage(final List<CompositeInstantiationObject> lsps) {
-               super(new ArrayList<PCEPObject>() {
-
-                       private static final long serialVersionUID = 1L;
-
-                       {
-                               if (lsps != null)
-                                       for (final CompositeInstantiationObject cio : lsps) {
-                                               this.addAll(cio.getCompositeAsList());
-                                       }
-                       }
-               });
                if (lsps == null || lsps.isEmpty())
                        throw new IllegalArgumentException("At least one CompositeStateReportObject is mandatory.");
 
                this.lsps = lsps;
+               this.objects = Lists.newArrayList();
+               for (final CompositeInstantiationObject cio : lsps) {
+                       this.objects.addAll(cio.getCompositeAsList());
+               }
        }
 
        /**
         * Gets list of {@link CompositeStateReportObject}.
-        *
+        * 
         * @return List<CompositeStateReportObject>. Can't be null or empty.
         */
        public List<CompositeInstantiationObject> getLSPs() {
                return this.lsps;
        }
 
+       public List<PCEPObject> getAllObjects() {
+               return this.objects;
+       }
+
        /* (non-Javadoc)
         * @see java.lang.Object#hashCode()
         */
@@ -76,7 +71,7 @@ public class PCCreateMessage extends PCEPMessage {
         * @see java.lang.Object#equals(java.lang.Object)
         */
        @Override
-       public boolean equals(Object obj) {
+       public boolean equals(final Object obj) {
                if (this == obj)
                        return true;
                if (!super.equals(obj))
index 5426f9989cff34ab307430e26b36e42a80b372a5..940173e8b9a1e1a05a3bab64c120fa4fbaa3ee49 100644 (file)
@@ -7,63 +7,58 @@
  */
 package org.opendaylight.protocol.pcep.message;
 
-import java.util.ArrayList;
+import java.util.List;
 
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPObject;
 import org.opendaylight.protocol.pcep.object.PCEPCloseObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+
+import com.google.common.collect.Lists;
 
 /**
  * Structure of Close Message.
- *
- * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.8">Close
- *      Message</a>
+ * 
+ * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.8">Close Message</a>
  */
-public class PCEPCloseMessage extends PCEPMessage {
-
-       private static final long serialVersionUID = -2365304678646268281L;
+public class PCEPCloseMessage implements Message {
 
        private final PCEPCloseObject closeObj;
 
+       private final List<PCEPObject> objects;
+
        /**
-        * Constructs a new Close Message, which has to include PCEP Close Object.
-        * Is used to close an established session between PCEP Peers.
-        *
-        * @throws IllegalArgumentException
-        *             if the CloseObject passed, is null.
-        *
-        * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.8">Close
-        *      Message</a>
-        *
-        * @param closeObj
-        *            Can't be null.
+        * Constructs a new Close Message, which has to include PCEP Close Object. Is used to close an established session
+        * between PCEP Peers.
+        * 
+        * @throws IllegalArgumentException if the CloseObject passed, is null.
+        * 
+        * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.8">Close Message</a>
+        * 
+        * @param closeObj Can't be null.
         */
        public PCEPCloseMessage(final PCEPCloseObject closeObj) {
-               super(new ArrayList<PCEPObject>() {
-
-                       private static final long serialVersionUID = -8094080277421295531L;
-
-                       {
-                               if (closeObj != null)
-                                       this.add(closeObj);
-                       }
-               });
                if (closeObj == null)
                        throw new IllegalArgumentException("PCEPCloseObject is mandatory. Can't be null.");
 
                this.closeObj = closeObj;
+               this.objects = Lists.newArrayList();
+               if (closeObj != null)
+                       this.objects.add(closeObj);
        }
 
        /**
-        * Gets {@link PCEPCloseObject}, which is mandatory object of PCEP Close
-        * Message.
-        *
+        * Gets {@link PCEPCloseObject}, which is mandatory object of PCEP Close Message.
+        * 
         * @return {@link PCEPCloseObject} . Can't be null.
         */
        public PCEPCloseObject getCloseObject() {
                return this.closeObj;
        }
 
+       public List<PCEPObject> getAllObjects() {
+               return this.objects;
+       }
+
        @Override
        public int hashCode() {
                final int prime = 31;
@@ -73,7 +68,7 @@ public class PCEPCloseMessage extends PCEPMessage {
        }
 
        @Override
-       public boolean equals(Object obj) {
+       public boolean equals(final Object obj) {
                if (this == obj)
                        return true;
                if (!super.equals(obj))
index 868a5ce7e797e9d6e7695f49f915efeb1a9631a4..f5a4ebe05a33ea05e301c858dff42cd487dc94a0 100644 (file)
@@ -11,21 +11,20 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPObject;
 import org.opendaylight.protocol.pcep.object.CompositeErrorObject;
 import org.opendaylight.protocol.pcep.object.PCEPErrorObject;
 import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+
+import com.google.common.collect.Lists;
 
 /**
  * Structure of Error Message.
- *
- * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.7">Error
- *      Message</a>
+ * 
+ * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.7">Error Message</a>
  */
-public class PCEPErrorMessage extends PCEPMessage {
-
-       private static final long serialVersionUID = 604782651368689577L;
+public class PCEPErrorMessage implements Message {
 
        private PCEPOpenObject openObj;
 
@@ -33,6 +32,8 @@ public class PCEPErrorMessage extends PCEPMessage {
 
        private final List<CompositeErrorObject> errors;
 
+       private final List<PCEPObject> objects;
+
        public PCEPErrorMessage(final PCEPErrorObject errorObject) {
                this(new ArrayList<PCEPErrorObject>() {
                        private static final long serialVersionUID = 72172137965955228L;
@@ -55,33 +56,22 @@ public class PCEPErrorMessage extends PCEPMessage {
        }
 
        /**
-        * Constructs Error Message from list of {@link PCEPErrorObject} or
-        * {@link CompositeErrorObject}.
-        *
-        * @param errorObjects
-        *            List<?> either objects of type: {@link PCEPErrorObject} or
-        *            {@link CompositeErrorObject}
-        *
-        * @throws IllegalArgumentException
-        *             if any other type is passed in the list, that cannot be
-        *             processed
+        * Constructs Error Message from list of {@link PCEPErrorObject} or {@link CompositeErrorObject}.
+        * 
+        * @param errorObjects List<?> either objects of type: {@link PCEPErrorObject} or {@link CompositeErrorObject}
+        * 
+        * @throws IllegalArgumentException if any other type is passed in the list, that cannot be processed
         */
        public PCEPErrorMessage(final List<?> errorObjects) {
-               super(new ArrayList<PCEPObject>() {
-
-                       private static final long serialVersionUID = -8607527575304297642L;
-
-                       {
-                               if (errorObjects != null)
-                                       for (int i = 0; i < errorObjects.size(); i++) {
-                                               if (errorObjects.get(i) instanceof CompositeErrorObject) {
-                                                       this.addAll(((CompositeErrorObject) errorObjects.get(i)).getCompositeAsList());
-                                               } else if (errorObjects.get(i) instanceof PCEPErrorObject) {
-                                                       this.add((PCEPErrorObject) errorObjects.get(i));
-                                               }
-                                       }
+               this.objects = Lists.newArrayList();
+               if (errorObjects != null)
+                       for (int i = 0; i < errorObjects.size(); i++) {
+                               if (errorObjects.get(i) instanceof CompositeErrorObject) {
+                                       this.objects.addAll(((CompositeErrorObject) errorObjects.get(i)).getCompositeAsList());
+                               } else if (errorObjects.get(i) instanceof PCEPErrorObject) {
+                                       this.objects.add((PCEPErrorObject) errorObjects.get(i));
+                               }
                        }
-               });
                this.errors = new ArrayList<CompositeErrorObject>();
                this.errorObjects = new ArrayList<PCEPErrorObject>();
 
@@ -98,35 +88,25 @@ public class PCEPErrorMessage extends PCEPMessage {
        }
 
        /**
-        * Constructs Error Message from list of {@link PCEPErrorObject} and
-        * {@link CompositeErrorObject} and {@link PCEPOpenObject} that cannot be
-        * null. This constructor is used during PCEP handshake to suggest new
-        * session characteristics for the session that are listen in
-        * {@link PCEPOpenObject}.
-        *
-        * @param openObj
-        *            {@link PCEPOpenObject} cannot be null
-        * @param errorObjects
-        *            List<PCEPErrorObject> list of error objects
-        * @param errors
-        *            List<CompositeErrorObject> list of composite error objects
+        * Constructs Error Message from list of {@link PCEPErrorObject} and {@link CompositeErrorObject} and
+        * {@link PCEPOpenObject} that cannot be null. This constructor is used during PCEP handshake to suggest new session
+        * characteristics for the session that are listen in {@link PCEPOpenObject}.
+        * 
+        * @param openObj {@link PCEPOpenObject} cannot be null
+        * @param errorObjects List<PCEPErrorObject> list of error objects
+        * @param errors List<CompositeErrorObject> list of composite error objects
         */
        public PCEPErrorMessage(final PCEPOpenObject openObj, final List<PCEPErrorObject> errorObjects, final List<CompositeErrorObject> errors) {
-               super(new ArrayList<PCEPObject>() {
-
-                       private static final long serialVersionUID = -4238105145756981972L;
-
-                       {
-                               if (errorObjects != null)
-                                       this.addAll(errorObjects);
-                               if (openObj != null)
-                                       this.add(openObj);
-                               if (errors != null)
-                                       for (final CompositeErrorObject ceo : errors) {
-                                               this.addAll(ceo.getCompositeAsList());
-                                       }
+               this.objects = Lists.newArrayList();
+               if (errorObjects != null)
+                       this.objects.addAll(errorObjects);
+               if (openObj != null)
+                       this.objects.add(openObj);
+               if (errors != null)
+                       for (final CompositeErrorObject ceo : errors) {
+                               this.objects.addAll(ceo.getCompositeAsList());
                        }
-               });
+
                this.openObj = openObj;
 
                if (errorObjects == null)
@@ -140,9 +120,9 @@ public class PCEPErrorMessage extends PCEPMessage {
        }
 
        /**
-        * Gets {@link PCEPOpenObject} if this is included. If its included, it
-        * proposes alternative acceptable session characteristic values.
-        *
+        * Gets {@link PCEPOpenObject} if this is included. If its included, it proposes alternative acceptable session
+        * characteristic values.
+        * 
         * @return PCEPOpenObject. May be null.
         */
        public PCEPOpenObject getOpenObject() {
@@ -150,10 +130,9 @@ public class PCEPErrorMessage extends PCEPMessage {
        }
 
        /**
-        * In unsolicited manner can be included List of
-        * <code>PCEPErrorObjects</code> <code>PCEPErrorMessage</code>, which is not
-        * sent in response to a request.
-        *
+        * In unsolicited manner can be included List of <code>PCEPErrorObjects</code> <code>PCEPErrorMessage</code>, which
+        * is not sent in response to a request.
+        * 
         * @return List<PCEPErrorObject>
         */
        public List<PCEPErrorObject> getErrorObjects() {
@@ -161,18 +140,21 @@ public class PCEPErrorMessage extends PCEPMessage {
        }
 
        /**
-        * If the PCErr message is sent in response to a request, the PCErr message
-        * MUST include set of RP objects related to pending path computation
-        * requests that triggered the error condition. In this situation it is
-        * constructed as {@link org.opendaylight.protocol.pcep.object.CompositeErrorObject
-        * CompCompositeErrorObject}. That includes list of RP objects.
-        *
+        * If the PCErr message is sent in response to a request, the PCErr message MUST include set of RP objects related
+        * to pending path computation requests that triggered the error condition. In this situation it is constructed as
+        * {@link org.opendaylight.protocol.pcep.object.CompositeErrorObject CompCompositeErrorObject}. That includes list
+        * of RP objects.
+        * 
         * @return CompositeErrorObject. May be null.
         */
        public List<CompositeErrorObject> getErrors() {
                return this.errors;
        }
 
+       public List<PCEPObject> getAllObjects() {
+               return this.objects;
+       }
+
        @Override
        public int hashCode() {
                final int prime = 31;
@@ -184,7 +166,7 @@ public class PCEPErrorMessage extends PCEPMessage {
        }
 
        @Override
-       public boolean equals(Object obj) {
+       public boolean equals(final Object obj) {
                if (this == obj)
                        return true;
                if (!super.equals(obj))
index 77a6e85264d76ad2e10f9504577fee566903a426..d9f36005eb1dd2c45daa8404c6e9f1dbf65bdd93 100644 (file)
@@ -7,26 +7,19 @@
  */
 package org.opendaylight.protocol.pcep.message;
 
-import java.util.Collections;
-
-import org.opendaylight.protocol.pcep.PCEPMessage;
-import org.opendaylight.protocol.pcep.PCEPObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 
 /**
  * Structure of Keepalive Message
- *
- * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.3">KeepAlive
- *      Message</a>
+ * 
+ * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.3">KeepAlive Message</a>
  */
-public final class PCEPKeepAliveMessage extends PCEPMessage {
-
-       private static final long serialVersionUID = 8133032616718362219L;
+public final class PCEPKeepAliveMessage implements Message {
 
        /**
         * Default constructor PCEPKeepAliveMessage.
         */
        public PCEPKeepAliveMessage() {
-               super(Collections.<PCEPObject> emptyList());
        }
 
        @Override
index b9fb652826d31e68f95e855c6ba14cbdc6e556b1..9923ab44505b138579294ce9876576eeaf1997b8 100644 (file)
@@ -7,48 +7,39 @@
  */
 package org.opendaylight.protocol.pcep.message;
 
-import java.util.ArrayList;
 import java.util.List;
 
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPObject;
 import org.opendaylight.protocol.pcep.object.CompositeNotifyObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+
+import com.google.common.collect.Lists;
 
 /**
  * Structure of Notification Message.
- *
- * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.6">Notification
- *      Message</a>
+ * 
+ * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.6">Notification Message</a>
  */
-public class PCEPNotificationMessage extends PCEPMessage {
-
-       private static final long serialVersionUID = 2647656169727976386L;
+public class PCEPNotificationMessage implements Message {
 
        private final List<CompositeNotifyObject> notifications;
 
+       private final List<PCEPObject> objects;
+
        /**
         * Constructs new Notification Message.
-        *
-        * @throws IllegalArgumentException
-        *             if there is not even one {@link CompositeNotifyObject} in the
-        *             list.
-        *
-        * @param notifications
-        *            List<CompositeNotifyObject>. Can't be empty or null.
+        * 
+        * @throws IllegalArgumentException if there is not even one {@link CompositeNotifyObject} in the list.
+        * 
+        * @param notifications List<CompositeNotifyObject>. Can't be empty or null.
         */
        public PCEPNotificationMessage(final List<CompositeNotifyObject> notifications) {
-               super(new ArrayList<PCEPObject>() {
-
-                       private static final long serialVersionUID = 8359665614469883203L;
-
-                       {
-                               if (notifications != null)
-                                       for (final CompositeNotifyObject cno : notifications) {
-                                               this.addAll(cno.getCompositeAsList());
-                                       }
+               this.objects = Lists.newArrayList();
+               if (notifications != null) {
+                       for (final CompositeNotifyObject cno : notifications) {
+                               this.objects.addAll(cno.getCompositeAsList());
                        }
-               });
-
+               }
                if (notifications == null || notifications.isEmpty())
                        throw new IllegalArgumentException("At least one CompositeNotifyObject is mandatory.");
 
@@ -56,15 +47,18 @@ public class PCEPNotificationMessage extends PCEPMessage {
        }
 
        /**
-        * Gets list of {@link org.opendaylight.protocol.pcep.object.CompositeNotifyObject
-        * CompositeNotifyObjects}.
-        *
+        * Gets list of {@link org.opendaylight.protocol.pcep.object.CompositeNotifyObject CompositeNotifyObjects}.
+        * 
         * @return List<CompositeNotifyObject>. Can't be null or empty.
         */
        public List<CompositeNotifyObject> getNotifications() {
                return this.notifications;
        }
 
+       public List<PCEPObject> getAllObjects() {
+               return this.objects;
+       }
+
        @Override
        public int hashCode() {
                final int prime = 31;
@@ -74,7 +68,7 @@ public class PCEPNotificationMessage extends PCEPMessage {
        }
 
        @Override
-       public boolean equals(Object obj) {
+       public boolean equals(final Object obj) {
                if (this == obj)
                        return true;
                if (!super.equals(obj))
index 34ab8d2086c0697a31d179cbbc03302fc11a24b9..1f4bd294c65148f75599b2439e182c58c0834544 100644 (file)
@@ -7,45 +7,37 @@
  */
 package org.opendaylight.protocol.pcep.message;
 
-import java.util.ArrayList;
+import java.util.List;
 
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPObject;
 import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+
+import com.google.common.collect.Lists;
 
 /**
  * Structure of Open Message.
- *
- * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.2">Open
- *      Message</a>
+ * 
+ * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.2">Open Message</a>
  */
-public class PCEPOpenMessage extends PCEPMessage {
-
-       private static final long serialVersionUID = -588927926753235030L;
+public class PCEPOpenMessage implements Message {
 
        private final PCEPOpenObject openObj;
 
+       private final List<PCEPObject> objects;
+
        /**
         * Constructs new Open Message.
-        *
-        * @throws IllegalArgumentException
-        *             if the PCEPOpenObject is null.
-        *
-        * @param openObj
-        *            {@link PCEPOpenObject}. Can't be null.
+        * 
+        * @throws IllegalArgumentException if the PCEPOpenObject is null.
+        * 
+        * @param openObj {@link PCEPOpenObject}. Can't be null.
         */
        public PCEPOpenMessage(final PCEPOpenObject openObj) {
-               super(new ArrayList<PCEPObject>() {
-
-                       private static final long serialVersionUID = -1339062869814655362L;
-
-                       {
-                               if (openObj != null)
-                                       this.add(openObj);
-                       }
-               });
-
-               if (openObj == null)
+               this.objects = Lists.newArrayList();
+               if (openObj != null)
+                       this.objects.add(openObj);
+               else
                        throw new IllegalArgumentException("PCEPOpenObject is mandatory.");
 
                this.openObj = openObj;
@@ -53,13 +45,17 @@ public class PCEPOpenMessage extends PCEPMessage {
 
        /**
         * Gets {@link PCEPOpenObject}
-        *
+        * 
         * @return {@link PCEPOpenObject}. Can't be null.
         */
        public PCEPOpenObject getOpenObject() {
                return this.openObj;
        }
 
+       public List<PCEPObject> getAllObjects() {
+               return this.objects;
+       }
+
        @Override
        public int hashCode() {
                final int prime = 31;
@@ -69,7 +65,7 @@ public class PCEPOpenMessage extends PCEPMessage {
        }
 
        @Override
-       public boolean equals(Object obj) {
+       public boolean equals(final Object obj) {
                if (this == obj)
                        return true;
                if (!super.equals(obj))
index 56208dceaf14e24359c30670cc97b704ff912008..8330b02c936100adbdafefdc5a3d48416555558d 100644 (file)
@@ -7,38 +7,35 @@
  */
 package org.opendaylight.protocol.pcep.message;
 
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPObject;
 import org.opendaylight.protocol.pcep.object.CompositeReplySvecObject;
 import org.opendaylight.protocol.pcep.object.CompositeResponseObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+
+import com.google.common.collect.Lists;
 
 /**
  * Structure for Reply Message.
- *
- * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.5">Reply
- *      Message</a>
+ * 
+ * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.5">Reply Message</a>
  */
-public class PCEPReplyMessage extends PCEPMessage {
-
-       private static final long serialVersionUID = -4604680426345882626L;
+public class PCEPReplyMessage implements Message {
 
        private final List<CompositeReplySvecObject> svecList;
 
        private final List<CompositeResponseObject> responses;
 
+       private final List<PCEPObject> objects;
+
        /**
         * Constructs new Reply Message.
-        *
-        * @throws IllegalArgumentException
-        *             if there is not even one {@link CompositeResponseObject} in
-        *             the list.
-        *
-        * @param responses
-        *            List<CompositeResponseObject>. Can't be empty or null.
+        * 
+        * @throws IllegalArgumentException if there is not even one {@link CompositeResponseObject} in the list.
+        * 
+        * @param responses List<CompositeResponseObject>. Can't be empty or null.
         */
        public PCEPReplyMessage(final List<CompositeResponseObject> responses) {
                this(responses, null);
@@ -46,32 +43,22 @@ public class PCEPReplyMessage extends PCEPMessage {
 
        /**
         * Constructs {@link PCEPReplyMessage}.
-        *
-        * @throws IllegalArgumentException
-        *             if there is not even one {@link CompositeResponseObject} in
-        *             the list.
-        *
-        * @param svecList
-        *            List<CompositeSvecObject>
-        * @param responses
-        *            List<CompositeResponseObject>. Can't be empty or null.
+        * 
+        * @throws IllegalArgumentException if there is not even one {@link CompositeResponseObject} in the list.
+        * 
+        * @param svecList List<CompositeSvecObject>
+        * @param responses List<CompositeResponseObject>. Can't be empty or null.
         */
        public PCEPReplyMessage(final List<CompositeResponseObject> responses, final List<CompositeReplySvecObject> svecList) {
-               super(new ArrayList<PCEPObject>() {
-
-                       private static final long serialVersionUID = 4464502017081110298L;
-
-                       {
-                               if (svecList != null)
-                                       for (final CompositeReplySvecObject cno : svecList) {
-                                               this.addAll(cno.getCompositeAsList());
-                                       }
-                               if (responses != null)
-                                       for (final CompositeResponseObject cno : responses) {
-                                               this.addAll(cno.getCompositeAsList());
-                                       }
+               this.objects = Lists.newArrayList();
+               if (svecList != null)
+                       for (final CompositeReplySvecObject cno : svecList) {
+                               this.objects.addAll(cno.getCompositeAsList());
+                       }
+               if (responses != null)
+                       for (final CompositeResponseObject cno : responses) {
+                               this.objects.addAll(cno.getCompositeAsList());
                        }
-               });
 
                if (responses == null || responses.isEmpty())
                        throw new IllegalArgumentException("At least one CompositeResponseObject is mandatory.");
@@ -85,7 +72,7 @@ public class PCEPReplyMessage extends PCEPMessage {
 
        /**
         * Gets list of {@link CompositeResponseObject}.
-        *
+        * 
         * @return List<CompositeResponseObject>. Can't be null or empty.
         */
        public List<CompositeResponseObject> getResponses() {
@@ -94,13 +81,17 @@ public class PCEPReplyMessage extends PCEPMessage {
 
        /**
         * Gets list of {@link CompositeReplySvecObject}.
-        *
+        * 
         * @return List<CompositeReplySvecObject>. Can't be null but may be empty.
         */
        public List<CompositeReplySvecObject> getSvecList() {
                return this.svecList;
        }
 
+       public List<PCEPObject> getAllObjects() {
+               return this.objects;
+       }
+
        @Override
        public int hashCode() {
                final int prime = 31;
@@ -111,7 +102,7 @@ public class PCEPReplyMessage extends PCEPMessage {
        }
 
        @Override
-       public boolean equals(Object obj) {
+       public boolean equals(final Object obj) {
                if (this == obj)
                        return true;
                if (!super.equals(obj))
index 91f6bb446e83abc8db1595b3362bcdeb8910410f..a76ba9ac6c11f8c92936320317cc4e28823c2efb 100644 (file)
@@ -7,48 +7,38 @@
  */
 package org.opendaylight.protocol.pcep.message;
 
-import java.util.ArrayList;
 import java.util.List;
 
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPObject;
 import org.opendaylight.protocol.pcep.object.CompositeStateReportObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+
+import com.google.common.collect.Lists;
 
 /**
  * Structure of Report Message
- *
- * @see <a
- *      href="http://tools.ietf.org/html/draft-crabbe-pce-stateful-pce-02#section-6.1">State
- *      Report Message</a>
+ * 
+ * @see <a href="http://tools.ietf.org/html/draft-crabbe-pce-stateful-pce-02#section-6.1">State Report Message</a>
  */
-public class PCEPReportMessage extends PCEPMessage {
-
-       private static final long serialVersionUID = -3319055709351802748L;
+public class PCEPReportMessage implements Message {
 
        private final List<CompositeStateReportObject> reports;
 
+       private final List<PCEPObject> objects;
+
        /**
         * Constructs {@link PCEPReportMessage}.
-        *
-        * @throws IllegalArgumentException
-        *             if there is not even one {@link CompositeStateReportObject}
-        *             in the list.
-        *
-        * @param reports
-        *            List<CompositeStateReportObject>. Can't be empty or null.
+        * 
+        * @throws IllegalArgumentException if there is not even one {@link CompositeStateReportObject} in the list.
+        * 
+        * @param reports List<CompositeStateReportObject>. Can't be empty or null.
         */
        public PCEPReportMessage(final List<CompositeStateReportObject> reports) {
-               super(new ArrayList<PCEPObject>() {
-
-                       private static final long serialVersionUID = 2785287687806615951L;
-
-                       {
-                               if (reports != null)
-                                       for (final CompositeStateReportObject csro : reports) {
-                                               this.addAll(csro.getCompositeAsList());
-                                       }
+               this.objects = Lists.newArrayList();
+               if (reports != null)
+                       for (final CompositeStateReportObject csro : reports) {
+                               this.objects.addAll(csro.getCompositeAsList());
                        }
-               });
                if (reports == null || reports.isEmpty())
                        throw new IllegalArgumentException("At least one CompositeStateReportObject is mandatory.");
 
@@ -57,13 +47,17 @@ public class PCEPReportMessage extends PCEPMessage {
 
        /**
         * Gets list of {@link CompositeStateReportObject}.
-        *
+        * 
         * @return List<CompositeStateReportObject>. Can't be null or empty.
         */
        public List<CompositeStateReportObject> getStateReports() {
                return this.reports;
        }
 
+       public List<PCEPObject> getAllObjects() {
+               return this.objects;
+       }
+
        @Override
        public int hashCode() {
                final int prime = 31;
@@ -73,7 +67,7 @@ public class PCEPReportMessage extends PCEPMessage {
        }
 
        @Override
-       public boolean equals(Object obj) {
+       public boolean equals(final Object obj) {
                if (this == obj)
                        return true;
                if (!super.equals(obj))
index edb944dd431d312e5216395dce5db1675a908a00..a839efd09d65f2aab28140e48cfed80e3743e04d 100644 (file)
@@ -7,38 +7,35 @@
  */
 package org.opendaylight.protocol.pcep.message;
 
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPObject;
 import org.opendaylight.protocol.pcep.object.CompositeRequestObject;
 import org.opendaylight.protocol.pcep.object.CompositeRequestSvecObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+
+import com.google.common.collect.Lists;
 
 /**
  * Structure of Request Message.
- *
- * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.4">Request
- *      Message</a>
+ * 
+ * @see <a href="http://tools.ietf.org/html/rfc5440#section-6.4">Request Message</a>
  */
-public class PCEPRequestMessage extends PCEPMessage {
-
-       private static final long serialVersionUID = -1914670070018415483L;
+public class PCEPRequestMessage implements Message {
 
        private final List<CompositeRequestSvecObject> svecList;
 
        private final List<CompositeRequestObject> requests;
 
+       private final List<PCEPObject> objects;
+
        /**
         * Constructs new Request Message.
-        *
-        * @throws IllegalArgumentException
-        *             if there is not even one {@link CompositeRequestObject} in
-        *             the list.
-        *
-        * @param requests
-        *            List<CompositeRequestObject>. Can't be empty or null.
+        * 
+        * @throws IllegalArgumentException if there is not even one {@link CompositeRequestObject} in the list.
+        * 
+        * @param requests List<CompositeRequestObject>. Can't be empty or null.
         */
        public PCEPRequestMessage(final List<CompositeRequestObject> requests) {
                this(null, requests);
@@ -46,32 +43,23 @@ public class PCEPRequestMessage extends PCEPMessage {
 
        /**
         * Constructs new Request Message.
-        *
-        * @throws IllegalArgumentException
-        *             if there is not even one {@link CompositeRequestObject} in
-        *             the list.
-        *
-        * @param svecList
-        *            List<CompositeSvecObject>
-        * @param requests
-        *            List<CompositeRequestObject>. Can't be null or empty.
+        * 
+        * @throws IllegalArgumentException if there is not even one {@link CompositeRequestObject} in the list.
+        * 
+        * @param svecList List<CompositeSvecObject>
+        * @param requests List<CompositeRequestObject>. Can't be null or empty.
         */
        public PCEPRequestMessage(final List<CompositeRequestSvecObject> svecList, final List<CompositeRequestObject> requests) {
-               super(new ArrayList<PCEPObject>() {
-
-                       private static final long serialVersionUID = -6183368691183167076L;
-
-                       {
-                               if (svecList != null)
-                                       for (final CompositeRequestSvecObject cso : svecList) {
-                                               this.addAll(cso.getCompositeAsList());
-                                       }
-                               if (requests != null)
-                                       for (final CompositeRequestObject cro : requests) {
-                                               this.addAll(cro.getCompositeAsList());
-                                       }
+               this.objects = Lists.newArrayList();
+               if (svecList != null)
+                       for (final CompositeRequestSvecObject cso : svecList) {
+                               this.objects.addAll(cso.getCompositeAsList());
                        }
-               });
+               if (requests != null)
+                       for (final CompositeRequestObject cro : requests) {
+                               this.objects.addAll(cro.getCompositeAsList());
+                       }
+
                if (svecList != null)
                        this.svecList = svecList;
                else
@@ -85,7 +73,7 @@ public class PCEPRequestMessage extends PCEPMessage {
 
        /**
         * Gets list of {@link CompositeRequestSvecObject}.
-        *
+        * 
         * @return List<CompositeSvecObject>. Can't be null, but may be empty.
         */
        public List<CompositeRequestSvecObject> getSvecObjects() {
@@ -94,13 +82,17 @@ public class PCEPRequestMessage extends PCEPMessage {
 
        /**
         * Gets list of {@link CompositeRequestObject}.
-        *
+        * 
         * @return List<CompositeRequestObject>. Can't be null or empty.
         */
        public List<CompositeRequestObject> getRequests() {
                return this.requests;
        }
 
+       public List<PCEPObject> getAllObjects() {
+               return this.objects;
+       }
+
        @Override
        public int hashCode() {
                final int prime = 31;
@@ -111,7 +103,7 @@ public class PCEPRequestMessage extends PCEPMessage {
        }
 
        @Override
-       public boolean equals(Object obj) {
+       public boolean equals(final Object obj) {
                if (this == obj)
                        return true;
                if (!super.equals(obj))
index e477d11ab5117393441728c5d36aefb17ec11f42..09eb16bddadd0d33d4840062392ab4573e42c74a 100644 (file)
@@ -7,48 +7,38 @@
  */
 package org.opendaylight.protocol.pcep.message;
 
-import java.util.ArrayList;
 import java.util.List;
 
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPObject;
 import org.opendaylight.protocol.pcep.object.CompositeUpdateRequestObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+
+import com.google.common.collect.Lists;
 
 /**
  * Structure of Update Request Message.
- *
- * @see <a
- *      href="http://tools.ietf.org/html/draft-crabbe-pce-stateful-pce-02#section-6.2">Update
- *      Request Message</a>
+ * 
+ * @see <a href="http://tools.ietf.org/html/draft-crabbe-pce-stateful-pce-02#section-6.2">Update Request Message</a>
  */
-public class PCEPUpdateRequestMessage extends PCEPMessage {
-
-       private static final long serialVersionUID = 3577204028363946097L;
+public class PCEPUpdateRequestMessage implements Message {
 
        private final List<CompositeUpdateRequestObject> updateRequests;
 
+       private final List<PCEPObject> objects;
+
        /**
         * Constructs new Update Request Message.
-        *
-        * @throws IllegalArgumentException
-        *             if there is not even one {@link CompositeUpdateRequestObject}
-        *             in the list.
-        *
-        * @param updateRequests
-        *            List<CompositeUpdateRequestObject>. Can't be empty or null.
+        * 
+        * @throws IllegalArgumentException if there is not even one {@link CompositeUpdateRequestObject} in the list.
+        * 
+        * @param updateRequests List<CompositeUpdateRequestObject>. Can't be empty or null.
         */
        public PCEPUpdateRequestMessage(final List<CompositeUpdateRequestObject> updateRequests) {
-               super(new ArrayList<PCEPObject>() {
-
-                       private static final long serialVersionUID = 8591736379229064997L;
-
-                       {
-                               if (updateRequests != null)
-                                       for (final CompositeUpdateRequestObject curo : updateRequests) {
-                                               this.addAll(curo.getCompositeAsList());
-                                       }
+               this.objects = Lists.newArrayList();
+               if (updateRequests != null)
+                       for (final CompositeUpdateRequestObject curo : updateRequests) {
+                               this.objects.addAll(curo.getCompositeAsList());
                        }
-               });
 
                if (updateRequests == null || updateRequests.isEmpty())
                        throw new IllegalArgumentException("At least one CompositeUpdateRequestObject is mandatory.");
@@ -57,13 +47,17 @@ public class PCEPUpdateRequestMessage extends PCEPMessage {
 
        /**
         * Gets list of {@link CompositeUpdateRequestObject}.
-        *
+        * 
         * @return List<CompositeUpdateRequestObject>. Can't be null or empty.
         */
        public List<CompositeUpdateRequestObject> getUpdateRequests() {
                return this.updateRequests;
        }
 
+       public List<PCEPObject> getAllObjects() {
+               return this.objects;
+       }
+
        @Override
        public int hashCode() {
                final int prime = 31;
@@ -73,7 +67,7 @@ public class PCEPUpdateRequestMessage extends PCEPMessage {
        }
 
        @Override
-       public boolean equals(Object obj) {
+       public boolean equals(final Object obj) {
                if (this == obj)
                        return true;
                if (!super.equals(obj))
index d71226d27e6a6c1af4fd1f6a31ca186dab6f7774..46d35f18209f105b208f664a7ccaef4b8f9ba580 100644 (file)
@@ -11,14 +11,10 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotSame;
 import static org.junit.Assert.assertTrue;
 
-import java.util.ArrayList;
-import java.util.List;
-
 import org.junit.Test;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPObject;
 import org.opendaylight.protocol.pcep.object.PCEPErrorObject;
 import org.opendaylight.protocol.pcep.subobject.EROAsNumberSubobject;
@@ -46,22 +42,6 @@ public class APITest {
                assertEquals(PCEPErrors.C_BIT_SET, de.getError());
        }
 
-       @Test
-       public void testPCEPMessage() {
-               final List<PCEPObject> objs = new ArrayList<PCEPObject>();
-               objs.add(new PCEPErrorObject(PCEPErrors.ATTEMPT_2ND_SESSION));
-               final PCEPMessage msg1 = new PCEPMessage(objs) {
-                       private static final long serialVersionUID = 1L;
-               };
-               final PCEPMessage msg2 = new PCEPMessage(objs) {
-                       private static final long serialVersionUID = 1L;
-               };
-
-               assertNotSame(msg1, msg2); // not same because they are anonymous classes
-               assertEquals(msg1.hashCode(), msg2.hashCode());
-               assertEquals(msg1.toString(), msg2.toString());
-       }
-
        @Test
        public void testPCEPObject() {
                final PCEPObject obj1 = new PCEPObject(true, false) {
diff --git a/pcep/api/src/test/java/org/opendaylight/protocol/pcep/api/MessagesTest.java b/pcep/api/src/test/java/org/opendaylight/protocol/pcep/api/MessagesTest.java
deleted file mode 100644 (file)
index b633e9f..0000000
+++ /dev/null
@@ -1,323 +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.api;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.Test;
-
-import org.opendaylight.protocol.concepts.IPv4Address;
-import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.message.PCEPCloseMessage;
-import org.opendaylight.protocol.pcep.message.PCEPErrorMessage;
-import org.opendaylight.protocol.pcep.message.PCEPKeepAliveMessage;
-import org.opendaylight.protocol.pcep.message.PCEPNotificationMessage;
-import org.opendaylight.protocol.pcep.message.PCEPOpenMessage;
-import org.opendaylight.protocol.pcep.message.PCEPReplyMessage;
-import org.opendaylight.protocol.pcep.message.PCEPReportMessage;
-import org.opendaylight.protocol.pcep.message.PCEPRequestMessage;
-import org.opendaylight.protocol.pcep.message.PCEPUpdateRequestMessage;
-import org.opendaylight.protocol.pcep.object.CompositeErrorObject;
-import org.opendaylight.protocol.pcep.object.CompositeNotifyObject;
-import org.opendaylight.protocol.pcep.object.CompositeRequestObject;
-import org.opendaylight.protocol.pcep.object.CompositeResponseObject;
-import org.opendaylight.protocol.pcep.object.CompositeStateReportObject;
-import org.opendaylight.protocol.pcep.object.CompositeUpdateRequestObject;
-import org.opendaylight.protocol.pcep.object.PCEPCloseObject;
-import org.opendaylight.protocol.pcep.object.PCEPCloseObject.Reason;
-import org.opendaylight.protocol.pcep.object.PCEPEndPointsObject;
-import org.opendaylight.protocol.pcep.object.PCEPErrorObject;
-import org.opendaylight.protocol.pcep.object.PCEPLspObject;
-import org.opendaylight.protocol.pcep.object.PCEPNotificationObject;
-import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
-import org.opendaylight.protocol.pcep.object.PCEPRequestParameterObject;
-
-public class MessagesTest {
-
-       @Test
-       public void errorMessageTest() {
-               final List<PCEPErrorObject> errorObjs = new ArrayList<PCEPErrorObject>() {
-                       private static final long serialVersionUID = 1L;
-
-                       {
-                               this.add(new PCEPErrorObject(PCEPErrors.ATTEMPT_2ND_SESSION));
-                               this.add(new PCEPErrorObject(PCEPErrors.ATTEMPT_2ND_SESSION));
-                       }
-               };
-               final List<CompositeErrorObject> errors = new ArrayList<CompositeErrorObject>() {
-                       private static final long serialVersionUID = 1L;
-
-                       {
-                               this.add(new CompositeErrorObject(errorObjs));
-                       }
-               };
-
-               final List<?> objs = new ArrayList<Object>() {
-                       private static final long serialVersionUID = 1L;
-
-                       {
-                               this.add(new CompositeErrorObject(errorObjs));
-                               this.add(new PCEPErrorObject(PCEPErrors.BANDWIDTH_MISSING));
-                       }
-               };
-
-               final PCEPErrorMessage m = new PCEPErrorMessage(new PCEPOpenObject(10, 10, 1), errorObjs, errors);
-               final PCEPErrorMessage m2 = new PCEPErrorMessage(new PCEPOpenObject(10, 10, 1), errorObjs, errors);
-               final PCEPErrorMessage m3 = new PCEPErrorMessage(objs);
-
-               assertEquals(m, m2);
-               assertEquals(m.toString(), m2.toString());
-               assertEquals(m.hashCode(), m2.hashCode());
-               assertEquals(m.getOpenObject(), m2.getOpenObject());
-               assertEquals(m.getErrors(), m2.getErrors());
-               assertEquals(m.getErrorObjects(), m2.getErrorObjects());
-               assertFalse(m.equals(null));
-               assertFalse(m.equals(m3));
-               assertFalse(m.equals(new PCEPCloseMessage(new PCEPCloseObject(Reason.EXP_DEADTIMER))));
-               assertTrue(m.equals(m));
-       }
-
-       @Test(expected = IllegalArgumentException.class)
-       public void closeMessageTest() {
-               final PCEPCloseMessage m = new PCEPCloseMessage(new PCEPCloseObject(Reason.EXP_DEADTIMER));
-               final PCEPCloseMessage m2 = new PCEPCloseMessage(new PCEPCloseObject(Reason.EXP_DEADTIMER));
-               final PCEPCloseMessage m3 = new PCEPCloseMessage(new PCEPCloseObject(Reason.MALFORMED_MSG));
-
-               assertEquals(m, m2);
-               assertEquals(m.toString(), m2.toString());
-               assertEquals(m.hashCode(), m2.hashCode());
-               assertEquals(m.getCloseObject(), m2.getCloseObject());
-               assertFalse(m.equals(null));
-               assertFalse(m.equals(m3));
-               assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
-               assertTrue(m.equals(m));
-
-               new PCEPCloseMessage(null);
-       }
-
-       @Test(expected = IllegalArgumentException.class)
-       public void openMessageTest() {
-               final PCEPOpenMessage m = new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1));
-               final PCEPOpenMessage m2 = new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1));
-               final PCEPOpenMessage m3 = new PCEPOpenMessage(new PCEPOpenObject(5, 5, 1));
-
-               assertEquals(m, m2);
-               assertEquals(m.toString(), m2.toString());
-               assertEquals(m.hashCode(), m2.hashCode());
-               assertEquals(m.getOpenObject(), m2.getOpenObject());
-               assertFalse(m.equals(null));
-               assertFalse(m.equals(m3));
-               assertFalse(m.equals(new PCEPCloseMessage(new PCEPCloseObject(Reason.EXP_DEADTIMER))));
-               assertTrue(m.equals(m));
-
-               new PCEPOpenMessage(null);
-       }
-
-       @Test(expected = IllegalArgumentException.class)
-       public void keepAliveMessageTest() {
-               final PCEPKeepAliveMessage m = new PCEPKeepAliveMessage();
-               final PCEPKeepAliveMessage m2 = new PCEPKeepAliveMessage();
-
-               assertEquals(m, m2);
-               assertEquals(m.toString(), m2.toString());
-               assertEquals(m.hashCode(), m2.hashCode());
-               assertFalse(m.equals(null));
-               assertFalse(m.equals(new PCEPCloseMessage(new PCEPCloseObject(Reason.EXP_DEADTIMER))));
-               assertTrue(m.equals(m));
-
-               new PCEPOpenMessage(null);
-       }
-
-       @Test(expected = IllegalArgumentException.class)
-       public void notifyMessageTest() {
-               final List<CompositeNotifyObject> notifications = new ArrayList<CompositeNotifyObject>() {
-                       private static final long serialVersionUID = 1L;
-
-                       {
-                               this.add(new CompositeNotifyObject(new ArrayList<PCEPNotificationObject>() {
-                                       private static final long serialVersionUID = 1L;
-
-                                       {
-                                               this.add(new PCEPNotificationObject((short) 2, (short) 3));
-                                       }
-                               }));
-                       }
-               };
-
-               final PCEPNotificationMessage m = new PCEPNotificationMessage(notifications);
-               final PCEPNotificationMessage m2 = new PCEPNotificationMessage(notifications);
-               final PCEPNotificationMessage m3 = new PCEPNotificationMessage(new ArrayList<CompositeNotifyObject>() {
-                       private static final long serialVersionUID = 1L;
-
-                       {
-                               this.add(new CompositeNotifyObject(new ArrayList<PCEPNotificationObject>() {
-                                       private static final long serialVersionUID = 1L;
-
-                                       {
-                                               this.add(new PCEPNotificationObject((short) 2, (short) 5));
-                                       }
-                               }));
-                       }
-               });
-
-               assertEquals(m, m2);
-               assertEquals(m.toString(), m2.toString());
-               assertEquals(m.hashCode(), m2.hashCode());
-               assertEquals(m.getNotifications(), m2.getNotifications());
-               assertFalse(m.equals(null));
-               assertFalse(m.equals(m3));
-               assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
-               assertTrue(m.equals(m));
-
-               new PCEPNotificationMessage(null);
-       }
-
-       @Test(expected = IllegalArgumentException.class)
-       public void replyMessageTest() {
-               final List<CompositeResponseObject> replies = new ArrayList<CompositeResponseObject>() {
-                       private static final long serialVersionUID = 1L;
-
-                       {
-                               this.add(new CompositeResponseObject(new PCEPRequestParameterObject(true, true, true, true, true, false, false, false, (short) 1, 1, true,
-                                               false)));
-                       }
-               };
-
-               final PCEPReplyMessage m = new PCEPReplyMessage(replies);
-               final PCEPReplyMessage m2 = new PCEPReplyMessage(replies);
-               final PCEPReplyMessage m3 = new PCEPReplyMessage(new ArrayList<CompositeResponseObject>() {
-                       private static final long serialVersionUID = 1L;
-
-                       {
-                               this.add(new CompositeResponseObject(new PCEPRequestParameterObject(true, true, true, false, true, false, false, false, (short) 2, 1, false,
-                                               false)));
-                       }
-               });
-
-               assertEquals(m, m2);
-               assertEquals(m.toString(), m2.toString());
-               assertEquals(m.hashCode(), m2.hashCode());
-               assertEquals(m.getResponses(), m2.getResponses());
-               assertFalse(m.equals(null));
-               assertFalse(m.equals(m3));
-               assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
-               assertTrue(m.equals(m));
-
-               new PCEPReplyMessage(null);
-       }
-
-       @Test(expected = IllegalArgumentException.class)
-       public void reportMessageTest() {
-               final List<CompositeStateReportObject> reports = new ArrayList<CompositeStateReportObject>() {
-                       private static final long serialVersionUID = 1L;
-
-                       {
-                               this.add(new CompositeStateReportObject(new PCEPLspObject(1, true, true, true, true)));
-                       }
-               };
-
-               final PCEPReportMessage m = new PCEPReportMessage(reports);
-               final PCEPReportMessage m2 = new PCEPReportMessage(reports);
-               final PCEPReportMessage m3 = new PCEPReportMessage(new ArrayList<CompositeStateReportObject>() {
-                       private static final long serialVersionUID = 1L;
-
-                       {
-                               this.add(new CompositeStateReportObject(new PCEPLspObject(5, false, true, true, true)));
-                       }
-               });
-
-               assertEquals(m, m2);
-               assertEquals(m.toString(), m2.toString());
-               assertEquals(m.hashCode(), m2.hashCode());
-               assertEquals(m.getStateReports(), m2.getStateReports());
-               assertFalse(m.equals(null));
-               assertFalse(m.equals(m3));
-               assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
-               assertTrue(m.equals(m));
-
-               new PCEPReportMessage(null);
-       }
-
-       @Test(expected = IllegalArgumentException.class)
-       public void requestMessageTest() {
-               final List<CompositeRequestObject> reports = new ArrayList<CompositeRequestObject>() {
-                       private static final long serialVersionUID = 1L;
-
-                       {
-                               this.add(new CompositeRequestObject(
-                                               new PCEPRequestParameterObject(true, true, true, true, true, false, false, false, (short) 5, 5, true, true),
-                                               new PCEPEndPointsObject<IPv4Address>(
-                                                       new IPv4Address(new byte[] { (byte) 127, (byte) 0, (byte) 0, (byte) 1 }),
-                                                       new IPv4Address(new byte[] { (byte) 127, (byte) 0, (byte) 0, (byte) 1 }))));
-                       }
-               };
-
-               final PCEPRequestMessage m = new PCEPRequestMessage(reports);
-               final PCEPRequestMessage m2 = new PCEPRequestMessage(reports);
-               final PCEPRequestMessage m3 = new PCEPRequestMessage(new ArrayList<CompositeRequestObject>() {
-                       private static final long serialVersionUID = 1L;
-
-                       {
-                               this.add(new CompositeRequestObject(
-                                               new PCEPRequestParameterObject(true, true, true, false, true, false, false, false, (short) 5, 5, true, true),
-                                               new PCEPEndPointsObject<IPv4Address>(
-                                                       new IPv4Address(new byte[] { (byte) 127, (byte) 0, (byte) 0, (byte) 2 }),
-                                                       new IPv4Address(new byte[] { (byte) 127, (byte) 0, (byte) 0, (byte) 1 }))));
-                       }
-               });
-
-               assertEquals(m, m2);
-               assertEquals(m.toString(), m2.toString());
-               assertEquals(m.hashCode(), m2.hashCode());
-               assertEquals(m.getSvecObjects(), m2.getSvecObjects());
-               assertEquals(m.getRequests(), m2.getRequests());
-               assertFalse(m.equals(null));
-               assertFalse(m.equals(m3));
-               assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
-               assertTrue(m.equals(m));
-
-               new PCEPRequestMessage(null);
-       }
-
-       @Test(expected = IllegalArgumentException.class)
-       public void updateRequestMessageTest() {
-               final List<CompositeUpdateRequestObject> reports = new ArrayList<CompositeUpdateRequestObject>() {
-                       private static final long serialVersionUID = 1L;
-
-                       {
-                               this.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, true, true, true)));
-                       }
-               };
-
-               final PCEPUpdateRequestMessage m = new PCEPUpdateRequestMessage(reports);
-               final PCEPUpdateRequestMessage m2 = new PCEPUpdateRequestMessage(reports);
-               final PCEPUpdateRequestMessage m3 = new PCEPUpdateRequestMessage(new ArrayList<CompositeUpdateRequestObject>() {
-                       private static final long serialVersionUID = 1L;
-
-                       {
-                               this.add(new CompositeUpdateRequestObject(new PCEPLspObject(5, true, true, true, true)));
-                       }
-               });
-
-               assertEquals(m, m2);
-               assertEquals(m.toString(), m2.toString());
-               assertEquals(m.hashCode(), m2.hashCode());
-               assertEquals(m.getUpdateRequests(), m2.getUpdateRequests());
-               assertFalse(m.equals(null));
-               assertFalse(m.equals(m3));
-               assertFalse(m.equals(new PCEPOpenMessage(new PCEPOpenObject(10, 10, 1))));
-               assertTrue(m.equals(m));
-
-               new PCEPUpdateRequestMessage(null);
-       }
-}
index dbfe3dbffb536aaf356925536772cbff7e42168a..ca80fc3e472f1f3a9de544294a46dcfa5600484e 100644 (file)
@@ -20,12 +20,13 @@ import javax.annotation.concurrent.GuardedBy;
 
 import org.opendaylight.protocol.framework.AbstractSessionNegotiator;
 import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.message.PCEPErrorMessage;
-import org.opendaylight.protocol.pcep.message.PCEPKeepAliveMessage;
 import org.opendaylight.protocol.pcep.message.PCEPOpenMessage;
 import org.opendaylight.protocol.pcep.object.PCEPErrorObject;
 import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.KeepaliveMessage;
+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.keepalive.message.KeepaliveMessageBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -33,29 +34,25 @@ import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableList;
 
 /**
- * Abstract PCEP session negotiator. Takes care of basic handshake without
- * implementing a specific policy. Policies need to be provided by a specific
- * subclass.
+ * Abstract PCEP session negotiator. Takes care of basic handshake without implementing a specific policy. Policies need
+ * to be provided by a specific subclass.
  */
-public abstract class AbstractPCEPSessionNegotiator extends AbstractSessionNegotiator<PCEPMessage, PCEPSessionImpl> {
+public abstract class AbstractPCEPSessionNegotiator extends AbstractSessionNegotiator<Message, PCEPSessionImpl> {
        /**
         * Unified KeepWait and OpenWait timer expiration, in seconds.
         */
        public static final int FAIL_TIMER_VALUE = 60;
 
        /**
-        * PCEP session negotiation state transitions are described in RFC5440.
-        * Simplification the two timers (KeepWait and OpenWait) are merged into
-        * a FailTimer, as they are mutually exclusive, have the same timeout
-        * value and their action is to terminate negotiation. This timer is
-        * restarted between state transitions and runs in all states except
-        * Idle and Finished.
+        * PCEP session negotiation state transitions are described in RFC5440. Simplification the two timers (KeepWait and
+        * OpenWait) are merged into a FailTimer, as they are mutually exclusive, have the same timeout value and their
+        * action is to terminate negotiation. This timer is restarted between state transitions and runs in all states
+        * except Idle and Finished.
         */
        private enum State {
                /**
-                * Negotiation has not begun. It will be activated once we are asked
-                * to provide our initial proposal, at which point we move into
-                * OpenWait state.
+                * Negotiation has not begun. It will be activated once we are asked to provide our initial proposal, at which
+                * point we move into OpenWait state.
                 */
                Idle,
                /**
@@ -96,13 +93,13 @@ public abstract class AbstractPCEPSessionNegotiator extends AbstractSessionNegot
 
        /**
         * Get the initial session parameters proposal.
+        * 
         * @return Session parameters proposal.
         */
        protected abstract PCEPOpenObject getInitialProposal();
 
        /**
-        * Get the revised session parameters proposal based on the feedback
-        * the peer has provided to us.
+        * Get the revised session parameters proposal based on the feedback the peer has provided to us.
         * 
         * @param suggestion Peer-provided suggested session parameters
         * @return Session parameters proposal.
@@ -118,14 +115,11 @@ public abstract class AbstractPCEPSessionNegotiator extends AbstractSessionNegot
        protected abstract boolean isProposalAcceptable(PCEPOpenObject proposal);
 
        /**
-        * Given a peer-provided session parameters proposal which we found
-        * unacceptable, provide a counter-proposal. The requirement is that
-        * the isProposalAcceptable() method has to return true when presented
-        * with this proposal.
+        * Given a peer-provided session parameters proposal which we found unacceptable, provide a counter-proposal. The
+        * requirement is that the isProposalAcceptable() method has to return true when presented with this proposal.
         * 
         * @param proposal unacceptable peer proposal
-        * @return our counter-proposal, or null if there is no way to negotiate
-        *         an acceptable proposal
+        * @return our counter-proposal, or null if there is no way to negotiate an acceptable proposal
         */
        protected abstract PCEPOpenObject getCounterProposal(PCEPOpenObject proposal);
 
@@ -139,8 +133,7 @@ public abstract class AbstractPCEPSessionNegotiator extends AbstractSessionNegot
         * @param remotePrefs Session preferences proposed by the peer and accepted by us.
         * @return New protocol session.
         */
-       protected abstract PCEPSessionImpl createSession(Timer timer, Channel channel,
-                       PCEPOpenObject localPrefs, PCEPOpenObject remotePrefs);
+       protected abstract PCEPSessionImpl createSession(Timer timer, Channel channel, PCEPOpenObject localPrefs, PCEPOpenObject remotePrefs);
 
        /**
         * Sends PCEP Error Message with one PCEPError.
@@ -148,32 +141,32 @@ public abstract class AbstractPCEPSessionNegotiator extends AbstractSessionNegot
         * @param value
         */
        private void sendErrorMessage(final PCEPErrors value) {
-               channel.writeAndFlush(new PCEPErrorMessage(ImmutableList.of(new PCEPErrorObject(value))));
+               this.channel.writeAndFlush(new PCEPErrorMessage(ImmutableList.of(new PCEPErrorObject(value))));
        }
 
        private void scheduleFailTimer() {
                final Object lock = this;
 
-               failTimer = timer.newTimeout(new TimerTask() {
+               this.failTimer = this.timer.newTimeout(new TimerTask() {
                        @Override
                        public void run(final Timeout timeout) throws Exception {
                                synchronized (lock) {
                                        // This closes the race between timer expiring and new timer
                                        // being armed while it waits for the lock.
-                                       if (failTimer == timeout) {
-                                               switch (state) {
+                                       if (AbstractPCEPSessionNegotiator.this.failTimer == timeout) {
+                                               switch (AbstractPCEPSessionNegotiator.this.state) {
                                                case Finished:
                                                case Idle:
                                                        break;
                                                case KeepWait:
                                                        sendErrorMessage(PCEPErrors.NO_MSG_BEFORE_EXP_KEEPWAIT);
                                                        negotiationFailed(new TimeoutException("KeepWait timer expired"));
-                                                       state = State.Finished;
+                                                       AbstractPCEPSessionNegotiator.this.state = State.Finished;
                                                        break;
                                                case OpenWait:
                                                        sendErrorMessage(PCEPErrors.NO_OPEN_BEFORE_EXP_OPENWAIT);
                                                        negotiationFailed(new TimeoutException("OpenWait timer expired"));
-                                                       state = State.Finished;
+                                                       AbstractPCEPSessionNegotiator.this.state = State.Finished;
                                                        break;
                                                }
                                        }
@@ -184,50 +177,50 @@ public abstract class AbstractPCEPSessionNegotiator extends AbstractSessionNegot
 
        @Override
        final synchronized protected void startNegotiation() {
-               Preconditions.checkState(state == State.Idle);
-               localPrefs = getInitialProposal();
-               channel.writeAndFlush(new PCEPOpenMessage(localPrefs));
-               state = State.OpenWait;
+               Preconditions.checkState(this.state == State.Idle);
+               this.localPrefs = getInitialProposal();
+               this.channel.writeAndFlush(new PCEPOpenMessage(this.localPrefs));
+               this.state = State.OpenWait;
                scheduleFailTimer();
 
-               logger.debug("Channel {} started sent proposal {}", channel, localPrefs);
+               logger.debug("Channel {} started sent proposal {}", this.channel, this.localPrefs);
        }
 
        @Override
-       final synchronized protected void handleMessage(final PCEPMessage msg) throws Exception {
-               failTimer.cancel();
+       final synchronized protected void handleMessage(final Message msg) throws Exception {
+               this.failTimer.cancel();
 
-               logger.debug("Channel {} handling message in state {}", channel, state);
+               logger.debug("Channel {} handling message in state {}", this.channel, this.state);
 
-               switch (state) {
+               switch (this.state) {
                case Finished:
                case Idle:
-                       throw new IllegalStateException("Unexpected handleMessage in state " + state);
+                       throw new IllegalStateException("Unexpected handleMessage in state " + this.state);
                case KeepWait:
-                       if (msg instanceof PCEPKeepAliveMessage) {
-                               localOK = true;
-                               if (remoteOK) {
-                                       negotiationSuccessful(createSession(timer, channel, localPrefs, remotePrefs));
-                                       state = State.Finished;
+                       if (msg instanceof KeepaliveMessage) {
+                               this.localOK = true;
+                               if (this.remoteOK) {
+                                       negotiationSuccessful(createSession(this.timer, this.channel, this.localPrefs, this.remotePrefs));
+                                       this.state = State.Finished;
                                } else {
                                        scheduleFailTimer();
-                                       state = State.OpenWait;
-                                       logger.debug("Channel {} moved to OpenWait state with localOK=1", channel);
+                                       this.state = State.OpenWait;
+                                       logger.debug("Channel {} moved to OpenWait state with localOK=1", this.channel);
                                }
 
                                return;
                        } else if (msg instanceof PCEPErrorMessage) {
                                final PCEPErrorMessage err = (PCEPErrorMessage) msg;
-                               localPrefs = getRevisedProposal(err.getOpenObject());
-                               if (localPrefs == null) {
+                               this.localPrefs = getRevisedProposal(err.getOpenObject());
+                               if (this.localPrefs == null) {
                                        sendErrorMessage(PCEPErrors.PCERR_NON_ACC_SESSION_CHAR);
                                        negotiationFailed(new RuntimeException("Peer suggested unacceptable retry proposal"));
-                                       state = State.Finished;
+                                       this.state = State.Finished;
                                        return;
                                }
 
-                               if (!remoteOK) {
-                                       state = State.OpenWait;
+                               if (!this.remoteOK) {
+                                       this.state = State.OpenWait;
                                }
                                scheduleFailTimer();
                                return;
@@ -238,24 +231,24 @@ public abstract class AbstractPCEPSessionNegotiator extends AbstractSessionNegot
                        if (msg instanceof PCEPOpenMessage) {
                                final PCEPOpenObject open = ((PCEPOpenMessage) msg).getOpenObject();
                                if (isProposalAcceptable(open)) {
-                                       channel.writeAndFlush(new PCEPKeepAliveMessage());
-                                       remotePrefs = open;
-                                       remoteOK = true;
-                                       if (localOK) {
-                                               negotiationSuccessful(createSession(timer, channel, localPrefs, remotePrefs));
-                                               state = State.Finished;
+                                       this.channel.writeAndFlush(new KeepaliveMessageBuilder().build());
+                                       this.remotePrefs = open;
+                                       this.remoteOK = true;
+                                       if (this.localOK) {
+                                               negotiationSuccessful(createSession(this.timer, this.channel, this.localPrefs, this.remotePrefs));
+                                               this.state = State.Finished;
                                        } else {
                                                scheduleFailTimer();
-                                               state = State.KeepWait;
-                                               logger.debug("Channel {} moved to KeepWait state with remoteOK=1", channel);
+                                               this.state = State.KeepWait;
+                                               logger.debug("Channel {} moved to KeepWait state with remoteOK=1", this.channel);
                                        }
                                        return;
                                }
 
-                               if (openRetry) {
+                               if (this.openRetry) {
                                        sendErrorMessage(PCEPErrors.SECOND_OPEN_MSG);
                                        negotiationFailed(new RuntimeException("OPEN renegotiation failed"));
-                                       state = State.Finished;
+                                       this.state = State.Finished;
                                        return;
                                }
 
@@ -263,16 +256,14 @@ public abstract class AbstractPCEPSessionNegotiator extends AbstractSessionNegot
                                if (newPrefs == null) {
                                        sendErrorMessage(PCEPErrors.NON_ACC_NON_NEG_SESSION_CHAR);
                                        negotiationFailed(new RuntimeException("Peer sent unacceptable session parameters"));
-                                       state = State.Finished;
+                                       this.state = State.Finished;
                                        return;
                                }
 
-                               channel.writeAndFlush(
-                                               new PCEPErrorMessage(newPrefs, ImmutableList.of(
-                                                               new PCEPErrorObject(PCEPErrors.NON_ACC_NEG_SESSION_CHAR)), null));
+                               this.channel.writeAndFlush(new PCEPErrorMessage(newPrefs, ImmutableList.of(new PCEPErrorObject(PCEPErrors.NON_ACC_NEG_SESSION_CHAR)), null));
 
-                               openRetry = true;
-                               state = localOK ? State.OpenWait : State.KeepWait;
+                               this.openRetry = true;
+                               this.state = this.localOK ? State.OpenWait : State.KeepWait;
                                scheduleFailTimer();
                                return;
                        }
@@ -280,9 +271,9 @@ public abstract class AbstractPCEPSessionNegotiator extends AbstractSessionNegot
                        break;
                }
 
-               logger.warn("Channel {} in state {} received unexpected message {}", channel, state, msg);
+               logger.warn("Channel {} in state {} received unexpected message {}", this.channel, this.state, msg);
                sendErrorMessage(PCEPErrors.NON_OR_INVALID_OPEN_MSG);
                negotiationFailed(new Exception("Illegal message encountered"));
-               state = State.Finished;
+               this.state = State.Finished;
        }
 }
index b3dd19840b9f63354d0e00b845affb0bcbbb137d..accabad458559d043cbcad6a0807dbe6d3dbe318 100644 (file)
@@ -25,8 +25,8 @@ import org.opendaylight.protocol.framework.AbstractSessionNegotiator;
 import org.opendaylight.protocol.framework.SessionListenerFactory;
 import org.opendaylight.protocol.framework.SessionNegotiator;
 import org.opendaylight.protocol.framework.SessionNegotiatorFactory;
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPSessionListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -35,19 +35,18 @@ import com.google.common.collect.HashBiMap;
 import com.google.common.primitives.UnsignedBytes;
 
 /**
- * SessionNegotiator which takes care of making sure sessions between PCEP
- * peers are kept unique. This needs to be further subclassed to provide
- * either a client or server factory.
+ * SessionNegotiator which takes care of making sure sessions between PCEP peers are kept unique. This needs to be
+ * further subclassed to provide either a client or server factory.
  */
-public abstract class AbstractPCEPSessionNegotiatorFactory implements SessionNegotiatorFactory<PCEPMessage, PCEPSessionImpl, PCEPSessionListener> {
+public abstract class AbstractPCEPSessionNegotiatorFactory implements
+               SessionNegotiatorFactory<Message, PCEPSessionImpl, PCEPSessionListener> {
        private static final Comparator<byte[]> comparator = UnsignedBytes.lexicographicalComparator();
        private static final Logger logger = LoggerFactory.getLogger(AbstractPCEPSessionNegotiatorFactory.class);
        private final BiMap<byte[], Closeable> sessions = HashBiMap.create();
        private final Map<byte[], Short> sessionIds = new WeakHashMap<>();
 
        /**
-        * Create a new negotiator. This method needs to be implemented by
-        * subclasses to actually provide a negotiator.
+        * Create a new negotiator. This method needs to be implemented by subclasses to actually provide a negotiator.
         * 
         * @param promise Session promise to be completed by the negotiator
         * @param channel Associated channel
@@ -64,63 +63,64 @@ public abstract class AbstractPCEPSessionNegotiatorFactory implements SessionNeg
                final Object lock = this;
 
                logger.debug("Instantiating bootstrap negotiator for channel {}", channel);
-               return new AbstractSessionNegotiator<PCEPMessage, PCEPSessionImpl>(promise, channel) {
+               return new AbstractSessionNegotiator<Message, PCEPSessionImpl>(promise, channel) {
                        @Override
                        protected void startNegotiation() throws Exception {
-                               logger.debug("Bootstrap negotiation for channel {} started", channel);
+                               logger.debug("Bootstrap negotiation for channel {} started", this.channel);
 
                                /*
                                 * We have a chance to see if there's a client session already
                                 * registered for this client.
                                 */
-                               final byte[] clientAddress = ((InetSocketAddress) channel.remoteAddress()).getAddress().getAddress();
+                               final byte[] clientAddress = ((InetSocketAddress) this.channel.remoteAddress()).getAddress().getAddress();
 
                                synchronized (lock) {
 
-                                       if (sessions.containsKey(clientAddress)) {
+                                       if (AbstractPCEPSessionNegotiatorFactory.this.sessions.containsKey(clientAddress)) {
                                                // FIXME: cross-reference this to RFC5440
 
-                                               final byte[] serverAddress = ((InetSocketAddress) channel.localAddress()).getAddress().getAddress();
+                                               final byte[] serverAddress = ((InetSocketAddress) this.channel.localAddress()).getAddress().getAddress();
                                                if (comparator.compare(serverAddress, clientAddress) > 0) {
-                                                       final Closeable n = sessions.remove(clientAddress);
+                                                       final Closeable n = AbstractPCEPSessionNegotiatorFactory.this.sessions.remove(clientAddress);
                                                        try {
                                                                n.close();
-                                                       } catch (IOException e) {
+                                                       } catch (final IOException e) {
                                                                logger.warn("Unexpected failure to close old session", e);
                                                        }
                                                } else {
-                                                       negotiationFailed(new RuntimeException("A conflicting session for address " +
-                                                                       ((InetSocketAddress) channel.remoteAddress()).getAddress() + " found."));
+                                                       negotiationFailed(new RuntimeException("A conflicting session for address "
+                                                                       + ((InetSocketAddress) this.channel.remoteAddress()).getAddress() + " found."));
                                                        return;
                                                }
                                        }
 
                                        final short sessionId = nextSession(clientAddress);
-                                       final AbstractPCEPSessionNegotiator n = createNegotiator(promise, factory.getSessionListener(), channel, sessionId);
+                                       final AbstractPCEPSessionNegotiator n = createNegotiator(promise, factory.getSessionListener(), this.channel, sessionId);
 
-                                       sessions.put(clientAddress, new Closeable() {
+                                       AbstractPCEPSessionNegotiatorFactory.this.sessions.put(clientAddress, new Closeable() {
                                                @Override
                                                public void close() {
                                                        channel.close();
-                                               }});
+                                               }
+                                       });
 
-                                       channel.closeFuture().addListener(new ChannelFutureListener() {
+                                       this.channel.closeFuture().addListener(new ChannelFutureListener() {
                                                @Override
                                                public void operationComplete(final ChannelFuture future) throws Exception {
                                                        synchronized (lock) {
-                                                               sessions.inverse().remove(this);
+                                                               AbstractPCEPSessionNegotiatorFactory.this.sessions.inverse().remove(this);
                                                        }
                                                }
                                        });
 
-                                       logger.debug("Replacing bootstrap negotiator for channel {}", channel);
-                                       channel.pipeline().replace(this, "negotiator", n);
+                                       logger.debug("Replacing bootstrap negotiator for channel {}", this.channel);
+                                       this.channel.pipeline().replace(this, "negotiator", n);
                                        n.startNegotiation();
                                }
                        }
 
                        @Override
-                       protected void handleMessage(final PCEPMessage msg) throws Exception {
+                       protected void handleMessage(final Message msg) throws Exception {
                                throw new IllegalStateException("Bootstrap negotiator should have been replaced");
                        }
                };
@@ -133,12 +133,12 @@ public abstract class AbstractPCEPSessionNegotiatorFactory implements SessionNeg
                 * - no duplicate IDs are assigned
                 * - we retain former session IDs for a reasonable time
                 */
-               Short next = sessionIds.get(clientAddress);
+               Short next = this.sessionIds.get(clientAddress);
                if (next == null) {
                        next = 0;
                }
 
-               sessionIds.put(clientAddress, (short)((next + 1) % 255));
+               this.sessionIds.put(clientAddress, (short) ((next + 1) % 255));
                return next;
        }
 }
index 7740e10a87715b5d27c99624c538dca87aa1c419..1fda6fe572328698e938e258c52a52ebb7f54195 100644 (file)
@@ -18,8 +18,8 @@ import org.opendaylight.protocol.framework.AbstractDispatcher;
 import org.opendaylight.protocol.framework.SessionListenerFactory;
 import org.opendaylight.protocol.framework.SessionNegotiatorFactory;
 import org.opendaylight.protocol.pcep.PCEPDispatcher;
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPSessionListener;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 
 import com.google.common.base.Preconditions;
 
@@ -28,7 +28,7 @@ import com.google.common.base.Preconditions;
  */
 public class PCEPDispatcherImpl extends AbstractDispatcher<PCEPSessionImpl, PCEPSessionListener> implements PCEPDispatcher {
 
-       private final SessionNegotiatorFactory<PCEPMessage, PCEPSessionImpl, PCEPSessionListener> snf;
+       private final SessionNegotiatorFactory<Message, PCEPSessionImpl, PCEPSessionListener> snf;
 
        private final PCEPHandlerFactory hf = new PCEPHandlerFactory();
 
@@ -37,7 +37,7 @@ public class PCEPDispatcherImpl extends AbstractDispatcher<PCEPSessionImpl, PCEP
         * 
         * @throws IOException if some error occurred during opening the selector
         */
-       public PCEPDispatcherImpl(final SessionNegotiatorFactory<PCEPMessage, PCEPSessionImpl, PCEPSessionListener> negotiatorFactory) {
+       public PCEPDispatcherImpl(final SessionNegotiatorFactory<Message, PCEPSessionImpl, PCEPSessionListener> negotiatorFactory) {
                super();
                this.snf = Preconditions.checkNotNull(negotiatorFactory);
        }
@@ -47,9 +47,9 @@ public class PCEPDispatcherImpl extends AbstractDispatcher<PCEPSessionImpl, PCEP
                return super.createServer(address, new PipelineInitializer<PCEPSessionImpl>() {
                        @Override
                        public void initializeChannel(final SocketChannel ch, final Promise<PCEPSessionImpl> promise) {
-                               ch.pipeline().addLast(hf.getDecoders());
-                               ch.pipeline().addLast("negotiator", snf.getSessionNegotiator(listenerFactory, ch, promise));
-                               ch.pipeline().addLast(hf.getEncoders());
+                               ch.pipeline().addLast(PCEPDispatcherImpl.this.hf.getDecoders());
+                               ch.pipeline().addLast("negotiator", PCEPDispatcherImpl.this.snf.getSessionNegotiator(listenerFactory, ch, promise));
+                               ch.pipeline().addLast(PCEPDispatcherImpl.this.hf.getEncoders());
                        }
                });
        }
index 5eadc1ec72808c0286da5335e0a267286d9cf111..df7a5539eb15b6a282122f1bd8fc8c9a9346207f 100644 (file)
@@ -12,17 +12,17 @@ import io.netty.channel.ChannelHandler;
 import org.opendaylight.protocol.framework.ProtocolHandlerFactory;
 import org.opendaylight.protocol.framework.ProtocolMessageDecoder;
 import org.opendaylight.protocol.framework.ProtocolMessageEncoder;
-import org.opendaylight.protocol.pcep.PCEPMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 
 /**
  * PCEP specific factory for protocol inbound/outbound handlers.
  */
-public class PCEPHandlerFactory extends ProtocolHandlerFactory<PCEPMessage> {
-       private final ProtocolMessageEncoder<PCEPMessage> encoder;
+public class PCEPHandlerFactory extends ProtocolHandlerFactory<Message> {
+       private final ProtocolMessageEncoder<Message> encoder;
 
        public PCEPHandlerFactory() {
                super(new PCEPMessageFactory());
-               this.encoder = new ProtocolMessageEncoder<PCEPMessage>(this.msgFactory);
+               this.encoder = new ProtocolMessageEncoder<Message>(this.msgFactory);
        }
 
        @Override
@@ -32,6 +32,6 @@ public class PCEPHandlerFactory extends ProtocolHandlerFactory<PCEPMessage> {
 
        @Override
        public ChannelHandler[] getDecoders() {
-               return new ChannelHandler[] { new PCEPMessageHeaderDecoder(), new ProtocolMessageDecoder<PCEPMessage>(this.msgFactory) };
+               return new ChannelHandler[] { new PCEPMessageHeaderDecoder(), new ProtocolMessageDecoder<Message>(this.msgFactory) };
        }
 }
index 10bc6ecc9d6b4038096f4b93ac6ab9d4f7ef9ed9..99ee06896443bf509d0cfd8850079e4d2c2f5f22 100644 (file)
@@ -14,23 +14,23 @@ import org.opendaylight.protocol.framework.DeserializerException;
 import org.opendaylight.protocol.framework.DocumentedException;
 import org.opendaylight.protocol.framework.ProtocolMessageFactory;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.spi.RawMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 
 import com.google.common.base.Preconditions;
 
 /**
  * A PCEP message parser which also does validation.
  */
-public final class PCEPMessageFactory implements ProtocolMessageFactory<PCEPMessage> {
+public final class PCEPMessageFactory implements ProtocolMessageFactory<Message> {
        private static final RawPCEPMessageFactory rawFactory = new RawPCEPMessageFactory();
 
        @Override
-       public List<PCEPMessage> parse(final byte[] bytes) throws DeserializerException, DocumentedException {
-               final List<PCEPMessage> parsed = rawFactory.parse(bytes);
-               final List<PCEPMessage> validated = new ArrayList<>(parsed.size());
+       public List<Message> parse(final byte[] bytes) throws DeserializerException, DocumentedException {
+               final List<Message> parsed = rawFactory.parse(bytes);
+               final List<Message> validated = new ArrayList<>(parsed.size());
 
-               for (PCEPMessage msg : parsed) {
+               for (final Message msg : parsed) {
                        Preconditions.checkState(msg instanceof RawMessage);
                        final RawMessage raw = (RawMessage) msg;
 
@@ -38,7 +38,7 @@ public final class PCEPMessageFactory implements ProtocolMessageFactory<PCEPMess
                                validated.addAll(PCEPMessageValidator.getValidator(raw.getMsgType()).validate(raw.getAllObjects()));
                        } catch (final PCEPDeserializerException e) {
                                // FIXME: at validation time we may want to terminate with:
-                               //logger.error("Malformed message, terminating. ", e);
+                               // logger.error("Malformed message, terminating. ", e);
                                // this.terminate(Reason.MALFORMED_MSG);
                                throw e;
                        }
@@ -48,7 +48,7 @@ public final class PCEPMessageFactory implements ProtocolMessageFactory<PCEPMess
        }
 
        @Override
-       public byte[] put(final PCEPMessage msg) {
+       public byte[] put(final Message msg) {
                return rawFactory.put(msg);
        }
 }
index b49848eaca27641fae4e802351df6b3f7d3c77b0..0e3b2a181d8c397066c59368a0a7d4ce79d079db 100644 (file)
@@ -7,12 +7,12 @@
  */
 package org.opendaylight.protocol.pcep.impl;
 
-import org.opendaylight.protocol.pcep.PCEPMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 
 /**
  * Interface for specific message parsers
  */
 public interface PCEPMessageParser {
 
-       public byte[] put(PCEPMessage obj);
+       public byte[] put(Message obj);
 }
index c940bf80e4a1c2bcbf9e2efa7c31a490af548eb7..eb3b6bb2805960e09d1e593502b7cacbc9dade05 100644 (file)
@@ -11,7 +11,6 @@ import java.util.HashMap;
 import java.util.List;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPObject;
 import org.opendaylight.protocol.pcep.impl.message.PCCreateMessageValidator;
 import org.opendaylight.protocol.pcep.impl.message.PCEPCloseMessageValidator;
@@ -24,6 +23,7 @@ import org.opendaylight.protocol.pcep.impl.message.PCEPReportMessageValidator;
 import org.opendaylight.protocol.pcep.impl.message.PCEPRequestMessageValidator;
 import org.opendaylight.protocol.pcep.impl.message.PCEPUpdateRequestMessageValidator;
 import org.opendaylight.protocol.pcep.spi.PCEPMessageType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 
 /**
  * Base class for message validators
@@ -58,7 +58,7 @@ public abstract class PCEPMessageValidator {
                }
        }
 
-       public abstract List<PCEPMessage> validate(List<PCEPObject> objects) throws PCEPDeserializerException;
+       public abstract List<Message> validate(List<PCEPObject> objects) throws PCEPDeserializerException;
 
        public static PCEPMessageValidator getValidator(final PCEPMessageType msgType) {
                return MapOfValidators.getInstance().get(msgType);
index 5a2079244abb5eb3b96a6ad0e3439690a3cc9a75..2480d62f64486fa80b9d1bc61d7cd90a542c96e3 100644 (file)
@@ -24,19 +24,20 @@ 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.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPSession;
 import org.opendaylight.protocol.pcep.PCEPSessionListener;
 import org.opendaylight.protocol.pcep.PCEPTlv;
 import org.opendaylight.protocol.pcep.message.PCEPCloseMessage;
 import org.opendaylight.protocol.pcep.message.PCEPErrorMessage;
-import org.opendaylight.protocol.pcep.message.PCEPKeepAliveMessage;
 import org.opendaylight.protocol.pcep.message.PCEPOpenMessage;
 import org.opendaylight.protocol.pcep.object.PCEPCloseObject;
 import org.opendaylight.protocol.pcep.object.PCEPCloseObject.Reason;
 import org.opendaylight.protocol.pcep.object.PCEPErrorObject;
 import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
 import org.opendaylight.protocol.pcep.tlv.NodeIdentifierTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.KeepaliveMessage;
+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.keepalive.message.KeepaliveMessageBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -49,7 +50,7 @@ import com.google.common.base.Preconditions;
  * Implementation of PCEPSession. (Not final for testing.)
  */
 @VisibleForTesting
-public class PCEPSessionImpl extends AbstractProtocolSession<PCEPMessage> implements PCEPSession, PCEPSessionRuntimeMXBean {
+public class PCEPSessionImpl extends AbstractProtocolSession<Message> implements PCEPSession, PCEPSessionRuntimeMXBean {
        /**
         * System.nanoTime value about when was sent the last message Protected to be updated also in tests.
         */
@@ -95,6 +96,8 @@ public class PCEPSessionImpl extends AbstractProtocolSession<PCEPMessage> implem
 
        private final Channel channel;
 
+       private final KeepaliveMessage kaMessage = (KeepaliveMessage) new KeepaliveMessageBuilder().build();
+
        PCEPSessionImpl(final Timer timer, final PCEPSessionListener listener, final int maxUnknownMessages, final Channel channel,
                        final PCEPOpenObject localOpen, final PCEPOpenObject remoteOpen) {
                this.listener = Preconditions.checkNotNull(listener);
@@ -168,7 +171,7 @@ public class PCEPSessionImpl extends AbstractProtocolSession<PCEPMessage> implem
 
                if (this.channel.isActive()) {
                        if (ct >= nextKeepalive) {
-                               this.sendMessage(new PCEPKeepAliveMessage());
+                               this.sendMessage(this.kaMessage);
                                nextKeepalive = this.lastMessageSentAt + TimeUnit.SECONDS.toNanos(getKeepAliveTimerValue());
                        }
 
@@ -187,11 +190,11 @@ public class PCEPSessionImpl extends AbstractProtocolSession<PCEPMessage> implem
         * @param msg to be sent
         */
        @Override
-       public void sendMessage(final PCEPMessage msg) {
+       public void sendMessage(final Message msg) {
                try {
                        this.channel.writeAndFlush(msg);
                        this.lastMessageSentAt = System.nanoTime();
-                       if (!(msg instanceof PCEPKeepAliveMessage)) {
+                       if (!(msg instanceof KeepaliveMessage)) {
                                logger.debug("Sent message: " + msg);
                        }
                        this.sentMsgCount++;
@@ -218,14 +221,16 @@ public class PCEPSessionImpl extends AbstractProtocolSession<PCEPMessage> implem
        public synchronized void close(final PCEPCloseObject.Reason reason) {
                logger.debug("Closing session: {}", this);
                this.closed = true;
-               this.sendMessage(new PCEPCloseMessage(new PCEPCloseObject(reason)));
+               // FIXME: just to get rid of compilation errors
+               this.sendMessage((Message) new PCEPCloseMessage(new PCEPCloseObject(reason)));
                this.channel.close();
        }
 
        private synchronized void terminate(final PCEPCloseObject.Reason reason) {
                this.listener.onSessionTerminated(this, new PCEPCloseTermination(reason));
                this.closed = true;
-               this.sendMessage(new PCEPCloseMessage(new PCEPCloseObject(reason)));
+               // FIXME: just to get rid of compilation errors
+               this.sendMessage((Message) new PCEPCloseMessage(new PCEPCloseObject(reason)));
                this.close();
        }
 
@@ -251,7 +256,8 @@ public class PCEPSessionImpl extends AbstractProtocolSession<PCEPMessage> implem
                final PCEPErrorObject error = new PCEPErrorObject(value);
                final List<PCEPErrorObject> errors = new ArrayList<PCEPErrorObject>();
                errors.add(error);
-               this.sendMessage(new PCEPErrorMessage(open, errors, null));
+               // FIXME: just to get rid of compilation errors
+               this.sendMessage((Message) new PCEPErrorMessage(open, errors, null));
        }
 
        /**
@@ -284,13 +290,13 @@ public class PCEPSessionImpl extends AbstractProtocolSession<PCEPMessage> implem
         * @param msg incoming message
         */
        @Override
-       public void handleMessage(final PCEPMessage msg) {
+       public void handleMessage(final Message msg) {
                // Update last reception time
                this.lastMessageReceivedAt = System.nanoTime();
                this.receivedMsgCount++;
 
                // Internal message handling. The user does not see these messages
-               if (msg instanceof PCEPKeepAliveMessage) {
+               if (msg instanceof KeepaliveMessage) {
                        // Do nothing, the timer has been already reset
                } else if (msg instanceof PCEPOpenMessage) {
                        this.sendErrorMessage(PCEPErrors.ATTEMPT_2ND_SESSION);
index 09aef389a717b0d6b0a067e8dac1ac85eae3e4b0..451349d608db5c6b1eefadb8ef110445df1cd053 100644 (file)
@@ -16,7 +16,6 @@ import org.opendaylight.protocol.framework.ProtocolMessageFactory;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.impl.message.PCCreateMessageParser;
 import org.opendaylight.protocol.pcep.impl.message.PCEPCloseMessageParser;
 import org.opendaylight.protocol.pcep.impl.message.PCEPErrorMessageParser;
@@ -30,7 +29,6 @@ import org.opendaylight.protocol.pcep.impl.message.PCEPUpdateRequestMessageParse
 import org.opendaylight.protocol.pcep.message.PCCreateMessage;
 import org.opendaylight.protocol.pcep.message.PCEPCloseMessage;
 import org.opendaylight.protocol.pcep.message.PCEPErrorMessage;
-import org.opendaylight.protocol.pcep.message.PCEPKeepAliveMessage;
 import org.opendaylight.protocol.pcep.message.PCEPNotificationMessage;
 import org.opendaylight.protocol.pcep.message.PCEPOpenMessage;
 import org.opendaylight.protocol.pcep.message.PCEPReplyMessage;
@@ -40,6 +38,8 @@ import org.opendaylight.protocol.pcep.message.PCEPUpdateRequestMessage;
 import org.opendaylight.protocol.pcep.spi.PCEPMessageType;
 import org.opendaylight.protocol.pcep.spi.RawMessage;
 import org.opendaylight.protocol.util.ByteArray;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.KeepaliveMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -48,9 +48,9 @@ import com.google.common.collect.Lists;
 import com.google.common.primitives.UnsignedBytes;
 
 /**
- * Factory for subclasses of {@link org.opendaylight.protocol.pcep.PCEPMessage PCEPMessage}
+ * Factory for subclasses of {@link Message}
  */
-class RawPCEPMessageFactory implements ProtocolMessageFactory<PCEPMessage> {
+class RawPCEPMessageFactory implements ProtocolMessageFactory<Message> {
 
        private final static Logger logger = LoggerFactory.getLogger(PCEPMessageFactory.class);
 
@@ -60,6 +60,11 @@ class RawPCEPMessageFactory implements ProtocolMessageFactory<PCEPMessage> {
 
        public final static int COMMON_HEADER_LENGTH = 4; // bytes
 
+       /**
+        * Current supported version of PCEP.
+        */
+       public static final int PCEP_VERSION = 1;
+
        private static class MapOfParsers extends HashMap<PCEPMessageType, PCEPMessageParser> {
 
                private static final long serialVersionUID = -5715193806554448822L;
@@ -97,7 +102,7 @@ class RawPCEPMessageFactory implements ProtocolMessageFactory<PCEPMessage> {
         */
 
        @Override
-       public List<PCEPMessage> parse(final byte[] bytes) throws DeserializerException, DocumentedException {
+       public List<Message> parse(final byte[] bytes) throws DeserializerException, DocumentedException {
                Preconditions.checkArgument(bytes != null, "Bytes may not be null");
                Preconditions.checkArgument(bytes.length != 0, "Bytes may not be empty");
 
@@ -110,20 +115,21 @@ class RawPCEPMessageFactory implements ProtocolMessageFactory<PCEPMessage> {
                final byte[] msgBody = ByteArray.cutBytes(bytes, TYPE_SIZE + 1 + LENGTH_SIZE);
 
                if (msgBody.length != msgLength - COMMON_HEADER_LENGTH) {
-                       throw new DeserializerException("Body size " + msgBody.length + " does not match header size " + (msgLength - COMMON_HEADER_LENGTH));
+                       throw new DeserializerException("Body size " + msgBody.length + " does not match header size "
+                                       + (msgLength - COMMON_HEADER_LENGTH));
                }
 
                /*
                 * if PCEPObjectIdentifier.getObjectClassFromInt() dont't throws
                 * exception and if returned null we know the error type
                 */
-               PCEPMessageType msgType = PCEPMessageType.getFromInt(type);
+               final PCEPMessageType msgType = PCEPMessageType.getFromInt(type);
                if (msgType == null) {
                        logger.debug("Unknown message type {}", type);
                        throw new DocumentedException("Unhandled message type " + type, new PCEPDocumentedException("Unhandled message type " + type, PCEPErrors.CAPABILITY_NOT_SUPPORTED));
                }
 
-               PCEPMessage msg;
+               Message msg;
                try {
                        msg = new RawMessage(PCEPObjectFactory.parseObjects(msgBody), msgType);
                } catch (final PCEPDeserializerException e) {
@@ -138,7 +144,7 @@ class RawPCEPMessageFactory implements ProtocolMessageFactory<PCEPMessage> {
        }
 
        @Override
-       public byte[] put(final PCEPMessage msg) {
+       public byte[] put(final Message msg) {
                if (msg == null) {
                        throw new IllegalArgumentException("PCEPMessage is mandatory.");
                }
@@ -147,7 +153,7 @@ class RawPCEPMessageFactory implements ProtocolMessageFactory<PCEPMessage> {
 
                if (msg instanceof PCEPOpenMessage) {
                        msgType = PCEPMessageType.OPEN;
-               } else if (msg instanceof PCEPKeepAliveMessage) {
+               } else if (msg instanceof KeepaliveMessage) {
                        msgType = PCEPMessageType.KEEPALIVE;
                } else if (msg instanceof PCEPCloseMessage) {
                        msgType = PCEPMessageType.CLOSE;
@@ -175,7 +181,7 @@ class RawPCEPMessageFactory implements ProtocolMessageFactory<PCEPMessage> {
                final byte[] msgBody = MapOfParsers.getInstance().get(msgType).put(msg);
 
                final PCEPMessageHeader msgHeader = new PCEPMessageHeader(msgType.getIdentifier(), msgBody.length
-                               + PCEPMessageHeader.COMMON_HEADER_LENGTH, PCEPMessage.PCEP_VERSION);
+                               + PCEPMessageHeader.COMMON_HEADER_LENGTH, PCEP_VERSION);
 
                final byte[] headerBytes = msgHeader.toBytes();
                final byte[] retBytes = new byte[headerBytes.length + msgBody.length];
index f0953d9d1c50b47d45acc45e95327b94393e43a5..e47be9076a896a83bdf58a9c3c3e4844498d837f 100644 (file)
@@ -7,10 +7,10 @@
  */
 package org.opendaylight.protocol.pcep.impl.message;
 
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.impl.PCEPMessageParser;
 import org.opendaylight.protocol.pcep.impl.PCEPObjectFactory;
 import org.opendaylight.protocol.pcep.message.PCCreateMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 
 /**
  * Parser for {@link PCCreateMessage}
@@ -25,9 +25,10 @@ public class PCCreateMessageParser implements PCEPMessageParser {
         * )
         */
        @Override
-       public byte[] put(PCEPMessage msg) {
+       public byte[] put(final Message msg) {
                if (!(msg instanceof PCCreateMessage))
-                       throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass() + ". Needed PCCreateMessage.");
+                       throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass()
+                                       + ". Needed PCCreateMessage.");
 
                return PCEPObjectFactory.put(((PCCreateMessage) msg).getAllObjects());
        }
index 891fd8a3a57474e32483338da5768e88c33b47b0..42fa0c0756c1268ce53b6e0263bff53345781680 100644 (file)
@@ -14,7 +14,6 @@ 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.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPObject;
 import org.opendaylight.protocol.pcep.impl.PCEPMessageValidator;
 import org.opendaylight.protocol.pcep.impl.object.UnknownObject;
@@ -27,97 +26,98 @@ import org.opendaylight.protocol.pcep.object.PCEPExplicitRouteObject;
 import org.opendaylight.protocol.pcep.object.PCEPLspaObject;
 import org.opendaylight.protocol.pcep.object.PCEPMetricObject;
 import org.opendaylight.protocol.pcep.object.PCEPRequestedPathBandwidthObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 
 /**
  * PCCCreateMessage validator. Validates message integrity.
  */
 public class PCCreateMessageValidator extends PCEPMessageValidator {
 
-    @Override
-    public List<PCEPMessage> validate(List<PCEPObject> objects) throws PCEPDeserializerException {
-       if (objects == null)
-           throw new IllegalArgumentException("Passed list can't be null.");
+       @Override
+       public List<Message> validate(final List<PCEPObject> objects) throws PCEPDeserializerException {
+               if (objects == null)
+                       throw new IllegalArgumentException("Passed list can't be null.");
 
-       final List<CompositeInstantiationObject> insts = new ArrayList<CompositeInstantiationObject>();
+               final List<CompositeInstantiationObject> insts = new ArrayList<CompositeInstantiationObject>();
 
-       CompositeInstantiationObject inst;
-       while (!objects.isEmpty()) {
-           try {
-               if ((inst = this.getValidInstantiationObject(objects)) == null)
-                   break;
-           } catch (final PCEPDocumentedException e) {
-               return Arrays.asList((PCEPMessage) new PCEPErrorMessage(new PCEPErrorObject(e.getError())));
-           }
+               CompositeInstantiationObject inst;
+               while (!objects.isEmpty()) {
+                       try {
+                               if ((inst = this.getValidInstantiationObject(objects)) == null)
+                                       break;
+                       } catch (final PCEPDocumentedException e) {
+                               return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(e.getError())));
+                       }
 
-           insts.add(inst);
-       }
+                       insts.add(inst);
+               }
+
+               if (insts.isEmpty())
+                       throw new PCEPDeserializerException("At least one CompositeInstantiationObject is mandatory.");
 
-       if (insts.isEmpty())
-           throw new PCEPDeserializerException("At least one CompositeInstantiationObject is mandatory.");
-
-       if (!objects.isEmpty())
-           throw new PCEPDeserializerException("Unprocessed objects: " + objects);
-
-       return Arrays.asList((PCEPMessage) new PCCreateMessage(insts));
-    }
-
-    private CompositeInstantiationObject getValidInstantiationObject(List<PCEPObject> objects) throws PCEPDocumentedException {
-       if (objects.get(0) instanceof UnknownObject)
-           throw new PCEPDocumentedException("Unknown object", ((UnknownObject) objects.get(0)).getError());
-       if (!(objects.get(0) instanceof PCEPEndPointsObject<?>))
-           return null;
-
-       final PCEPEndPointsObject<?> endPoints = ((PCEPEndPointsObject<?>) objects.get(0));
-       objects.remove(0);
-
-       if (objects.get(0) instanceof UnknownObject)
-           throw new PCEPDocumentedException("Unknown object", ((UnknownObject) objects.get(0)).getError());
-       if (!(objects.get(0) instanceof PCEPLspaObject))
-           throw new PCEPDocumentedException("LSPA Object must be second.", PCEPErrors.LSPA_MISSING);
-       final PCEPLspaObject lspa = (PCEPLspaObject) objects.get(0);
-       objects.remove(0);
-
-       PCEPExplicitRouteObject ero = null;
-       PCEPRequestedPathBandwidthObject bandwidth = null;
-       final List<PCEPMetricObject> metrics = new ArrayList<PCEPMetricObject>();
-
-       PCEPObject obj;
-       int state = 1;
-       while (!objects.isEmpty()) {
-           obj = objects.get(0);
-           if (obj instanceof UnknownObject) {
-               throw new PCEPDocumentedException("Unknown object", ((UnknownObject) obj).getError());
-           }
-
-           switch (state) {
-               case 1:
-                   state = 2;
-                   if (obj instanceof PCEPExplicitRouteObject) {
-                       ero = (PCEPExplicitRouteObject) obj;
-                       break;
-                   }
-               case 2:
-                   state = 3;
-                   if (obj instanceof PCEPRequestedPathBandwidthObject) {
-                       bandwidth = (PCEPRequestedPathBandwidthObject) obj;
-                       break;
-                   }
-               case 3:
-                   state = 4;
-                   if (obj instanceof PCEPMetricObject) {
-                       metrics.add((PCEPMetricObject) obj);
-                       state = 3;
-                       break;
-                   }
-           }
-
-           if (state == 4)
-               break;
-
-           objects.remove(0);
+               if (!objects.isEmpty())
+                       throw new PCEPDeserializerException("Unprocessed objects: " + objects);
+
+               return Arrays.asList((Message) new PCCreateMessage(insts));
        }
 
-       return new CompositeInstantiationObject(endPoints, lspa, ero, bandwidth, metrics);
-    }
+       private CompositeInstantiationObject getValidInstantiationObject(final List<PCEPObject> objects) throws PCEPDocumentedException {
+               if (objects.get(0) instanceof UnknownObject)
+                       throw new PCEPDocumentedException("Unknown object", ((UnknownObject) objects.get(0)).getError());
+               if (!(objects.get(0) instanceof PCEPEndPointsObject<?>))
+                       return null;
+
+               final PCEPEndPointsObject<?> endPoints = ((PCEPEndPointsObject<?>) objects.get(0));
+               objects.remove(0);
+
+               if (objects.get(0) instanceof UnknownObject)
+                       throw new PCEPDocumentedException("Unknown object", ((UnknownObject) objects.get(0)).getError());
+               if (!(objects.get(0) instanceof PCEPLspaObject))
+                       throw new PCEPDocumentedException("LSPA Object must be second.", PCEPErrors.LSPA_MISSING);
+               final PCEPLspaObject lspa = (PCEPLspaObject) objects.get(0);
+               objects.remove(0);
+
+               PCEPExplicitRouteObject ero = null;
+               PCEPRequestedPathBandwidthObject bandwidth = null;
+               final List<PCEPMetricObject> metrics = new ArrayList<PCEPMetricObject>();
+
+               PCEPObject obj;
+               int state = 1;
+               while (!objects.isEmpty()) {
+                       obj = objects.get(0);
+                       if (obj instanceof UnknownObject) {
+                               throw new PCEPDocumentedException("Unknown object", ((UnknownObject) obj).getError());
+                       }
+
+                       switch (state) {
+                       case 1:
+                               state = 2;
+                               if (obj instanceof PCEPExplicitRouteObject) {
+                                       ero = (PCEPExplicitRouteObject) obj;
+                                       break;
+                               }
+                       case 2:
+                               state = 3;
+                               if (obj instanceof PCEPRequestedPathBandwidthObject) {
+                                       bandwidth = (PCEPRequestedPathBandwidthObject) obj;
+                                       break;
+                               }
+                       case 3:
+                               state = 4;
+                               if (obj instanceof PCEPMetricObject) {
+                                       metrics.add((PCEPMetricObject) obj);
+                                       state = 3;
+                                       break;
+                               }
+                       }
+
+                       if (state == 4)
+                               break;
+
+                       objects.remove(0);
+               }
+
+               return new CompositeInstantiationObject(endPoints, lspa, ero, bandwidth, metrics);
+       }
 
 }
index 9f280e5bf04c9566e6f2a29dd4826702f0cb1afa..4280ce95060978cfd1ebea751997bf77b4f1c251 100644 (file)
@@ -7,23 +7,23 @@
  */
 package org.opendaylight.protocol.pcep.impl.message;
 
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.impl.PCEPMessageParser;
 import org.opendaylight.protocol.pcep.impl.PCEPObjectFactory;
 import org.opendaylight.protocol.pcep.message.PCEPCloseMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 
 /**
- * Parser for {@link org.opendaylight.protocol.pcep.message.PCEPCloseMessage
- * PCEPCloseMessage}
+ * Parser for {@link org.opendaylight.protocol.pcep.message.PCEPCloseMessage PCEPCloseMessage}
  */
 public class PCEPCloseMessageParser implements PCEPMessageParser {
 
-    @Override
-    public byte[] put(PCEPMessage msg) {
-       if (!(msg instanceof PCEPCloseMessage))
-           throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass() + ". Nedded PCEPCloseMessage.");
+       @Override
+       public byte[] put(final Message msg) {
+               if (!(msg instanceof PCEPCloseMessage))
+                       throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass()
+                                       + ". Nedded PCEPCloseMessage.");
 
-       return PCEPObjectFactory.put(((PCEPCloseMessage) msg).getAllObjects());
-    }
+               return PCEPObjectFactory.put(((PCEPCloseMessage) msg).getAllObjects());
+       }
 
 }
index bd46b8569773b033f907057a14d384d00c0b0538..2bf4f7d01f612324b7742a39f7cbeac5ae0790ba 100644 (file)
@@ -11,11 +11,11 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPObject;
 import org.opendaylight.protocol.pcep.impl.PCEPMessageValidator;
 import org.opendaylight.protocol.pcep.message.PCEPCloseMessage;
 import org.opendaylight.protocol.pcep.object.PCEPCloseObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 
 /**
  * PCEPCloseMessage validator. Validates message integrity.
@@ -23,7 +23,7 @@ import org.opendaylight.protocol.pcep.object.PCEPCloseObject;
 public class PCEPCloseMessageValidator extends PCEPMessageValidator {
 
        @Override
-       public List<PCEPMessage> validate(List<PCEPObject> objects) throws PCEPDeserializerException {
+       public List<Message> validate(final List<PCEPObject> objects) throws PCEPDeserializerException {
                if (objects == null)
                        throw new IllegalArgumentException("Passed list can't be null.");
 
@@ -36,7 +36,7 @@ public class PCEPCloseMessageValidator extends PCEPMessageValidator {
                if (!objects.isEmpty())
                        throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
 
-               return new ArrayList<PCEPMessage>() {
+               return new ArrayList<Message>() {
                        private static final long serialVersionUID = 1L;
                        {
                                this.add(msg);
index 6ebc315632dfe924a06694c2a7b466a905d04a2e..7b8d8df68e3be369b7d328630537f4613035a227 100644 (file)
@@ -7,21 +7,21 @@
  */
 package org.opendaylight.protocol.pcep.impl.message;
 
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.impl.PCEPMessageParser;
 import org.opendaylight.protocol.pcep.impl.PCEPObjectFactory;
 import org.opendaylight.protocol.pcep.message.PCEPErrorMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 
 /**
- * Parser for {@link org.opendaylight.protocol.pcep.message.PCEPErrorMessage
- * PCEPErrorMessage}
+ * Parser for {@link org.opendaylight.protocol.pcep.message.PCEPErrorMessage PCEPErrorMessage}
  */
 public class PCEPErrorMessageParser implements PCEPMessageParser {
 
        @Override
-       public byte[] put(PCEPMessage msg) {
+       public byte[] put(final Message msg) {
                if (!(msg instanceof PCEPErrorMessage))
-                       throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance " + msg.getClass() + ". Nedded PCEPErrorMessage.");
+                       throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance " + msg.getClass()
+                                       + ". Nedded PCEPErrorMessage.");
 
                return PCEPObjectFactory.put(((PCEPErrorMessage) msg).getAllObjects());
        }
index df6942efbf27655b195ff599cfd70c3ecc9b420f..3cdeb3aadaaf5f16e9010b40384c4cd0a2bb29e7 100644 (file)
@@ -14,7 +14,6 @@ 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.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPObject;
 import org.opendaylight.protocol.pcep.impl.PCEPMessageValidator;
 import org.opendaylight.protocol.pcep.impl.object.UnknownObject;
@@ -23,6 +22,7 @@ import org.opendaylight.protocol.pcep.object.CompositeErrorObject;
 import org.opendaylight.protocol.pcep.object.PCEPErrorObject;
 import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
 import org.opendaylight.protocol.pcep.object.PCEPRequestParameterObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 
 /**
  * PCEPErrorMessage validator. Validates message integrity.
@@ -30,7 +30,7 @@ import org.opendaylight.protocol.pcep.object.PCEPRequestParameterObject;
 public class PCEPErrorMessageValidator extends PCEPMessageValidator {
 
        @Override
-       public List<PCEPMessage> validate(List<PCEPObject> objects) throws PCEPDeserializerException {
+       public List<Message> validate(final List<PCEPObject> objects) throws PCEPDeserializerException {
                if (objects == null)
                        throw new IllegalArgumentException("Passed list can't be null.");
 
@@ -44,39 +44,39 @@ public class PCEPErrorMessageValidator extends PCEPMessageValidator {
                        obj = objects.get(0);
 
                        if (obj instanceof UnknownObject)
-                               return Arrays.asList((PCEPMessage) new PCEPErrorMessage(new PCEPErrorObject(((UnknownObject) obj).getError())));
+                               return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(((UnknownObject) obj).getError())));
 
                        switch (state) {
-                               case 1:
-                                       if (obj instanceof PCEPErrorObject) {
-                                               errorObjects.add((PCEPErrorObject) obj);
-                                               break;
-                                       }
-                                       state = 2;
-                               case 2:
-                                       state = 3;
-                                       if (obj instanceof PCEPOpenObject) {
-                                               openObj = (PCEPOpenObject) obj;
-                                               break;
+                       case 1:
+                               if (obj instanceof PCEPErrorObject) {
+                                       errorObjects.add((PCEPErrorObject) obj);
+                                       break;
+                               }
+                               state = 2;
+                       case 2:
+                               state = 3;
+                               if (obj instanceof PCEPOpenObject) {
+                                       openObj = (PCEPOpenObject) obj;
+                                       break;
+                               }
+                       case 3:
+                               while (!objects.isEmpty()) {
+                                       CompositeErrorObject comObj;
+
+                                       try {
+                                               comObj = getValidErrorComposite(objects);
+                                       } catch (final PCEPDocumentedException e) {
+                                               return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(e.getError())));
                                        }
-                               case 3:
-                                       while (!objects.isEmpty()) {
-                                               CompositeErrorObject comObj;
-
-                                               try {
-                                                       comObj = getValidErrorComposite(objects);
-                                               } catch (final PCEPDocumentedException e) {
-                                                       return Arrays.asList((PCEPMessage) new PCEPErrorMessage(new PCEPErrorObject(e.getError())));
-                                               }
 
-                                               if (comObj == null)
-                                                       break;
+                                       if (comObj == null)
+                                               break;
 
-                                               errors.add(comObj);
-                                       }
+                                       errors.add(comObj);
+                               }
 
-                                       state = 4;
-                                       break;
+                               state = 4;
+                               break;
                        }
 
                        if (state == 4) {
@@ -92,10 +92,11 @@ public class PCEPErrorMessageValidator extends PCEPMessageValidator {
                if (!objects.isEmpty())
                        throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
 
-               return Arrays.asList((PCEPMessage) new PCEPErrorMessage(openObj, errorObjects, errors));
+               return Arrays.asList((Message) new PCEPErrorMessage(openObj, errorObjects, errors));
        }
 
-       private static CompositeErrorObject getValidErrorComposite(List<PCEPObject> objects) throws PCEPDocumentedException, PCEPDeserializerException {
+       private static CompositeErrorObject getValidErrorComposite(final List<PCEPObject> objects) throws PCEPDocumentedException,
+                       PCEPDeserializerException {
                final List<PCEPRequestParameterObject> requestParameters = new ArrayList<PCEPRequestParameterObject>();
                final List<PCEPErrorObject> errors = new ArrayList<PCEPErrorObject>();
                PCEPObject obj;
@@ -108,22 +109,22 @@ public class PCEPErrorMessageValidator extends PCEPMessageValidator {
                                throw new PCEPDocumentedException("Unknown object", ((UnknownObject) obj).getError());
 
                        switch (state) {
-                               case 1:
+                       case 1:
+                               state = 2;
+                               if (obj instanceof PCEPRequestParameterObject) {
+                                       if (((PCEPRequestParameterObject) obj).isProcessed())
+                                               throw new PCEPDocumentedException("Invalid setting of P flag.", PCEPErrors.P_FLAG_NOT_SET);
+                                       requestParameters.add((PCEPRequestParameterObject) obj);
+                                       state = 1;
+                                       break;
+                               }
+                       case 2:
+                               if (obj instanceof PCEPErrorObject) {
+                                       errors.add((PCEPErrorObject) obj);
                                        state = 2;
-                                       if (obj instanceof PCEPRequestParameterObject) {
-                                               if (((PCEPRequestParameterObject) obj).isProcessed())
-                                                       throw new PCEPDocumentedException("Invalid setting of P flag.", PCEPErrors.P_FLAG_NOT_SET);
-                                               requestParameters.add((PCEPRequestParameterObject) obj);
-                                               state = 1;
-                                               break;
-                                       }
-                               case 2:
-                                       if (obj instanceof PCEPErrorObject) {
-                                               errors.add((PCEPErrorObject) obj);
-                                               state = 2;
-                                               break;
-                                       }
-                                       state = 3;
+                                       break;
+                               }
+                               state = 3;
                        }
 
                        if (state == 3)
index 89fa5cdc617a8a4b948f404f58d1c384a1307fa9..b0d20ab822962dd3c1b0b65e182531ce83f6e2c5 100644 (file)
@@ -7,20 +7,20 @@
  */
 package org.opendaylight.protocol.pcep.impl.message;
 
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.impl.PCEPMessageParser;
 import org.opendaylight.protocol.pcep.message.PCEPKeepAliveMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 
 /**
- * Parser for {@link org.opendaylight.protocol.pcep.message.PCEPKeepAliveMessage
- * PCEPKeepAliveMessage}
+ * Parser for {@link org.opendaylight.protocol.pcep.message.PCEPKeepAliveMessage PCEPKeepAliveMessage}
  */
 public class PCEPKeepAliveMessageParser implements PCEPMessageParser {
 
        @Override
-       public byte[] put(PCEPMessage msg) {
+       public byte[] put(final Message msg) {
                if (!(msg instanceof PCEPKeepAliveMessage))
-                       throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass() + ". Nedded PCEPKeepAliveMessage.");
+                       throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass()
+                                       + ". Nedded PCEPKeepAliveMessage.");
 
                return new byte[0];
        }
index c989d0b1b8513266f428f7ea250cd6dcafc3ae60..47b77f9c2d54c95c62a821fcef90f16cc9c14773 100644 (file)
@@ -11,10 +11,10 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPObject;
 import org.opendaylight.protocol.pcep.impl.PCEPMessageValidator;
 import org.opendaylight.protocol.pcep.message.PCEPKeepAliveMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 
 /**
  * PCEPKeepAliveMessage validator. Validates message integrity.
@@ -22,11 +22,11 @@ import org.opendaylight.protocol.pcep.message.PCEPKeepAliveMessage;
 public class PCEPKeepAliveMessageValidator extends PCEPMessageValidator {
 
        @Override
-       public List<PCEPMessage> validate(List<PCEPObject> objects) throws PCEPDeserializerException {
+       public List<Message> validate(final List<PCEPObject> objects) throws PCEPDeserializerException {
                if (objects != null && !objects.isEmpty())
                        throw new PCEPDeserializerException("KeepAlive message has content.");
 
-               return new ArrayList<PCEPMessage>() {
+               return new ArrayList<Message>() {
                        private static final long serialVersionUID = 1L;
 
                        {
index 280ed1767ad04e52c85f31fdaa31086cbcef57d2..67c215953d4660bfb9934a7463acca1c8b9d762c 100644 (file)
@@ -7,21 +7,21 @@
  */
 package org.opendaylight.protocol.pcep.impl.message;
 
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.impl.PCEPMessageParser;
 import org.opendaylight.protocol.pcep.impl.PCEPObjectFactory;
 import org.opendaylight.protocol.pcep.message.PCEPNotificationMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 
 /**
- * Parser for {@link org.opendaylight.protocol.pcep.message.PCEPNotificationMessage
- * PCEPNotificationMessage}
+ * Parser for {@link org.opendaylight.protocol.pcep.message.PCEPNotificationMessage PCEPNotificationMessage}
  */
 public class PCEPNotificationMessageParser implements PCEPMessageParser {
 
        @Override
-       public byte[] put(PCEPMessage msg) {
+       public byte[] put(final Message msg) {
                if (!(msg instanceof PCEPNotificationMessage))
-                       throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass() + ". Needed PCEPNotificationMessage.");
+                       throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass()
+                                       + ". Needed PCEPNotificationMessage.");
 
                return PCEPObjectFactory.put(((PCEPNotificationMessage) msg).getAllObjects());
        }
index 056fe57a1a02b3ea1eecbb4551c7cdfcf5063779..21324160a2d423dcc3e3c06e028c74cdadb998e0 100644 (file)
@@ -14,7 +14,6 @@ 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.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPObject;
 import org.opendaylight.protocol.pcep.impl.PCEPMessageValidator;
 import org.opendaylight.protocol.pcep.impl.object.UnknownObject;
@@ -24,6 +23,7 @@ import org.opendaylight.protocol.pcep.object.CompositeNotifyObject;
 import org.opendaylight.protocol.pcep.object.PCEPErrorObject;
 import org.opendaylight.protocol.pcep.object.PCEPNotificationObject;
 import org.opendaylight.protocol.pcep.object.PCEPRequestParameterObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 
 /**
  * PCEPNotificationMessage validator. Validates message integrity.
@@ -31,7 +31,7 @@ import org.opendaylight.protocol.pcep.object.PCEPRequestParameterObject;
 public class PCEPNotificationMessageValidator extends PCEPMessageValidator {
 
        @Override
-       public List<PCEPMessage> validate(List<PCEPObject> objects) throws PCEPDeserializerException {
+       public List<Message> validate(final List<PCEPObject> objects) throws PCEPDeserializerException {
                if (objects == null)
                        throw new IllegalArgumentException("Passed list can't be null.");
 
@@ -42,7 +42,7 @@ public class PCEPNotificationMessageValidator extends PCEPMessageValidator {
                        try {
                                comObj = getValidNotificationComposite(objects);
                        } catch (final PCEPDocumentedException e) {
-                               return Arrays.asList((PCEPMessage) new PCEPErrorMessage(new PCEPErrorObject(e.getError())));
+                               return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(e.getError())));
                        }
 
                        if (comObj == null)
@@ -57,10 +57,10 @@ public class PCEPNotificationMessageValidator extends PCEPMessageValidator {
                if (!objects.isEmpty())
                        throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
 
-               return Arrays.asList((PCEPMessage) new PCEPNotificationMessage(compositeNotifications));
+               return Arrays.asList((Message) new PCEPNotificationMessage(compositeNotifications));
        }
 
-       private static CompositeNotifyObject getValidNotificationComposite(List<PCEPObject> objects) throws PCEPDocumentedException {
+       private static CompositeNotifyObject getValidNotificationComposite(final List<PCEPObject> objects) throws PCEPDocumentedException {
                final List<PCEPRequestParameterObject> requestParameters = new ArrayList<PCEPRequestParameterObject>();
                final List<PCEPNotificationObject> notifications = new ArrayList<PCEPNotificationObject>();
                PCEPObject obj;
@@ -73,22 +73,22 @@ public class PCEPNotificationMessageValidator extends PCEPMessageValidator {
                                throw new PCEPDocumentedException("Unknown object", ((UnknownObject) obj).getError());
 
                        switch (state) {
-                               case 1:
+                       case 1:
+                               state = 2;
+                               if (obj instanceof PCEPRequestParameterObject) {
+                                       if (((PCEPRequestParameterObject) obj).isProcessed())
+                                               throw new PCEPDocumentedException("Invalid setting of P flag.", PCEPErrors.P_FLAG_NOT_SET);
+                                       requestParameters.add((PCEPRequestParameterObject) obj);
+                                       state = 1;
+                                       break;
+                               }
+                       case 2:
+                               if (obj instanceof PCEPNotificationObject) {
+                                       notifications.add((PCEPNotificationObject) obj);
                                        state = 2;
-                                       if (obj instanceof PCEPRequestParameterObject) {
-                                               if (((PCEPRequestParameterObject) obj).isProcessed())
-                                                       throw new PCEPDocumentedException("Invalid setting of P flag.", PCEPErrors.P_FLAG_NOT_SET);
-                                               requestParameters.add((PCEPRequestParameterObject) obj);
-                                               state = 1;
-                                               break;
-                                       }
-                               case 2:
-                                       if (obj instanceof PCEPNotificationObject) {
-                                               notifications.add((PCEPNotificationObject) obj);
-                                               state = 2;
-                                               break;
-                                       }
-                                       state = 3;
+                                       break;
+                               }
+                               state = 3;
                        }
 
                        if (state == 3)
index 33776049bbc3ec1f7b49eb4498d12d50ebb2aa64..c262edf083304f98be2cf98c538b89679479215b 100644 (file)
@@ -7,22 +7,23 @@
  */
 package org.opendaylight.protocol.pcep.impl.message;
 
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.impl.PCEPMessageParser;
 import org.opendaylight.protocol.pcep.impl.PCEPObjectFactory;
 import org.opendaylight.protocol.pcep.message.PCEPOpenMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 
 /**
  * Parser for {@link org.opendaylight.protocol.pcep.message.PCEPOpenMessage PCEPOpenMessage}
  */
 public class PCEPOpenMessageParser implements PCEPMessageParser {
 
-    @Override
-    public byte[] put(PCEPMessage msg) {
-       if (!(msg instanceof PCEPOpenMessage))
-           throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance " + msg.getClass() + ". Nedded PCEPOpenMessage.");
+       @Override
+       public byte[] put(final Message msg) {
+               if (!(msg instanceof PCEPOpenMessage))
+                       throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance " + msg.getClass()
+                                       + ". Nedded PCEPOpenMessage.");
 
-       return PCEPObjectFactory.put(((PCEPOpenMessage) msg).getAllObjects());
-    }
+               return PCEPObjectFactory.put(((PCEPOpenMessage) msg).getAllObjects());
+       }
 
 }
index 47105eaa8e15b98810705e0d3379b0f99561dbeb..6ef9841bfdf4dd3a46a1bdf82ccebad02da29b30 100644 (file)
@@ -11,11 +11,11 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPObject;
 import org.opendaylight.protocol.pcep.impl.PCEPMessageValidator;
 import org.opendaylight.protocol.pcep.message.PCEPOpenMessage;
 import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 
 /**
  * PCEPOpenMessage validator. Validates message integrity.
@@ -23,7 +23,7 @@ import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
 public class PCEPOpenMessageValidator extends PCEPMessageValidator {
 
        @Override
-       public List<PCEPMessage> validate(List<PCEPObject> objects) throws PCEPDeserializerException {
+       public List<Message> validate(final List<PCEPObject> objects) throws PCEPDeserializerException {
                if (objects == null)
                        throw new IllegalArgumentException("Passed list can't be null.");
 
@@ -36,7 +36,7 @@ public class PCEPOpenMessageValidator extends PCEPMessageValidator {
                if (!objects.isEmpty())
                        throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
 
-               return new ArrayList<PCEPMessage>() {
+               return new ArrayList<Message>() {
                        private static final long serialVersionUID = 1L;
                        {
                                this.add(msg);
index 637386f3ab07420f8f9baa47e202dd1181ef83ec..0245720c260387c4951d053489308b0026c6179c 100644 (file)
@@ -7,21 +7,21 @@
  */
 package org.opendaylight.protocol.pcep.impl.message;
 
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.impl.PCEPMessageParser;
 import org.opendaylight.protocol.pcep.impl.PCEPObjectFactory;
 import org.opendaylight.protocol.pcep.message.PCEPReplyMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 
 /**
- * Parser for {@link org.opendaylight.protocol.pcep.message.PCEPReplyMessage
- * PCEPReplyMessage}
+ * Parser for {@link org.opendaylight.protocol.pcep.message.PCEPReplyMessage PCEPReplyMessage}
  */
 public class PCEPReplyMessageParser implements PCEPMessageParser {
 
        @Override
-       public byte[] put(PCEPMessage msg) {
+       public byte[] put(final Message msg) {
                if (!(msg instanceof PCEPReplyMessage))
-                       throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass() + ". Nedded PCEPReplyMessage.");
+                       throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass()
+                                       + ". Nedded PCEPReplyMessage.");
 
                return PCEPObjectFactory.put(((PCEPReplyMessage) msg).getAllObjects());
        }
index fe7befbc9370504d68fb413ace0f114a33383a73..a1c415f5d0e386a752772d7bb01bc7fba6df0c1d 100644 (file)
@@ -15,7 +15,6 @@ 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.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPObject;
 import org.opendaylight.protocol.pcep.impl.PCEPMessageValidator;
 import org.opendaylight.protocol.pcep.impl.object.UnknownObject;
@@ -36,6 +35,9 @@ import org.opendaylight.protocol.pcep.object.PCEPObjectiveFunctionObject;
 import org.opendaylight.protocol.pcep.object.PCEPRequestParameterObject;
 import org.opendaylight.protocol.pcep.object.PCEPRequestedPathBandwidthObject;
 import org.opendaylight.protocol.pcep.object.PCEPSvecObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+
+import com.google.common.collect.Lists;
 
 /**
  * PCEPReplyMessage validator. Validates message integrity.
@@ -46,7 +48,7 @@ public class PCEPReplyMessageValidator extends PCEPMessageValidator {
 
                private boolean requestRejected = true;
 
-               private List<PCEPMessage> msgs = new ArrayList<PCEPMessage>();
+               private List<Message> msgs = Lists.newArrayList();
 
                private PCEPRequestParameterObject rpObj;
 
@@ -60,7 +62,7 @@ public class PCEPReplyMessageValidator extends PCEPMessageValidator {
 
                private void init() {
                        this.requestRejected = false;
-                       this.msgs = new ArrayList<PCEPMessage>();
+                       this.msgs = Lists.newArrayList();
 
                        this.noPath = null;
                        this.lsp = null;
@@ -71,7 +73,7 @@ public class PCEPReplyMessageValidator extends PCEPMessageValidator {
                        this.paths = new ArrayList<CompositePathObject>();
                }
 
-               public List<PCEPMessage> validate(List<PCEPObject> objects, List<CompositeReplySvecObject> svecList) {
+               public List<Message> validate(final List<PCEPObject> objects, final List<CompositeReplySvecObject> svecList) {
                        this.init();
 
                        if (!(objects.get(0) instanceof PCEPRequestParameterObject))
@@ -86,8 +88,7 @@ public class PCEPReplyMessageValidator extends PCEPMessageValidator {
                                obj = objects.get(0);
                                if (obj instanceof UnknownObject) {
                                        if (((UnknownObject) obj).isProcessed()) {
-                                               this.msgs.add(new PCEPErrorMessage(
-                                                               new CompositeErrorObject(copyRP(rpObj, false), new PCEPErrorObject(((UnknownObject) obj).getError()))));
+                                               this.msgs.add(new PCEPErrorMessage(new CompositeErrorObject(copyRP(rpObj, false), new PCEPErrorObject(((UnknownObject) obj).getError()))));
                                                this.requestRejected = true;
                                        }
 
@@ -96,44 +97,44 @@ public class PCEPReplyMessageValidator extends PCEPMessageValidator {
                                }
 
                                switch (state) {
-                                       case 1:
-                                               state = 2;
-                                               if (obj instanceof PCEPNoPathObject) {
-                                                       this.noPath = (PCEPNoPathObject) obj;
-                                                       break;
-                                               }
-                                       case 2:
-                                               state = 3;
-                                               if (obj instanceof PCEPLspObject) {
-                                                       this.lsp = (PCEPLspObject) obj;
-                                                       break;
-                                               }
-                                       case 3:
-                                               state = 4;
-                                               if (obj instanceof PCEPLspaObject) {
-                                                       this.lspa = (PCEPLspaObject) obj;
-                                                       break;
-                                               }
-                                       case 4:
+                               case 1:
+                                       state = 2;
+                                       if (obj instanceof PCEPNoPathObject) {
+                                               this.noPath = (PCEPNoPathObject) obj;
+                                               break;
+                                       }
+                               case 2:
+                                       state = 3;
+                                       if (obj instanceof PCEPLspObject) {
+                                               this.lsp = (PCEPLspObject) obj;
+                                               break;
+                                       }
+                               case 3:
+                                       state = 4;
+                                       if (obj instanceof PCEPLspaObject) {
+                                               this.lspa = (PCEPLspaObject) obj;
+                                               break;
+                                       }
+                               case 4:
+                                       state = 5;
+                                       if (obj instanceof PCEPRequestedPathBandwidthObject) {
+                                               this.bandwidth = (PCEPRequestedPathBandwidthObject) obj;
+                                               break;
+                                       }
+                               case 5:
+                                       state = 6;
+                                       if (obj instanceof PCEPMetricObject) {
+                                               this.metrics.add((PCEPMetricObject) obj);
                                                state = 5;
-                                               if (obj instanceof PCEPRequestedPathBandwidthObject) {
-                                                       this.bandwidth = (PCEPRequestedPathBandwidthObject) obj;
-                                                       break;
-                                               }
-                                       case 5:
-                                               state = 6;
-                                               if (obj instanceof PCEPMetricObject) {
-                                                       this.metrics.add((PCEPMetricObject) obj);
-                                                       state = 5;
-                                                       break;
-                                               }
-                                       case 6:
-                                               state = 7;
-                                               if (obj instanceof PCEPIncludeRouteObject) {
-                                                       this.iro = (PCEPIncludeRouteObject) obj;
-                                                       state = 8;
-                                                       break;
-                                               }
+                                               break;
+                                       }
+                               case 6:
+                                       state = 7;
+                                       if (obj instanceof PCEPIncludeRouteObject) {
+                                               this.iro = (PCEPIncludeRouteObject) obj;
+                                               state = 8;
+                                               break;
+                                       }
                                }
 
                                if (state == 7)
@@ -156,14 +157,13 @@ public class PCEPReplyMessageValidator extends PCEPMessageValidator {
                        }
 
                        if (!this.requestRejected) {
-                               this.msgs.add(new PCEPReplyMessage(Collections.unmodifiableList(Arrays.asList(new CompositeResponseObject(rpObj, this.noPath, this.lsp,
-                                               this.lspa, this.bandwidth, this.metrics, this.iro, this.paths))), Collections.unmodifiableList(svecList)));
+                               this.msgs.add(new PCEPReplyMessage(Collections.unmodifiableList(Arrays.asList(new CompositeResponseObject(rpObj, this.noPath, this.lsp, this.lspa, this.bandwidth, this.metrics, this.iro, this.paths))), Collections.unmodifiableList(svecList)));
                        }
 
                        return this.msgs;
                }
 
-               private CompositePathObject getValidCompositePath(List<PCEPObject> objects) {
+               private CompositePathObject getValidCompositePath(final List<PCEPObject> objects) {
                        if (!(objects.get(0) instanceof PCEPExplicitRouteObject))
                                return null;
 
@@ -181,8 +181,7 @@ public class PCEPReplyMessageValidator extends PCEPMessageValidator {
                                obj = objects.get(0);
                                if (obj instanceof UnknownObject) {
                                        if (((UnknownObject) obj).isProcessed()) {
-                                               this.msgs.add(new PCEPErrorMessage(new CompositeErrorObject(copyRP(this.rpObj, false), new PCEPErrorObject(((UnknownObject) obj)
-                                                               .getError()))));
+                                               this.msgs.add(new PCEPErrorMessage(new CompositeErrorObject(copyRP(this.rpObj, false), new PCEPErrorObject(((UnknownObject) obj).getError()))));
                                                this.requestRejected = true;
                                        }
                                        objects.remove(0);
@@ -190,32 +189,32 @@ public class PCEPReplyMessageValidator extends PCEPMessageValidator {
                                }
 
                                switch (state) {
-                                       case 1:
-                                               state = 2;
-                                               if (obj instanceof PCEPLspaObject) {
-                                                       pathLspa = (PCEPLspaObject) obj;
-                                                       break;
-                                               }
-                                       case 2:
+                               case 1:
+                                       state = 2;
+                                       if (obj instanceof PCEPLspaObject) {
+                                               pathLspa = (PCEPLspaObject) obj;
+                                               break;
+                                       }
+                               case 2:
+                                       state = 3;
+                                       if (obj instanceof PCEPRequestedPathBandwidthObject) {
+                                               pathBandwidth = (PCEPRequestedPathBandwidthObject) obj;
+                                               break;
+                                       }
+                               case 3:
+                                       state = 4;
+                                       if (obj instanceof PCEPMetricObject) {
+                                               pathMetrics.add((PCEPMetricObject) obj);
                                                state = 3;
-                                               if (obj instanceof PCEPRequestedPathBandwidthObject) {
-                                                       pathBandwidth = (PCEPRequestedPathBandwidthObject) obj;
-                                                       break;
-                                               }
-                                       case 3:
-                                               state = 4;
-                                               if (obj instanceof PCEPMetricObject) {
-                                                       pathMetrics.add((PCEPMetricObject) obj);
-                                                       state = 3;
-                                                       break;
-                                               }
-                                       case 4:
-                                               state = 5;
-                                               if (obj instanceof PCEPIncludeRouteObject) {
-                                                       pathIro = (PCEPIncludeRouteObject) obj;
-                                                       state = 6;
-                                                       break;
-                                               }
+                                               break;
+                                       }
+                               case 4:
+                                       state = 5;
+                                       if (obj instanceof PCEPIncludeRouteObject) {
+                                               pathIro = (PCEPIncludeRouteObject) obj;
+                                               state = 6;
+                                               break;
+                                       }
 
                                }
 
@@ -233,11 +232,11 @@ public class PCEPReplyMessageValidator extends PCEPMessageValidator {
        }
 
        @Override
-       public List<PCEPMessage> validate(List<PCEPObject> objects) throws PCEPDeserializerException {
+       public List<Message> validate(final List<PCEPObject> objects) throws PCEPDeserializerException {
                if (objects == null)
                        throw new IllegalArgumentException("Passed list can't be null.");
 
-               final List<PCEPMessage> msgs = new ArrayList<PCEPMessage>();
+               final List<Message> msgs = Lists.newArrayList();
                final List<CompositeReplySvecObject> svecList = new ArrayList<CompositeReplySvecObject>();
 
                CompositeReplySvecObject svecComp;
@@ -253,7 +252,7 @@ public class PCEPReplyMessageValidator extends PCEPMessageValidator {
                        svecList.add(svecComp);
                }
 
-               List<PCEPMessage> subMessages;
+               List<Message> subMessages;
                final SubReplyValidator subValidator = new SubReplyValidator();
                while (!objects.isEmpty()) {
                        subMessages = subValidator.validate(objects, svecList);
@@ -273,7 +272,7 @@ public class PCEPReplyMessageValidator extends PCEPMessageValidator {
                return msgs;
        }
 
-       private CompositeReplySvecObject getValidSvecComposite(List<PCEPObject> objects) throws PCEPDocumentedException {
+       private CompositeReplySvecObject getValidSvecComposite(final List<PCEPObject> objects) throws PCEPDocumentedException {
                if (objects == null)
                        throw new IllegalArgumentException("List cannot be null.");
 
@@ -295,19 +294,19 @@ public class PCEPReplyMessageValidator extends PCEPMessageValidator {
                                throw new PCEPDocumentedException("Unknown object", ((UnknownObject) obj).getError());
 
                        switch (state) {
-                               case 1:
+                       case 1:
+                               state = 2;
+                               if (obj instanceof PCEPObjectiveFunctionObject) {
+                                       of = (PCEPObjectiveFunctionObject) obj;
+                                       break;
+                               }
+                       case 2:
+                               state = 3;
+                               if (obj instanceof PCEPMetricObject) {
+                                       metrics.add((PCEPMetricObject) obj);
                                        state = 2;
-                                       if (obj instanceof PCEPObjectiveFunctionObject) {
-                                               of = (PCEPObjectiveFunctionObject) obj;
-                                               break;
-                                       }
-                               case 2:
-                                       state = 3;
-                                       if (obj instanceof PCEPMetricObject) {
-                                               metrics.add((PCEPMetricObject) obj);
-                                               state = 2;
-                                               break;
-                                       }
+                                       break;
+                               }
                        }
 
                        if (state == 3)
@@ -319,9 +318,7 @@ public class PCEPReplyMessageValidator extends PCEPMessageValidator {
                return new CompositeReplySvecObject(svec, of, metrics);
        }
 
-       private static PCEPRequestParameterObject copyRP(PCEPRequestParameterObject origRp, boolean processed) {
-               return new PCEPRequestParameterObject(origRp.isLoose(), origRp.isBidirectional(), origRp.isReoptimized(), origRp.isMakeBeforeBreak(),
-                               origRp.isReportRequestOrder(), origRp.isSuplyOFOnResponse(), origRp.isFragmentation(), origRp.isP2mp(), origRp.isEroCompression(),
-                               origRp.getPriority(), origRp.getRequestID(), origRp.getTlvs(), processed, origRp.isIgnored());
+       private static PCEPRequestParameterObject copyRP(final PCEPRequestParameterObject origRp, final boolean processed) {
+               return new PCEPRequestParameterObject(origRp.isLoose(), origRp.isBidirectional(), origRp.isReoptimized(), origRp.isMakeBeforeBreak(), origRp.isReportRequestOrder(), origRp.isSuplyOFOnResponse(), origRp.isFragmentation(), origRp.isP2mp(), origRp.isEroCompression(), origRp.getPriority(), origRp.getRequestID(), origRp.getTlvs(), processed, origRp.isIgnored());
        }
 }
index e4128f6f01b1a370f5ffad714d0cd8a7f199710b..64f664023bca6122ad6f6e9004b5f3f0354aa306 100644 (file)
@@ -7,21 +7,21 @@
  */
 package org.opendaylight.protocol.pcep.impl.message;
 
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.impl.PCEPMessageParser;
 import org.opendaylight.protocol.pcep.impl.PCEPObjectFactory;
 import org.opendaylight.protocol.pcep.message.PCEPReportMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 
 /**
- * Parser for {@link org.opendaylight.protocol.pcep.message.PCEPReportMessage
- * PCEPReportMessage}
+ * Parser for {@link org.opendaylight.protocol.pcep.message.PCEPReportMessage PCEPReportMessage}
  */
 public class PCEPReportMessageParser implements PCEPMessageParser {
 
        @Override
-       public byte[] put(PCEPMessage msg) {
+       public byte[] put(final Message msg) {
                if (!(msg instanceof PCEPReportMessage))
-                       throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass() + ". Nedded PCEPReportMessage.");
+                       throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass()
+                                       + ". Nedded PCEPReportMessage.");
 
                return PCEPObjectFactory.put(((PCEPReportMessage) msg).getAllObjects());
        }
index a9b06b435ba1fe035b1ad737adb8dcb548223f58..f7794ae6a005a4c312f15730ed5ba181415387bc 100644 (file)
@@ -14,7 +14,6 @@ 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.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPObject;
 import org.opendaylight.protocol.pcep.impl.PCEPMessageValidator;
 import org.opendaylight.protocol.pcep.impl.object.UnknownObject;
@@ -29,6 +28,7 @@ import org.opendaylight.protocol.pcep.object.PCEPLspObject;
 import org.opendaylight.protocol.pcep.object.PCEPLspaObject;
 import org.opendaylight.protocol.pcep.object.PCEPMetricObject;
 import org.opendaylight.protocol.pcep.object.PCEPReportedRouteObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 
 /**
  * PCEPReportMessage validator. Validates message integrity.
@@ -36,7 +36,7 @@ import org.opendaylight.protocol.pcep.object.PCEPReportedRouteObject;
 public class PCEPReportMessageValidator extends PCEPMessageValidator {
 
        @Override
-       public List<PCEPMessage> validate(final List<PCEPObject> objects) throws PCEPDeserializerException {
+       public List<Message> validate(final List<PCEPObject> objects) throws PCEPDeserializerException {
                if (objects == null)
                        throw new IllegalArgumentException("Passed list can't be null.");
 
@@ -44,10 +44,10 @@ public class PCEPReportMessageValidator extends PCEPMessageValidator {
 
                while (!objects.isEmpty()) {
                        if (objects.get(0) instanceof UnknownObject)
-                               return Arrays.asList((PCEPMessage) new PCEPErrorMessage(new PCEPErrorObject(((UnknownObject) objects.get(0)).getError())));
+                               return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(((UnknownObject) objects.get(0)).getError())));
 
                        if (!(objects.get(0) instanceof PCEPLspObject))
-                               return Arrays.asList((PCEPMessage) new PCEPErrorMessage(new PCEPErrorObject(PCEPErrors.LSP_MISSING)));
+                               return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(PCEPErrors.LSP_MISSING)));
 
                        final PCEPLspObject lsp = (PCEPLspObject) objects.get(0);
                        objects.remove(0);
@@ -65,7 +65,7 @@ public class PCEPReportMessageValidator extends PCEPMessageValidator {
                                                path = this.getValidCompositePath(objects);
                                        }
                                } catch (final PCEPDocumentedException e) {
-                                       return Arrays.asList((PCEPMessage) new PCEPErrorMessage(new PCEPErrorObject(e.getError())));
+                                       return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(e.getError())));
                                }
                        }
 
@@ -77,11 +77,11 @@ public class PCEPReportMessageValidator extends PCEPMessageValidator {
 
                if (!objects.isEmpty()) {
                        if (objects.get(0) instanceof UnknownObject)
-                               return Arrays.asList((PCEPMessage) new PCEPErrorMessage(new PCEPErrorObject(((UnknownObject) objects.get(0)).getError())));
+                               return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(((UnknownObject) objects.get(0)).getError())));
                        throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
                }
 
-               return Arrays.asList((PCEPMessage) new PCEPReportMessage(report));
+               return Arrays.asList((Message) new PCEPReportMessage(report));
        }
 
        private CompositeRptPathObject getValidCompositePath(final List<PCEPObject> objects) throws PCEPDocumentedException {
@@ -106,32 +106,32 @@ public class PCEPReportMessageValidator extends PCEPMessageValidator {
                        }
 
                        switch (state) {
-                               case 1:
-                                       state = 2;
-                                       if (obj instanceof PCEPLspaObject) {
-                                               pathLspa = (PCEPLspaObject) obj;
-                                               break;
-                                       }
-                               case 2:
-                                       state = 3;
-                                       if (obj instanceof PCEPExistingPathBandwidthObject) {
-                                               pathBandwidth = (PCEPExistingPathBandwidthObject) obj;
-                                               break;
-                                       }
+                       case 1:
+                               state = 2;
+                               if (obj instanceof PCEPLspaObject) {
+                                       pathLspa = (PCEPLspaObject) obj;
+                                       break;
+                               }
+                       case 2:
+                               state = 3;
+                               if (obj instanceof PCEPExistingPathBandwidthObject) {
+                                       pathBandwidth = (PCEPExistingPathBandwidthObject) obj;
+                                       break;
+                               }
 
-                               case 3:
+                       case 3:
+                               state = 4;
+                               if (obj instanceof PCEPReportedRouteObject) {
+                                       pathRro = (PCEPReportedRouteObject) obj;
+                                       break;
+                               }
+                       case 4:
+                               state = 5;
+                               if (obj instanceof PCEPMetricObject) {
+                                       pathMetrics.add((PCEPMetricObject) obj);
                                        state = 4;
-                                       if (obj instanceof PCEPReportedRouteObject) {
-                                               pathRro = (PCEPReportedRouteObject) obj;
-                                               break;
-                                       }
-                               case 4:
-                                       state = 5;
-                                       if (obj instanceof PCEPMetricObject) {
-                                               pathMetrics.add((PCEPMetricObject) obj);
-                                               state = 4;
-                                               break;
-                                       }
+                                       break;
+                               }
                        }
 
                        if (state == 5)
index 2bf9dab34e0e45da860cecb9848ed3bbb8f7fd65..e0fb7f71c27a91bab9bb6d9aa52ac8dd4f78487c 100644 (file)
@@ -7,21 +7,21 @@
  */
 package org.opendaylight.protocol.pcep.impl.message;
 
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.impl.PCEPMessageParser;
 import org.opendaylight.protocol.pcep.impl.PCEPObjectFactory;
 import org.opendaylight.protocol.pcep.message.PCEPRequestMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 
 /**
- * Parser for {@link org.opendaylight.protocol.pcep.message.PCEPReportMessage
- * PCEPReportMessage}
+ * Parser for {@link org.opendaylight.protocol.pcep.message.PCEPReportMessage PCEPReportMessage}
  */
 public class PCEPRequestMessageParser implements PCEPMessageParser {
 
        @Override
-       public byte[] put(PCEPMessage msg) {
+       public byte[] put(final Message msg) {
                if (!(msg instanceof PCEPRequestMessage))
-                       throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass() + ". Needed PCEPRequestMessage.");
+                       throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass()
+                                       + ". Needed PCEPRequestMessage.");
 
                return PCEPObjectFactory.put(((PCEPRequestMessage) msg).getAllObjects());
        }
index 6597467ef44ec1ccc61a349e3f7eec6b73b17d58..7cf0213852f17dff5412ef04694d4537b4c2f3cf 100644 (file)
@@ -13,7 +13,6 @@ import java.util.List;
 
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPObject;
 import org.opendaylight.protocol.pcep.impl.PCEPMessageValidator;
 import org.opendaylight.protocol.pcep.impl.object.UnknownObject;
@@ -39,6 +38,9 @@ import org.opendaylight.protocol.pcep.object.PCEPRequestParameterObject;
 import org.opendaylight.protocol.pcep.object.PCEPRequestedPathBandwidthObject;
 import org.opendaylight.protocol.pcep.object.PCEPSvecObject;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nps.concepts.rev130930.Bandwidth;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+
+import com.google.common.collect.Lists;
 
 /**
  * PCEPRequestMessage validator. Validates message integrity.
@@ -46,11 +48,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nps.conc
 public class PCEPRequestMessageValidator extends PCEPMessageValidator {
 
        @Override
-       public List<PCEPMessage> validate(final List<PCEPObject> objects) {
+       public List<Message> validate(final List<PCEPObject> objects) {
                if (objects == null)
                        throw new IllegalArgumentException("Passed list can't be null.");
 
-               final List<PCEPMessage> msgs = new ArrayList<PCEPMessage>();
+               final List<Message> msgs = Lists.newArrayList();
                final List<CompositeRequestSvecObject> svecList = new ArrayList<CompositeRequestSvecObject>();
 
                CompositeRequestSvecObject svecComp;
index 002f48a0ac0b2e02e64cba677dcd255f78e750f8..c2254418c38f4061b2095932a6c38ac29f38cb56 100644 (file)
@@ -7,16 +7,17 @@
  */
 package org.opendaylight.protocol.pcep.impl.message;
 
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.impl.PCEPMessageParser;
 import org.opendaylight.protocol.pcep.impl.PCEPObjectFactory;
 import org.opendaylight.protocol.pcep.message.PCEPUpdateRequestMessage;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 
 public class PCEPUpdateRequestMessageParser implements PCEPMessageParser {
        @Override
-       public byte[] put(PCEPMessage msg) {
+       public byte[] put(final Message msg) {
                if (!(msg instanceof PCEPUpdateRequestMessage))
-                       throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass() + ". Nedded PCEPUpdateRequestMessage.");
+                       throw new IllegalArgumentException("Wrong instance of PCEPMessage. Passed instance of " + msg.getClass()
+                                       + ". Nedded PCEPUpdateRequestMessage.");
 
                return PCEPObjectFactory.put(((PCEPUpdateRequestMessage) msg).getAllObjects());
        }
index 64497b19e28cac501b71dd1421756bf645ec6614..27f78e95ec1ae9eeca7c74eaa46258b123a86d30 100644 (file)
@@ -11,13 +11,9 @@ import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPObject;
 import org.opendaylight.protocol.pcep.impl.PCEPMessageValidator;
 import org.opendaylight.protocol.pcep.impl.object.UnknownObject;
@@ -31,6 +27,9 @@ import org.opendaylight.protocol.pcep.object.PCEPLspObject;
 import org.opendaylight.protocol.pcep.object.PCEPLspaObject;
 import org.opendaylight.protocol.pcep.object.PCEPMetricObject;
 import org.opendaylight.protocol.pcep.object.PCEPRequestedPathBandwidthObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * PCEPUpdateRequestMessage validator. Validates message integrity.
@@ -40,7 +39,7 @@ public class PCEPUpdateRequestMessageValidator extends PCEPMessageValidator {
        private static final Logger logger = LoggerFactory.getLogger(PCEPUpdateRequestMessageValidator.class);
 
        @Override
-       public List<PCEPMessage> validate(final List<PCEPObject> objects) throws PCEPDeserializerException {
+       public List<Message> validate(final List<PCEPObject> objects) throws PCEPDeserializerException {
                if (objects == null)
                        throw new IllegalArgumentException("Passed list can't be null.");
 
@@ -49,10 +48,10 @@ public class PCEPUpdateRequestMessageValidator extends PCEPMessageValidator {
                while (!objects.isEmpty()) {
                        if (objects.get(0) instanceof UnknownObject) {
                                logger.warn("Unknown object found (should be Lsp) - {}.", objects.get(0));
-                               return Arrays.asList((PCEPMessage) new PCEPErrorMessage(new PCEPErrorObject(((UnknownObject) objects.get(0)).getError())));
+                               return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(((UnknownObject) objects.get(0)).getError())));
                        }
                        if (!(objects.get(0) instanceof PCEPLspObject))
-                               return Arrays.asList((PCEPMessage) new PCEPErrorMessage(new PCEPErrorObject(PCEPErrors.LSP_MISSING)));
+                               return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(PCEPErrors.LSP_MISSING)));
 
                        final PCEPLspObject lsp = (PCEPLspObject) objects.get(0);
                        objects.remove(0);
@@ -71,7 +70,7 @@ public class PCEPUpdateRequestMessageValidator extends PCEPMessageValidator {
                                        }
                                } catch (final PCEPDocumentedException e) {
                                        logger.warn("Serializing failed: {}.", e);
-                                       return Arrays.asList((PCEPMessage) new PCEPErrorMessage(new PCEPErrorObject(e.getError())));
+                                       return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(e.getError())));
                                }
                        }
 
@@ -79,12 +78,12 @@ public class PCEPUpdateRequestMessageValidator extends PCEPMessageValidator {
                }
 
                if (updateRequests.isEmpty())
-                       return Arrays.asList((PCEPMessage) new PCEPErrorMessage(new PCEPErrorObject(PCEPErrors.LSP_MISSING)));
+                       return Arrays.asList((Message) new PCEPErrorMessage(new PCEPErrorObject(PCEPErrors.LSP_MISSING)));
 
                if (!objects.isEmpty())
                        throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
 
-               return Arrays.asList((PCEPMessage) new PCEPUpdateRequestMessage(updateRequests));
+               return Arrays.asList((Message) new PCEPUpdateRequestMessage(updateRequests));
        }
 
        private CompositeUpdPathObject getValidCompositePath(final List<PCEPObject> objects) throws PCEPDocumentedException {
@@ -109,25 +108,25 @@ public class PCEPUpdateRequestMessageValidator extends PCEPMessageValidator {
                        }
 
                        switch (state) {
-                               case 1:
-                                       state = 2;
-                                       if (obj instanceof PCEPLspaObject) {
-                                               pathLspa = (PCEPLspaObject) obj;
-                                               break;
-                                       }
-                               case 2:
+                       case 1:
+                               state = 2;
+                               if (obj instanceof PCEPLspaObject) {
+                                       pathLspa = (PCEPLspaObject) obj;
+                                       break;
+                               }
+                       case 2:
+                               state = 3;
+                               if (obj instanceof PCEPRequestedPathBandwidthObject) {
+                                       pathBandwidth = (PCEPRequestedPathBandwidthObject) obj;
+                                       break;
+                               }
+                       case 3:
+                               state = 4;
+                               if (obj instanceof PCEPMetricObject) {
+                                       pathMetrics.add((PCEPMetricObject) obj);
                                        state = 3;
-                                       if (obj instanceof PCEPRequestedPathBandwidthObject) {
-                                               pathBandwidth = (PCEPRequestedPathBandwidthObject) obj;
-                                               break;
-                                       }
-                               case 3:
-                                       state = 4;
-                                       if (obj instanceof PCEPMetricObject) {
-                                               pathMetrics.add((PCEPMetricObject) obj);
-                                               state = 3;
-                                               break;
-                                       }
+                                       break;
+                               }
                        }
 
                        if (state == 4)
index eb619417d2d94744aafb891656dc0b4edea2f6a0..713e984f17d537825535b7a9548241537d3fbf0c 100644 (file)
@@ -17,15 +17,16 @@ import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.message.PCEPErrorMessage;
-import org.opendaylight.protocol.pcep.message.PCEPKeepAliveMessage;
 import org.opendaylight.protocol.pcep.message.PCEPNotificationMessage;
 import org.opendaylight.protocol.pcep.message.PCEPOpenMessage;
 import org.opendaylight.protocol.pcep.object.CompositeNotifyObject;
 import org.opendaylight.protocol.pcep.object.PCEPErrorObject;
 import org.opendaylight.protocol.pcep.object.PCEPNotificationObject;
 import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.KeepaliveMessage;
+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.keepalive.message.KeepaliveMessageBuilder;
 
 public class FiniteStateMachineTest {
 
@@ -43,22 +44,21 @@ public class FiniteStateMachineTest {
        }
 
        /**
-        * Both PCEs accept session characteristics. Also tests KeepAliveTimer and
-        * error message and when pce attempts to establish pce session for the 2nd
-        * time.
-        *
+        * Both PCEs accept session characteristics. Also tests KeepAliveTimer and error message and when pce attempts to
+        * establish pce session for the 2nd time.
+        * 
         * @throws InterruptedException
         */
        @Test
        @Ignore
        public void testSessionCharsAccBoth() throws InterruptedException {
-               //this.serverSession.startSession();
+               // this.serverSession.startSession();
                assertEquals(1, this.client.getListMsg().size());
                assertTrue(this.client.getListMsg().get(0) instanceof PCEPOpenMessage);
                this.client.sendMessage(new PCEPOpenMessage(new PCEPOpenObject(3, 9, 2)));
                assertEquals(2, this.client.getListMsg().size());
-               assertTrue(this.client.getListMsg().get(1) instanceof PCEPKeepAliveMessage);
-               this.client.sendMessage(new PCEPKeepAliveMessage());
+               assertTrue(this.client.getListMsg().get(1) instanceof KeepaliveMessage);
+               this.client.sendMessage((Message) new KeepaliveMessageBuilder().build());
                synchronized (this.serverListener) {
                        while (!this.serverListener.up) {
                                try {
@@ -69,13 +69,13 @@ public class FiniteStateMachineTest {
                        }
                }
                assertTrue(this.serverListener.up);
-               //              Thread.sleep(PCEPSessionImpl.KEEP_ALIVE_TIMER_VALUE * 1000);
-               //              assertEquals(3, this.client.getListMsg().size());
-               //              assertTrue(this.client.getListMsg().get(2) instanceof PCEPKeepAliveMessage); // test of keepalive timer
+               // Thread.sleep(PCEPSessionImpl.KEEP_ALIVE_TIMER_VALUE * 1000);
+               // assertEquals(3, this.client.getListMsg().size());
+               // assertTrue(this.client.getListMsg().get(2) instanceof PCEPKeepAliveMessage); // test of keepalive timer
                this.client.sendMessage(new PCEPOpenMessage(new PCEPOpenObject(1, 1, 1)));
                assertEquals(3, this.client.getListMsg().size());
                assertTrue(this.client.getListMsg().get(2) instanceof PCEPErrorMessage);
-               for (final PCEPMessage m : this.client.getListMsg()) {
+               for (final Message m : this.client.getListMsg()) {
                        if (m instanceof PCEPErrorMessage) {
                                final PCEPErrorObject obj = ((PCEPErrorMessage) m).getErrorObjects().get(0);
                                assertEquals(PCEPErrors.ATTEMPT_2ND_SESSION, obj.getError()); // test of error type 9
@@ -85,21 +85,21 @@ public class FiniteStateMachineTest {
 
        /**
         * Mock PCE does not accept session characteristics the first time.
-        *
+        * 
         * @throws InterruptedException
         */
        @Test
        @Ignore
        public void testSessionCharsAccMe() throws InterruptedException {
-               //this.serverSession.startSession();
+               // this.serverSession.startSession();
                this.client.sendMessage(new PCEPOpenMessage(new PCEPOpenObject(4, 9, 2)));
                assertEquals(2, this.client.getListMsg().size());
                assertTrue(this.client.getListMsg().get(0) instanceof PCEPOpenMessage);
-               assertTrue(this.client.getListMsg().get(1) instanceof PCEPKeepAliveMessage);
+               assertTrue(this.client.getListMsg().get(1) instanceof KeepaliveMessage);
                this.client.sendErrorMessage(PCEPErrors.NON_ACC_NEG_SESSION_CHAR, new PCEPOpenObject(3, 7, 2, null));
                assertEquals(3, this.client.getListMsg().size());
                assertTrue(this.client.getListMsg().get(2) instanceof PCEPOpenMessage);
-               this.client.sendMessage(new PCEPKeepAliveMessage());
+               this.client.sendMessage((Message) new KeepaliveMessageBuilder().build());
                synchronized (this.serverListener) {
                        while (!this.serverListener.up) {
                                try {
@@ -114,13 +114,13 @@ public class FiniteStateMachineTest {
 
        /**
         * Sending different PCEP Message than Open in session establishment phase.
-        *
+        * 
         * @throws InterruptedException
         */
        @Test
        @Ignore
        public void testErrorOneOne() throws InterruptedException {
-               //this.serverSession.startSession();
+               // this.serverSession.startSession();
                assertEquals(1, this.client.getListMsg().size());
                assertTrue(this.client.getListMsg().get(0) instanceof PCEPOpenMessage);
                this.client.sendMessage(new PCEPNotificationMessage(new ArrayList<CompositeNotifyObject>() {
@@ -136,7 +136,7 @@ public class FiniteStateMachineTest {
                                }));
                        }
                }));
-               for (final PCEPMessage m : this.client.getListMsg()) {
+               for (final Message m : this.client.getListMsg()) {
                        if (m instanceof PCEPErrorMessage) {
                                final PCEPErrorObject obj = ((PCEPErrorMessage) m).getErrorObjects().get(0);
                                assertEquals(PCEPErrors.NON_OR_INVALID_OPEN_MSG, obj.getError());
@@ -148,17 +148,17 @@ public class FiniteStateMachineTest {
 
        /**
         * OpenWait timer expired.
-        *
+        * 
         * @throws InterruptedException
         */
        @Test
        @Ignore
        public void testErrorOneTwo() throws InterruptedException {
-               //this.serverSession.startSession();
+               // this.serverSession.startSession();
                assertEquals(1, this.client.getListMsg().size());
                assertTrue(this.client.getListMsg().get(0) instanceof PCEPOpenMessage);
                Thread.sleep(60 * 1000);
-               for (final PCEPMessage m : this.client.getListMsg()) {
+               for (final Message m : this.client.getListMsg()) {
                        if (m instanceof PCEPErrorMessage) {
                                final PCEPErrorObject obj = ((PCEPErrorMessage) m).getErrorObjects().get(0);
                                assertEquals(PCEPErrors.NO_OPEN_BEFORE_EXP_OPENWAIT, obj.getError());
@@ -168,18 +168,18 @@ public class FiniteStateMachineTest {
 
        /**
         * KeepWaitTimer expired.
-        *
+        * 
         * @throws InterruptedException
         */
        @Test
        @Ignore
        public void testErrorOneSeven() throws InterruptedException {
-               //this.serverSession.startSession();
+               // this.serverSession.startSession();
                assertEquals(1, this.client.getListMsg().size());
                assertTrue(this.client.getListMsg().get(0) instanceof PCEPOpenMessage);
                this.client.sendMessage(new PCEPOpenMessage(new PCEPOpenObject(3, 9, 2)));
-               Thread.sleep(serverSession.getKeepAliveTimerValue() * 1000);
-               for (final PCEPMessage m : this.client.getListMsg()) {
+               Thread.sleep(this.serverSession.getKeepAliveTimerValue() * 1000);
+               for (final Message m : this.client.getListMsg()) {
                        if (m instanceof PCEPErrorMessage) {
                                final PCEPErrorObject obj = ((PCEPErrorMessage) m).getErrorObjects().get(0);
                                assertEquals(PCEPErrors.NO_MSG_BEFORE_EXP_KEEPWAIT, obj.getError());
index ed9ffbe7fbf766b0a200712c2a7aef53d965b3c5..c6a0d0fcb16741babbe86b4178fc9594fbbf5095 100644 (file)
@@ -11,19 +11,19 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPSession;
 import org.opendaylight.protocol.pcep.PCEPSessionListener;
 import org.opendaylight.protocol.pcep.PCEPTerminationReason;
 import org.opendaylight.protocol.pcep.message.PCEPErrorMessage;
 import org.opendaylight.protocol.pcep.object.PCEPErrorObject;
 import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class MockPCE implements PCEPSessionListener {
 
-       private final List<PCEPMessage> listMsg = new ArrayList<PCEPMessage>();
+       private final List<Message> listMsg = new ArrayList<Message>();
 
        private PCEPSessionImpl session = null;
 
@@ -36,7 +36,7 @@ public class MockPCE implements PCEPSessionListener {
        public MockPCE() {
        }
 
-       public void sendMessage(final PCEPMessage msg) {
+       public void sendMessage(final Message msg) {
                this.session.handleMessage(msg);
        }
 
@@ -47,7 +47,7 @@ public class MockPCE implements PCEPSessionListener {
                this.sendMessage(new PCEPErrorMessage(open, errors, null));
        }
 
-       public List<PCEPMessage> getListMsg() {
+       public List<Message> getListMsg() {
                return this.listMsg;
        }
 
@@ -56,7 +56,7 @@ public class MockPCE implements PCEPSessionListener {
        }
 
        @Override
-       public void onMessage(final PCEPSession session, final PCEPMessage message) {
+       public void onMessage(final PCEPSession session, final Message message) {
                this.listMsg.add(message);
                logger.debug("Message received: {}", message);
        }
index 2623335a9c6814b9c731c209faee488c34291fa1..60a31fd4bcc4b39a940be79a39bdc49313c8146e 100644 (file)
@@ -24,7 +24,6 @@ import org.opendaylight.protocol.framework.DocumentedException;
 import org.opendaylight.protocol.pcep.PCEPDeserializerException;
 import org.opendaylight.protocol.pcep.PCEPDocumentedException;
 import org.opendaylight.protocol.pcep.PCEPErrors;
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPOFCodes;
 import org.opendaylight.protocol.pcep.PCEPObject;
 import org.opendaylight.protocol.pcep.PCEPTlv;
@@ -89,6 +88,9 @@ import org.opendaylight.protocol.pcep.tlv.PCEStatefulCapabilityTlv;
 import org.opendaylight.protocol.util.ByteArray;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.AsNumber;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nps.concepts.rev130930.Bandwidth;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
+
+import com.google.common.collect.Lists;
 
 public class PCEPValidatorTest {
 
@@ -121,7 +123,7 @@ public class PCEPValidatorTest {
        // private final PCEPClassTypeObjectProvider classTypeProvider = new
        // PCEPClassTypeObjectProvider((short) 7, true);
 
-       private static List<PCEPMessage> deserMsg(final String srcFile) throws IOException, DeserializerException, DocumentedException,
+       private static List<Message> deserMsg(final String srcFile) throws IOException, DeserializerException, DocumentedException,
                        PCEPDeserializerException {
                final byte[] bytesFromFile = ByteArray.fileToBytes(srcFile);
                final RawMessage rawMessage = (RawMessage) msgFactory.parse(bytesFromFile).get(0);
@@ -133,31 +135,36 @@ public class PCEPValidatorTest {
        public void testOpenMessageValidationFromBin() throws IOException, DeserializerException, DocumentedException,
                        PCEPDeserializerException {
                assertEquals(
-                               deserMsg("src/test/resources/PCEPOpenMessage1.bin"),
-                               asList(new PCEPOpenMessage(new PCEPOpenObject(30, 120, 1, asList(new PCEStatefulCapabilityTlv(false, true, true),
-                                               new LSPStateDBVersionTlv(0x80))))));
+                               deserMsg("src/test/resources/PCEPOpenMessage1.bin").toString(),
+                               asList(
+                                               new PCEPOpenMessage(new PCEPOpenObject(30, 120, 1, asList(new PCEStatefulCapabilityTlv(false, true, true),
+                                                               new LSPStateDBVersionTlv(0x80))))).toString());
 
-               assertEquals(deserMsg("src/test/resources/Open.1.bin"), asList(new PCEPOpenMessage(new PCEPOpenObject(1, 4, 1))));
+               assertEquals(deserMsg("src/test/resources/Open.1.bin").toString(),
+                               asList(new PCEPOpenMessage(new PCEPOpenObject(1, 4, 1))).toString());
 
                assertEquals(
-                               deserMsg("src/test/resources/Open.3.bin"),
-                               asList(new PCEPOpenMessage(new PCEPOpenObject(1, 4, 1, asList(new PCEStatefulCapabilityTlv(false, true, true),
-                                               new LSPStateDBVersionTlv(53))))));
+                               deserMsg("src/test/resources/Open.3.bin").toString(),
+                               asList(
+                                               new PCEPOpenMessage(new PCEPOpenObject(1, 4, 1, asList(new PCEStatefulCapabilityTlv(false, true, true),
+                                                               new LSPStateDBVersionTlv(53))))).toString());
        }
 
        @Test
        public void testKeepAliveMessageValidationFromBin() throws IOException, PCEPDeserializerException, PCEPDocumentedException,
                        DeserializerException, DocumentedException {
-               assertEquals(deserMsg("src/test/resources/PCEPKeepAliveMessage1.bin"), asList(new PCEPKeepAliveMessage()));
-               assertEquals(deserMsg("src/test/resources/Keepalive.1.bin"), asList(new PCEPKeepAliveMessage()));
+               assertEquals(deserMsg("src/test/resources/PCEPKeepAliveMessage1.bin").toString(),
+                               asList((Message) new PCEPKeepAliveMessage()).toString());
+               assertEquals(deserMsg("src/test/resources/Keepalive.1.bin").toString(), asList(new PCEPKeepAliveMessage()).toString());
        }
 
        @Test
        public void testCloseMsg() throws PCEPDeserializerException, IOException, PCEPDocumentedException, DeserializerException,
                        DocumentedException {
-               assertEquals(deserMsg("src/test/resources/PCEPCloseMessage1.bin"),
-                               asList(new PCEPCloseMessage(new PCEPCloseObject(Reason.TOO_MANY_UNKNOWN_MSG))));
-               assertEquals(deserMsg("src/test/resources/Close.1.bin"), asList(new PCEPCloseMessage(new PCEPCloseObject(Reason.UNKNOWN))));
+               assertEquals(deserMsg("src/test/resources/PCEPCloseMessage1.bin").toString(),
+                               asList(new PCEPCloseMessage(new PCEPCloseObject(Reason.TOO_MANY_UNKNOWN_MSG))).toString());
+               assertEquals(deserMsg("src/test/resources/Close.1.bin").toString(),
+                               asList(new PCEPCloseMessage(new PCEPCloseObject(Reason.UNKNOWN))).toString());
        }
 
        @Test
@@ -167,11 +174,11 @@ public class PCEPValidatorTest {
                final byte[] ipAdress = { (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
                requests.add(new CompositeRequestObject(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 5, 0xDEADBEEFL, true, false), new PCEPEndPointsObject<IPv4Address>(new IPv4Address(ipAdress), new IPv4Address(ipAdress))));
                PCEPRequestMessage specMessage = new PCEPRequestMessage(requests);
-               List<PCEPMessage> deserMsgs = deserMsg("src/test/resources/PCEPRequestMessage1.bin");
-               final List<PCEPMessage> specMessages = new ArrayList<PCEPMessage>();
+               List<Message> deserMsgs = deserMsg("src/test/resources/PCEPRequestMessage1.bin");
+               final List<Message> specMessages = Lists.newArrayList();
                specMessages.add(specMessage);
 
-               assertEquals(deserMsgs, specMessages);
+               assertEquals(deserMsgs.toString(), specMessages.toString());
 
                requests = new ArrayList<CompositeRequestObject>();
                final byte[] ipAdress2 = { (byte) 0x7F, (byte) 0x00, (byte) 0x00, (byte) 0x01 };
@@ -180,7 +187,7 @@ public class PCEPValidatorTest {
                deserMsgs = deserMsg("src/test/resources/PCReq.1.bin");
                specMessages.clear();
                specMessages.add(specMessage);
-               assertEquals(deserMsgs, specMessages);
+               assertEquals(deserMsgs.toString(), specMessages.toString());
 
                requests = new ArrayList<CompositeRequestObject>();
                requests.add(new CompositeRequestObject(this.requestParameter, new PCEPEndPointsObject<IPv4Address>(new IPv4Address(ipAdress2), new IPv4Address(ipAdress2)), null, null, null, null, null, null, null, null, new PCEPLoadBalancingObject(3, new Bandwidth(ByteArray.floatToBytes((float) 1024.75)), false)));
@@ -188,8 +195,7 @@ public class PCEPValidatorTest {
                deserMsgs = deserMsg("src/test/resources/PCReq.2.bin");
                specMessages.clear();
                specMessages.add(specMessage);
-               // FIXME BUG-89
-               // assertEquals(deserMsgs, specMessages);
+               assertEquals(deserMsgs.toString(), specMessages.toString());
 
                requests = new ArrayList<CompositeRequestObject>();
                requests.add(new CompositeRequestObject(this.requestParameter, new PCEPEndPointsObject<IPv4Address>(new IPv4Address(ipAdress2), new IPv4Address(ipAdress2)), null, new PCEPLspObject(1, false, false, true, false), PCEPValidatorTest.lspa, new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(1000)), false, false), new ArrayList<PCEPMetricObject>() {
@@ -231,7 +237,7 @@ public class PCEPValidatorTest {
 
                specMessages.add(new PCEPRequestMessage(requests));
                deserMsgs = deserMsg("src/test/resources/PCReq.4.bin");
-               assertEquals(deserMsgs, specMessages);
+               assertEquals(deserMsgs.toString(), specMessages.toString());
 
                specMessages.clear();
                svecList = new ArrayList<CompositeRequestSvecObject>();
@@ -274,7 +280,7 @@ public class PCEPValidatorTest {
                }, new PCEPReportedRouteObject(this.rroSubobjects, false), new PCEPExistingPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(5353)), false, false), new PCEPIncludeRouteObject(this.eroSubobjects, false, false), new PCEPLoadBalancingObject(5, new Bandwidth(ByteArray.floatToBytes(3f)), false)));
                deserMsgs = deserMsg("src/test/resources/PCReq.5.bin");
                specMessages.add(new PCEPRequestMessage(svecList, requests));
-               // FIXME BUG-89
+               // FIXME
                // assertEquals(deserMsgs, specMessages);
 
                // FIXME: need construct with invalid processed parameter
@@ -298,7 +304,7 @@ public class PCEPValidatorTest {
        @Test
        public void testRequestMessageValidationFromRawMsg() throws PCEPDeserializerException {
                List<PCEPObject> objs = new ArrayList<PCEPObject>();
-               List<PCEPMessage> msgs;
+               List<Message> msgs;
                PCEPRequestParameterObject tmpRP;
 
                // test unrecognized object in svec list
@@ -308,13 +314,13 @@ public class PCEPValidatorTest {
 
                msgs = PCEPMessageValidator.getValidator(PCEPMessageType.REQUEST).validate(objs);
 
-               assertEquals(msgs.get(0), new PCEPErrorMessage(new ArrayList<PCEPErrorObject>() {
+               assertEquals(msgs.get(0).toString(), new PCEPErrorMessage(new ArrayList<PCEPErrorObject>() {
                        private static final long serialVersionUID = 1L;
 
                        {
                                this.add(new PCEPErrorObject(PCEPErrors.UNRECOGNIZED_OBJ_CLASS));
                        }
-               }));
+               }).toString());
 
                // test with request p flag not set and ignoracion of more than one
                // end-points objects
@@ -360,16 +366,16 @@ public class PCEPValidatorTest {
                List<PCEPReplyMessage> specMessages = new ArrayList<PCEPReplyMessage>();
                specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 5, 0xDEADBEEFL, true, true)))));
                specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true, true, true, false, false, false, false, false, (short) 7, 0x12345678L, false, false)))));
-               assertEquals(deserMsg("src/test/resources/PCEPReplyMessage1.bin"), specMessages);
+               assertEquals(deserMsg("src/test/resources/PCEPReplyMessage1.bin").toString(), specMessages.toString());
 
                specMessages = new ArrayList<PCEPReplyMessage>();
                specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 3, 1, false, false)))));
-               assertEquals(deserMsg("src/test/resources/PCRep.1.bin"), specMessages);
+               assertEquals(deserMsg("src/test/resources/PCRep.1.bin").toString(), specMessages.toString());
 
                specMessages = new ArrayList<PCEPReplyMessage>();
                specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 3, 1, false, false)))));
                specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(false, false, false, false, false, false, false, false, (short) 5, 2, false, false), new PCEPNoPathObject((short) 0, false, false), null, null, null, null, null, null))));
-               assertEquals(deserMsg("src/test/resources/PCRep.2.bin"), specMessages);
+               assertEquals(deserMsg("src/test/resources/PCRep.2.bin").toString(), specMessages.toString());
 
                specMessages = new ArrayList<PCEPReplyMessage>();
                specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 3, 1, false, false), new PCEPNoPathObject((short) 1, true, false), new PCEPLspObject(1, true, true, false, true), PCEPValidatorTest.lspa, new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(500)), false, false), new ArrayList<PCEPMetricObject>() {
@@ -400,7 +406,7 @@ public class PCEPValidatorTest {
                specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 2, 4, false, false)))));
                specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(false, false, false, false, false, false, false, false, (short) 3, 4, false, false)))));
                specMessages.add(new PCEPReplyMessage(asList(new CompositeResponseObject(new PCEPRequestParameterObject(false, false, false, false, false, false, false, false, (short) 6, 5, false, false)))));
-               assertEquals(deserMsg("src/test/resources/PCRep.4.bin"), specMessages);
+               assertEquals(deserMsg("src/test/resources/PCRep.4.bin").toString(), specMessages.toString());
 
                specMessages = new ArrayList<PCEPReplyMessage>();
                final List<Long> requestIDs = new ArrayList<Long>();
@@ -459,30 +465,29 @@ public class PCEPValidatorTest {
                                }, new PCEPIncludeRouteObject(PCEPValidatorTest.this.eroSubobjects, false, false)));
                        }
                })), svecList));
-               // FIXME : BUG-89
-               // assertEquals(deserMsg("src/test/resources/PCRep.5.bin"), specMessages);
+               assertEquals(deserMsg("src/test/resources/PCRep.5.bin").toString(), specMessages.toString());
        }
 
        @Test
        public void testUpdMessageValidatorFromBin() throws IOException, PCEPDeserializerException, PCEPDocumentedException,
                        DeserializerException, DocumentedException {
-               List<PCEPMessage> specMessages = new ArrayList<PCEPMessage>();
+               List<Message> specMessages = Lists.newArrayList();
 
                List<CompositeUpdateRequestObject> requests = new ArrayList<CompositeUpdateRequestObject>();
                requests.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, false, true, true)));
 
                specMessages.add(new PCEPUpdateRequestMessage(requests));
-               assertEquals(deserMsg("src/test/resources/PCUpd.1.bin"), specMessages);
+               assertEquals(deserMsg("src/test/resources/PCUpd.1.bin").toString(), specMessages.toString());
 
-               specMessages = new ArrayList<PCEPMessage>();
+               specMessages = Lists.newArrayList();
                List<CompositeUpdPathObject> paths = new ArrayList<CompositeUpdPathObject>();
                paths.add(new CompositeUpdPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false), PCEPValidatorTest.lspa, null, null));
                requests = new ArrayList<CompositeUpdateRequestObject>();
                requests.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, false, true, true), paths));
                specMessages.add(new PCEPUpdateRequestMessage(requests));
-               assertEquals(deserMsg("src/test/resources/PCUpd.2.bin"), specMessages);
+               assertEquals(deserMsg("src/test/resources/PCUpd.2.bin").toString(), specMessages.toString());
 
-               specMessages = new ArrayList<PCEPMessage>();
+               specMessages = Lists.newArrayList();
                paths = new ArrayList<CompositeUpdPathObject>();
                paths.add(new CompositeUpdPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false), PCEPValidatorTest.lspa, new PCEPRequestedPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(5353)), false, false), new ArrayList<PCEPMetricObject>() {
                        private static final long serialVersionUID = 1L;
@@ -494,17 +499,16 @@ public class PCEPValidatorTest {
                requests = new ArrayList<CompositeUpdateRequestObject>();
                requests.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, false, true, true), paths));
                specMessages.add(new PCEPUpdateRequestMessage(requests));
-               // FIXME BUG-89
-               // assertEquals(deserMsg("src/test/resources/PCUpd.3.bin"), specMessages);
+               assertEquals(deserMsg("src/test/resources/PCUpd.3.bin").toString(), specMessages.toString());
 
-               specMessages = new ArrayList<PCEPMessage>();
+               specMessages = Lists.newArrayList();
                requests = new ArrayList<CompositeUpdateRequestObject>();
                requests.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, false, true, true)));
                requests.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, false, true, true)));
                specMessages.add(new PCEPUpdateRequestMessage(requests));
-               assertEquals(deserMsg("src/test/resources/PCUpd.4.bin"), specMessages);
+               assertEquals(deserMsg("src/test/resources/PCUpd.4.bin").toString(), specMessages.toString());
 
-               specMessages = new ArrayList<PCEPMessage>();
+               specMessages = Lists.newArrayList();
                requests = new ArrayList<CompositeUpdateRequestObject>();
                requests.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, false, true, true)));
                paths = new ArrayList<CompositeUpdPathObject>();
@@ -541,28 +545,27 @@ public class PCEPValidatorTest {
                }));
                requests.add(new CompositeUpdateRequestObject(new PCEPLspObject(1, true, false, true, true), paths));
                specMessages.add(new PCEPUpdateRequestMessage(requests));
-               // FIXME BUG-89
-               // assertEquals(deserMsg("src/test/resources/PCUpd.5.bin"), specMessages);
+               assertEquals(deserMsg("src/test/resources/PCUpd.5.bin").toString(), specMessages.toString());
        }
 
        @Test
        public void testRptMessageValidatorFromBin() throws IOException, PCEPDeserializerException, PCEPDocumentedException,
                        DeserializerException, DocumentedException {
-               List<PCEPMessage> specMessages = new ArrayList<PCEPMessage>();
+               List<Message> specMessages = Lists.newArrayList();
                List<CompositeStateReportObject> reports = new ArrayList<CompositeStateReportObject>();
                reports.add(new CompositeStateReportObject(new PCEPLspObject(1, true, false, true, true)));
                specMessages.add(new PCEPReportMessage(reports));
-               assertEquals(deserMsg("src/test/resources/PCRpt.1.bin"), specMessages);
+               assertEquals(deserMsg("src/test/resources/PCRpt.1.bin").toString(), specMessages.toString());
 
-               specMessages = new ArrayList<PCEPMessage>();
+               specMessages = Lists.newArrayList();
                List<CompositeRptPathObject> paths = new ArrayList<CompositeRptPathObject>();
                paths.add(new CompositeRptPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false), PCEPValidatorTest.lspa, null, null, null));
                reports = new ArrayList<CompositeStateReportObject>();
                reports.add(new CompositeStateReportObject(new PCEPLspObject(1, true, false, true, true), paths));
                specMessages.add(new PCEPReportMessage(reports));
-               assertEquals(deserMsg("src/test/resources/PCRpt.2.bin"), specMessages);
+               assertEquals(deserMsg("src/test/resources/PCRpt.2.bin").toString(), specMessages.toString());
 
-               specMessages = new ArrayList<PCEPMessage>();
+               specMessages = Lists.newArrayList();
                paths = new ArrayList<CompositeRptPathObject>();
                paths.add(new CompositeRptPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false), PCEPValidatorTest.lspa, new PCEPExistingPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(5353)), false, false), new PCEPReportedRouteObject(this.rroSubobjects, false), new ArrayList<PCEPMetricObject>() {
                        private static final long serialVersionUID = 1L;
@@ -575,18 +578,19 @@ public class PCEPValidatorTest {
                reports = new ArrayList<CompositeStateReportObject>();
                reports.add(new CompositeStateReportObject(new PCEPLspObject(1, true, false, true, true), paths));
                specMessages.add(new PCEPReportMessage(reports));
-               // FIXME:
+
+               // FIXME
                // assertEquals(deserMsg("src/test/resources/PCRpt.3.bin"), specMessages);
 
-               specMessages = new ArrayList<PCEPMessage>();
+               specMessages = Lists.newArrayList();
                reports = new ArrayList<CompositeStateReportObject>();
                reports.add(new CompositeStateReportObject(new PCEPLspObject(1, true, false, true, true)));
                reports.add(new CompositeStateReportObject(new PCEPLspObject(1, true, false, true, true)));
                reports.add(new CompositeStateReportObject(new PCEPLspObject(1, true, false, true, true)));
                specMessages.add(new PCEPReportMessage(reports));
-               assertEquals(deserMsg("src/test/resources/PCRpt.4.bin"), specMessages);
+               assertEquals(deserMsg("src/test/resources/PCRpt.4.bin").toString(), specMessages.toString());
 
-               specMessages = new ArrayList<PCEPMessage>();
+               specMessages = Lists.newArrayList();
                reports = new ArrayList<CompositeStateReportObject>();
                paths = new ArrayList<CompositeRptPathObject>();
                paths.add(new CompositeRptPathObject(new PCEPExplicitRouteObject(this.eroSubobjects, false), PCEPValidatorTest.lspa, new PCEPExistingPathBandwidthObject(new Bandwidth(ByteArray.floatToBytes(5353)), false, false), new PCEPReportedRouteObject(this.rroSubobjects, false), new ArrayList<PCEPMetricObject>() {
@@ -617,7 +621,7 @@ public class PCEPValidatorTest {
                reports.add(new CompositeStateReportObject(new PCEPLspObject(1, true, false, true, true), paths));
                specMessages.add(new PCEPReportMessage(reports));
                // FIXME
-               // assertEquals(deserMsg("src/test/resources/PCRpt.5.bin"), specMessages);
+               // assertEquals(deserMsg("src/test/resources/PCRpt.5.bin").toString(), specMessages.toString());
        }
 
        @Test
@@ -644,8 +648,8 @@ public class PCEPValidatorTest {
                // FIXME: need construct with invalid processed parameter
                final RawMessage rawMessage = (RawMessage) msgFactory.parse(bytes).get(0);
 
-               assertEquals(PCEPMessageValidator.getValidator(rawMessage.getMsgType()).validate(rawMessage.getAllObjects()),
-                               asList((PCEPMessage) msg));
+               assertEquals(PCEPMessageValidator.getValidator(rawMessage.getMsgType()).validate(rawMessage.getAllObjects()).toString(),
+                               asList((Message) msg).toString());
        }
 
        @Test
@@ -656,7 +660,7 @@ public class PCEPValidatorTest {
                notificationsList.add(new PCEPNotificationObject((short) 1, (short) 1));
                notifications.add(new CompositeNotifyObject(notificationsList));
                PCEPNotificationMessage specMessage = new PCEPNotificationMessage(notifications);
-               assertEquals(deserMsg("src/test/resources/PCNtf.1.bin"), asList((PCEPMessage) specMessage));
+               assertEquals(deserMsg("src/test/resources/PCNtf.1.bin").toString(), asList((Message) specMessage).toString());
 
                notifications = new ArrayList<CompositeNotifyObject>();
                notificationsList = new ArrayList<PCEPNotificationObject>();
@@ -665,7 +669,7 @@ public class PCEPValidatorTest {
                requestsList.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 3, 1, false, false));
                notifications.add(new CompositeNotifyObject(requestsList, notificationsList));
                specMessage = new PCEPNotificationMessage(notifications);
-               assertEquals(deserMsg("src/test/resources/PCNtf.2.bin"), asList((PCEPMessage) specMessage));
+               assertEquals(deserMsg("src/test/resources/PCNtf.2.bin").toString(), asList((Message) specMessage).toString());
 
                notifications = new ArrayList<CompositeNotifyObject>();
                notificationsList = new ArrayList<PCEPNotificationObject>();
@@ -674,7 +678,7 @@ public class PCEPValidatorTest {
                requestsList.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 1, 10, false, false));
                notifications.add(new CompositeNotifyObject(requestsList, notificationsList));
                specMessage = new PCEPNotificationMessage(notifications);
-               assertEquals(deserMsg("src/test/resources/PCNtf.3.bin"), asList((PCEPMessage) specMessage));
+               assertEquals(deserMsg("src/test/resources/PCNtf.3.bin").toString(), asList((Message) specMessage).toString());
 
                notifications = new ArrayList<CompositeNotifyObject>();
                notificationsList = new ArrayList<PCEPNotificationObject>();
@@ -684,7 +688,7 @@ public class PCEPValidatorTest {
                notificationsList.add(new PCEPNotificationObject((short) 2, (short) 2));
                notifications.add(new CompositeNotifyObject(notificationsList));
                specMessage = new PCEPNotificationMessage(notifications);
-               assertEquals(deserMsg("src/test/resources/PCNtf.4.bin"), asList((PCEPMessage) specMessage));
+               assertEquals(deserMsg("src/test/resources/PCNtf.4.bin").toString(), asList((Message) specMessage).toString());
 
                notifications = new ArrayList<CompositeNotifyObject>();
                notificationsList = new ArrayList<PCEPNotificationObject>();
@@ -700,7 +704,7 @@ public class PCEPValidatorTest {
                requestsList.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 1, 10, false, false));
                notifications.add(new CompositeNotifyObject(requestsList, notificationsList));
                specMessage = new PCEPNotificationMessage(notifications);
-               assertEquals(deserMsg("src/test/resources/PCNtf.5.bin"), asList((PCEPMessage) specMessage));
+               assertEquals(deserMsg("src/test/resources/PCNtf.5.bin").toString(), asList((Message) specMessage).toString());
        }
 
        @Test
@@ -710,7 +714,7 @@ public class PCEPValidatorTest {
                errorsList.add(new PCEPErrorObject(PCEPErrors.UNRECOGNIZED_OBJ_CLASS));
 
                PCEPErrorMessage specMessage = new PCEPErrorMessage(errorsList);
-               assertEquals(deserMsg("src/test/resources/PCErr.1.bin"), asList((PCEPMessage) specMessage));
+               assertEquals(deserMsg("src/test/resources/PCErr.1.bin").toString(), asList((Message) specMessage).toString());
 
                List<PCEPRequestParameterObject> requests = new ArrayList<PCEPRequestParameterObject>();
                requests.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 3, 1, false, false));
@@ -719,10 +723,10 @@ public class PCEPValidatorTest {
                errors.add(new CompositeErrorObject(requests, errorsList));
 
                specMessage = new PCEPErrorMessage(errors);
-               assertEquals(deserMsg("src/test/resources/PCErr.2.bin"), asList((PCEPMessage) specMessage));
+               assertEquals(deserMsg("src/test/resources/PCErr.2.bin").toString(), asList((Message) specMessage).toString());
 
                specMessage = new PCEPErrorMessage(new PCEPOpenObject(0, 0, 0), errorsList, null);
-               assertEquals(deserMsg("src/test/resources/PCErr.3.bin"), asList((PCEPMessage) specMessage));
+               assertEquals(deserMsg("src/test/resources/PCErr.3.bin").toString(), asList((Message) specMessage).toString());
 
                requests = new ArrayList<PCEPRequestParameterObject>();
                requests.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 1, 53, false, false));
@@ -731,7 +735,7 @@ public class PCEPValidatorTest {
                errors.add(new CompositeErrorObject(requests, errorsList));
 
                specMessage = new PCEPErrorMessage(errors);
-               assertEquals(deserMsg("src/test/resources/PCErr.3b.bin"), asList((PCEPMessage) specMessage));
+               assertEquals(deserMsg("src/test/resources/PCErr.3b.bin").toString(), asList((Message) specMessage).toString());
 
                errorsList = new ArrayList<PCEPErrorObject>();
                errorsList.add(new PCEPErrorObject(PCEPErrors.UNRECOGNIZED_OBJ_CLASS));
@@ -739,7 +743,7 @@ public class PCEPValidatorTest {
                errorsList.add(new PCEPErrorObject(PCEPErrors.UNRECOGNIZED_OBJ_CLASS));
 
                specMessage = new PCEPErrorMessage(null, errorsList, null);
-               assertEquals(deserMsg("src/test/resources/PCErr.4.bin"), asList((PCEPMessage) specMessage));
+               assertEquals(deserMsg("src/test/resources/PCErr.4.bin").toString(), asList((Message) specMessage).toString());
 
                requests = new ArrayList<PCEPRequestParameterObject>();
                requests.add(new PCEPRequestParameterObject(true, false, false, false, false, false, false, false, (short) 1, 53, false, false));
@@ -752,6 +756,6 @@ public class PCEPValidatorTest {
                errors.add(new CompositeErrorObject(requests, errorsList));
 
                specMessage = new PCEPErrorMessage(errors);
-               assertEquals(deserMsg("src/test/resources/PCErr.5.bin"), asList((PCEPMessage) specMessage));
+               assertEquals(deserMsg("src/test/resources/PCErr.5.bin").toString(), asList((Message) specMessage).toString());
        }
 }
index b50bb434828a7be50ea6b56f8f4be55d7f948e18..567c1e14b30c9c4b8ec45d26530d08f8ee63858d 100644 (file)
@@ -12,10 +12,10 @@ import io.netty.channel.Channel;
 import io.netty.util.HashedWheelTimer;
 
 import org.opendaylight.protocol.pcep.PCEPCloseTermination;
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPSessionListener;
 import org.opendaylight.protocol.pcep.object.PCEPCloseObject.Reason;
 import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 
 public class ServerSessionMock extends PCEPSessionImpl {
 
@@ -27,7 +27,7 @@ public class ServerSessionMock extends PCEPSessionImpl {
        }
 
        @Override
-       public void sendMessage(final PCEPMessage msg) {
+       public void sendMessage(final Message msg) {
                this.lastMessageSentAt = System.nanoTime();
                this.client.onMessage(this, msg);
        }
index f811598bb54a67b1789b5625af92ad667adfb1fb..6fbfe31c23dd97f99497b2c97eed5048eaf3951b 100644 (file)
@@ -7,22 +7,23 @@
  */
 package org.opendaylight.protocol.pcep.impl;
 
-import java.util.ArrayList;
 import java.util.List;
 
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPSession;
 import org.opendaylight.protocol.pcep.PCEPSessionListener;
 import org.opendaylight.protocol.pcep.PCEPTerminationReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.collect.Lists;
+
 /**
  * Simple Session Listener that is notified about messages and changes in the session.
  */
 public class SimpleSessionListener implements PCEPSessionListener {
 
-       public List<PCEPMessage> messages = new ArrayList<PCEPMessage>();
+       public List<Message> messages = Lists.newArrayList();
 
        public boolean up = false;
 
@@ -32,7 +33,7 @@ public class SimpleSessionListener implements PCEPSessionListener {
        }
 
        @Override
-       public void onMessage(final PCEPSession session, final PCEPMessage message) {
+       public void onMessage(final PCEPSession session, final Message message) {
                logger.debug("Received message: {} {}", message.getClass(), message);
                this.messages.add(message);
        }
index abaa51b96634fb885a7a965613539b87225b893b..097444c0bbbc2151be212d021b532ff0b3d64df6 100644 (file)
@@ -9,22 +9,29 @@ package org.opendaylight.protocol.pcep.spi;
 
 import java.util.List;
 
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPObject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 
 /**
  * Class representing raw message.
  */
-public class RawMessage extends PCEPMessage {
+public class RawMessage implements Message {
        private final PCEPMessageType msgType;
+       private final List<PCEPObject> objects;
 
        public RawMessage(final List<PCEPObject> objects, final PCEPMessageType msgType) {
-               super(objects);
                this.msgType = msgType;
+               if (objects.contains(null)) {
+                       throw new IllegalArgumentException("Object list contains null element at offset " + objects.indexOf(null));
+               }
+               this.objects = objects;
        }
 
        public PCEPMessageType getMsgType() {
                return this.msgType;
        }
 
+       public List<PCEPObject> getAllObjects() {
+               return this.objects;
+       }
 }
index ee09a743e531c7c38f49e6414a8287106956180f..6485ca76dcc98e7e404cb6fc3b740be29001dbde 100644 (file)
@@ -14,7 +14,6 @@ import org.opendaylight.protocol.concepts.IPv4;
 import org.opendaylight.protocol.concepts.IPv4Address;
 import org.opendaylight.protocol.concepts.IPv4Prefix;
 import org.opendaylight.protocol.concepts.Prefix;
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPSession;
 import org.opendaylight.protocol.pcep.PCEPSessionListener;
 import org.opendaylight.protocol.pcep.PCEPTerminationReason;
@@ -25,6 +24,7 @@ import org.opendaylight.protocol.pcep.object.PCEPExplicitRouteObject;
 import org.opendaylight.protocol.pcep.object.PCEPLspaObject;
 import org.opendaylight.protocol.pcep.subobject.EROIPPrefixSubobject;
 import org.opendaylight.protocol.pcep.subobject.ExplicitRouteSubobject;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -35,7 +35,7 @@ import com.google.common.collect.Lists;
  */
 public class SimpleSessionListener implements PCEPSessionListener {
 
-       public List<PCEPMessage> messages = new ArrayList<PCEPMessage>();
+       public List<Message> messages = Lists.newArrayList();
 
        private static final Logger logger = LoggerFactory.getLogger(SimpleSessionListener.class);
 
@@ -43,7 +43,7 @@ public class SimpleSessionListener implements PCEPSessionListener {
        }
 
        @Override
-       public void onMessage(final PCEPSession session, final PCEPMessage message) {
+       public void onMessage(final PCEPSession session, final Message message) {
                logger.debug("Received message: {}", message);
                this.messages.add(message);
        }
index d785d6bb109ed396258551834f8fb40c6cf837c8..1e60189650575a281c4d7c1c121a7374764565b1 100644 (file)
@@ -7,19 +7,20 @@
  */
 package org.opendaylight.protocol.pcep.testtool;
 
-import java.util.ArrayList;
 import java.util.List;
 
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPSession;
 import org.opendaylight.protocol.pcep.PCEPSessionListener;
 import org.opendaylight.protocol.pcep.PCEPTerminationReason;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.collect.Lists;
+
 public class TestingSessionListener implements PCEPSessionListener {
 
-       public List<PCEPMessage> messages = new ArrayList<PCEPMessage>();
+       public List<Message> messages = Lists.newArrayList();
 
        public boolean up = false;
 
@@ -29,7 +30,7 @@ public class TestingSessionListener implements PCEPSessionListener {
        }
 
        @Override
-       public void onMessage(final PCEPSession session, final PCEPMessage message) {
+       public void onMessage(final PCEPSession session, final Message message) {
                logger.debug("Received message: {}", message);
                this.messages.add(message);
        }
index d668e571adbcbd1f401ad825cc3c273e54684f6c..d40c22aa4029c9adb7ee21b97fd2f6ab880e65cb 100644 (file)
@@ -25,7 +25,6 @@ import org.opendaylight.protocol.framework.ReconnectStrategy;
 import org.opendaylight.protocol.framework.SessionListener;
 import org.opendaylight.protocol.framework.SessionListenerFactory;
 import org.opendaylight.protocol.framework.SessionNegotiatorFactory;
-import org.opendaylight.protocol.pcep.PCEPMessage;
 import org.opendaylight.protocol.pcep.PCEPSessionListener;
 import org.opendaylight.protocol.pcep.PCEPTlv;
 import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory;
@@ -33,12 +32,12 @@ import org.opendaylight.protocol.pcep.impl.PCEPHandlerFactory;
 import org.opendaylight.protocol.pcep.impl.PCEPSessionImpl;
 import org.opendaylight.protocol.pcep.object.PCEPOpenObject;
 import org.opendaylight.protocol.pcep.tlv.NodeIdentifierTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Message;
 
 import com.google.common.base.Preconditions;
 import com.google.common.collect.Lists;
 
-public class PCCMock<M, S extends ProtocolSession<M>, L extends SessionListener<M, ?, ?>> extends
-AbstractDispatcher<S, L> {
+public class PCCMock<M, S extends ProtocolSession<M>, L extends SessionListener<M, ?, ?>> extends AbstractDispatcher<S, L> {
 
        private final SessionNegotiatorFactory<M, S, L> negotiatorFactory;
        private final ProtocolHandlerFactory<?> factory;
@@ -49,13 +48,14 @@ AbstractDispatcher<S, L> {
                this.factory = Preconditions.checkNotNull(factory);
        }
 
-       public Future<S> createClient(final InetSocketAddress address, final ReconnectStrategy strategy, final SessionListenerFactory<L> listenerFactory) {
+       public Future<S> createClient(final InetSocketAddress address, final ReconnectStrategy strategy,
+                       final SessionListenerFactory<L> listenerFactory) {
                return super.createClient(address, strategy, new PipelineInitializer<S>() {
                        @Override
                        public void initializeChannel(final SocketChannel ch, final Promise<S> promise) {
-                               ch.pipeline().addLast(factory.getDecoders());
-                               ch.pipeline().addLast("negotiator", negotiatorFactory.getSessionNegotiator(listenerFactory, ch, promise));
-                               ch.pipeline().addLast(factory.getEncoders());
+                               ch.pipeline().addLast(PCCMock.this.factory.getDecoders());
+                               ch.pipeline().addLast("negotiator", PCCMock.this.negotiatorFactory.getSessionNegotiator(listenerFactory, ch, promise));
+                               ch.pipeline().addLast(PCCMock.this.factory.getEncoders());
                        }
                });
        }
@@ -64,17 +64,17 @@ AbstractDispatcher<S, L> {
                final List<PCEPTlv> tlvs = Lists.newArrayList();
                tlvs.add(new NodeIdentifierTlv(new byte[] { (byte) 127, (byte) 2, (byte) 3, (byte) 7 }));
 
-               final SessionNegotiatorFactory<PCEPMessage, PCEPSessionImpl, PCEPSessionListener> snf = new DefaultPCEPSessionNegotiatorFactory(new HashedWheelTimer(), new PCEPOpenObject(30, 120, 0, tlvs), 0);
+               final SessionNegotiatorFactory<Message, PCEPSessionImpl, PCEPSessionListener> snf = new DefaultPCEPSessionNegotiatorFactory(new HashedWheelTimer(), new PCEPOpenObject(30, 120, 0, tlvs), 0);
 
-               final PCCMock<PCEPMessage, PCEPSessionImpl, PCEPSessionListener> pcc = new PCCMock<>(snf, new PCEPHandlerFactory(), new DefaultPromise<PCEPSessionImpl>(GlobalEventExecutor.INSTANCE));
+               final PCCMock<Message, PCEPSessionImpl, PCEPSessionListener> pcc = new PCCMock<>(snf, new PCEPHandlerFactory(), new DefaultPromise<PCEPSessionImpl>(GlobalEventExecutor.INSTANCE));
 
                pcc.createClient(new InetSocketAddress("127.0.0.3", 12345), new NeverReconnectStrategy(GlobalEventExecutor.INSTANCE, 2000),
                                new SessionListenerFactory<PCEPSessionListener>() {
 
-                       @Override
-                       public PCEPSessionListener getSessionListener() {
-                               return new SimpleSessionListener();
-                       }
-               }).get();
+                                       @Override
+                                       public PCEPSessionListener getSessionListener() {
+                                               return new SimpleSessionListener();
+                                       }
+                               }).get();
        }
 }