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;
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;
}
}
@Override
- public byte[] put(final PCEPMessage msg) {
+ public byte[] put(final Message msg) {
return rawFactory.put(msg);
}
}