/** * Implementation for the {@link OperationType#BLIP_DELETE} method. It deletes * the blip specified in the operation. * * @param operation the operation to execute. * @param context the context of the operation. * @param participant the participant performing this operation. * @param conversation the conversation to operate on. * @throws InvalidRequestException if the operation fails to perform */ private void delete(OperationRequest operation, OperationContext context, ParticipantId participant, ObservableConversation conversation) throws InvalidRequestException { Preconditions.checkArgument( OperationUtil.getOperationType(operation) == OperationType.BLIP_DELETE, "Unsupported operation " + operation); String blipId = OperationUtil.getRequiredParameter(operation, ParamsProperty.BLIP_ID); context.getBlip(conversation, blipId).delete(); // report success. context.constructResponse(operation, Maps.<ParamsProperty, Object> newHashMap()); }
/** * Implementation for the {@link OperationType#DOCUMENT_APPEND_MARKUP} * method. It appends markup within the blip specified in * the operation. * * @param operation the operation to execute. * @param context the context of the operation. * @param participant the participant performing this operation. * @param wavelet the wavelet to operate on. * @param conversation the conversation to operate on. * @throws InvalidRequestException if the operation fails to perform */ private void appendMarkup(OperationRequest operation, OperationContext context, ParticipantId participant, ObservableWavelet wavelet, ObservableConversation conversation) throws InvalidRequestException { Preconditions.checkArgument( OperationUtil.getOperationType(operation) == OperationType.DOCUMENT_APPEND_MARKUP, "Unsupported operation " + operation); String content = OperationUtil.getRequiredParameter(operation, ParamsProperty.CONTENT); String blipId = OperationUtil.getRequiredParameter(operation, ParamsProperty.BLIP_ID); ConversationBlip convBlip = context.getBlip(conversation, blipId); // Create builder from xml content. XmlStringBuilder markupBuilder = XmlStringBuilder.createFromXmlString(content); // Append the new markup to the blip doc. Document doc = convBlip.getContent(); LineContainers.appendLine(doc, markupBuilder); // Report success. context.constructResponse(operation, Maps.<ParamsProperty, Object> newHashMap()); }
/** * Implementation for the {@link OperationType#WAVELET_APPEND_BLIP} method. It * appends a blip at the end of the root thread. * * @param operation the operation to execute. * @param context the context of the operation. * @param participant the participant performing this operation. * @param conversation the conversation to operate on. * @throws InvalidRequestException if the operation fails to perform */ private void appendBlip(OperationRequest operation, OperationContext context, ParticipantId participant, ObservableConversation conversation) throws InvalidRequestException { Preconditions.checkArgument( OperationUtil.getOperationType(operation) == OperationType.WAVELET_APPEND_BLIP, "Unsupported operation " + operation); BlipData blipData = OperationUtil.getRequiredParameter(operation, ParamsProperty.BLIP_DATA); ObservableConversationBlip newBlip = conversation.getRootThread().appendBlip(); context.putBlip(blipData.getBlipId(), newBlip); putContentForNewBlip(newBlip, blipData.getContent()); processBlipCreatedEvent(operation, context, participant, conversation, newBlip); }
/** * Executes an {@link OperationRequest}. If the operation throws an * {@link InvalidRequestException} this exception will be used to construct an * error response in the {@link OperationContext}. * * @param operation the operation to be executed. If the operation contains * {@link ParamsProperty.PROXYING_FOR} - then it will be taken in * account. * @param operationRegistry the registry containing the operations that can be * performed. * @param context the context in which the operation is to be executed. * @param author the author of the operation. */ public static void executeOperation(OperationRequest operation, OperationServiceRegistry operationRegistry, OperationContext context, ParticipantId author) { try { OperationService service = operationRegistry.getServiceFor(OperationUtil.getOperationType(operation)); ParticipantId proxyParticipant = OperationUtil.computeParticipant(operation, author); service.execute(operation, context, proxyParticipant); } catch (InvalidRequestException e) { LOG.warning("Operation " + operation + " failed to execute", e); context.constructErrorResponse(operation, e.getMessage()); } }
/** * Implementation of the {@link OperationType#BLIP_CONTINUE_THREAD} method. It * appends a new blip to the end of the thread of the blip specified in the * operation. * * @param operation the operation to execute. * @param context the context of the operation. * @param participant the participant performing this operation. * @param conversation the conversation to operate on. * @throws InvalidRequestException if the operation fails to perform */ private void continueThread(OperationRequest operation, OperationContext context, ParticipantId participant, ObservableConversation conversation) throws InvalidRequestException { Preconditions.checkArgument( OperationUtil.getOperationType(operation) == OperationType.BLIP_CONTINUE_THREAD, "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); ConversationBlip newBlip = parentBlip.getThread().appendBlip(); context.putBlip(blipData.getBlipId(), newBlip); putContentForNewBlip(newBlip, blipData.getContent()); processBlipCreatedEvent(operation, context, participant, conversation, newBlip); }
/** * Implementation of the {@link OperationType#BLIP_CREATE_CHILD} method. It * appends a new reply thread to the blip specified in the operation. * * @param operation the operation to execute. * @param context the context of the operation. * @param participant the participant performing this operation. * @param conversation the conversation to operate on. * @throws InvalidRequestException if the operation fails to perform */ private void createChild(OperationRequest operation, OperationContext context, ParticipantId participant, ObservableConversation conversation) throws InvalidRequestException { Preconditions.checkArgument( OperationUtil.getOperationType(operation) == OperationType.BLIP_CREATE_CHILD, "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); ConversationBlip newBlip = parentBlip.addReplyThread().appendBlip(); context.putBlip(blipData.getBlipId(), newBlip); putContentForNewBlip(newBlip, blipData.getContent()); processBlipCreatedEvent(operation, context, participant, conversation, newBlip); }
List<String> participantsRemoved = Lists.newArrayList(); OperationType type = OperationUtil.getOperationType(operation); switch (type) { case WAVELET_ADD_PARTICIPANT_NEWSYNTAX:
throws InvalidRequestException { Preconditions.checkArgument( OperationUtil.getOperationType(operation) == OperationType.DOCUMENT_APPEND_INLINE_BLIP, "Unsupported operation " + operation);
throws InvalidRequestException { Preconditions.checkArgument( OperationUtil.getOperationType(operation) == OperationType.DOCUMENT_INSERT_INLINE_BLIP, "Unsupported operation " + operation);
ParticipantId participant, OpBasedWavelet wavelet, ObservableConversation conversation) throws InvalidRequestException { Preconditions.checkArgument(OperationUtil.getOperationType(operation) == OperationType.DOCUMENT_INSERT_INLINE_BLIP_AFTER_ELEMENT, "Unsupported operation " + operation);
OperationType type = OperationUtil.getOperationType(operation); switch (type) { case BLIP_CONTINUE_THREAD: