Search in sources :

Example 1 with XObjectPropertyEvent

use of com.xpn.xwiki.internal.event.XObjectPropertyEvent in project xwiki-platform by xwiki.

the class TemplateListener method onEvent.

@Override
public void onEvent(Event event, Object source, Object data) {
    XWikiDocument document = (XWikiDocument) source;
    // Is this a skin document
    if (document.getXObject(WikiSkinUtils.SKINCLASS_REFERENCE) != null) {
        if (event instanceof AbstractAttachmentEvent) {
            AttachmentReference attachment = new AttachmentReference(((AbstractAttachmentEvent) event).getName(), document.getDocumentReference());
            String id = this.referenceSerializer.serialize(attachment);
            if (event instanceof AttachmentDeletedEvent) {
                this.observation.notify(new TemplateDeletedEvent(id), this);
            } else if (event instanceof AttachmentUpdatedEvent) {
                this.observation.notify(new TemplateUpdatedEvent(id), this);
            }
        } else if (event instanceof XObjectPropertyEvent) {
            String id = this.referenceSerializer.serialize(((XObjectPropertyEvent) event).getReference());
            if (event instanceof XObjectPropertyDeletedEvent) {
                this.observation.notify(new TemplateDeletedEvent(id), this);
            } else if (event instanceof XObjectPropertyUpdatedEvent) {
                this.observation.notify(new TemplateUpdatedEvent(id), this);
            }
        }
    }
}
Also used : AttachmentReference(org.xwiki.model.reference.AttachmentReference) XObjectPropertyUpdatedEvent(com.xpn.xwiki.internal.event.XObjectPropertyUpdatedEvent) TemplateDeletedEvent(org.xwiki.template.event.TemplateDeletedEvent) XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) TemplateUpdatedEvent(org.xwiki.template.event.TemplateUpdatedEvent) XObjectPropertyDeletedEvent(com.xpn.xwiki.internal.event.XObjectPropertyDeletedEvent) XObjectPropertyEvent(com.xpn.xwiki.internal.event.XObjectPropertyEvent) AttachmentUpdatedEvent(com.xpn.xwiki.internal.event.AttachmentUpdatedEvent) AbstractAttachmentEvent(com.xpn.xwiki.internal.event.AbstractAttachmentEvent) AttachmentDeletedEvent(com.xpn.xwiki.internal.event.AttachmentDeletedEvent)

Aggregations

XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)1 AbstractAttachmentEvent (com.xpn.xwiki.internal.event.AbstractAttachmentEvent)1 AttachmentDeletedEvent (com.xpn.xwiki.internal.event.AttachmentDeletedEvent)1 AttachmentUpdatedEvent (com.xpn.xwiki.internal.event.AttachmentUpdatedEvent)1 XObjectPropertyDeletedEvent (com.xpn.xwiki.internal.event.XObjectPropertyDeletedEvent)1 XObjectPropertyEvent (com.xpn.xwiki.internal.event.XObjectPropertyEvent)1 XObjectPropertyUpdatedEvent (com.xpn.xwiki.internal.event.XObjectPropertyUpdatedEvent)1 AttachmentReference (org.xwiki.model.reference.AttachmentReference)1 TemplateDeletedEvent (org.xwiki.template.event.TemplateDeletedEvent)1 TemplateUpdatedEvent (org.xwiki.template.event.TemplateUpdatedEvent)1