/** * Creates a new {@code Blip} object used for this session. A temporary id will be assigned to the * newly created {@code Blip} object. * * @param wavelet the wavelet that owns this blip. * @param initialContent the initial content of the new blip. * @param parentBlipId the parent of this blip. * @return an instance of new {@code Blip} object used for this session. */ private static Blip newBlip( Wavelet wavelet, String initialContent, String parentBlipId, String blipId, String threadId) { Blip newBlip = new BlipImpl(blipId, initialContent, parentBlipId, threadId, wavelet); if (parentBlipId != null) { Blip parentBlip = wavelet.getBlips().get(parentBlipId); if (parentBlip != null) { parentBlip.getChildBlipIds().add(newBlip.getBlipId()); } } wavelet.getBlips().put(newBlip.getBlipId(), newBlip); BlipThread thread = wavelet.getThread(threadId); if (thread != null) { thread.appendBlip(newBlip); } return newBlip; }
/* (non-Javadoc) * @see com.google.wave.api.OperationQueue#createChildOfBlip(com.google.wave.api.Blip) */ @Override public Blip createChildOfBlip(Blip blip) { // Create a new thread. String tempBlipId = generateTempBlipId(blip.getWavelet()); Wavelet wavelet = blip.getWavelet(); BlipThread thread = new BlipThread(tempBlipId, -1, new ArrayList<String>(), wavelet.getBlips()); // Add the new thread to the blip and wavelet. blip.addThread(thread); ((WaveletImpl) wavelet).addThread(thread); // Create a new blip in the new thread. Blip newBlip = newBlip(blip.getWavelet(), "", blip.getBlipId(), tempBlipId, thread.getId()); appendOperation( OperationType.BLIP_CREATE_CHILD, blip, Parameter.of(ParamsProperty.BLIP_DATA, newBlip.serialize())); return newBlip; }
/* (non-Javadoc) * @see com.google.wave.api.OperationQueue#insertInlineBlipToDocument(com.google.wave.api.Blip, int) */ @Override public Blip insertInlineBlipToDocument(Blip blip, int position) { // Create a new thread. String tempBlipId = generateTempBlipId(blip.getWavelet()); Wavelet wavelet = blip.getWavelet(); BlipThread thread = new BlipThread(tempBlipId, position, new ArrayList<String>(), wavelet.getBlips()); // Add the new thread to the blip and wavelet. blip.addThread(thread); ((WaveletImpl) wavelet).addThread(thread); // Create a new blip in the new thread. Blip inlineBlip = newBlip(blip.getWavelet(), "", blip.getBlipId(), tempBlipId, thread.getId()); appendOperation( OperationType.DOCUMENT_INSERT_INLINE_BLIP, blip, Parameter.of(ParamsProperty.INDEX, position), Parameter.of(ParamsProperty.BLIP_DATA, inlineBlip.serialize())); return inlineBlip; }
/** * Creates and appends a new operation to the operation queue. * * @param opType the type of the operation. * @param blip the blip to apply this operation to. * @param parameters the parameters that should be added as a property of the operation. * @return an instance of {@link OperationRequest} that represents the queued operation. */ OperationRequest appendOperation(OperationType opType, Blip blip, Parameter... parameters) { return appendOperation( opType, blip.getWaveId(), blip.getWaveletId(), blip.getBlipId(), parameters); }