34 Using Developer Tools Command Line Interface (CLI)

You use the Developer Tools CLI for deployment and other resource movement activities. CLI gives you freedom to work with any workspace, not just the Developer Tools workspace. The command line interface also include import and export features. For example, with CLI you can create reusable modules (workspaces). These workspaces include resources that you can import into any site.

For information about running and using CLI, see these topics:

34.1 Running and Using the Command Line Interface (CLI)

Running CLI involves a few easy steps.

To run the command line interface:

  1. Unzip the developer-tools-command-line-x.y.z.zip file, which is located in the clients folder in your WebCenter Sites installation directory (${Oracle Home}/wcsites/clients).
  2. Execute the developer-tools-command-line-x.y.z.jar file and include the Java EE libraries (for example, the Servlet API implementation) in the classpath as follows:
    java -Xbootclasspath/a:lib/servlet-api.jar -jar developer-tools-command-line.jar 
    http://<hostname>:<port>/<context-path>/ContentServer username=<username> password=<password>  
    cmd=export|import|listcs|listds [options] 
    

    Replace the placeholder parameters with the information about your development environment and the command you want to run:

    • http://<hostname>:<port>/<context-path>: The URL of your local WebCenter Sites instance, including the ContentServer servlet (for example, http://localhost:8080/cs/ContentServer)

    • username and password: The user name and password of a WebCenter Sites general administrator. This user must be a member of the RestAdmin group (for example, fwadmin/xceladmin).

    • cmd: The command to execute. The following commands are available:

      • export: Export data from WebCenter Sites to a workspace.

      • import: Import data into WebCenter Sites from a workspace.

      • listcs: List WebCenter Sites content.

      • listds: List workspace content.

    • options: Specify one of the following to either import or export:

      • resources: Specify which resources you want to import or export in a semicolon-separated list of resource type and resource ID. To specify multiple resources, use a comma-separated list. To specify all resources of a given type, use the * symbol. To export a resource (to a workspace), specify the resource's local ID. For example, use resources=Content_C:12345;Product_C:* to export a specific Content_C asset and all Product_C assets.

        If you are importing a resource (to a WebCenter Sites instance), specify the resource's fw_uid. To get the resource's fw_uid, use the listds option.

        The following is a full listing of resource selectors:

        @SITE: Specify the sites.

        @ROLE: Specify the roles.

        @ASSET_TYPE: Specify the asset types.

        @TREETAB: Specify the tree tabs.

        @STARTMENU: Specify the start menu items.

        @ELEMENTCATALOG: Specify the ElementCatalog entries.

        @SITECATALOG: Specify the site catalog entries.

        @ALL_NONASSETS: Use this short-hand notation to select all non-asset resources.

        @ALL_ASSETS: Use this short-hand notation to select all available assets.

        asset type: Specify assets of a certain type.

        Note:

        To verify that selectors are picking up the correct resources before import or export, use listcs for export activities and listds for import activities. These commands fine-tune the selectors before execution by providing a list of the resources that will be moved.

        Resources' dependencies are exported and imported automatically. However, dependencies are not listed using the listcs and listds commands.

        User preferences such as bookmarks and saved searches are not imported/exported as part of the CSDT import/export.

      • fromSites: Select resources from specified sites only.

      • toSites: (Import only) Override the natural site affiliation during import with a comma-separated list of sites. Specified sites must exist on the target system.

      • modifiedSince: (Assets only) Select only resources that have been modified since the specified date. The date format is yyyy-mm-dd hh:MM:ss. The date is treated as UTC 0 time zone.

      • datastore: Specify the workspace you want to either export WebCenter Sites resources to or import WebCenter Sites resources from. If you do not specify a value for this parameter, the main Developer Tools workspace is specified by default. If you are exporting resources and specify a workspace that does not exist, CLI automatically creates the workspace and exports the resources to it.

34.2 Example Commands

