/** * {@inheritDoc} * * @see org.modeshape.graph.request.ChangeRequest#changedWorkspace() */ @Override public String changedWorkspace() { return intoWorkspace(); }
@Test public void shouldCreateValidRequestWithValidFromLocationAndValidToLocation() { request = new CopyBranchRequest(validPathLocation1, workspace1, validPathLocation2, workspace2); assertThat(request.from(), is(sameInstance(validPathLocation1))); assertThat(request.into(), is(sameInstance(validPathLocation2))); assertThat(request.fromWorkspace(), is(sameInstance(workspace1))); assertThat(request.intoWorkspace(), is(sameInstance(workspace2))); assertThat(request.hasError(), is(false)); assertThat(request.getError(), is(nullValue())); }
return; ProjectedNode projectedIntoNode = project(request.into(), request.intoWorkspace(), request, true); if (projectedIntoNode == null) { submit(new FederatedRequest(request)); request.fromWorkspace(), readable(request.into()), request.intoWorkspace(), getSourceName()); request.setError(new UnsupportedRequestException(msg));
/** * {@inheritDoc} * * @see org.modeshape.graph.request.processor.RequestProcessor#process(org.modeshape.graph.request.CopyBranchRequest) */ @Override public void process( CopyBranchRequest request ) { if (!updatesAllowed(request)) return; MapWorkspace workspace = getWorkspace(request, request.fromWorkspace()); MapWorkspace newWorkspace = getWorkspace(request, request.intoWorkspace()); if (workspace == null || newWorkspace == null) return; MapNode node = getTargetNode(workspace, request, request.from()); if (node == null) return; // Look up the new parent, which must exist ... Path newParentPath = request.into().getPath(); Name desiredName = request.desiredName(); MapNode newParent = newWorkspace.getNode(newParentPath); MapNode newNode = workspace.copyNode(getExecutionContext(), node, newWorkspace, newParent, desiredName, true); Path newPath = getExecutionContext().getValueFactories().getPathFactory().create(newParentPath, newNode.getName()); Location oldLocation = getActualLocation(request.from(), node); Location newLocation = Location.create(newPath, newNode.getUuid()); request.setActualLocations(oldLocation, newLocation); recordChange(request); }
/** * {@inheritDoc} * * @see org.modeshape.graph.request.processor.RequestProcessor#process(org.modeshape.graph.request.CopyBranchRequest) */ @Override public void process( CopyBranchRequest request ) { if (!updatesAllowed(request)) return; WorkspaceType workspace = getWorkspace(request, request.fromWorkspace()); WorkspaceType newWorkspace = getWorkspace(request, request.intoWorkspace()); if (workspace == null || newWorkspace == null) return; NodeType node = getTargetNode(workspace, request, request.from()); if (node == null) return; // Look up the new parent, which must exist ... Path newParentPath = request.into().getPath(); Name desiredName = request.desiredName(); NodeType newParent = getTargetNode(newWorkspace, request, request.into()); if (newParent == null) return; NodeType newNode = txn.copyNode(workspace, node, newWorkspace, newParent, desiredName, true); Path newPath = getExecutionContext().getValueFactories().getPathFactory().create(newParentPath, newNode.getName()); Location oldLocation = getActualLocation(workspace, request.from(), node); Location newLocation = Location.create(newPath, newNode.getUuid()); request.setActualLocations(oldLocation, newLocation); recordChange(request); }
@Override public void process( CopyBranchRequest request ) { if (!updatesAllowed(request)) return; PathWorkspace workspace = getWorkspace(request, request.fromWorkspace()); PathWorkspace intoWorkspace = getWorkspace(request, request.intoWorkspace()); if (workspace == null || intoWorkspace == null) return; PathNode node = getTargetNode(workspace, request, request.from()); if (node == null) return; if (!(intoWorkspace instanceof WritablePathWorkspace)) { I18n msg = GraphI18n.workspaceIsReadOnly; request.setError(new InvalidRequestException(msg.text(repository.getSourceName(), intoWorkspace.getName()))); return; } WritablePathWorkspace newWorkspace = (WritablePathWorkspace)intoWorkspace; // Look up the new parent, which must exist ... Path newParentPath = request.into().getPath(); Name desiredName = request.desiredName(); PathNode newParent = newWorkspace.getNode(newParentPath); PathNode newNode = newWorkspace.copyNode(getExecutionContext(), node, workspace, newParent, desiredName, true); Location oldLocation = Location.create(node.getPath(), node.getUuid()); Location newLocation = Location.create(newNode.getPath(), newNode.getUuid()); request.setActualLocations(oldLocation, newLocation); recordChange(request); }