use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.MonitoringRequest 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();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.MonitoringRequest in project bgpcep by opendaylight.
the class PCEPRequestMessageParser method getMonitoring.
protected MonitoringRequest getMonitoring(final List<Object> objects) {
final MonitoringRequestBuilder builder = new MonitoringRequestBuilder();
if (!objects.isEmpty() && objects.get(0) instanceof Monitoring) {
builder.setMonitoring((Monitoring) objects.get(0));
objects.remove(0);
} else {
return null;
}
if (!objects.isEmpty() && objects.get(0) instanceof PccIdReq) {
builder.setPccIdReq((PccIdReq) objects.get(0));
objects.remove(0);
}
final List<PceIdList> pceIdList = new ArrayList<>();
while (!objects.isEmpty() && objects.get(0) instanceof PceId) {
pceIdList.add(new PceIdListBuilder().setPceId((PceId) objects.get(0)).build());
objects.remove(0);
}
if (!pceIdList.isEmpty()) {
builder.setPceIdList(pceIdList);
}
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcreq.message.pcreq.message.MonitoringRequest in project bgpcep by opendaylight.
the class PCEPRequestMessageParser method serializeMonitoringRequest.
protected void serializeMonitoringRequest(final MonitoringRequest monReq, final ByteBuf out) {
serializeObject(monReq.getMonitoring(), out);
serializeObject(monReq.getPccIdReq(), out);
if (monReq.getPceIdList() != null) {
for (final PceIdList pceId : monReq.getPceIdList()) {
serializeObject(pceId.getPceId(), out);
}
}
}
Aggregations