Difference between revisions of "Documentation/DevGuide/UCB/Copying, Moving and Linking"

From Apache OpenOffice Wiki
Jump to: navigation, search
m (Robot: Changing Category:Documentation/Developers Guide/Universal Content Broker)
m (FINAL VERSION FOR L10N)
Line 6: Line 6:
 
|NextPage=Documentation/DevGuide/UCB/Configuration
 
|NextPage=Documentation/DevGuide/UCB/Configuration
 
}}
 
}}
{{DISPLAYTITLE:Copying, Moving and Linking}}
+
{{Documentation/DevGuideLanguages|Documentation/DevGuide/UCB/{{SUBPAGENAME}}}}
 +
{{DISPLAYTITLE:Copying, Moving and Linking}}
 
Copying, moving and creating links to a resource works differently from the other operations available for UCB Contents. There are ''three UCB Contents'' involved in these operations, the source object, target folder, and target object. There may even be ''two content Providers'', for example, when moving a file located on an FTP server to the local file system of a workstation. Each implementation of the <idl>com.sun.star.ucb.UniversalContentBroker</idl> service supports the <idl>com.sun.star.ucb.XCommandProcessor</idl> interface. This command processor implements the command "<code>globalTransfer</code>" that can be used to copy and move UCB Contents, and create links to UCB Contents. The command takes an argument of type <idl>com.sun.star.ucb.GlobalTransferCommandArgument</idl>. To copy, move or create a link to a resource, execute the "<code>globalTransfer</code>" command at the UCB.
 
Copying, moving and creating links to a resource works differently from the other operations available for UCB Contents. There are ''three UCB Contents'' involved in these operations, the source object, target folder, and target object. There may even be ''two content Providers'', for example, when moving a file located on an FTP server to the local file system of a workstation. Each implementation of the <idl>com.sun.star.ucb.UniversalContentBroker</idl> service supports the <idl>com.sun.star.ucb.XCommandProcessor</idl> interface. This command processor implements the command "<code>globalTransfer</code>" that can be used to copy and move UCB Contents, and create links to UCB Contents. The command takes an argument of type <idl>com.sun.star.ucb.GlobalTransferCommandArgument</idl>. To copy, move or create a link to a resource, execute the "<code>globalTransfer</code>" command at the UCB.
  

Revision as of 13:07, 15 May 2009



Copying, moving and creating links to a resource works differently from the other operations available for UCB Contents. There are three UCB Contents involved in these operations, the source object, target folder, and target object. There may even be two content Providers, for example, when moving a file located on an FTP server to the local file system of a workstation. Each implementation of the com.sun.star.ucb.UniversalContentBroker service supports the com.sun.star.ucb.XCommandProcessor interface. This command processor implements the command "globalTransfer" that can be used to copy and move UCB Contents, and create links to UCB Contents. The command takes an argument of type com.sun.star.ucb.GlobalTransferCommandArgument. To copy, move or create a link to a resource, execute the "globalTransfer" command at the UCB.

Template:Documentation/Note

Copying, moving and creating links to a resource are shown in the following example:

  import com.sun.star.ucb.*;
  import com.sun.star.uno.UnoRuntime;
  import com.sun.star.uno.XInterface;
 
  {
      String aSourceURL = ... // URL of the source object
      String aTargetFolderURL = ... // URL of the target folder
 
      /////////////////////////////////////////////////////////////////////
      // Obtain access to UCB...
      /////////////////////////////////////////////////////////////////////
      XInterface xUCB = ...
 
      // Obtain XCommandProcessor interface from UCB...
      XCommandProcessor xProcessor = (XCommandProcessor)UnoRuntime.queryInterface(
          XCommandProcessor.class, xUCB);
 
      if (xProcessor == null)
          ... error ...
      /////////////////////////////////////////////////////////////////////
      // Copy a resource to another location...
      /////////////////////////////////////////////////////////////////////
      try {
          GlobalTransferCommandArgument aArg = new GlobalTransferCommandArgument();
          aArg.TransferCommandOperation = TransferCommandOperation_COPY;
          aArg.SourceURL = aSourceURL;
          aArg.TargetURL = aTargetFolderURL;
 
          // object keeps it current name
          aArg.NewTitle = "";
 
          // fail,if object with same name exists in target folder
          aArg.NameClash = NameClash.ERROR;
 
          // Let UCB execute the command "globalTransfer",
          // using helper method executeCommand (see [CHAPTER:UCB.Using.Commands])
          executeCommand(xProcessor, "globalTransfer", aArg);
      }
      catch (com.sun.star.ucb.CommandAbortedException e) {
          ... error ...
      }
      catch (com.sun.star.uno.Exception e) {
          ... error ...
      }
  }
Content on this page is licensed under the Public Documentation License (PDL).
Personal tools
In other languages