use of org.apache.jackrabbit.spi.ChildInfo in project jackrabbit by apache.
the class NodeEntryImpl method setNodeEntries.
/**
* @see NodeEntry#setNodeEntries(Iterator)
*/
public void setNodeEntries(Iterator<ChildInfo> childInfos) throws RepositoryException {
if (childNodeAttic.isEmpty()) {
((ChildNodeEntriesImpl) childNodeEntries).update(childInfos);
} else {
// filter those entries that have been moved to the attic.
List<ChildInfo> remaining = new ArrayList<ChildInfo>();
while (childInfos.hasNext()) {
ChildInfo ci = childInfos.next();
if (!childNodeAttic.contains(ci.getName(), ci.getIndex(), ci.getUniqueID())) {
remaining.add(ci);
}
}
((ChildNodeEntriesImpl) childNodeEntries).update(remaining.iterator());
}
}
use of org.apache.jackrabbit.spi.ChildInfo in project jackrabbit by apache.
the class ChildNodeEntriesImpl method reload.
/**
* @see ChildNodeEntries#reload()
*/
public synchronized void reload() throws ItemNotFoundException, RepositoryException {
if (isComplete()) {
// nothing to do
return;
}
NodeId id = parent.getWorkspaceId();
Iterator<ChildInfo> childNodeInfos = factory.getItemStateFactory().getChildNodeInfos(id);
update(childNodeInfos);
}
use of org.apache.jackrabbit.spi.ChildInfo in project jackrabbit by apache.
the class RepositoryServiceImpl method getChildInfos.
@Override
public Iterator<ChildInfo> getChildInfos(SessionInfo sessionInfo, NodeId parentId) throws RepositoryException {
// set of properties to be retrieved
DavPropertyNameSet nameSet = new DavPropertyNameSet();
nameSet.add(JcrRemotingConstants.JCR_NAME_LN, ItemResourceConstants.NAMESPACE);
nameSet.add(JcrRemotingConstants.JCR_INDEX_LN, ItemResourceConstants.NAMESPACE);
nameSet.add(JcrRemotingConstants.JCR_PARENT_LN, ItemResourceConstants.NAMESPACE);
nameSet.add(JcrRemotingConstants.JCR_UUID_LN, ItemResourceConstants.NAMESPACE);
nameSet.add(DavPropertyName.RESOURCETYPE);
HttpPropfind request = null;
try {
String uri = getItemUri(parentId, sessionInfo);
request = new HttpPropfind(uri, nameSet, DEPTH_1);
HttpResponse response = executeRequest(sessionInfo, request);
request.checkSuccess(response);
List<ChildInfo> childEntries;
MultiStatusResponse[] mresponses = request.getResponseBodyAsMultiStatus(response).getResponses();
if (mresponses.length < 1) {
throw new ItemNotFoundException("Unable to retrieve the node with id " + saveGetIdString(parentId, sessionInfo));
} else if (mresponses.length == 1) {
// no child nodes nor properties
childEntries = Collections.emptyList();
return childEntries.iterator();
}
childEntries = new ArrayList<ChildInfo>();
for (MultiStatusResponse mresponse : mresponses) {
if (!isSameResource(uri, mresponse)) {
DavPropertySet childProps = mresponse.getProperties(DavServletResponse.SC_OK);
if (childProps.contains(DavPropertyName.RESOURCETYPE) && childProps.get(DavPropertyName.RESOURCETYPE).getValue() != null) {
childEntries.add(buildChildInfo(childProps, sessionInfo));
}
// else: property -> ignore
}
// else: ignore the response related to the parent
}
return childEntries.iterator();
} catch (IOException e) {
throw new RepositoryException(e);
} catch (DavException e) {
throw ExceptionConverter.generate(e);
} finally {
if (request != null) {
request.releaseConnection();
}
}
}
use of org.apache.jackrabbit.spi.ChildInfo in project jackrabbit by apache.
the class BatchTest method testReorder1.
public void testReorder1() throws RepositoryException {
NodeId nid = getNodeId(testPath);
Batch b = rs.createBatch(si, nid);
b.addNode(nid, resolver.getQName("2"), NameConstants.NT_UNSTRUCTURED, null);
b.addNode(nid, resolver.getQName("3"), NameConstants.NT_UNSTRUCTURED, null);
b.addNode(nid, resolver.getQName("1"), NameConstants.NT_UNSTRUCTURED, null);
rs.submit(b);
b = rs.createBatch(si, nid);
b.reorderNodes(nid, getNodeId(testPath + "/1"), getNodeId(testPath + "/2"));
rs.submit(b);
Iterator<ChildInfo> it = rs.getChildInfos(si, nid);
int i = 1;
while (it.hasNext()) {
ChildInfo ci = it.next();
assertEquals(i, Integer.parseInt(ci.getName().getLocalName()));
i++;
}
}
use of org.apache.jackrabbit.spi.ChildInfo in project jackrabbit by apache.
the class BatchTest method testAddNode.
public void testAddNode() throws RepositoryException {
NodeId nid = getNodeId(testPath);
Batch b = rs.createBatch(si, nid);
b.addNode(nid, resolver.getQName("aNode"), NameConstants.NT_UNSTRUCTURED, null);
b.addProperty(nid, resolver.getQName("aString"), rs.getQValueFactory().create("ba", PropertyType.STRING));
b.addProperty(nid, resolver.getQName("aName"), new QValue[] { rs.getQValueFactory().create(NameConstants.JCR_ENCODING), rs.getQValueFactory().create(NameConstants.JCR_DATA) });
b.addProperty(nid, resolver.getQName("aBinary"), rs.getQValueFactory().create(new byte[] { 'a', 'b', 'c' }));
rs.submit(b);
NodeId id = rs.getIdFactory().createNodeId(nid, resolver.getQPath("aNode"));
Iterator<? extends ItemInfo> it = rs.getItemInfos(si, id);
while (it.hasNext()) {
ItemInfo info = it.next();
if (info.denotesNode()) {
NodeInfo nInfo = (NodeInfo) info;
assertEquals(NameConstants.NT_UNSTRUCTURED, nInfo.getNodetype());
Iterator<ChildInfo> childIt = nInfo.getChildInfos();
assertTrue(childIt == null || !childIt.hasNext());
assertEquals(id, nInfo.getId());
}
}
b = rs.createBatch(si, nid);
b.remove(id);
rs.submit(b);
}
Aggregations