use of com.google.storage.v2.Object in project bgpcep by opendaylight.
the class Stateful07PCReportMessageParser method parsePath.
private static void parsePath(final List<Object> objects, final PathBuilder builder) {
final List<Metrics> pathMetrics = Lists.newArrayList();
Object obj;
State state = State.INIT;
while (!objects.isEmpty() && !state.equals(State.END)) {
obj = objects.get(0);
state = insertObject(state, obj, builder, pathMetrics);
if (!state.equals(State.END)) {
objects.remove(0);
}
}
if (!pathMetrics.isEmpty()) {
builder.setMetrics(pathMetrics);
}
}
use of com.google.storage.v2.Object in project bgpcep by opendaylight.
the class Stateful07PCReportMessageParser method getValidReports.
protected Reports getValidReports(final List<Object> objects, final List<Message> errors) {
final ReportsBuilder builder = new ReportsBuilder();
boolean lspViaSR = false;
Object object = objects.remove(0);
if (object instanceof Srp) {
final Srp srp = (Srp) object;
final Tlvs tlvs = srp.getTlvs();
if (tlvs != null) {
lspViaSR = PSTUtil.isDefaultPST(tlvs.getPathSetupType());
}
builder.setSrp(srp);
if (objects.isEmpty()) {
object = null;
} else {
object = objects.remove(0);
}
}
if (validateLsp(object, lspViaSR, errors, builder)) {
if (!objects.isEmpty()) {
if (!validatePath(objects, errors, builder)) {
return null;
}
}
return builder.build();
}
return null;
}
use of com.google.storage.v2.Object in project bgpcep by opendaylight.
the class Stateful07PCUpdateRequestMessageParser method parsePath.
private static void parsePath(final List<Object> objects, final PathBuilder pBuilder) {
final List<Metrics> pathMetrics = Lists.newArrayList();
Object obj;
State state = State.INIT;
while (!objects.isEmpty() && !state.equals(State.END)) {
obj = objects.get(0);
state = insertObject(state, obj, pBuilder, pathMetrics);
if (!state.equals(State.END)) {
objects.remove(0);
}
}
if (!pathMetrics.isEmpty()) {
pBuilder.setMetrics(pathMetrics);
}
}
use of com.google.storage.v2.Object in project bgpcep by opendaylight.
the class Stateful07PCUpdateRequestMessageParser method validatePath.
private static boolean validatePath(final List<Object> objects, final List<Message> errors, final UpdatesBuilder 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 com.google.storage.v2.Object in project bgpcep by opendaylight.
the class Stateful07ErrorMessageParser method validate.
@Override
protected PcerrMessage 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("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();
Object obj = objects.get(0);
State state = State.INIT;
if (obj instanceof ErrorObject) {
final ErrorObject o = (ErrorObject) obj;
errorObjects.add(new ErrorsBuilder().setErrorObject(o).build());
state = State.ERROR_IN;
} else if (obj instanceof Rp) {
final Rp o = (Rp) obj;
if (o.isProcessingRule()) {
errors.add(createErrorMsg(PCEPErrors.P_FLAG_NOT_SET, Optional.absent()));
return null;
}
requestParameters.add(new RpsBuilder().setRp(o).build());
state = State.RP_IN;
} else if (obj instanceof Srp) {
final Srp s = (Srp) obj;
srps.add(new SrpsBuilder().setSrp(s).build());
state = State.SRP_IN;
}
if (!state.equals(State.INIT)) {
objects.remove(0);
}
while (!objects.isEmpty() && !state.equals(State.END)) {
obj = objects.get(0);
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.equals(State.END)) {
objects.remove(0);
}
}
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