61 Developer Tools: Using the Command-line Tool to Create Reusable Modules

The Developer Tools kit provides the ability 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.

This chapter contains the following sections:

61.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 will create a module containing these resources. This scenario uses the command-line tool to create a module containing the resources Artie and his team developed in Chapter 60, "Developer Tools: Development Team Integration Use Case."

Note:

To use the command-line tool, 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:

61.2 List the Resources in the WebCenter Sites Instance

Artie uses the command-line tool 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:

/opt/cs/export/envision/cs_workspace$ export CLASSPATH=csdt-client-1.0.2.jar
/opt/cs/export/envision/cs_workspace$ java com.fatwire.csdt.client.main.CSDT
http://localhost:9010/cs/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.

61.3 List Start Menu Items

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

Command:

/opt/cs/export/envision/cs_workspace$ java com.fatwire.csdt.client.main.CSDT
http://localhost:9010/cs/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 ||| -

61.4 Export All Resources to the Desired Workspace

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

Command:

/opt/cs/export/envision/cs_workspace$ java com.fatwire.csdt.client.main.CSDT 
http://localhost:9010/cs/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 in order to make the module Artie is creating reusable on other WebCenter Sites instances.

61.5 Inspect the Module's Content

Artie inspects the authorModule workspace on his file system.

Description of pic32_inspectmodule.png follows
Description of the illustration pic32_inspectmodule.png

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.

61.6 Archive the Module

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

61.7 Import the Module to a WebCenter Sites Instance

Artie decides to import the module into the FirstSiteII sample site.

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

    Description of pic33_importmodule.png follows
    Description of the illustration pic33_importmodule.png

  2. Using the command-line tool, Artie imports the asset types and start menu items into the target WebCenter Sites instance.

    Command:

    D:\FatWire\JSKdemo\ContentServer>java com.fatwire.csdt
       .client.main.CSDT
    http://localhost:8080/cs/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 access the WebCenter Sites Admin interface for the FirstSiteII sample site and confirms that the asset types and start menu items were imported successfully.

    Description of pic34_inspectadmin.png follows
    Description of the illustration pic34_inspectadmin.png

  4. Now, Artie imports the assets.

    Command:

    D:\FatWire\JSKdemo\ContentServer>java com.fatwire.csdt
       .client.main.CSDT http://localhost:8080/cs/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:

    Description of pic35_verifyflexdef.png follows
    Description of the illustration pic35_verifyflexdef.png

  6. Using the command-line tool, he also imports the Template asset. He then accesses the WebCenter Sites Admin interface again to verify the Template asset is imported correctly.

    Description of pic36_verifytemplate.png follows
    Description of the illustration pic36_verifytemplate.png

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