public void copy(String srcWorkspace, String srcAbsPath, String destAbsPath) throws NoSuchWorkspaceException,
      ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException,
      ItemExistsException, RepositoryException
   {
      session.checkLive();
      // get source session
      SessionImpl srcSession = null;
      if (!getName().equals(srcWorkspace))
      {
         srcSession = repository().internalLogin(session.getUserState(), srcWorkspace);
      }
      else
      {
         srcSession = session;
      }

      // get destination node
      JCRPath destNodePath = session.getLocationFactory().parseAbsPath(destAbsPath);
      if (destNodePath.isIndexSetExplicitly())
      {
         throw new RepositoryException("The path provided must not have an index on its final element. "
            + destNodePath.getAsString(false));
      }
      // get source node
      JCRPath srcNodePath = srcSession.getLocationFactory().parseAbsPath(srcAbsPath);

      NodeImpl srcNode = (NodeImpl)srcSession.getTransientNodesManager().getItem(srcNodePath.getInternalPath(), false);

      // get dst parent node
      NodeImpl destParentNode =
         (NodeImpl)session.getTransientNodesManager().getItem(destNodePath.makeParentPath().getInternalPath(), true);

      if (srcNode == null || destParentNode == null)
      {
         throw new PathNotFoundException("No node exists at " + srcAbsPath + " or no node exists one level above "
            + destAbsPath);
      }
      try
      {
         destParentNode.checkPermission(PermissionType.ADD_NODE);
      }
      catch (AccessControlException e)
      {
         throw new AccessDeniedException(e.getMessage());
      }
      destParentNode.validateChildNode(destNodePath.getName().getInternalName(), ((NodeTypeImpl)srcNode
         .getPrimaryNodeType()).getQName());

      NodeImpl destNode =
         (NodeImpl)session.getTransientNodesManager().getItem((NodeData)destParentNode.getData(),
            new QPathEntry(destNodePath.getInternalPath().getName(), 0), false, ItemType.NODE);

      if (destNode != null)
      {

         if (!destNode.getDefinition().allowsSameNameSiblings())
         {
            throw new ItemExistsException("A node with name (" + destAbsPath + ") is already exists.");
         }
      }

      ItemDataCopyVisitor initializer =
         new ItemDataCopyVisitor((NodeData)destParentNode.getData(), destNodePath.getName().getInternalName(),
            nodeTypeManager, srcSession.getTransientNodesManager(), session.getTransientNodesManager(), false);

      srcNode.getData().accept(initializer);

      PlainChangesLogImpl changesLog = new PlainChangesLogImpl(initializer.getItemAddStates(), session);

      session.getTransientNodesManager().getTransactManager().save(changesLog);
   }
public void copy ( String srcWorkspace , String srcAbsPath , String destAbsPath ) throws NoSuchWorkspaceException , ConstraintViolationException , VersionException , AccessDeniedException , PathNotFoundException , ItemExistsException , RepositoryException { session . checkLive ( ) ; SessionImpl srcSession = null ; if ( ! getName ( ) . equals ( srcWorkspace ) ) { srcSession = repository ( ) . internalLogin ( session . getUserState ( ) , srcWorkspace ) ; } else { srcSession = session ; } JCRPath destNodePath = session . getLocationFactory ( ) . parseAbsPath ( destAbsPath ) ; if ( destNodePath . isIndexSetExplicitly ( ) ) { throw new RepositoryException ( "The path provided must not have an index on its final element. " + destNodePath . getAsString ( false ) ) ; } JCRPath srcNodePath = srcSession . getLocationFactory ( ) . parseAbsPath ( srcAbsPath ) ; NodeImpl srcNode = ( NodeImpl ) srcSession . getTransientNodesManager ( ) . getItem ( srcNodePath . getInternalPath ( ) , false ) ; NodeImpl destParentNode = ( NodeImpl ) session . getTransientNodesManager ( ) . getItem ( destNodePath . makeParentPath ( ) . getInternalPath ( ) , true ) ; if ( srcNode == null || destParentNode == null ) { throw new PathNotFoundException ( "No node exists at " + srcAbsPath + " or no node exists one level above " + destAbsPath ) ; } try { destParentNode . checkPermission ( PermissionType . ADD_NODE ) ; } catch ( AccessControlException e ) { throw new AccessDeniedException ( e . getMessage ( ) ) ; } destParentNode . validateChildNode ( destNodePath . getName ( ) . getInternalName ( ) , ( ( NodeTypeImpl ) srcNode . getPrimaryNodeType ( ) ) . getQName ( ) ) ; NodeImpl destNode = ( NodeImpl ) session . getTransientNodesManager ( ) . getItem ( ( NodeData ) destParentNode . getData ( ) , new QPathEntry ( destNodePath . getInternalPath ( ) . getName ( ) , 0 ) , false , ItemType . NODE ) ; if ( destNode != null ) { if ( ! destNode . getDefinition ( ) . allowsSameNameSiblings ( ) ) { throw new ItemExistsException ( "A node with name (" + destAbsPath + ") is already exists." ) ; } } ItemDataCopyVisitor initializer = new ItemDataCopyVisitor ( ( NodeData ) destParentNode . getData ( ) , destNodePath . getName ( ) . getInternalName ( ) , nodeTypeManager , srcSession . getTransientNodesManager ( ) , session . getTransientNodesManager ( ) , false ) ; srcNode . getData ( ) . accept ( initializer ) ; PlainChangesLogImpl changesLog = new PlainChangesLogImpl ( initializer . getItemAddStates ( ) , session ) ; session . getTransientNodesManager ( ) . getTransactManager ( ) . save ( changesLog ) ; }
@see javax.jcr.Workspace#copy