}
@Override
public void onDocumentChanged(DocumentChangedEvent event) {
Blip blip = event.getBlip();
Wavelet wavelet = event.getWavelet();
if (wavelet.getDataDocuments().contains("issue-tracker-project")) {
return;
}
Annotations annotations = event.getBlip().getAnnotations();
Iterator<Annotation> iterator = annotations.iterator();
while (iterator.hasNext()) {
Annotation annotation = iterator.next();
String name = annotation.getName();
String value = annotation.getValue();
if (name.equals(this.HIGHLIGHT_ANNOTATION_NAME) && value.equals("new")) {
// Check for authsub token first
String user = event.getModifiedBy();
UserInfo userInfo = util.getUserInfo(user);
if (userInfo == null) {
appendAuthSubGadget(blip, user);
} else {
BlipContentRefs blipContentRefs = blip.range(annotation.getRange().getStart(), annotation
.getRange().getEnd());
blipContentRefs.annotate(this.HIGHLIGHT_ANNOTATION_NAME, "done");
Set<String> participants = new HashSet<String>();
participants.add(event.getModifiedBy());
Wavelet newWavelet = null;
try {
newWavelet = this.newWave(this.getDomain(), participants, "test", event.getBundle().getProxyingFor(), this.getRpcServerUrl());
newWavelet.setTitle(DEFAULT_ISSUE_TITLE);
newWavelet.getDataDocuments().set("issue-tracker-project",
event.getBundle().getProxyingFor());
newWavelet.getRootBlip().append(new Line());
newWavelet.getRootBlip().append(blipContentRefs.value());
newWavelet.getRootBlip().append(new Line());
newWavelet.getRootBlip().append(new Line());
this.appendButton(newWavelet.getRootBlip(), "createIssue", "createIssue");
// Linkify to new wave
blipContentRefs.annotate("link/wave", this.domain + "!"
+ newWavelet.getWaveId().getId());
this.submit(newWavelet, this.getRpcServerUrl());
} catch (IOException e) {
LOG.log(Level.SEVERE, e.getMessage(), e);
}