public Location getLocation() { return request.getActualLocationOfNode(); }
/** * {@inheritDoc} * * @see org.modeshape.graph.request.processor.RequestProcessor#process(org.modeshape.graph.request.ReadBranchRequest) */ @Override public void process( ReadBranchRequest request ) { CacheableRequest source = (CacheableRequest)federatedRequest.getFirstProjectedRequest().getRequest(); if (checkErrorOrCancel(request, source)) return; if (RequestType.READ_BRANCH == source.getType()) { ReadBranchRequest readSource = (ReadBranchRequest)source; request.setActualLocationOfNode(readSource.getActualLocationOfNode()); for (Location node : readSource) { List<Location> children = readSource.getChildren(node); if (children != null) request.setChildren(node, children); Map<Name, Property> props = readSource.getPropertiesFor(node); if (props != null) request.setProperties(node, props.values()); } } else if (RequestType.READ_NODE == source.getType()) { ReadNodeRequest readSource = (ReadNodeRequest)source; request.setActualLocationOfNode(readSource.getActualLocationOfNode()); Location parent = readSource.getActualLocationOfNode(); request.setChildren(parent, readSource.getChildren()); request.setProperties(parent, readSource.getPropertiesByName().values()); } request.setCachePolicy(getDefaultCachePolicy()); setCacheableInfo(request, source.getCachePolicy()); }
Location actualLocation = readNode.getActualLocationOfNode(); if (first) {
@Test public void shouldMakeAvailablePredefinedWorkspaces() { RepositoryConnection connection = source.getConnection(); GetWorkspacesRequest request = new GetWorkspacesRequest(); connection.execute(context, request); Set<String> workspaces = request.getAvailableWorkspaceNames(); Set<String> graphWorkspaces = new HashSet<String>(Arrays.asList(predefinedWorkspaces)); assertThat(workspaces, is(graphWorkspaces)); // Use each workspace ... for (String workspaceName : predefinedWorkspaces) { ReadNodeRequest readRoot = new ReadNodeRequest(locationFor("/"), workspaceName); connection.execute(context, readRoot); assertThat(readRoot.getActualLocationOfNode().getPath(), is(pathFor("/"))); } }
@Test public void shouldJoinSingleMirroredReadNodeRequest() { // Create the original read node request ... final ReadNodeRequest original = new ReadNodeRequest(location("/a/b/c"), "workspaceM"); // Create a single federated request... final FederatedRequest request = new FederatedRequest(original); // And "fork" the original request ... final ReadNodeRequest projected = new ReadNodeRequest(location("/a/b/c"), "workspaceM"); projected.setActualLocationOfNode(Location.create(projected.at().getPath(), UUID.randomUUID())); projected.addProperty(property("propA", "valueA")); projected.addProperty(property("propB", "valueB")); projected.addChild(child(projected.getActualLocationOfNode(), "child1")); projected.addChild(child(projected.getActualLocationOfNode(), "child2")); request.add(projected, true, false, mirrorProjection); request.freeze(); request.getLatch().countDown(); joinQueue.add(request); // Add a terminating request and join the request... joinQueue.add(new NoMoreFederatedRequests()); joinProcessor.process(joinQueue); // Check the results of the original has the same results of the projected... assertThat(original.getChildren(), is(projected.getChildren())); assertThat(original.getPropertiesByName(), is(projected.getPropertiesByName())); assertThat(original.getActualLocationOfNode(), is(projected.getActualLocationOfNode())); }
projected1.addProperty(property("propA", "valueA")); projected1.addProperty(property("propB", "valueB")); projected1.addChild(child(projected1.getActualLocationOfNode(), "child1")); projected1.addChild(child(projected1.getActualLocationOfNode(), "child2")); request.add(projected1, false, false, projectionA); projected2.addProperty(property("propC", "valueC")); projected2.addProperty(property("propD", "valueD")); projected2.addChild(child(projected2.getActualLocationOfNode(), "child2")); projected2.addChild(child(projected2.getActualLocationOfNode(), "child3")); request.add(projected2, true, false, mirrorProjection); request.freeze(); assertThat(original.getActualLocationOfNode().getPath(), is(path("/a/b/c"))); assertThat(original.getActualLocationOfNode().getUuid(), is(projected1.getActualLocationOfNode().getUuid())); assertThat(original.getActualLocationOfNode().getIdProperty(ModeShapeLexicon.UUID).isMultiple(), is(true)); assertThat(original.getActualLocationOfNode().getIdProperty(ModeShapeLexicon.UUID).getValuesAsArray()[0], is((Object)projected1.getActualLocationOfNode().getUuid())); assertThat(original.getActualLocationOfNode().getIdProperty(ModeShapeLexicon.UUID).getValuesAsArray()[1], is((Object)projected2.getActualLocationOfNode().getUuid())); assertThat(original.getChildren().get(0).getPath(), is(path("/a/b/c/child1"))); assertThat(original.getChildren().get(1).getPath(), is(path("/a/b/c/child2")));
/** * {@inheritDoc} * * @see org.modeshape.graph.request.processor.RequestProcessor#process(org.modeshape.graph.request.ReadNodeRequest) */ @Override public void process( ReadNodeRequest request ) { ReadNodeRequest source = (ReadNodeRequest)federatedRequest.getFirstProjectedRequest().getRequest(); if (checkErrorOrCancel(request, source)) return; request.setActualLocationOfNode(source.getActualLocationOfNode()); for (Location childInSource : source.getChildren()) { request.addChild(childInSource); } for (Property propertyInSource : source.getProperties()) { request.addProperties(propertyInSource); } request.setCachePolicy(getDefaultCachePolicy()); setCacheableInfo(request, source.getCachePolicy()); }
/** * {@inheritDoc} * * @see org.modeshape.graph.request.processor.RequestProcessor#process(org.modeshape.graph.request.CreateNodeRequest) */ @Override public void process( CreateNodeRequest request ) { ProjectedRequest projected = federatedRequest.getFirstProjectedRequest(); // Check the projection first ... if (checkErrorOrCancel(request, federatedRequest)) return; Request projectedRequest = projected.getRequest(); // Check the error on the projected request ... if (checkErrorOrCancel(request, projectedRequest)) return; // No error, so project the results back to the federated repository ... Location sourceLocation = null; if (RequestType.CREATE_NODE == projectedRequest.getType()) { CreateNodeRequest source = (CreateNodeRequest)projectedRequest; sourceLocation = source.getActualLocationOfNode(); } else if (RequestType.READ_NODE == projectedRequest.getType()) { // In this case, the original request was to create the node only if it was missing, // but we knew it already exists because the parent was a placeholder and the child // mapped to an existing proxy node. Therefore, record the location... ReadNodeRequest source = (ReadNodeRequest)projectedRequest; sourceLocation = source.getActualLocationOfNode(); } request.setActualLocationOfNode(projectToFederated(request.under(), projected.getProjection(), sourceLocation, request)); }
@Test public void shouldJoinSingleOffsetReadNodeRequest() { // Create the original read node request ... final ReadNodeRequest original = new ReadNodeRequest(location("/a/b/c"), "workspaceM"); // Create a single federated request using the mirror projection... final FederatedRequest request = new FederatedRequest(original); // And "fork" the original request by creating a mirror final ReadNodeRequest projected = new ReadNodeRequest(location("/b/c"), "workspaceM"); projected.setActualLocationOfNode(Location.create(projected.at().getPath(), UUID.randomUUID())); projected.addProperty(property("propA", "valueA")); projected.addProperty(property("propB", "valueB")); projected.addChild(child(projected.getActualLocationOfNode(), "child1")); projected.addChild(child(projected.getActualLocationOfNode(), "child2")); request.add(projected, false, false, projectionA); request.freeze(); request.getLatch().countDown(); joinQueue.add(request); // Add a terminating request and join the request... joinQueue.add(new NoMoreFederatedRequests()); joinProcessor.process(joinQueue); // Check the results of the original has the same results of the projected... assertThat(original.getPropertiesByName(), is(projected.getPropertiesByName())); assertThat(original.getActualLocationOfNode().getPath(), is(path("/a/b/c"))); assertThat(original.getChildren().get(0).getPath(), is(path("/a/b/c/child1"))); assertThat(original.getChildren().get(1).getPath(), is(path("/a/b/c/child2"))); }
@Test public void shouldCancelFederatedRequestIfOneOfSeveralMultipleReadNodeRequestIsCancelled() { // Create the original read node request ... final ReadNodeRequest original = new ReadNodeRequest(location("/a/b/c"), "workspaceM"); // Create a single federated request using the mirror projection... final FederatedRequest request = new FederatedRequest(original); // And "fork" the original request into the first source request ... final ReadNodeRequest projected1 = new ReadNodeRequest(location("/b/c"), "workspaceM"); projected1.setActualLocationOfNode(Location.create(projected1.at().getPath(), UUID.randomUUID())); projected1.addProperty(property("propA", "valueA")); projected1.addProperty(property("propB", "valueB")); projected1.addChild(child(projected1.getActualLocationOfNode(), "child1")); projected1.addChild(child(projected1.getActualLocationOfNode(), "child2")); request.add(projected1, false, false, projectionA); // And a second source request (that was cancelled)... final ReadNodeRequest projected2 = new ReadNodeRequest(location("/a/b/c"), "workspaceM"); projected2.cancel(); request.add(projected2, true, false, mirrorProjection); request.freeze(); request.getLatch().countDown(); request.getLatch().countDown(); joinQueue.add(request); // Add a terminating request and join the request... joinQueue.add(new NoMoreFederatedRequests()); joinProcessor.process(joinQueue); // Check the results of the original has the same results of the projected... assertThat(original.getProperties().isEmpty(), is(true)); assertThat(original.getChildren().isEmpty(), is(true)); assertThat(original.isCancelled(), is(true)); }
ReadNodeRequest readNode = (ReadNodeRequest)request; expires = computeExpirationTime(readNode); node = getOrCreateNode(readNode.getActualLocationOfNode(), expires); node.setProperties(readNode.getPropertiesByName()); node.setChildren(readNode.getChildren());
ReadNodeRequest readNode = (ReadNodeRequest)request; expires = computeExpirationTime(readNode); node = getOrCreateNode(readNode.getActualLocationOfNode(), expires); node.setProperties(readNode.getPropertiesByName()); node.setChildren(readNode.getChildren());
if (RequestType.READ_NODE == fromSource.getType()) { ReadNodeRequest readFromSource = (ReadNodeRequest)fromSource; Location parent = readFromSource.getActualLocationOfNode(); List<Location> children = readFromSource.getChildren(); for (int i = 0; i != children.size(); ++i) {
} else { ReadNodeRequest readFromSource = (ReadNodeRequest)sourceRequest; Location sourceLocation = readFromSource.getActualLocationOfNode(); if (sourceLocation.hasIdProperties()) {