37 Using the Developer Tools Command Line Interface (CLI) to Create Reusable Modules

With the Developer Tools kit you are able to reuse and share resources in the form of modules. Modules are workspaces that are not site-specific and contain resources such as Templates, flex families, and ElementCatalog entries. Unlike the standard export/import functionality where assets are added to sites using natural mappings, modules typically utilize site overriding so they can be imported into any site you designate.

Topics:

37.1 Creating a Reusable Model

Artie has a flex family with a flex definition that he wants to reuse in other sites. He also has a Template asset associated with the flex definition. In the following scenario, Artie creates a module containing these resources.

This scenario uses the command line interface to create a module containing the resources Artie and his team developed in Using Developer Tools to Manage and Exchange Resources.

Note:

To use the command line interface, Artie must specify the user name and password of a general administrator in each command he executes. This user must be a member of the RestAdmin group. In this scenario, Artie uses fwadmin/xceladmin.

See the following sections:

37.2 List the Resources in the WebCenter Sites Instance

Artie uses the command line interface to browse his WebCenter Sites instance. He uses the resources=@ALL_ASSETS and the fromSites=Acceptance selectors to list all the assets of the Acceptance site. The command Artie uses is listcs, which lists all the resources on his WebCenter Sites instance.

Command:

${sites-shared}/config/export/envision/cs_workspace$
java - Xbootclasspath/a:lib/servlet-api.jar -jar
developer-tools-command-line.jar http://<host>:<port>/
     <context>/ContentServer username=fwadmin password=xceladmin 
   resources=@ALL_ASSETS fromSites=Acceptance cmd=listcs

Output:

Resource Type ||| Resource Id ||| Name ||| Description ||| Modified On
--------------------------------------------------------------------------------
Author_CD ||| 1297720502271 ||| fictionAuthor (status=ED) ||| authors who write fiction ||| 2011-02-17 15:10:41
Author_A ||| 1297720502260 ||| authorName (status=ED) ||| author name ||| 2011-02-17 14:46:40
Author_A ||| 1297720502265 ||| authorBio (status=ED) ||| author biography ||| 2011-02-17 14:46:40
Author_A ||| 1297720502289 ||| 1297720502289 (status=VO) ||| author birthplace ||| 2011-02-17 15:12:35
Author_A ||| 1297720502293 ||| DOB (status=PL) ||| date of birth ||| 2011-02-17 14:46:40
Author_A ||| 1297720502305 ||| birthPlace (status=PL) ||| place of birth ||| 2011-02-17 15:10:22
Template ||| 1297720502331 ||| welcome (Typeless, status=ED) ||| welcome page ||| 2011-02-17 23:18:18

Artie notes that there are five Author_A flex attribute instances (one of which is voided), one Author_CD flex definition, and a Template asset.

37.3 List Start Menu Items

Artie further uses the command line interface to browse for any start menu items that are assigned to the Acceptance site.

Command:

${sites-shared}/config/export/envision/cs_workspace$
java - Xbootclasspath/a:lib/servlet-api.jar -jar
    developer-tools-command-line.jar http://<host>:<port>/
    <context>/ContentServer username=fwadmin password=xceladmin 
   resources=@STARTMENU:* fromSites=Acceptance cmd=listcs

Output:

Resource Type ||| Resource Id ||| Name ||| Description ||| Modified On
--------------------------------------------------------------------------------
@STARTMENU ||| 1297720502206 ||| Find Author ||| null ||| -
@STARTMENU ||| 1297720502214 ||| Find Author Attribute ||| null ||| -
@STARTMENU ||| 1297720502222 ||| Find Author Definition ||| null ||| -
@STARTMENU ||| 1297720502230 ||| Find Author Filter ||| null ||| -
@STARTMENU ||| 1297720502238 ||| Find Author Parent ||| null ||| -
@STARTMENU ||| 1297720502246 ||| Find Author Parent Def ||| null ||| -
@STARTMENU ||| 1297720494070 ||| Find CSElement, FirstSiteII ||| Find CSElement ||| -
@STARTMENU ||| 1297720494086 ||| Find Page, FirstSiteII ||| Find Page ||| -
@STARTMENU ||| 1297720494078 ||| Find SiteEntry, FirstSiteII ||| Find SiteEntry ||| -
@STARTMENU ||| 1297720494066 ||| Find Template, FirstSiteII ||| Find Template ||| -
@STARTMENU ||| 1297720502210 ||| New Author ||| null ||| -
@STARTMENU ||| 1297720502218 ||| New Author Attribute ||| null ||| -
@STARTMENU ||| 1297720502226 ||| New Author Definition ||| null ||| -
@STARTMENU ||| 1297720502234 ||| New Author Filter ||| null ||| -
@STARTMENU ||| 1297720502242 ||| New Author Parent ||| null ||| -
@STARTMENU ||| 1297720502250 ||| New Author Parent Def ||| null ||| -
@STARTMENU ||| 1297720501427 ||| New CSElement ||| null ||| -
@STARTMENU ||| 1297720494052 ||| New Page, FirstSiteII ||| New Page ||| -
@STARTMENU ||| 1297720501431 ||| New SiteEntry ||| null ||| -
@STARTMENU ||| 1297720501435 ||| New Template ||| null ||| -

