use of org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry in project jackrabbit by apache.
the class VersionHistoryImpl method getAllVersions.
/**
* @see VersionHistory#getAllVersions()
*/
public VersionIterator getAllVersions() throws RepositoryException {
checkStatus();
refreshEntry(vhEntry);
Iterator<NodeEntry> childIter = vhEntry.getNodeEntries();
List<NodeEntry> versionEntries = new ArrayList<NodeEntry>();
// all child-nodes except from jcr:versionLabels point to Versions.
while (childIter.hasNext()) {
NodeEntry entry = childIter.next();
if (!NameConstants.JCR_VERSIONLABELS.equals(entry.getName())) {
versionEntries.add(entry);
}
}
return new LazyItemIterator(getItemManager(), new RangeIteratorAdapter(versionEntries));
}
use of org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry in project jackrabbit by apache.
the class VersionHistoryImpl method getVersionState.
/**
*
* @param versionName
* @return
* @throws VersionException
* @throws RepositoryException
*/
private NodeState getVersionState(String versionName) throws VersionException, RepositoryException {
try {
Name vName = session.getNameResolver().getQName(versionName);
refreshEntry(vhEntry);
NodeEntry vEntry = vhEntry.getNodeEntry(vName, Path.INDEX_DEFAULT, true);
if (vEntry == null) {
throw new VersionException("Version '" + versionName + "' does not exist in this version history.");
} else {
return vEntry.getNodeState();
}
} catch (org.apache.jackrabbit.spi.commons.conversion.NameException e) {
throw new RepositoryException(e);
}
}
use of org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry in project jackrabbit by apache.
the class VersionHistoryImpl method getRootVersion.
/**
* @see VersionHistory#getRootVersion()
*/
public Version getRootVersion() throws RepositoryException {
checkStatus();
NodeEntry vEntry = vhEntry.getNodeEntry(NameConstants.JCR_ROOTVERSION, Path.INDEX_DEFAULT, true);
if (vEntry == null) {
String msg = "Unexpected error: VersionHistory state does not contain a root version child node entry.";
log.error(msg);
throw new RepositoryException(msg);
}
return (Version) getItemManager().getItem(vEntry);
}
use of org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry in project jackrabbit by apache.
the class VersionManagerImpl method isCheckedOut.
/**
* Search nearest ancestor that is versionable. If no versionable ancestor
* can be found, <code>true</code> is returned.
*
* @param nodeState
* @return
* @throws RepositoryException
*/
public boolean isCheckedOut(NodeState nodeState) throws RepositoryException {
// shortcut: if state is new, its ancestor must be checkout
if (nodeState.getStatus() == Status.NEW) {
return true;
}
NodeEntry nodeEntry = nodeState.getNodeEntry();
try {
// save or upon executing the workspace operation.
while (!nodeEntry.hasPropertyEntry(NameConstants.JCR_ISCHECKEDOUT)) {
NodeEntry parent = nodeEntry.getParent();
if (parent == null) {
// reached root state without finding a jcr:isCheckedOut property
return true;
}
nodeEntry = parent;
}
PropertyState propState = nodeEntry.getPropertyEntry(NameConstants.JCR_ISCHECKEDOUT).getPropertyState();
Boolean b = Boolean.valueOf(propState.getValue().getString());
return b.booleanValue();
} catch (ItemNotFoundException e) {
// error while accessing jcr:isCheckedOut property state.
// -> assume that checkedOut status is ok. see above for general
// notes about the capabilities of the jcr2spi implementation.
}
return true;
}
use of org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry in project jackrabbit by apache.
the class SessionItemStateManager method visit.
/**
* @see OperationVisitor#visit(SetMixin)
*/
public void visit(SetMixin operation) throws ConstraintViolationException, AccessDeniedException, NoSuchNodeTypeException, UnsupportedRepositoryOperationException, VersionException, RepositoryException {
// NOTE: nodestate is only modified upon save of the changes!
Name[] mixinNames = operation.getMixinNames();
NodeState nState = operation.getNodeState();
NodeEntry nEntry = nState.getNodeEntry();
// assert the existence of the property entry and set the array of
// mixinNames to be set on the corresponding property state
PropertyEntry mixinEntry = nEntry.getPropertyEntry(NameConstants.JCR_MIXINTYPES);
if (mixinNames.length > 0) {
// update/create corresponding property state
if (mixinEntry != null) {
// execute value of existing property
PropertyState pState = mixinEntry.getPropertyState();
setPropertyStateValue(pState, getQValues(mixinNames, qValueFactory), PropertyType.NAME, operation.getOptions());
} else {
// create new jcr:mixinTypes property
ItemDefinitionProvider defProvider = mgrProvider.getItemDefinitionProvider();
QPropertyDefinition pd = defProvider.getQPropertyDefinition(nState.getAllNodeTypeNames(), NameConstants.JCR_MIXINTYPES, PropertyType.NAME, true);
QValue[] mixinValue = getQValues(mixinNames, qValueFactory);
addPropertyState(nState, pd.getName(), pd.getRequiredType(), mixinValue, pd, operation.getOptions());
}
nState.markModified();
transientStateMgr.addOperation(operation);
} else if (mixinEntry != null) {
// remove the jcr:mixinTypes property state if already present
PropertyState pState = mixinEntry.getPropertyState();
removeItemState(pState, operation.getOptions());
nState.markModified();
transientStateMgr.addOperation(operation);
}
// else: empty Name array and no mixin-prop-entry (should not occur)
}
Aggregations