public void execute(
OperationRequest operation, OperationContext context, ParticipantId participant)
throws InvalidRequestException {
String blipId = OperationUtil.getRequiredParameter(operation, ParamsProperty.BLIP_ID);
DocumentModifyAction modifyAction =
OperationUtil.getRequiredParameter(operation, ParamsProperty.MODIFY_ACTION);
OpBasedWavelet wavelet = context.openWavelet(operation, participant);
ObservableConversation conversation =
context.openConversation(operation, participant).getRoot();
Document doc = context.getBlip(conversation, blipId).getContent();
ApiView view = new ApiView(doc, wavelet);
DocumentHitIterator hitIterator = getDocumentHitIterator(operation, view);
switch (modifyAction.getModifyHow()) {
case ANNOTATE:
annotate(operation, doc, view, hitIterator, modifyAction);
break;
case CLEAR_ANNOTATION:
clearAnnotation(operation, doc, view, hitIterator, modifyAction);
break;
case DELETE:
delete(operation, view, hitIterator);
break;
case INSERT:
insert(operation, doc, view, hitIterator, modifyAction);
break;
case INSERT_AFTER:
insertAfter(operation, doc, view, hitIterator, modifyAction);
break;
case REPLACE:
replace(operation, doc, view, hitIterator, modifyAction);
break;
case UPDATE_ELEMENT:
updateElement(operation, doc, view, hitIterator, modifyAction);
break;
default:
throw new UnsupportedOperationException(
"Unsupported ModifyHow " + modifyAction.getModifyHow());
}
}