37.4 Export All Resources to a Workspace

Before he creates a module, Artie first exports all resources into a particular workspace.

Artie wants to create a module using all of the resources listed in List the Resources in the WebCenter Sites Instance and List Start Menu Items. He runs the following command to export all of the resources, at one time, into the specified workspace:

Command:

${sites-shared}/config/export/envision/cs_workspace$
java - Xbootclasspath/a:lib/servlet-api.jar -jar
  developer-tools-command-line.jar http://<host>:<port>/
  <context>/ContentServer username=fwadmin password=xceladmin 
  resources=@STARTMENU:*;@ALL_ASSETS fromSites=Acceptance cmd=export 
  datastore=authorModule

Output:

*** Exporting batch 1298385511005
Exporting ASSETDATA Author_CD:1297720502271 (batch 1298385511005)
Exporting ASSETDATA Author_A:1297720502260 (batch 1298385511005)
Exporting ASSET_TYPE Author_A (batch 1298385511005)
Exporting ELEMENTCATALOG OpenMarket/Xcelerate/AssetType/Author_A/LoadSiteTree (batch 1298385511005)
Exporting ELEMENTCATALOG OpenMarket/Xcelerate/AssetType/Author_A/AppendSelectDetails (batch 1298385511005)
Exporting ELEMENTCATALOG OpenMarket/Xcelerate/AssetType/Author_A/AppendSelectDetailsSE (batch 1298385511005)
Exporting ELEMENTCATALOG OpenMarket/Xcelerate/AssetType/Author_A/IndexAdd (batch 1298385511005)
Exporting ELEMENTCATALOG OpenMarket/Xcelerate/AssetType/Author_A/IndexReplace (batch 1298385511005)
Exporting ELEMENTCATALOG OpenMarket/Xcelerate/AssetType/Author_A/IndexCreateVerity (batch 1298385511005)
Exporting ELEMENTCATALOG OpenMarket/Xcelerate/AssetType/Author_A/ContentDetails (batch 1298385511005)
Exporting ELEMENTCATALOG OpenMarket/Xcelerate/AssetType/Author_A/ContentForm (batch 1298385511005)
Exporting ELEMENTCATALOG OpenMarket/Xcelerate/AssetType/Author_A/PostUpdate (batch 1298385511005)
Exporting ELEMENTCATALOG OpenMarket/Xcelerate/AssetType/Author_A/PreUpdate (batch 1298385511005)
...

All asset types for the flex family are included in the export. In addition, all elements belonging to those types are included as well. This information, although not usually modified, is necessary to make the module Artie is creating reusable on other WebCenter Sites instances.

37.5 Inspect the Module's Content

Artie inspects the authorModule workspace on his file system.

Artie notes that the Template asset, flex family members, asset types, and start menu items were all exported to the workspace on his file system.

37.6 Archive the Module

Artie is just one step away from importing the authorModule to a WebCenter Sites instance.

Artie creates a .zip file archive of the authorModule workspace and saves it.

37.7 Import the Module to a WebCenter Sites Instance

