@Test public void shouldAllowAddingChildren() { request = new ReadAllChildrenRequest(validPathLocation1, workspace1); request.addChild(validPathLocation1); request.addChild(validPathLocation2); assertThat(request.getChildren().size(), is(2)); assertThat(request.getChildren(), hasItems(validPathLocation1, validPathLocation2)); } }
@Override public void process( ReadAllChildrenRequest request ) { // Read the children from the map ... if (children.containsKey(request.of())) { for (Location child : children.get(request.of())) { request.addChild(child); } } // Set the actual location request.setActualLocationOfNode(actualLocationOf(request.of())); }
/** * {@inheritDoc} * * @see org.modeshape.graph.request.processor.RequestProcessor#process(org.modeshape.graph.request.ReadAllChildrenRequest) */ @Override public void process( ReadAllChildrenRequest request ) { ReadAllChildrenRequest source = (ReadAllChildrenRequest)federatedRequest.getFirstProjectedRequest().getRequest(); if (checkErrorOrCancel(request, source)) return; request.setActualLocationOfNode(source.getActualLocationOfNode()); for (Location childInSource : source.getChildren()) { request.addChild(childInSource); } request.setCachePolicy(getDefaultCachePolicy()); setCacheableInfo(request, source.getCachePolicy()); }
/** * {@inheritDoc} * * @see org.modeshape.graph.request.processor.RequestProcessor#process(org.modeshape.graph.request.ReadAllChildrenRequest) */ @Override public void process( ReadAllChildrenRequest request ) { MapWorkspace workspace = getWorkspace(request, request.inWorkspace()); MapNode node = getTargetNode(workspace, request, request.of()); if (node == null) { assert request.hasError(); return; } Location actualLocation = getActualLocation(request.of(), node); assert actualLocation != null; Path path = actualLocation.getPath(); // Get the names of the children ... List<MapNode> children = node.getChildren(); for (MapNode child : children) { Segment childName = child.getName(); Path childPath = pathFactory.create(path, childName); request.addChild(childPath, propertyFactory.create(ModeShapeLexicon.UUID, child.getUuid())); } request.setActualLocationOfNode(actualLocation); setCacheableInfo(request); }
@Override public void process( ReadAllChildrenRequest request ) { PathWorkspace workspace = getWorkspace(request, request.inWorkspace()); if (workspace == null) return; PathNode node = getTargetNode(workspace, request, request.of()); if (node == null) { request.setError(new PathNotFoundException(request.of(), workspace.getLowestExistingPath(request.of().getPath()))); return; } List<Path.Segment> childSegments = node.getChildSegments(); for (Path.Segment childSegment : childSegments) { request.addChild(Location.create(pathFactory.create(node.getPath(), childSegment))); } request.setActualLocationOfNode(Location.create(node.getPath(), node.getUuid())); setCacheableInfo(request); }
childLocation = Location.create(childPath); request.addChild(childLocation);