use of org.apache.jackrabbit.jcr2spi.state.PropertyState in project jackrabbit by apache.
the class NodeEntryImpl method complete.
private void complete(SetMixin operation) throws RepositoryException {
if (operation.getNodeState().getHierarchyEntry() != this) {
throw new IllegalArgumentException();
}
PropertyEntry pe = getPropertyEntry(NameConstants.JCR_MIXINTYPES);
if (pe != null) {
PropertyState pState = pe.getPropertyState();
switch(operation.getStatus()) {
case Operation.STATUS_PERSISTED:
Name[] mixins = StateUtility.getMixinNames(pState);
getNodeState().setMixinTypeNames(mixins);
if (pState.getStatus() == Status.NEW || pState.getStatus() == Status.EXISTING_MODIFIED) {
pState.setStatus(Status.EXISTING);
}
break;
case Operation.STATUS_UNDO:
pe.revert();
break;
// ignore
default:
}
}
// else: no such prop-Entry (should not occur)
}
use of org.apache.jackrabbit.jcr2spi.state.PropertyState in project jackrabbit by apache.
the class ItemManagerImpl method getItem.
/**
* @see ItemManager#getItem(HierarchyEntry)
*/
public Item getItem(HierarchyEntry hierarchyEntry) throws ItemNotFoundException, RepositoryException {
session.checkIsAlive();
ItemState state = hierarchyEntry.getItemState();
if (!state.isValid()) {
throw new ItemNotFoundException(LogUtil.safeGetJCRPath(state, session.getPathResolver()));
}
// first try to access item from cache
Item item = itemCache.getItem(state);
// not yet in cache, need to create instance
if (item == null) {
// create instance of item
if (hierarchyEntry.denotesNode()) {
item = createNodeInstance((NodeState) state);
} else {
item = createPropertyInstance((PropertyState) state);
}
}
return item;
}
use of org.apache.jackrabbit.jcr2spi.state.PropertyState in project jackrabbit by apache.
the class VersionManagerImpl method getVersionHistoryEntry.
public NodeEntry getVersionHistoryEntry(NodeState versionableState) throws RepositoryException {
PropertyState ps = versionableState.getPropertyState(NameConstants.JCR_VERSIONHISTORY);
String uniqueID = ps.getValue().getString();
NodeId vhId = workspaceManager.getIdFactory().createNodeId(uniqueID);
return workspaceManager.getHierarchyManager().getNodeEntry(vhId);
}
use of org.apache.jackrabbit.jcr2spi.state.PropertyState in project jackrabbit by apache.
the class NodeEntryImpl method notifyUUIDorMIXINModified.
/**
* Deals with modified jcr:uuid and jcr:mixinTypes property.
* See {@link #notifyUUIDorMIXINRemoved(Name)}
*
* @param child
*/
private void notifyUUIDorMIXINModified(PropertyEntry child) {
try {
if (NameConstants.JCR_UUID.equals(child.getName())) {
PropertyState ps = child.getPropertyState();
setUniqueID(ps.getValue().getString());
} else if (NameConstants.JCR_MIXINTYPES.equals(child.getName())) {
NodeState state = (NodeState) internalGetItemState();
if (state != null) {
PropertyState ps = child.getPropertyState();
state.setMixinTypeNames(StateUtility.getMixinNames(ps));
}
// nodestate not yet loaded -> ignore change
}
} catch (ItemNotFoundException e) {
log.debug("Property with name " + child.getName() + " does not exist (anymore)");
} catch (RepositoryException e) {
log.debug("Unable to access child property " + child.getName(), e.getMessage());
}
}
use of org.apache.jackrabbit.jcr2spi.state.PropertyState in project jackrabbit by apache.
the class NodeEntryImpl method complete.
private void complete(AddProperty operation) throws RepositoryException {
if (operation.getParentState().getHierarchyEntry() != this) {
throw new IllegalArgumentException();
}
PropertyEntry pe = getPropertyEntry(operation.getPropertyName());
if (pe != null && pe.getStatus() == Status.NEW) {
switch(operation.getStatus()) {
case Operation.STATUS_PERSISTED:
// for autocreated/protected props, mark to be reloaded
// upon next access.
PropertyState addedState = (PropertyState) ((PropertyEntryImpl) pe).internalGetItemState();
addedState.setStatus(Status.EXISTING);
QPropertyDefinition pd = addedState.getDefinition();
if (pd.isAutoCreated() || pd.isProtected()) {
pe.invalidate(true);
}
// else: assume added property is up to date.
break;
case Operation.STATUS_UNDO:
pe.revert();
break;
// ignore
default:
}
}
// else: no such prop entry or entry has already been persisted
// e.g due to external modifications merged into this NodeEntry.
}
Aggregations