use of no.mnemonic.act.platform.api.model.v1.Object in project bgpcep by opendaylight.
the class Stateful07PCReportMessageParser method validatePath.
private static boolean validatePath(final List<Object> objects, final List<Message> errors, final ReportsBuilder builder) {
final PathBuilder pBuilder = new PathBuilder();
Object object = objects.remove(0);
if (object instanceof Ero) {
pBuilder.setEro((Ero) object);
} else {
errors.add(createErrorMsg(PCEPErrors.ERO_MISSING, Optional.absent()));
return false;
}
parsePath(objects, pBuilder);
builder.setPath(pBuilder.build());
return true;
}
use of no.mnemonic.act.platform.api.model.v1.Object in project bgpcep by opendaylight.
the class Stateful07PCUpdateRequestMessageParser method getValidUpdates.
protected Updates getValidUpdates(final List<Object> objects, final List<Message> errors) {
final UpdatesBuilder builder = new UpdatesBuilder();
Object object = objects.remove(0);
if (object instanceof Srp) {
builder.setSrp((Srp) object);
if (objects.isEmpty()) {
object = null;
} else {
object = objects.remove(0);
}
} else {
errors.add(createErrorMsg(PCEPErrors.SRP_MISSING, Optional.absent()));
}
if (validateLsp(object, errors, builder)) {
if (!objects.isEmpty()) {
if (!validatePath(objects, errors, builder)) {
return null;
}
}
return builder.build();
}
return null;
}
use of no.mnemonic.act.platform.api.model.v1.Object in project bgpcep by opendaylight.
the class PCEPCloseMessageParser method validate.
@Override
protected Close validate(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
Preconditions.checkArgument(objects != null, "Passed list can't be null.");
if (objects.isEmpty() || !(objects.get(0) instanceof CClose)) {
throw new PCEPDeserializerException("Close message doesn't contain CLOSE object.");
}
final Object o = objects.get(0);
final CCloseMessage msg = new CCloseMessageBuilder().setCClose((CClose) o).build();
objects.remove(0);
if (!objects.isEmpty()) {
throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
}
return new CloseBuilder().setCCloseMessage(msg).build();
}
use of no.mnemonic.act.platform.api.model.v1.Object in project bgpcep by opendaylight.
the class PCEPNotificationMessageParser method getValidNotificationComposite.
private static Notifications getValidNotificationComposite(final List<Object> objects, final List<Message> errors) {
final List<Rps> requestParameters = new ArrayList<>();
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.notifications.Notifications> notifications = new ArrayList<>();
Object obj;
State state = State.INIT;
while (!objects.isEmpty() && !state.equals(State.END)) {
obj = objects.get(0);
if ((state = insertObject(state, obj, errors, requestParameters, notifications)) == null) {
return null;
}
if (!state.equals(State.END)) {
objects.remove(0);
}
}
if (notifications.isEmpty()) {
return null;
}
return new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcntf.message.pcntf.message.NotificationsBuilder().setNotifications(notifications).setRps(requestParameters).build();
}
use of no.mnemonic.act.platform.api.model.v1.Object in project bgpcep by opendaylight.
the class PCEPReplyMessageParser method getValidReply.
protected Replies getValidReply(final List<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
Object object = objects.remove(0);
if (!(object instanceof Rp)) {
errors.add(createErrorMsg(PCEPErrors.RP_MISSING, Optional.absent()));
return null;
}
final Rp rp = (Rp) object;
final RepliesBuilder repliesBuilder = new RepliesBuilder();
if (!objects.isEmpty() && objects.get(0) instanceof Monitoring) {
repliesBuilder.setMonitoring((Monitoring) objects.get(0));
objects.remove(0);
}
if (!objects.isEmpty() && objects.get(0) instanceof PccIdReq) {
repliesBuilder.setPccIdReq((PccIdReq) objects.get(0));
objects.remove(0);
}
final List<VendorInformationObject> vendorInfo = addVendorInformationObjects(objects);
Result res = null;
if (!objects.isEmpty()) {
if (objects.get(0) instanceof NoPath) {
res = handleNoPath((NoPath) objects.get(0), objects);
} else if (objects.get(0) instanceof Ero) {
res = handleEro((Ero) objects.get(0), objects);
}
}
final List<MetricPce> metricPceList = new ArrayList<>();
if (!objects.isEmpty() && objects.get(0) instanceof PceId) {
while (!objects.isEmpty()) {
metricPceList.add(Util.validateMonitoringMetrics(objects));
}
}
if (!vendorInfo.isEmpty()) {
repliesBuilder.setVendorInformationObject(vendorInfo);
}
if (!metricPceList.isEmpty()) {
repliesBuilder.setMetricPce(metricPceList);
}
return repliesBuilder.setRp(rp).setResult(res).build();
}
Aggregations