throws InvalidRequestException {
Preconditions.checkArgument(OperationUtil.getOperationType(operation)
== OperationType.DOCUMENT_INSERT_INLINE_BLIP_AFTER_ELEMENT,
"Unsupported operation " + operation);
BlipData blipData = OperationUtil.getRequiredParameter(operation, ParamsProperty.BLIP_DATA);
String parentBlipId = OperationUtil.getRequiredParameter(operation, ParamsProperty.BLIP_ID);
ConversationBlip parentBlip = context.getBlip(conversation, parentBlipId);
Element element = OperationUtil.getRequiredParameter(operation, ParamsProperty.ELEMENT);
// view.locateElement will tell where the element actually is.
ApiView view = new ApiView(parentBlip.getContent(), wavelet);
int elementApiLocation = view.locateElement(element);
if (elementApiLocation == -1) {
throw new InvalidRequestException("Requested element not found", operation);
}
// Insert just after the requested element
int xmlLocation = view.transformToXmlOffset(elementApiLocation + 1);
// Insert new inline thread with the blip at the location of the element.
ConversationBlip newBlip = parentBlip.addReplyThread(xmlLocation).appendBlip();
context.putBlip(blipData.getBlipId(), newBlip);
putContentForNewBlip(newBlip, blipData.getContent());
processBlipCreatedEvent(operation, context, participant, conversation, newBlip);
}