/** * {@inheritDoc} * * @see java.lang.Object#toString() */ @Override public String toString() { String workspaceName = this.workspaceName != null ? "'" + this.workspaceName + "'" : "default"; return "read " + printable(of()) + " (in '" + workspaceName + "' workspace) all children"; }
/** * {@inheritDoc} * * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals( Object obj ) { if (obj == this) return true; if (this.getClass().isInstance(obj)) { ReadAllChildrenRequest that = (ReadAllChildrenRequest)obj; if (!this.of().isSame(that.of())) return false; if (!this.inWorkspace().equals(that.inWorkspace())) return false; return true; } return false; }
@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())); }
@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); }
protected void assertNextRequestReadChildren( Location at, Location... children ) { Request request = executedRequests.poll(); assertThat(request, is(instanceOf(ReadAllChildrenRequest.class))); ReadAllChildrenRequest readAll = (ReadAllChildrenRequest)request; assertThat(readAll.of(), is(at)); assertThat(readAll.getChildren(), hasItems(children)); }
/** * {@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); }
@Test public void shouldCreateValidRequestWithValidLocation() { request = new ReadAllChildrenRequest(validPathLocation1, workspace1); assertThat(request.of(), is(sameInstance(validPathLocation1))); assertThat(request.inWorkspace(), is(sameInstance(workspace1))); assertThat(request.hasError(), is(false)); assertThat(request.getError(), is(nullValue())); }
public void process( ReadAllChildrenRequest request ) { WorkspaceType workspace = getWorkspace(request, request.inWorkspace()); NodeType node = getTargetNode(workspace, request, request.of()); if (node == null) { assert request.hasError(); Location actualLocation = getActualLocation(workspace, request.of(), node); assert actualLocation != null; Path path = actualLocation.getPath();
Path federatedPath = request.of().getPath(); Map<Name, Integer> childSnsIndexes = new HashMap<Name, Integer>(); ProjectedRequest projectedRequest = federatedRequest.getFirstProjectedRequest(); Location actualLocation = request.of(); int numMerged = 0; while (projectedRequest != null) { setPathNotFound(request, request.of(), federatedRequest.getFirstProjectedRequest()); } else { if (!actualLocation.hasPath()) {
public void process( ReadAllChildrenRequest request ) { ProjectedNode projectedNode = project(request.of(), request.inWorkspace(), request, false);