Here is a list of sample export and import commands that you can run using the command line interface.

  • This command exports the specified Content_C assets and all Product_C assets that belong to FirstSiteII and were modified since the specified date. Because no workspace is specified, the Developer Tools workspace is used by default:

    java -Xbootclasspath/a:lib/servlet-api.jar -jar developer-tools-command-line-x.y.z.jar http://localhost:8080/cs/ContentServer username=bob password=password resources=Content_C:123432123423,11234234212,111234341234;Product_C:* fromSites=FirstSiteII modifiedSince="2016-08-08 19:14:00" cmd=export
    
  • This command imports the specified Content_C asset and all Product_C assets that are found in the workspace to the FirstSiteII site and were modified since the specified date. Because no workspace is specified, the Developer Tools workspace is used by default:

    java -Xbootclasspath/a:lib/servlet-api.jar -jar developer-tools-command-line-x.y.z.jar  http://localhost:8080/cs/ContentServer username=bob password=password resources=Content_C:aad618e9-f04e-4ee4-b902-076224bb6f7b;Product_C:* toSites=FirstSiteII modifiedSince="2016-09-17 12:09:00" cmd=import
    
  • This command exports all resources from the site SecondSiteII into a workspace named TheOutput:

    java -Xbootclasspath/a:lib/servlet-api.jar -jar developer-tools-command-line-x.y.z.jar  http://localhost:8080/cs/ContentServer username=bob password=password resources=@ALL_ASSETS:*;@ALL_NONASSETS:*  fromSites=SecondSiteII  datastore=TheOutput cmd=export
    
  • This command imports all assets and tree tabs from the workspace named TheInput into the site MySite:

    java -Xbootclasspath/a:lib/servlet-api.jar -jar developer-tools-command-line-x.y.z.jar  http://localhost:8080/cs/ContentServer username=bob password=password resources=@ALL_ASSETS:*;@TREETAB:* toSites=MySite  datastore=TheInput cmd=import
    

Note:

modifiedSince works only with export|listcs|import.

34.3 About Importing Modules

Modules are sets of related resources that you export from your WebCenter Sites instance into a given workspace. Modules are reusable, so you can import their content into any CM sites (even if the site is not listed in the resources' canonical list of sites).

The datastore parameter enables you to specify the workspace you want to either export WebCenter Sites resources to or import WebCenter Sites resources from. If you export WebCenter Sites resources to a workspace that does not exist, the command line interface automatically creates that workspace and exports the resources into it.

To import a module into a CM site, you must execute an import command. In the datastore parameter, specify the workspace that contains the resources and in the toSites parameter, specify the site(s) to which you want to import those resources. This imports the content of the workspace into the specified CM site(s).

34.4 Status Codes for Operations Invoked from the Developer Tools Command Line Interface (CLI)

The CLI for the Developer Tools return these status codes for each operation invoked.

Status Code Description
SUCCESS -> 0 Represents a successful invocation of a developer tools command (for example, export / import). This status is returned only when the request has been processed without any errors either on the client or the server side and there is at least one resource which could be processed as a result of the invocation.
NO CONTENT -> 1 Represents a successful invocation of a developer tools command (for example, export / import). This status is returned only when the request has been processed without any errors either on the client or the server side, but there are no resources which could be processed as a result of the invocation.
IMPROPER SHUTDOWN -> 11 A rare error code due to an unexpected breakdown of the process invoked.
CONSOLE UNAVAILABLE -> 12 Client-side error code. It’s returned when the CLI interacts using a system other than the system console.
RUNTIME SANITY CHECK FAILED -> 13 Client-side error code. It’s returned when the runtime provided for running the application is not sufficient, for example, there are missing dependencies.
BAD REQUEST -> 40 Client side error code. It’s returned when the usage is violated.
UNAUTHORIZED -> 41 Client side error code. It’s returned when the credentials or roles are invalid or insufficient to perform the processing.
SERVICE ERROR -> 50 Server side error code. It’s returned if an exception occurs while invoking the request.
RESPONSE PARSE ERROR -> 50 Server side error code. It’s returned when the response sent from the server does not match the expectation of the client. This error code is currently the same as SERVICE ERROR, but maybe expanded in future.