use of org.apache.jackrabbit.spi.NodeId in project jackrabbit by apache.
the class DavPropertyTest method testVersion.
public void testVersion() throws Exception {
NodeId nid = getNodeId("/test");
Batch b = rs.createBatch(si, nid);
b.setMixins(nid, new Name[] { NameConstants.MIX_VERSIONABLE });
rs.submit(b);
NodeId vID = rs.checkin(si, nid);
String uri = rs.getItemUri(vID, si);
DavPropertyNameSet set = doPropFindNames(uri);
DavPropertyNameSet expected = new DavPropertyNameSet(BASE_SET);
expected.addAll(EXISTING_ITEM_BASE_SET);
expected.addAll(NODE_SET);
expected.addAll(VERSION_SET);
expected.add(JCR_PARENT);
expected.add(JCR_UUID);
/*
Expected property names
{DAV:}getlastmodified
{DAV:}version-name
{http://www.day.com/jcr/webdav/1.0}definition
{DAV:}comment
{http://www.day.com/jcr/webdav/1.0}references
{http://www.day.com/jcr/webdav/1.0}parent
{DAV:}displayname
{http://www.day.com/jcr/webdav/1.0}workspaceName
{http://www.day.com/jcr/webdav/1.0}subscriptiondiscovery
{http://www.day.com/jcr/webdav/1.0}uuid
{DAV:}checkout-set
{DAV:}predecessor-set
{http://www.day.com/jcr/webdav/1.0}name
{DAV:}current-user-privilege-set
{http://www.day.com/jcr/webdav/1.0}primarynodetype
{DAV:}version-history
{DAV:}successor-set
{DAV:}lockdiscovery
{DAV:}resourcetype
{DAV:}workspace
{http://www.day.com/jcr/webdav/1.0}depth
{http://www.day.com/jcr/webdav/1.0}index
{DAV:}label-name-set
{DAV:}supportedlock
{DAV:}supported-method-set
{DAV:}iscollection
{http://www.day.com/jcr/webdav/1.0}weakreferences
{DAV:}creator-displayname
{DAV:}getcontenttype
{DAV:}creationdate
{DAV:}supported-report-set
{http://www.day.com/jcr/webdav/1.0}mixinnodetypes
{http://www.day.com/jcr/webdav/1.0}path
*/
assertPropertyNames(expected, set);
DavPropertyNameSet all = doPropFindAll(uri);
expected.remove(DeltaVConstants.COMMENT);
expected.remove(DeltaVConstants.CREATOR_DISPLAYNAME);
expected.remove(DeltaVConstants.SUPPORTED_METHOD_SET);
expected.remove(DeltaVConstants.SUPPORTED_REPORT_SET);
expected.remove(DeltaVConstants.WORKSPACE);
expected.remove(SecurityConstants.CURRENT_USER_PRIVILEGE_SET);
expected.remove(ObservationConstants.SUBSCRIPTIONDISCOVERY);
expected.remove(JCR_DEFINITION);
expected.remove(JCR_INDEX);
expected.remove(JCR_REFERENCES);
expected.remove(JCR_WEAK_REFERENCES);
expected.remove(JCR_UUID);
expected.remove(VersionResource.VERSION_NAME);
expected.remove(VersionResource.LABEL_NAME_SET);
expected.remove(VersionResource.PREDECESSOR_SET);
expected.remove(VersionResource.SUCCESSOR_SET);
expected.remove(VersionResource.VERSION_HISTORY);
expected.remove(VersionResource.CHECKOUT_SET);
/*
Expected all-props
{DAV:}getlastmodified
{http://www.day.com/jcr/webdav/1.0}depth
{http://www.day.com/jcr/webdav/1.0}workspaceName
{DAV:}displayname
{http://www.day.com/jcr/webdav/1.0}parent
{DAV:}supportedlock
{DAV:}iscollection
{DAV:}getcontenttype
{http://www.day.com/jcr/webdav/1.0}name
{DAV:}creationdate
{http://www.day.com/jcr/webdav/1.0}mixinnodetypes
{http://www.day.com/jcr/webdav/1.0}path
{http://www.day.com/jcr/webdav/1.0}primarynodetype
{DAV:}lockdiscovery
{DAV:}resourcetype
*/
assertPropertyNames(expected, all);
DavPropertyNameSet props = new DavPropertyNameSet();
props.add(DeltaVConstants.COMMENT);
props.add(DeltaVConstants.CREATOR_DISPLAYNAME);
props.add(DeltaVConstants.SUPPORTED_METHOD_SET);
props.add(DeltaVConstants.SUPPORTED_REPORT_SET);
props.add(DeltaVConstants.WORKSPACE);
props.add(SecurityConstants.CURRENT_USER_PRIVILEGE_SET);
props.add(ObservationConstants.SUBSCRIPTIONDISCOVERY);
props.add(JCR_DEFINITION);
props.add(JCR_INDEX);
props.add(JCR_REFERENCES);
props.add(JCR_WEAK_REFERENCES);
props.add(JCR_UUID);
props.add(VersionResource.VERSION_NAME);
props.add(VersionResource.LABEL_NAME_SET);
props.add(VersionResource.PREDECESSOR_SET);
props.add(VersionResource.SUCCESSOR_SET);
props.add(VersionResource.VERSION_HISTORY);
props.add(VersionResource.CHECKOUT_SET);
DavPropertyNameSet result = doPropFindByProp(uri, props);
assertPropertyNames(props, result);
}
use of org.apache.jackrabbit.spi.NodeId in project jackrabbit by apache.
the class URIResolverImpl method buildNodeId.
protected NodeId buildNodeId(NodeId parentId, String baseUri, MultiStatusResponse response, String workspaceName, NamePathResolver resolver) throws RepositoryException {
IdURICache cache = getCache(workspaceName);
NodeId nodeId;
DavPropertySet propSet = response.getProperties(DavServletResponse.SC_OK);
String uniqueID = service.getUniqueID(propSet);
if (uniqueID != null) {
nodeId = service.getIdFactory().createNodeId(uniqueID);
} else {
Name qName = service.getQName(propSet, resolver);
if (NameConstants.ROOT.equals(qName)) {
nodeId = service.getIdFactory().createNodeId((String) null, service.getPathFactory().getRootPath());
} else {
int index = service.getIndex(propSet);
nodeId = service.getIdFactory().createNodeId(parentId, service.getPathFactory().create(qName, index));
}
}
// cache
cache.add(resolve(baseUri, response.getHref()), nodeId);
return nodeId;
}
use of org.apache.jackrabbit.spi.NodeId 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.spi.NodeId in project jackrabbit by apache.
the class NodeEntryImpl method getDeepNodeEntry.
/**
* @see NodeEntry#getDeepNodeEntry(Path)
*/
public NodeEntry getDeepNodeEntry(Path path) throws PathNotFoundException, RepositoryException {
NodeEntryImpl entry = this;
Path.Element[] elems = path.getElements();
for (int i = 0; i < elems.length; i++) {
Path.Element elem = elems[i];
// check for root element
if (elem.denotesRoot()) {
if (entry.getParent() != null) {
throw new RepositoryException("NodeEntry out of 'hierarchy' " + path.toString());
}
continue;
}
int index = elem.getNormalizedIndex();
Name name = elem.getName();
// first try to resolve to known node or property entry
NodeEntry cne = entry.getNodeEntry(name, index, false);
if (cne != null) {
entry = (NodeEntryImpl) cne;
} else {
// on the persistent layer.
if (entry.childNodeEntries.isComplete()) {
throw new PathNotFoundException(factory.saveGetJCRPath(path));
}
// -> check for moved child entry in node-attic
// -> check if child points to a removed/moved sns
List<NodeEntry> siblings = entry.childNodeEntries.get(name);
if (entry.containsAtticChild(siblings, name, index)) {
throw new PathNotFoundException(factory.saveGetJCRPath(path));
}
// elements -> hierarchy doesn't exist anyway.
if (entry.getStatus() == Status.NEW) {
throw new PathNotFoundException(factory.saveGetJCRPath(path));
}
/*
* Unknown entry (not-existing or not yet loaded):
* Skip all intermediate entries and directly try to load the ItemState
* (including building the intermediate entries. If that fails
* ItemNotFoundException is thrown.
*
* Since 'path' might be ambiguous (Node or Property):
* 1) first try Node
* 2) if the NameElement does not have SNS-index => try Property
* 3) else throw
*/
PathBuilder pb = new PathBuilder(getPathFactory());
for (int j = i; j < elems.length; j++) {
pb.addLast(elems[j]);
}
Path remainingPath = pb.getPath();
NodeId parentId = entry.getWorkspaceId();
IdFactory idFactory = factory.getIdFactory();
NodeId nodeId = idFactory.createNodeId(parentId, remainingPath);
NodeEntry ne = entry.loadNodeEntry(nodeId);
if (ne != null) {
return ne;
} else {
throw new PathNotFoundException(factory.saveGetJCRPath(path));
}
}
}
return entry;
}
use of org.apache.jackrabbit.spi.NodeId in project jackrabbit by apache.
the class NodeEntryImpl method getNodeEntry.
/**
* @see NodeEntry#getNodeEntry(Name, int, boolean)
*/
public NodeEntry getNodeEntry(Name nodeName, int index, boolean loadIfNotFound) throws RepositoryException {
List<NodeEntry> entries = childNodeEntries.get(nodeName);
NodeEntry cne = null;
if (entries.size() >= index) {
// position of entry might differ from index-1 if a SNS with lower
// index has been transiently removed.
int eIndex = 1;
for (int i = 0; i < entries.size() && cne == null; i++) {
NodeEntry ne = entries.get(i);
if (EntryValidation.isValidNodeEntry(ne)) {
if (eIndex == index) {
cne = ne;
}
eIndex++;
}
}
}
if (cne == null && loadIfNotFound && !containsAtticChild(entries, nodeName, index) && !childNodeEntries.isComplete()) {
NodeId cId = getIdFactory().createNodeId(getWorkspaceId(), getPathFactory().create(nodeName, index));
cne = loadNodeEntry(cId);
}
return cne;
}
Aggregations