use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Pcmonreq in project bgpcep by opendaylight.
the class PCEPMonitoringRequestMessageParser method serializeMessage.
@Override
public void serializeMessage(final Message message, final ByteBuf out) {
Preconditions.checkArgument(message instanceof Pcmonreq, "Wrong instance of Message. Passed instance of %s. Need Pcmonreq.", message.getClass());
final PcreqMessage msg = ((Pcmonreq) message).getPcreqMessage();
Preconditions.checkArgument(msg.getMonitoringRequest() != null, "MONITORING object MUST be present.");
final ByteBuf buffer = Unpooled.buffer();
serializeMonitoringRequest(msg.getMonitoringRequest(), buffer);
if (msg.getSvec() != null) {
serializeSvec(msg, buffer);
}
if (msg.getRequests() != null) {
serializeRequest(msg, buffer);
}
MessageUtil.formatMessage(TYPE, buffer, out);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.message.rev131007.Pcmonreq in project bgpcep by opendaylight.
the class PCEPMonitoringRequestMessageParser method validate.
@Override
protected Message validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
Preconditions.checkArgument(objects != null, "Passed list can't be null.");
if (objects.isEmpty()) {
throw new PCEPDeserializerException("Pcmonreq message cannot be empty.");
}
final MonitoringRequest monReq = getMonitoring(objects);
if (monReq == null) {
errors.add(createErrorMsg(PCEPErrors.MONITORING_OBJECT_MISSING, Optional.absent()));
}
final PcreqMessageBuilder mBuilder = new PcreqMessageBuilder();
mBuilder.setMonitoringRequest(monReq);
final List<Svec> svecs = getSvecs(objects);
if (!svecs.isEmpty()) {
mBuilder.setSvec(svecs);
}
final List<Requests> requests = getRequests(objects, errors);
if (requests != null && !requests.isEmpty()) {
mBuilder.setRequests(requests);
}
if (!objects.isEmpty()) {
throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
}
return new PcmonreqBuilder().setPcreqMessage(mBuilder.build()).build();
}
Aggregations