data.setDefinition(newDef);
}
protected void onRemove(NodeId parentId) throws RepositoryException {
// modify the state of 'this', i.e. the target node
NodeState thisState = (NodeState) getOrCreateTransientItemState();
// remove this node from its shared set
if (thisState.isShareable()) {
if (thisState.removeShare(parentId) > 0) {
// this state is still connected to some parents, so
// leave the child node entries and properties
// set state of this instance to 'invalid'
data.setStatus(STATUS_INVALIDATED);
// notify the item manager that this instance has been
// temporarily invalidated
itemMgr.itemInvalidated(id, data);
return;
}
}
if (thisState.hasChildNodeEntries()) {
// remove child nodes
// use temp array to avoid ConcurrentModificationException
ArrayList<ChildNodeEntry> tmp = new ArrayList<ChildNodeEntry>(thisState.getChildNodeEntries());
// remove from tail to avoid problems with same-name siblings
for (int i = tmp.size() - 1; i >= 0; i--) {
ChildNodeEntry entry =
tmp.get(i);
// recursively remove child node
NodeId childId = entry.getId();
//NodeImpl childNode = (NodeImpl) itemMgr.getItem(childId);
NodeImpl childNode = itemMgr.getNode(childId, getNodeId());
childNode.onRemove(thisState.getNodeId());
// remove the child node entry
thisState.removeChildNodeEntry(entry.getName(), entry.getIndex());
}
}
// remove properties
// use temp set to avoid ConcurrentModificationException
HashSet<Name> tmp = new HashSet<Name>(thisState.getPropertyNames());
for (Name propName : tmp) {
// remove the property entry
thisState.removePropertyName(propName);
// remove property
PropertyId propId = new PropertyId(thisState.getNodeId(), propName);
itemMgr.getItem(propId).setRemoved();
}
// finally remove this node
thisState.setParentId(null);
setRemoved();
}