Artie is ready to import the module into a sample site.

  1. Artie unzips the module into the workspace location of the target WebCenter Sites instance.

    Figure 37-2 authorModule in Workspace Location

    Description of Figure 37-2 follows
    Description of "Figure 37-2 authorModule in Workspace Location"
  2. Using the command line interface, Artie imports the asset types and start menu items into the target WebCenter Sites instance.

    Command:

    ${sites-shared}/config/JSKdemo/ContentServer>
       java - Xbootclasspath/a:lib/servlet-api.jar -jar
       developer-tools-command-line.jar http://<hots>:<port>/
       <context>/ContentServer username=fwadmin password=xceladmin 
       resources=@ALL_NONASSETS cmd=import datastore=authorModule
       toSites=FirstSiteII
    

    Output:

    *** Importing batch 1298052933085
    Importing DSKEY @STARTMENU-4340b65d-a9e4-4131-ac7f-51185a79b18d (batch 1298052933085)
    Saved 1297720494070 (batch 1298052933085)
    Importing DSKEY @STARTMENU-0a2decd4-b6be-418c-9992-a4332480bb20 (batch 1298052933085)
    Saved 1297720501435 (batch 1298052933085)
    Importing DSKEY @STARTMENU-66edea6d-218e-41b7-b5ac-ec3453bd53b7 (batch 1298052933085)
    Saved 1297720502210 (batch 1298052933085)
    Importing DSKEY @STARTMENU-c416c0d6-98a7-4ebf-babb-78d0699698de (batch 1298052933085)
    Saved 1297720502230 (batch 1298052933085)
    Importing DSKEY @ASSET_TYPE-162d0b70-7e69-4266-acca-2f472e3d71bd (batch 1298052933085)
    Dependency @ASSET_TYPE-Author_A already exists, skipping.
    Importing DSKEY @ELEMENTCATALOG-OpenMarket/Xcelerate/AssetType/Author_A/LoadSiteTree (batch 1298052933085)
    Saved OpenMarket/Xcelerate/AssetType/Author_A/LoadSiteTree (batch 1298052933085)
    Importing DSKEY @ELEMENTCATALOG-OpenMarket/Xcelerate/AssetType/Author_A/AppendSelectDetails (batch 1298052933085)
    Saved OpenMarket/Xcelerate/AssetType/Author_A/AppendSelectDetails (batch 1298052933085)
    Importing DSKEY @ELEMENTCATALOG-OpenMarket/Xcelerate/AssetType/Author_A/AppendSelectDetailsSE (batch 1298052933085)
    Saved OpenMarket/Xcelerate/AssetType/Author_A/AppendSelectDetailsSE (batch 1298052933085)
    Importing DSKEY @ELEMENTCATALOG-OpenMarket/Xcelerate/AssetType/Author_A/IndexAdd (batch 1298052933085)
    Saved OpenMarket/Xcelerate/AssetType/Author_A/IndexAdd (batch 1298052933085)
    ...
    
  3. Artie opens the Admin interface for the FirstSiteII sample site and confirms that the asset types and start menu items were imported successfully.

    Figure 37-3 Start Menus for FirstSiteII

    Description of Figure 37-3 follows
    Description of "Figure 37-3 Start Menus for FirstSiteII"
  4. Now, Artie imports the assets.

    Command:

    ${sites-shared}/config/JSKdemo/ContentServer>
    java - Xbootclasspath/a:lib/servlet-api.jar -jar 
      developer-tools-command-line.jar http://<host><:port>/
      <context>/ContentServer username=fwadmin 
      password=xceladmin resources=@ALL_ASSETS cmd=import datastore=authorModule 
      toSites=FirstSiteII
    

    Output:

    *** Importing batch 1298480206533
    Importing DSKEY Author_A-cbf4d8aa-d23a-4f0d-b55d-a87a0e9bbf33 (batch 1298480206533)
    Dependency @ASSET_TYPE-Author_A already exists, skipping.
    Saved Author_A:1297837451977 (batch 1298480206533)
    Importing DSKEY Author_A-42afd458-e90c-4e18-a4b6-47d322b46414 (batch 1298480206533)
    Dependency @ASSET_TYPE-Author_A already exists, skipping.
    Saved Author_A:1297837451981 (batch 1298480206533)
    Importing DSKEY Author_A-9fe04c6e-36e7-4ee3-8c76-8c02edf74136 (batch 1298480206533)
    Dependency @ASSET_TYPE-Author_A already exists, skipping.
    Saved Author_A:1297837451985 (batch 1298480206533)
    Importing DSKEY Author_CD-71d6067b-35f6-47f4-ae97-3876303abb37 (batch 1298480206533)
    Importing DSKEY Author_A-ada2d6be-ef14-4766-b446-911bfa838835 (batch 1298480206533)
    Dependency @ASSET_TYPE-Author_A already exists, skipping.
    Saved Author_A:1297837451989 (batch 1298480206533)
    Dependency @ASSET_TYPE-Author_C already exists, skipping.
    Dependency @ASSET_TYPE-Author_P already exists, skipping.
    Dependency @ASSET_TYPE-Author_CD already exists, skipping.
    Dependency @ASSET_TYPE-Author_PD already exists, skipping.
    Dependency @ASSET_TYPE-Author_F already exists, skipping.
    Dependency @ASSET_TYPE-Author_A already exists, skipping.
    Saved Author_CD:1297837451993 (batch 1298480206533)
    Importing DSKEY Template-89b05c0f-227b-4dcb-961e-2ab6e6af2dae (batch 1298480206533)
    Saved Template:1297837452000 (batch 1298480206533)
    *** Completed importing batch 1298480206533
    
  5. Artie verifies that the flex definition is imported into the FirstSiteII sample site successfully.

    Figure 37-4 Inspect Author Definition

    Description of Figure 37-4 follows
    Description of "Figure 37-4 Inspect Author Definition"
  6. Using the command line interface, he also imports the Template asset. He then opens the Admin interface again to verify the Template asset is imported correctly.

    Figure 37-5 Template Welcome

    Description of Figure 37-5 follows
    Description of "Figure 37-5 Template Welcome"

    The entire module is imported successfully into the FirstSiteII sample site. This module can be reused and imported into any WebCenter Sites instance.