/** * {@inheritDoc} * * @see java.lang.Object#toString() */ @Override public String toString() { String workspaceName = this.workspaceName != null ? "'" + this.workspaceName + "'" : "default"; return "delete " + printable(at()) + " (in " + workspaceName + " workspace) and all descendants"; }
/** * {@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)) { DeleteBranchRequest that = (DeleteBranchRequest)obj; if (!this.at().isSame(that.at())) return false; if (!this.inWorkspace().equals(that.inWorkspace())) return false; return true; } return false; }
@Override public void process( DeleteBranchRequest request ) { // Just update the actual location request.setActualLocationOfNode(actualLocationOf(request.at())); }
protected void assertNextRequestIsDelete( Location at ) { Request request = executedRequests.poll(); assertThat(request, is(instanceOf(DeleteBranchRequest.class))); DeleteBranchRequest delete = (DeleteBranchRequest)request; assertThat(delete.at(), is(at)); }
/** * {@inheritDoc} * * @see org.modeshape.graph.request.processor.RequestProcessor#process(org.modeshape.graph.request.DeleteBranchRequest) */ @Override public void process( DeleteBranchRequest request ) { if (!updatesAllowed(request)) return; MapWorkspace workspace = getWorkspace(request, request.inWorkspace()); if (workspace == null) return; MapNode node = getTargetNode(workspace, request, request.at()); if (node == null) return; workspace.removeNode(getExecutionContext(), node); Location actualLocation = getActualLocation(request.at(), node); request.setActualLocationOfNode(actualLocation); recordChange(request); }
/** * {@inheritDoc} * * @see org.modeshape.graph.request.processor.RequestProcessor#process(org.modeshape.graph.request.DeleteBranchRequest) */ @Override public void process( DeleteBranchRequest request ) { if (!updatesAllowed(request)) return; WorkspaceType workspace = getWorkspace(request, request.inWorkspace()); if (workspace == null) return; NodeType node = getTargetNode(workspace, request, request.at()); if (node == null) return; Location actualLocation = txn.removeNode(workspace, node); request.setActualLocationOfNode(actualLocation); recordChange(request); }
@Test public void shouldCreateValidRequestWithValidLocation() { request = new DeleteBranchRequest(validPathLocation1, workspace1); assertThat(request.at(), is(sameInstance(validPathLocation1))); assertThat(request.inWorkspace(), is(sameInstance(workspace1))); assertThat(request.hasError(), is(false)); assertThat(request.getError(), is(nullValue())); }
/** * {@inheritDoc} * * @see org.modeshape.graph.request.processor.RequestProcessor#process(org.modeshape.graph.request.DeleteBranchRequest) */ @Override public void process( DeleteBranchRequest request ) { // Figure out where this request is projected ... ProjectedNode projectedNode = project(request.at(), request.inWorkspace(), request, true); // Create the federated request ... FederatedRequest federatedRequest = new FederatedRequest(request); if (projectedNode == null) { submit(federatedRequest); return; } // A delete should be executed against any ProxyNode that applies ... FederatedWorkspace workspace = getWorkspace(request, request.inWorkspace()); boolean submit = deleteBranch(federatedRequest, projectedNode, workspace, getExecutionContext(), true); if (submit) { // Submit the requests for processing and then STOP ... submit(federatedRequest); } else { // Unable to perform this delete ... String msg = GraphI18n.unableToDeletePlaceholder.text(readable(request.at()), request.inWorkspace(), getSourceName()); request.setError(new UnsupportedRequestException(msg)); } }
@Override public void process( DeleteBranchRequest request ) { if (!updatesAllowed(request)) return; PathWorkspace workspace = getWorkspace(request, request.inWorkspace()); if (workspace == null) return; PathNode node = getTargetNode(workspace, request, request.at()); if (node == null) return; if (!(workspace instanceof WritablePathWorkspace)) { I18n msg = GraphI18n.workspaceIsReadOnly; request.setError(new InvalidRequestException(msg.text(repository.getSourceName(), workspace.getName()))); return; } WritablePathWorkspace newWorkspace = (WritablePathWorkspace)workspace; newWorkspace.removeNode(getExecutionContext(), node.getPath()); request.setActualLocationOfNode(Location.create(node.getPath(), node.getUuid())); recordChange(request); }
actual = projectToFederated(request.at(), projected.getProjection(), actual, request);