/**
  * Sets the actual and complete location of the node being created. 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 created, or null if the {@link #under()
  *     current location} should be used
  * @throws IllegalArgumentException 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));
   }
   assert actual.hasPath();
   this.actualLocation = actual;
 }
 /**
  * Find the existing node given the location.
  *
  * @param location the location of the node, which must have a {@link Location#getPath() path}
  *     and/or {@link Location#getUuid() UUID}
  * @return the existing node; never null
  * @throws RepositoryException if there is an error working with the session
  * @throws PathNotFoundException if the node could not be found by its path
  */
 public Node node(Location location) throws RepositoryException {
   Node root = session.getRootNode();
   UUID uuid = location.getUuid();
   if (uuid != null) {
     try {
       return session.getNodeByIdentifier(uuid.toString());
     } catch (ItemNotFoundException e) {
       if (!location.hasPath()) {
         String msg = JcrConnectorI18n.unableToFindNodeWithUuid.text(getSourceName(), uuid);
         throw new PathNotFoundException(
             location, factories.getPathFactory().createRootPath(), msg);
       }
       // Otherwise, try to find it by its path ...
     }
   }
   if (location.hasPath()) {
     Path relativePath = location.getPath().relativeToRoot();
     ValueFactory<String> stringFactory = factories.getStringFactory();
     String relativePathStr = stringFactory.create(relativePath);
     try {
       return root.getNode(relativePathStr);
     } catch (javax.jcr.PathNotFoundException e) {
       // Figure out the lowest existing path ...
       Node node = root;
       for (Path.Segment segment : relativePath) {
         try {
           node = node.getNode(stringFactory.create(segment));
         } catch (javax.jcr.PathNotFoundException e2) {
           String pathStr = stringFactory.create(location.getPath());
           Path lowestPath = factories.getPathFactory().create(node.getPath());
           throw new PathNotFoundException(
               location,
               lowestPath,
               JcrConnectorI18n.nodeDoesNotExist.text(
                   getSourceName(), session.getWorkspace().getName(), pathStr));
         }
       }
     }
   }
   // Otherwise, we can't find the node ...
   String msg =
       JcrConnectorI18n.unableToFindNodeWithoutPathOrUuid.text(getSourceName(), location);
   throw new IllegalArgumentException(msg);
 }
 /**
  * {@inheritDoc}
  *
  * @see java.lang.Object#toString()
  */
 @Override
 public String toString() {
   String parent = under() + "/";
   if (under.hasPath() && under.getPath().isRoot()) parent = "/";
   return "create in the \""
       + workspaceName
       + "\" workspace the node \""
       + parent
       + childName
       + "\" with properties "
       + properties();
 }
 /**
  * {@inheritDoc}
  *
  * @see org.modeshape.graph.request.ChangeRequest#changes(java.lang.String,
  *     org.modeshape.graph.property.Path)
  */
 @Override
 public boolean changes(String workspace, Path path) {
   return this.workspaceName.equals(workspace)
       && under.hasPath()
       && under.getPath().isAtOrBelow(path);
 }