use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.pcntf.message.notifications.RpsBuilder in project bgpcep by opendaylight.
the class Stateful07ErrorMessageParser method insertObject.
private static State insertObject(final State state, final Object obj, final List<Errors> errorObjects, final List<Rps> requestParameters, final List<Srps> srps, final PcerrMessageBuilder b) {
switch(state) {
case ERROR_IN:
if (obj instanceof ErrorObject) {
final ErrorObject o = (ErrorObject) obj;
errorObjects.add(new ErrorsBuilder().setErrorObject(o).build());
return State.ERROR_IN;
}
case RP_IN:
if (obj instanceof Rp) {
final Rp o = (Rp) obj;
requestParameters.add(new RpsBuilder().setRp(o).build());
return State.RP_IN;
}
case SRP_IN:
if (obj instanceof Srp) {
final Srp o = (Srp) obj;
srps.add(new SrpsBuilder().setSrp(o).build());
return State.SRP_IN;
}
case OPEN:
if (obj instanceof Open) {
b.setErrorType(new SessionCaseBuilder().setSession(new SessionBuilder().setOpen((Open) obj).build()).build());
return State.OPEN_IN;
}
case ERROR:
if (obj instanceof ErrorObject) {
final ErrorObject o = (ErrorObject) obj;
errorObjects.add(new ErrorsBuilder().setErrorObject(o).build());
return State.ERROR;
}
case OPEN_IN:
case END:
return State.END;
default:
return state;
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.pcntf.message.notifications.RpsBuilder in project bgpcep by opendaylight.
the class PCEPErrorMessageParser method insertObject.
private static State insertObject(final State state, final List<Errors> errorObjects, final Object obj, final List<Rps> requestParameters, final PcerrMessageBuilder msgBuilder) {
switch(state) {
case RP_IN:
if (obj instanceof Rp) {
final Rp o = (Rp) obj;
requestParameters.add(new RpsBuilder().setRp(o).build());
return State.RP_IN;
}
// fallthrough
case ERROR_IN:
if (obj instanceof ErrorObject) {
final ErrorObject o = (ErrorObject) obj;
errorObjects.add(new ErrorsBuilder().setErrorObject(o).build());
return State.ERROR_IN;
}
// fallthrough
case OPEN:
if (obj instanceof Open) {
msgBuilder.setErrorType(new SessionCaseBuilder().setSession(new SessionBuilder().setOpen((Open) obj).build()).build());
return State.OPEN_IN;
}
// fallthrough
case ERROR:
if (obj instanceof ErrorObject) {
final ErrorObject o = (ErrorObject) obj;
errorObjects.add(new ErrorsBuilder().setErrorObject(o).build());
return State.ERROR;
}
// fallthrough
case OPEN_IN:
case END:
return State.END;
default:
return state;
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.pcntf.message.notifications.RpsBuilder in project bgpcep by opendaylight.
the class PCEPErrorMessageParser method validate.
@Override
protected PcerrMessage validate(final Queue<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
checkArgument(objects != null, "Passed list can't be null.");
final List<Rps> requestParameters = new ArrayList<>();
final List<Errors> errorObjects = new ArrayList<>();
final State initialState;
final Object first = objects.poll();
if (first instanceof ErrorObject) {
errorObjects.add(new ErrorsBuilder().setErrorObject((ErrorObject) first).build());
initialState = State.ERROR_IN;
} else if (first instanceof Rp) {
final Rp rp = (Rp) first;
if (rp.getProcessingRule()) {
errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.empty()));
return null;
}
requestParameters.add(new RpsBuilder().setRp(rp).build());
initialState = State.RP_IN;
} else if (first == null) {
throw new PCEPDeserializerException("Error message is empty.");
} else {
throw new PCEPDeserializerException("At least one PCEPErrorObject is mandatory.");
}
final PcerrMessageBuilder msgBuilder = new PcerrMessageBuilder();
State state = initialState;
for (Object obj = objects.peek(); obj != null; obj = objects.peek()) {
if (obj instanceof UnknownObject) {
return new PcerrBuilder().setPcerrMessage(msgBuilder.setErrors(((UnknownObject) obj).getErrors()).build()).build();
}
state = insertObject(state, errorObjects, obj, requestParameters, msgBuilder);
if (state == State.END) {
break;
}
objects.remove();
}
if (errorObjects.isEmpty()) {
throw new PCEPDeserializerException("At least one PCEPErrorObject is mandatory.");
}
if (!objects.isEmpty()) {
throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
}
if (!requestParameters.isEmpty()) {
msgBuilder.setErrorType(new RequestCaseBuilder().setRequest(new RequestBuilder().setRps(requestParameters).build()).build());
}
return new PcerrBuilder().setPcerrMessage(msgBuilder.setErrors(errorObjects).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.pcntf.message.notifications.RpsBuilder in project bgpcep by opendaylight.
the class PCEPNotificationMessageParser method insertObject.
private static State insertObject(final State state, final Object obj, final List<Message> errors, final List<Rps> requestParameters, final List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.pcntf.message.notifications.Notifications> notifications) {
switch(state) {
case INIT:
if (obj instanceof Rp) {
final Rp rp = (Rp) obj;
if (rp.getProcessingRule()) {
errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.empty()));
return null;
}
requestParameters.add(new RpsBuilder().setRp(rp).build());
return State.INIT;
}
// fallthrough
case RP_IN:
if (obj instanceof CNotification) {
final CNotification n = (CNotification) obj;
notifications.add(new NotificationsBuilder().setCNotification(n).build());
return State.RP_IN;
}
// fallthrough
case NOTIFICATION_IN:
case END:
return State.END;
default:
return state;
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcntf.message.pcntf.message.notifications.RpsBuilder in project bgpcep by opendaylight.
the class StatefulErrorMessageParser method validate.
@Override
protected PcerrMessage validate(final Queue<Object> objects, final List<Message> errors) throws PCEPDeserializerException {
checkArgument(objects != null, "Passed list can't be null.");
final Object first = objects.peek();
if (first == null) {
throw new PCEPDeserializerException("Error message is empty.");
}
final List<Rps> requestParameters = new ArrayList<>();
final List<Srps> srps = new ArrayList<>();
final List<Errors> errorObjects = new ArrayList<>();
final PcerrMessageBuilder b = new PcerrMessageBuilder();
State state = State.INIT;
if (first instanceof ErrorObject) {
errorObjects.add(new ErrorsBuilder().setErrorObject((ErrorObject) first).build());
state = State.ERROR_IN;
} else if (first instanceof Rp) {
final Rp rp = (Rp) first;
if (rp.getProcessingRule()) {
errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.empty()));
return null;
}
requestParameters.add(new RpsBuilder().setRp(rp).build());
state = State.RP_IN;
} else if (first instanceof Srp) {
srps.add(new SrpsBuilder().setSrp((Srp) first).build());
state = State.SRP_IN;
}
if (state != State.INIT) {
objects.remove();
}
for (Object obj = objects.peek(); obj != null; obj = objects.peek()) {
if (obj instanceof UnknownObject) {
return new PcerrBuilder().setPcerrMessage(b.setErrors(((UnknownObject) obj).getErrors()).build()).build();
}
state = insertObject(state, obj, errorObjects, requestParameters, srps, b);
if (state == State.END) {
break;
}
objects.remove();
}
if (errorObjects.isEmpty()) {
throw new PCEPDeserializerException("At least one PCEPErrorObject is mandatory.");
}
if (!objects.isEmpty()) {
throw new PCEPDeserializerException("Unprocessed Objects: " + objects);
}
if (!requestParameters.isEmpty()) {
b.setErrorType(new RequestCaseBuilder().setRequest(new RequestBuilder().setRps(requestParameters).build()).build());
}
if (!srps.isEmpty()) {
b.setErrorType(new StatefulCaseBuilder().setStateful(new StatefulBuilder().setSrps(srps).build()).build());
}
return new PcerrBuilder().setPcerrMessage(b.setErrors(errorObjects).build()).build();
}
Aggregations