/** * {@inheritDoc} * <p> * This method does not clone the results. * </p> * * @see org.modeshape.graph.request.ChangeRequest#clone() */ @Override public CloneBranchRequest clone() { CloneBranchRequest result = new CloneBranchRequest(actualFromLocation != null ? actualFromLocation : from, fromWorkspace, actualIntoLocation != null ? actualIntoLocation : into, intoWorkspace, desiredName, desiredSegment, removeExisting); result.setRemovedNodes(removedExistingNodes); result.setActualLocations(actualFromLocation, actualIntoLocation); return result; }
/** * {@inheritDoc} * * @see org.modeshape.graph.request.processor.RequestProcessor#process(org.modeshape.graph.request.CloneBranchRequest) */ @Override public void process( CloneBranchRequest request ) { CloneBranchRequest source = (CloneBranchRequest)federatedRequest.getFirstProjectedRequest().getRequest(); if (checkErrorOrCancel(request, source)) return; request.setActualLocations(source.getActualLocationBefore(), source.getActualLocationAfter()); request.setRemovedNodes(source.getRemovedNodes()); }
/** * {@inheritDoc} * * @see org.modeshape.graph.request.processor.RequestProcessor#process(org.modeshape.graph.request.CloneBranchRequest) */ @Override public void process( CloneBranchRequest request ) { ProjectedRequest projected = federatedRequest.getFirstProjectedRequest(); // Check the projection first ... if (checkErrorOrCancel(request, federatedRequest)) return; CloneBranchRequest source = (CloneBranchRequest)projected.getRequest(); if (checkErrorOrCancel(request, source)) return; Location locationBefore = source.getActualLocationBefore(); Location locationAfter = source.getActualLocationBefore(); locationBefore = projectToFederated(request.from(), projected.getProjection(), locationBefore, request); locationAfter = projectToFederated(request.into(), projected.getSecondProjection(), locationAfter, request); request.setActualLocations(locationBefore, locationAfter); if (source.removeExisting()) { Set<Location> removed = new HashSet<Location>(); for (Location location : request.getRemovedNodes()) { removed.add(projectToFederated(projected.getSecondProjection(), location, request)); } request.setRemovedNodes(Collections.unmodifiableSet(removed)); } }
@Override public void process( CloneBranchRequest 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(); PathNode newParent = newWorkspace.getNode(newParentPath); Set<Location> removedExistingNodes = new HashSet<Location>(); Name desiredName = request.desiredName(); 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); request.setRemovedNodes(Collections.unmodifiableSet(removedExistingNodes)); recordChange(request); }
Location oldLocation = getActualLocation(workspace, request.from(), node); Location newLocation = Location.create(newPath, newNode.getUuid()); request.setActualLocations(oldLocation, newLocation); request.setRemovedNodes(Collections.unmodifiableSet(removedExistingNodes)); recordChange(request);
Location oldLocation = getActualLocation(request.from(), node); Location newLocation = Location.create(newPath, newNode.getUuid()); request.setActualLocations(oldLocation, newLocation); request.setRemovedNodes(Collections.unmodifiableSet(removedExistingNodes)); recordChange(request);
@Override public void process( CloneBranchRequest request ) { // Create a child under the new parent ... if (request.into().hasPath()) { Name childName = request.desiredName(); if (childName == null) childName = request.desiredSegment().getName(); Path childPath = context.getValueFactories().getPathFactory().create(request.into().getPath(), childName); Location newChild = actualLocationOf(Location.create(childPath)); // Just update the actual location request.setActualLocations(actualLocationOf(request.from()), newChild); } else { // Just update the actual location request.setActualLocations(actualLocationOf(request.from()), actualLocationOf(request.into())); } }