Skip to content

Instantly share code, notes, and snippets.

@vega113
Created January 21, 2014 20:57
Show Gist options
  • Save vega113/8548236 to your computer and use it in GitHub Desktop.
Save vega113/8548236 to your computer and use it in GitHub Desktop.
Another version of extractTitle for TitleHelper - not tested.
public static String getTitle(WaveId waveId, WaveletId waveletId, WaveMap waveMap,
ConversationUtil conversationUtil) {
String title = "";
WaveViewData wave =
AbstractSearchProviderImpl.buildWaveViewData(waveId, Lists.newArrayList(waveletId),
SolrSearchProviderImpl.matchesFunction, waveMap);
OpBasedWavelet wavelet = OpBasedWavelet.createReadOnly(wave.getWavelet(waveletId));
if (WaveletBasedConversation.waveletHasConversation(wavelet)) {
ObservableConversationView conversations = conversationUtil.buildConversation(wavelet);
ObservableConversation rootConversation = conversations.getRoot();
ObservableConversationBlip firstBlip = null;
if (rootConversation != null && rootConversation.getRootThread() != null
&& rootConversation.getRootThread().getFirstBlip() != null) {
firstBlip = rootConversation.getRootThread().getFirstBlip();
}
if (firstBlip != null) {
Document firstBlipContents = firstBlip.getContent();
title = TitleHelper.extractTitle(firstBlipContents).trim();
}
}
return title;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment