use of org.zalando.nakadi.exceptions.InvalidCursorException in project nakadi by zalando.
the class VersionOneConverter method convert.
public NakadiCursor convert(final String eventTypeStr, final Cursor cursor) throws InternalNakadiException, NoSuchEventTypeException, InvalidCursorException {
final String[] parts = cursor.getOffset().split("-", 3);
if (parts.length != 3) {
throw new InvalidCursorException(CursorError.INVALID_OFFSET);
}
final String versionStr = parts[0];
if (versionStr.length() != CursorConverter.VERSION_LENGTH) {
throw new InvalidCursorException(CursorError.INVALID_OFFSET);
}
final String orderStr = parts[1];
if (orderStr.length() != TIMELINE_ORDER_LENGTH) {
throw new InvalidCursorException(CursorError.INVALID_OFFSET);
}
final String offsetStr = parts[2];
if (offsetStr.isEmpty() || !NUMBERS_ONLY_PATTERN.matcher(offsetStr).matches()) {
throw new InvalidCursorException(CursorError.INVALID_OFFSET);
}
final int order;
try {
order = Integer.parseInt(orderStr, TIMELINE_ORDER_BASE);
} catch (final NumberFormatException ex) {
throw new InvalidCursorException(CursorError.INVALID_OFFSET);
}
return findCorrectTimelinedCursor(eventTypeStr, order, cursor.getPartition(), offsetStr);
}
Aggregations