Search in sources :

Example 1 with EventState

use of org.apache.jackrabbit.core.observation.EventState in project jackrabbit by apache.

the class ChangeLogRecord method readEventRecord.

/**
     * Read an event record.
     *
     * @throws JournalException if an error occurs
     */
private void readEventRecord() throws JournalException {
    int type = record.readByte();
    NodeId parentId = record.readNodeId();
    Path parentPath = record.readPath();
    NodeId childId = record.readNodeId();
    Path childRelPath = record.readPathElement();
    Name ntName = record.readQName();
    Set<Name> mixins = new HashSet<Name>();
    int mixinCount = record.readInt();
    for (int i = 0; i < mixinCount; i++) {
        mixins.add(record.readQName());
    }
    String userId = record.readString();
    Map<String, InternalValue> info = null;
    if (type == Event.NODE_MOVED) {
        info = new HashMap<String, InternalValue>();
        // read info map
        int infoSize = record.readInt();
        for (int i = 0; i < infoSize; i++) {
            String key = record.readString();
            int propType = record.readInt();
            InternalValue value;
            if (propType == PropertyType.UNDEFINED) {
                // indicates null value
                value = null;
            } else {
                value = InternalValue.valueOf(record.readString(), propType);
            }
            info.put(key, value);
        }
    }
    EventState es = createEventState(type, parentId, parentPath, childId, childRelPath, ntName, mixins, userId);
    if (info != null) {
        es.setInfo(info);
    }
    events.add(es);
}
Also used : Path(org.apache.jackrabbit.spi.Path) EventState(org.apache.jackrabbit.core.observation.EventState) NodeId(org.apache.jackrabbit.core.id.NodeId) InternalValue(org.apache.jackrabbit.core.value.InternalValue) Name(org.apache.jackrabbit.spi.Name) HashSet(java.util.HashSet)

Example 2 with EventState

use of org.apache.jackrabbit.core.observation.EventState in project jackrabbit by apache.

the class VirtualNodeTypeStateManager method nodeTypesUnregistered.

/**
     * {@inheritDoc}
     */
public void nodeTypesUnregistered(Collection<Name> names) {
    try {
        if (systemSession != null) {
            // generated observation events
            List<EventState> events = new ArrayList<EventState>();
            NodeImpl root = (NodeImpl) systemSession.getItemManager().getItem(rootNodeId);
            for (Name name : names) {
                NodeImpl child = root.getNode(name);
                recursiveRemove(events, root, child);
            }
            obsDispatcher.dispatch(events, systemSession, NODE_TYPES_PATH, null);
        }
        if (virtProvider != null) {
            // allow provider to update
            virtProvider.onNodeTypesRemoved(names);
        }
    } catch (RepositoryException e) {
        log.error("Unable to index removed nodetypes: " + names, e);
    }
}
Also used : EventState(org.apache.jackrabbit.core.observation.EventState) NodeImpl(org.apache.jackrabbit.core.NodeImpl) ArrayList(java.util.ArrayList) RepositoryException(javax.jcr.RepositoryException) Name(org.apache.jackrabbit.spi.Name)

Example 3 with EventState

use of org.apache.jackrabbit.core.observation.EventState in project jackrabbit by apache.

the class ChangeLogRecord method doWrite.

/**
     * {@inheritDoc}
     */
@Override
protected void doWrite() throws JournalException {
    writeTimestampRecord();
    writeUserDataRecord();
    for (ItemState state : changes.deletedStates()) {
        if (state.isNode()) {
            writeNodeRecord(DELETED, (NodeState) state);
        } else {
            writePropertyRecord(DELETED, (PropertyState) state);
        }
    }
    for (ItemState state : changes.modifiedStates()) {
        if (state.isNode()) {
            writeNodeRecord(MODIFIED, (NodeState) state);
        } else {
            writePropertyRecord(MODIFIED, (PropertyState) state);
        }
    }
    for (ItemState state : changes.addedStates()) {
        if (state.isNode()) {
            writeNodeRecord(ADDED, (NodeState) state);
        } else {
            writePropertyRecord(ADDED, (PropertyState) state);
        }
    }
    for (EventState event : events) {
        writeEventRecord(event);
    }
}
Also used : EventState(org.apache.jackrabbit.core.observation.EventState) ItemState(org.apache.jackrabbit.core.state.ItemState)

Example 4 with EventState

use of org.apache.jackrabbit.core.observation.EventState in project jackrabbit by apache.

the class VirtualNodeTypeStateManager method nodeTypeRegistered.

/**
     * {@inheritDoc}
     */
public void nodeTypeRegistered(Name ntName) {
    try {
        if (virtProvider != null) {
            // allow provider to update
            virtProvider.onNodeTypeAdded(ntName);
        }
        if (systemSession != null) {
            // generate observation events
            NodeImpl root = (NodeImpl) systemSession.getItemManager().getItem(rootNodeId);
            NodeImpl child = root.getNode(ntName);
            List<EventState> events = new ArrayList<EventState>();
            recursiveAdd(events, root, child);
            obsDispatcher.dispatch(events, systemSession, NODE_TYPES_PATH, null);
        }
    } catch (RepositoryException e) {
        log.error("Unable to index new nodetype: " + e.toString());
    }
}
Also used : EventState(org.apache.jackrabbit.core.observation.EventState) NodeImpl(org.apache.jackrabbit.core.NodeImpl) ArrayList(java.util.ArrayList) RepositoryException(javax.jcr.RepositoryException)

Aggregations

EventState (org.apache.jackrabbit.core.observation.EventState)4 ArrayList (java.util.ArrayList)2 RepositoryException (javax.jcr.RepositoryException)2 NodeImpl (org.apache.jackrabbit.core.NodeImpl)2 Name (org.apache.jackrabbit.spi.Name)2 HashSet (java.util.HashSet)1 NodeId (org.apache.jackrabbit.core.id.NodeId)1 ItemState (org.apache.jackrabbit.core.state.ItemState)1 InternalValue (org.apache.jackrabbit.core.value.InternalValue)1 Path (org.apache.jackrabbit.spi.Path)1