/** * {@inheritDoc} * * @see org.modeshape.graph.request.processor.RequestProcessor#process(org.modeshape.graph.request.VerifyNodeExistsRequest) */ @Override public void process( VerifyNodeExistsRequest request ) { WorkspaceType original = getWorkspace(request, request.inWorkspace()); if (original != null) { try { Location actualLoation = txn.verifyNodeExists(original, request.at()); request.setActualLocationOfNode(actualLoation); } catch (RuntimeException e) { request.setError(e); } } }
/** * Process a request to lock a node or branch within a workspace * <p> * The default implementation of this method does nothing, as most connectors will not support locking. Any implementation of * this method should do nothing if the request is null. * </p> * <p> * Implementations that do support locking should throw a {@link LockFailedException} if the request could not be fulfilled. * </p> * * @param request the request */ public void process( LockBranchRequest request ) { Location actualLocation = request.at(); if (!actualLocation.hasPath()) { VerifyNodeExistsRequest nodeExists = new VerifyNodeExistsRequest(request.at(), request.inWorkspace()); process(nodeExists); if (nodeExists.hasError()) { request.setError(nodeExists.getError()); return; } actualLocation = nodeExists.getActualLocationOfNode(); } request.setActualLocation(actualLocation); }
/** * {@inheritDoc} * * @see org.modeshape.graph.request.processor.RequestProcessor#process(org.modeshape.graph.request.VerifyNodeExistsRequest) */ @Override public void process( VerifyNodeExistsRequest request ) { VerifyNodeExistsRequest source = (VerifyNodeExistsRequest)federatedRequest.getFirstProjectedRequest().getRequest(); if (checkErrorOrCancel(request, source)) return; request.setActualLocationOfNode(source.getActualLocationOfNode()); request.setCachePolicy(getDefaultCachePolicy()); setCacheableInfo(request, source.getCachePolicy()); }
/** * {@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)) { VerifyNodeExistsRequest that = (VerifyNodeExistsRequest)obj; if (!this.at().isSame(that.at())) return false; if (!this.inWorkspace().equals(that.inWorkspace())) return false; return true; } return false; }
ProjectedRequest projectedRequest = federatedRequest.getFirstProjectedRequest(); request.setCachePolicy(getDefaultCachePolicy()); Location actualLocation = request.at(); int numMerged = 0; while (projectedRequest != null) { VerifyNodeExistsRequest readFromSource = (VerifyNodeExistsRequest)projectedRequest.getRequest(); if (readFromSource.hasError()) { projectedRequest = projectedRequest.next(); continue; if (readFromSource.isCancelled()) { request.cancel(); return; Location sourceLocation = readFromSource.getActualLocationOfNode(); actualLocation = determineActualLocation(actualLocation, sourceLocation, projectedRequest.getProjection()); setCacheableInfo(request, readFromSource.getCachePolicy()); projectedRequest = projectedRequest.next(); ++numMerged; setPathNotFound(request, request.at(), federatedRequest.getFirstProjectedRequest()); } else { request.setActualLocationOfNode(actualLocation);
/** * {@inheritDoc} * * @see org.modeshape.graph.request.processor.RequestProcessor#process(org.modeshape.graph.request.VerifyNodeExistsRequest) */ @Override public void process( VerifyNodeExistsRequest request ) { // Figure out where this request is projected ... ProjectedNode projectedNode = project(request.at(), request.inWorkspace(), request, false); // Create the federated request ... FederatedRequest federatedRequest = new FederatedRequest(request); while (projectedNode != null) { if (projectedNode.isPlaceholder()) { PlaceholderNode placeholder = projectedNode.asPlaceholder(); // Create a request and set the results ... VerifyNodeExistsRequest placeholderRequest = new VerifyNodeExistsRequest(request.at(), request.inWorkspace()); placeholderRequest.setActualLocationOfNode(placeholder.location()); federatedRequest.add(placeholderRequest, true, true, null); } else if (projectedNode.isProxy()) { ProxyNode proxy = projectedNode.asProxy(); // Create and submit a request for the projection ... VerifyNodeExistsRequest pushDownRequest = new VerifyNodeExistsRequest(proxy.location(), proxy.workspaceName()); federatedRequest.add(pushDownRequest, proxy.isSameLocationAsOriginal(), false, proxy.projection()); } projectedNode = projectedNode.next(); } // Submit for processing ... submit(federatedRequest); }
while (projectedRequest != null) { VerifyNodeExistsRequest readFromSource = (VerifyNodeExistsRequest)projectedRequest.getRequest(); if (readFromSource.hasError()) { request.setError(readFromSource.getError()); return; if (readFromSource.isCancelled()) { request.cancel(); return; Location sourceLocation = readFromSource.getActualLocationOfNode(); if (sourceLocation.hasIdProperties()) {
protected void assertNextRequestVerifyNodeExists( Location at ) { Request request = executedRequests.poll(); assertThat(request, is(instanceOf(VerifyNodeExistsRequest.class))); VerifyNodeExistsRequest read = (VerifyNodeExistsRequest)request; assertThat(read.at(), is(at)); }
PlaceholderNode placeholder = projectedNode.asPlaceholder(); VerifyNodeExistsRequest placeholderRequest = new VerifyNodeExistsRequest(root, workspace.getName()); placeholderRequest.setActualLocationOfNode(placeholder.location()); federatedRequest.add(placeholderRequest, true, true, null); } else if (projectedNode.isProxy()) { ProxyNode proxy = projectedNode.asProxy(); VerifyNodeExistsRequest pushDownRequest = new VerifyNodeExistsRequest(proxy.location(), proxy.workspaceName()); federatedRequest.add(pushDownRequest, proxy.isSameLocationAsOriginal(), false, proxy.projection());
if (parentPath == null) { VerifyNodeExistsRequest verifySibling = new VerifyNodeExistsRequest(request.startingAfter(), request.inWorkspace()); process(verifySibling); actualSiblingLocation = verifySibling.getActualLocationOfNode(); parentPath = actualSiblingLocation.getPath().getParent();
/** * Add a request to verify the existance and location of a node at the supplied location. * * @param at the location of the node to be verified * @param workspaceName the name of the workspace containing the node * @return the request; never null * @throws IllegalArgumentException if the location or workspace name is null */ public VerifyNodeExistsRequest verifyNodeExists( Location at, String workspaceName ) { return process(new VerifyNodeExistsRequest(at, workspaceName)); }
/** * {@inheritDoc} * * @see org.modeshape.graph.request.processor.RequestProcessor#process(org.modeshape.graph.request.VerifyWorkspaceRequest) */ @Override public void process( VerifyWorkspaceRequest request ) { VerifyNodeExistsRequest source = (VerifyNodeExistsRequest)federatedRequest.getFirstProjectedRequest().getRequest(); if (checkErrorOrCancel(request, source)) return; assert source.getActualLocationOfNode().getPath().isRoot(); request.setActualRootLocation(source.getActualLocationOfNode()); }
/** * Sets the actual and complete location of the node whose properties have been read. This method must be called when * processing the request, and the actual location must have a {@link Location#getPath() path}. * * @param actual the actual location of the node being read, or null if the {@link #at() current location} should be used * @throws IllegalArgumentException if the actual location is null or does not have a path. * @throws IllegalStateException if the request is frozen */ public void setActualLocationOfNode( Location actual ) { checkNotFrozen(); CheckArg.isNotNull(actual, "actual"); if (!actual.hasPath()) { throw new IllegalArgumentException(GraphI18n.actualLocationMustHavePath.text(actual)); } this.actualLocation = actual; }
/** * Add a request to verify the existance and location of a node at the supplied location. * * @param at the location of the node to be verified * @param workspaceName the name of the workspace containing the node * @return this builder for method chaining; never null * @throws IllegalArgumentException if the location or workspace name is null */ public BatchRequestBuilder verifyNodeExists( Location at, String workspaceName ) { return add(new VerifyNodeExistsRequest(at, workspaceName)); }
Location childInSource = verify.getActualLocationOfNode(); Location childInRepos = determineActualLocation(childInSource, projection); childInRepos = getChildLocationWithCorrectSnsIndex(childInRepos, federatedPath, childSnsIndexes, projection);
/** * Process a request to verify that a node exists at the supplied location. * <p> * This method does nothing if the request is null. Unless overridden, this method converts the request that * {@link ReadAllPropertiesRequest reads the node} and uses the result to determine if the node exists. * </p> * * @param request the read request */ public void process( VerifyNodeExistsRequest request ) { if (request == null) return; ReadAllPropertiesRequest readNode = new ReadAllPropertiesRequest(request.at(), request.inWorkspace()); process(readNode); if (readNode.hasError()) { request.setError(readNode.getError()); return; } // Set the actual location ... request.setActualLocationOfNode(readNode.getActualLocationOfNode()); setCacheableInfo(request); }
/** * Process a request to unlock a node or branch within a workspace * <p> * The default implementation of this method does nothing, as most connectors will not support locking. Any implementation of * this method should do nothing if the request is null. * </p> * * @param request the request */ public void process( UnlockBranchRequest request ) { Location actualLocation = request.at(); if (!actualLocation.hasPath()) { VerifyNodeExistsRequest nodeExists = new VerifyNodeExistsRequest(request.at(), request.inWorkspace()); process(nodeExists); if (nodeExists.hasError()) { request.setError(nodeExists.getError()); return; } actualLocation = nodeExists.getActualLocationOfNode(); } request.setActualLocation(actualLocation); }
VerifyNodeExistsRequest verifyRequest = new VerifyNodeExistsRequest(proxy.location(), proxy.workspaceName()); federatedRequest.add(verifyRequest, proxy.isSameLocationAsOriginal(), false, proxy.projection());
Location childInSource = verify.getActualLocationOfNode(); Location childInRepos = getChildLocationWithCorrectSnsIndex(childInSource, federatedPath,