Page tree
Skip to end of metadata
Go to start of metadata

The logs will reveal the events occuring in a workspace. So for example, if I moved the history page from /demo-project/about/history to /demo-project/about/subsection-articles/history, that would produce this log:

EVENT type: 2 path: /demo-project/about/history uuid: 674469eb-31c2-4dc3-aaa9-935469790539
EVENT type: 1 path: /demo-project/about/subsection-articles/history uuid: 674469eb-31c2-4dc3-aaa9-935469790539
EVENT type: 32 path: /demo-project/about/subsection-articles/history uuid: 674469eb-31c2-4dc3-aaa9-935469790539
EVENT type: 16 path: /demo-project/about/subsection-articles/history/mgnl:lastModifiedBy uuid: 674469eb-31c2-4dc3-aaa9-935469790539
EVENT type: 16 path: /demo-project/about/subsection-articles/history/mgnl:lastModified uuid: 674469eb-31c2-4dc3-aaa9-935469790539

Events (see javax.jcr.observation.Event)

Key
NODE_ADDED = 1
NODE_MOVED = 32
NODE_REMOVED = 2
PROPERTY_ADDED = 4
PROPERTY_CHANGED = 16
PROPERTY_REMOVED = 8
PERSIST = 64

Code

package info.magnolia.support.groovy.commands;

import info.magnolia.module.observation.commands.CommandEventListener;
import javax.jcr.observation.Event;
import javax.jcr.observation.EventIterator;
import javax.jcr.observation.EventListener;

import org.apache.commons.collections.IteratorUtils;

public class CommandEventListenerLogger extends CommandEventListener {
    
    @Override
    public void onEvent(EventIterator events) {
        
        List<Event>; eventList = IteratorUtils.toList(events);
        
        int len = eventList.size();
        Event event = null;
        for (int i = 0; i &lt; len; i++) {
            event = eventList.get(i);
            System.out.println("EVENT type: " + event.getType() + 
                " path: " + event.getPath() + " uuid: " + event.getIdentifier());
        }    
        
        super.onEvent(events);   
	}
}


  • No labels