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);
}
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);
}
}
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);
}
}
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());
}
}
Aggregations