31 Importing Assets of Any Type

You can import assets of all types into the WebCenter Sites database using the XMLPost utility.  This utility is based on the WebCenter Sites FormPoster Java class, and it is delivered with the WebCenter Sites base product. It imports data using the HTTP POST protocol.

Topics:

For information about importing your assets when you are using the flex asset data model, see Importing Flex Assets.

About Importing Assets Using the XMLPost Utility

After you have determined your data design, created your asset types, tested them on your development system, and moved them to your management system, you’re ready to import assets (content) from their current source into the database on the management system. You may also have remotely generated content (generated using a wire feed service or some other source) that you would like to import into the WebCenter Sites database on your management system.

You use the XMLPost utility to import any data into the WebCenter Sites database. To import assets, you instruct the XMLPost utility to invoke one of the importing (posting) elements provided by WebCenter Sites, as appropriate for that asset type.

There are four components involved in this process:

  • The XMLPost utility, which is delivered with WebCenter Sites.

  • A posting element. WebCenter Sites delivers a posting element named RemoteContentPost. WebCenter Sites delivers three additional posting elements, described in Importing Flex Assets.

  • A configuration file with an .ini file extension. You create a configuration file for each asset type that you plan to import. This file contains information about what to expect in the source files (what tags XMLPost will find there), what to do with the data provided, and which importing (posting) element to use to import the data.

  • The source files. You provide an individual source file for each asset that you want to import (well-formed XML files). Each tag in a file identifies a field for that asset type. The information contained in the tag is the data to be written to that column.

The XMLPost utility parses the configuration file to determine how to interpret the data provided for the asset type. It parses the source files and creates name/value pairs for each field value, and passes those name/value pairs as ICS variables to the RemoteContentPost element. The RemoteContentPost element then creates the asset from the variables.

You can also create your own posting elements that work with the XMLPost utility. However, for importing assets, the posting elements that are provided by WebCenter Sites should meet your needs.

Note:

For added security, you must rename the RemoteContentPost page to prevent attempts to hack into the system.

What the Developer Does

This section provides a brief overview of the steps that the developer completes before invoking the XMLPost utility and what the XMLPost utility does.

General steps that you perform when you import assets into your WebCenter Sites database:

  1. Create a configuration file that identifies the type of asset that is to be imported and the tags that are used in the source files.

    This file also sets several configuration properties, including the name of the SiteCatalog entry for the posting element that you want XMLPost to use. For all assets, the name of this posting element is RemoteContentPost. For information about the posting elements for flex assets, see Importing Flex Assets.

    Note that the configuration file is specific for this asset type. You must provide a separate configuration file for each asset type.

  2. Create the source files for the data that you want to import. Create a separate source file for each individual asset.

  3. Place the source and configuration files in a directory on the management system.

  4. From that directory, invoke the XMLPost utility, identifying the source files and the configuration file to use for those source files.

What XMLPost and WebCenter Sites Do

After you invoke the XMLPost utility to import the source files, the process begins as shown in the following figure and in the list of steps that follows.

Figure 31-1 XMLPost Utility Process Diagram

Description of Figure 31-1 follows
Description of "Figure 31-1 XMLPost Utility Process Diagram"
  1. The XMLPost utility parses the configuration file.

  2. XMLPost parses the source file and creates name/value pairs for each field value specified in the source file.

  3. XMLPost invokes the FormPoster Java class by posting (HTTP POST) the name/value pairs as ICS variables to the pagename passed in from the configuration file. When you are importing basic asset types, that pagename is:

    OpenMarket/Xcelerate/Actions/RemoteContentPost
    
  4. WebCenter Sites locates the page in the SiteCatalog table and invokes the root element of the RemoteContentPost page, which has the same name by default (RemoteContentPost).

  5. The RemoteContentPost element passes the data from the source files as variables to the PreUpdate element for assets of that type.

  6. The PreUpdate element sets the variable values for that asset and then returns to the RemoteContentPost element.

  7. The RemoteContentPost element creates the asset.

  8. The web server returns a stream of HTML to XMLPost, which then parses the stream to determine whether the import operation succeeded or failed, logging the results to a text file that you specify in the configuration file.

  9. If the asset type of the asset that you are importing uses a search engine, RemoteContentPost indexes the new element.

  10. If you set a certain parameter in the configuration file, RemoteContentPost deletes the source files for the assets that were successfully imported.

Using XMLPost Configuration Files

An XMLPost configuration file includes three types of properties. Some properties provide database and environment information to XMLPost, some import configuration values, and some specify the tags used in the source files.

  • Properties that provide information to XMLPost about the database and environment remain the same even if you create your own posting element.

  • Properties that provide configuration values for the posting (importing) process. The following topics describe properties that you must provide for the RemoteContentPost element to function correctly.

    Examples of properties include the URL of the page that invokes RemoteContentPost, a user name and password that gives XMLPost write privileges to the asset type table in the database, the name of the asset type that you want to import, how to log errors, and any data values that are the same for all of the assets that you are importing.

  • Properties that specify the tags that are used in the source files.

Certain information, such as which site the assets should belong to or which workflow should be assigned to the asset, can be configured either in the RemoteContentPost section of the configuration file or the source file section.

For example, when working with a single content management site or importing assets that belong to the same site, specify the name of the site in the configuration section to avoid repeating that information in each source file. For multiple content management sites, specify which sites an asset belongs to in the individual source files.

This section includes the following topics:

Configuration Properties for XMLPost

This table lists the properties that specify database connection information and other general configuration instructions that the XMLPost utility needs.

Table 31-1 Configuration Properties for XMLPost

Property Description

xmlpost.xmlfilenamefilter

Required.

The file extension for your source files. Typically set to xml.

For example:

xmlpost.xmlfilenamefilter: .xml

xmlpost.proxyhost

Optional.

If a firewall separates you and the WebCenter Sites database that you want to import the assets in to, use this property to specify the host name of the proxy server.

For example:

xmlpost.proxyhost: nameOfServer

xmlpost.proxyport

Optional.

If a firewall separates you and the WebCenter Sites database that you want to import the assets in to, use this property to specify the port number on the proxy server that XMLPost should connect to.

For example:

xmlpost.proxyport: 80

xmlpost.url

Required.

The first part of the URL for the page entry of the posting element.

XMLPost creates the URL for the posting element by prepending the value specified for this property to the value specified for the pagename postargname (described below).

The value that you set for this property should use the following convention:

  • The name of the server that holds the WebCenter Sites database.

  • The CGI path appropriate for the application server software installed on the server. For WebLogic and WebSphere this path is /servlet/.

  • The name of the ContentServer servlet.

For example:

xmlpost.url: http://servername/servlet/ContentServer

xmlpost.logfile

Optional.

The name of the file to log the results of importing (posting) each source file.

Each source file is posted to the WebCenter Sites database through a post request. When the post request returns from the web server, XMLPost parses the HTML stream that the web server returned, searching for the postsuccess and postfailure parameters. XMLPost then writes the result to the file that you name identify with this parameter.

For example:

xmlpost.logfile: ArticlePost.txt

xmlpost.success

Optional.

The string to look for in the response to determine if the post was a success.

For example:

xmlpost.success: Success!

xmlpost.failure

Optional.

The string to look for in the response to determine if the post was a failure.

For example:

xmlpost.failure: Error

xmlpost.deletefile

Optional.

Whether to delete the source files after they have been successfully imported into the WebCenter Sites database. Valid settings are y (yes) or n (no). By default, the source files are not deleted.

For example:

xmlpost.deletefile: y

Configuration Properties for the Posting Element

This table lists the arguments that specify information that must be posted to the RemoteContentPost page (and passed to the RemoteContentPost element). The values of these arguments are concatenated into the URL that is posted to the RemoteContentPost page. These arguments can be in any order in the configuration file.

Table 31-2 Configuration Properties for the Posting Element

Property Description

xmlpost.numargs

Required.

The page name is the primary variables out of several required variables that the configuration file passes to XMLPost as name/value pairs attached to the URL. Use this property (xmlpost.numargs) to tell XMLPost how many variables the configuration file is passing in.

For example:

xmlpost.numargs: 7

Note that you can also specify your own custom variables with these name/value pairs.

xmlpost.argname1: pagename

Required.

The pagename for the RemoteContentPost element. Typically the pagename argument is specified as xmlpost.argname1.

For example:

xmlpost.argname1: pagenamexmlpost.argvalue1: OpenMarket/Xcelerate/Actions/RemoteContentPost

xmlpost.argname2: AssetType

Required.

The asset type of the assets that are defined in the source files. Typically, AssetType is specified as xmlpost.argname2.

For example:

xmlpost.argname2: AssetType

xmlpost.argvalue2: Collection

Note that the value for the AssetType argument must exactly match the table name of the table that holds assets of this type.

xmlpost.argname3: authusername

Required.

The user name that you want XMLPost to use to log in to the WebCenter Sites database into which you are importing the assets. Typically, authusername is specified as xmlpost.argname3.

For example:

xmlpost.argname3: authusername

xmlpost.argvalue3: editor

The user name that you specify must have permission to write to the table that holds assets of the type that you are importing. (That is, it must have the appropriate ACLs assigned to it.)

xmlpost.argname4: authpassword

Required.

The password for the user that XMLPost logs in as to the WebCenter Sites database into which you are importing the assets. Typically, authpassword is specified as xmlpost.argname4.

For example:

xmlpost.argname4: authpassword

xmlpost.argvalue4: xceleditor

xmlpost.argname5: xmlpostdebug

Optional

Whether to include debugging information with the results information that is written to the XMLPost log file identified with the xmlpost.logfile property.

You can set this property to any value. For example:

xmlpost.argname5: xmlpostdebug

xmlpost.argvalue5: on

Note: Be sure to include a value for the xmlpost.logfile property if you enable debugging.

xmlpost.argname6: inifile

Optional.

The name of the ini file to use when connecting to the WebCenter Sites database. Typically, inifile is specified as xmlpost.argname5.

For example:

xmlpost.argname6: inifile

xmlpost.argvalue6: futuretense.ini

xmlpost.argname7: publication

Optional.

Although using this property is optional, you must specify a site for each asset that you are importing.

If your system uses one content management site (publication), or if all assets of this type should be enabled on the same site, use this argument to set the name of the site.

For example:

xmlpost.argname7: publicationxmlpost.argvalue7: Fiscal News

You must specify the value for site for each asset in the individual source files when using multiple content management sites.

xmlpost.argname8:startmenu

Optional.

If you are using workflow and you want the same workflow assigned to all of the assets that you are importing, use this argument to set the Start Menu shortcut for the assets. (It is a Start Menu shortcut that assigns a workflow ID to a new asset.)

For example:

xmlpost.argname8: startmenu

xmlpost.argvalue8: New Article

If you have multiple workflows for assets of this type, you must specify the value for the Start Menu shortcut for each asset in the individual source files.

Configuration Properties for the Source Files

The source file section in a configuration file specifies which tags are used in the source files. A tag represents a column name in the table that holds assets of this type. The content between a pair of tags is the information that is to be written to that column. Configuration files must list a tag for each column in the asset type's primary storage table, which is why you must provide a separate configuration file for each asset type.

This section includes the following topics:

Site Properties

In addition to the tags available for your asset types, The following table describes more tags that let you specify the sites an asset should be associated with and the workflow it should use.

Table 31-3 Site Properties

Site tag property Value Description

postpublication

y or n

(yes or no)

Optional.

Specifies that a source file will provide a site name that identifies which site the asset belongs to.

For example:

postpublication: y

Note that a site (publication) value provided in a source file with the publication tag overrides the value specified for a publication argument in the XMLPost section of the configuration file.

postprimarypubid

y or n

(yes or no)

Optional.

Specifies that a source file will provide a value for pubid (a unique ID for the site) that identifies which site the asset belongs to.

For example:

postprimarypubid: y

postpublist

y or n

(yes or no)

Optional.

Specifies that a source file will provide a list of sites that the asset is shared with.

For example:

postpublist: y

poststartmenu

y or n

(yes or no)

Optional.

Specifies that a source file will provide a value for the Start Menu short cut that places the asset into a workflow process.

For example:

poststartmenu: y

When the site or the workflow is the same for all of the assets that you are importing, specify the value for site or workflow as an argument in the XMLPost section of the configuration file. That way, you do not have to duplicate the same information in all of the source files.

Asset Type Properties

To set up the tags that are specific to your asset types, you specify a tag for each column in the database table for assets of that type. However, the source files are not required to include data tagged with every tag in the configuration file. (Of course, they must include data for required fields.)

For each tag representing a field (column), you specify the name of the tag and optionally some additional processing properties for the tag. The name of the tag is the name of the field (column). For the additional properties, the convention is a word prepended to the name of the tag.

This table describes how to specify the tags that are specific to your asset types:

Table 31-4 Asset Type Properties

Tag property Value Description

posttagname

y or n

(yes or no)

Required.

Specifies the name of the tag. The name should exactly match the name of the field that it represents.

For example, the tag property for a name field is:

postname: y

trunctagname

N

(integer)

Optional.

Whether to truncate the data in the source file marked by this tag.

For example:

truncname: 64

If XMLPost finds a string in the <name> tag that exceeds 64 characters, it shortens it to 64 characters and stores the truncated string in the variable.

notrimtagname

y or n

(yes or no)

Optional.

Whether to trim the white space at the beginning or end of the tag.

To keep the white space, set this property to y (yes).

For example:

notrimname: y

Leave it blank to let XMLPost trim the white space for the tag by default.

multitagname

combine

or

separate

Required if the same tag is used more than once in a single source file.

Determines how many variables to use for the data when a tag is used more than once in the source file.

Set it to combine, to store the data from all of the tags in the same variable with commas separating each value (a comma delimited string).

Set it to separate, to store the data from each tag in a separate variable. Those variables are identified by appending the value that you set for seedtagname to the variable name.

For example, for a keyword field (column):

  • If you set multikeyword: combine, XMLPost stores all the values marked by a keyword tag to the same keyword variable.

  • If you set multikeyword: separate and seedkeyword: 1, XMLPost stores each value in a separate variable. The first value it finds is stored in a variable named keyword1. The second value is stored in a variable named keyword2, and so on.

seedtagname

seed value

Required when multitagname is set to separate.

The number to start at when XMLPost increments the suffix assigned to variable names, when a tag is used more than once and you do not want the data contained in those tags written to the same variable. See the description of multitagname.

For example:

multikeyword: separate

seedkeyword: 1

filetagname

y or n

(yes or no)

Required if the tag represents an upload field (a URL column or BLOB).

If the tag represents a field that has a URL column, you must include this property and the source file must specify the name of the file that RemoteContentPost is to upload to that column.

For example, an imagefile asset type has an upload field named urlpicture. A configuration file for the imagefile asset type will contain the following properties:

posturlpicture: y

fileurlpicture: y

Then, in the source file for an imagefile asset, you specify the value for the urlpicture field like this:

<urlpicture>relative_path_to/filename.jpg

</urlpicture>

Note that you must specify the location of the file with a relative path (relative to the directory in which you are running the XMLPost utility).

Sample XMLPost Configuration File

Here is a sample configuration file named imagefile.ini, used to import imagefile assets for a site named Fiscal News.

xmlpost.xmlfilenamefilter: xml
#xmlpost.xmlproxypost: Future
#xmlpost.xmlproxyport: 80
xmlpost.url: http://localhost/servlet/ContentServer
xmlpost.numargs: 6
xmlpost.argname1: pagename
xmlpost.argvalue1: OpenMarket/Xcelerate/Actions/RemoteContentPost
xmlpost.argname2: AssetType
xmlpost.argvalue2: ImageFile
xmlpost.argname3: authusername
xmlpost.argvalue3: user_author
xmlpost.argname4: authpassword
xmlpost.argvalue4: user
xmlpost.argname5: inifile
xmlpost.argvalue5: futuretense.ini
xmlpost.argname6: publication
xmlpost.argvalue6: FiscalNews

xmlpost.success: Success
xmlpost.failure: Error
xmlpost.logfile: ImageFilePost.txt

postpublication: y
postprimarypubid: y
postpublist: y

postcategory: y
truncategory: 4

postpath: y
truncpath: 255

postname: y
truncname: 32

posttemplate: y
trunctemplate: 32

postsubtype: y
truncsubtype: 24

postfilename: y
truncfilename: 64

poststartdate: y

postdescription: y
truncdescription: 128

postsource: y

posturlpicture: y
fileurlpicture: y

posturlthumbnail: y
fileurlthumbnail: y

postmimetype: y
postwidth: y
postheight: y
postalign: y
postalttext: y

postkeywords: y
multikeywords: combine
trunckeywords: 128

postimagedate: y

Using XMLPost Source Files

Source files must be made up of well-formed XML without the need for a document type definition (DTD) file. Actually, the configuration file functions something like a DTD file—it defines the tags that are processed in the source files.

The data in your source files must be tagged with tags whose names match the column names for the table that holds assets of that type. For example, a source file for an imagefile asset uses tags named name, caption, picutureurl, and so on.

This section describes what needs to be in your source files and what XMLPost does with them. It does not describe how to automate the generation of your XML source files. How you create your source files depends on the source of your data and the tools that you have to convert your data into XML files.

This section includes the following topics:

Sample XMLPost Source File

Here is a sample source file for an imagefile asset. Its tags are defined in the sample configuration file in Sample XMLPost Configuration File.

<document>
<name>High Five 25</name>
<keyword>Five</keyword>
<category>a</category>
<artist>by Ann. Artist</artist>
<alttext>Congratulations</alttext>
<align>CENTER</align>
<caption>A man extends <keyword>congratulations</keyword> with a boy.</caption>
<pictureurl>/images/eZine/highfive.jpg</pictureurl>
</document>

How the Data is Passed (Posted)

All of the text contained between a pair of XML tags in a source file is passed to the RemoteContentPost element from XMLPost as a variable that uses the Variables.tagname syntax convention.

For example, this line of code:

<name>High Five 25</name>

is sent to RemoteContentPost as Variables.name and the value of name is the string High Five.

XMLPost and File Encoding

When the source file data doesn't use the WebCenter Sites system's default file encoding but the database can accommodate that character set, specify the alternate file encoding in the XML version statement at the beginning of the file. For example:

<?xml version= "1.0" encoding="UTF-8" ?>

Using the XMLPost Utility

You can invoke the XMLPost utility from the command line, or from a script or batch file, or from a program.

No matter how you start XMLPost, you must provide the following information:

  • The name of the configuration file to use

  • The source files, which can be specified as a single file, a list of files, or a directory of files

See these topics:

Before You Begin

  • Before you can use the XMLPost utility, the following must be true:

    • Your asset types are created. (Otherwise, there are no database tables to import the assets into.)

    • Your content management sites are created and the appropriate asset types are enabled for each site.

    • If you are using workflow, your workflow processes are created.

    • Your Start Menu shortcuts are created and, if you are using workflow, they assign the appropriate workflow process to the appropriate asset types.

    • The templates for the asset type are created.

    • The association fields for the asset types are created. However, custom code is required to set the value of an association field using XMLPost. See Customizing RemoteContentPost and PreUpdate.

  • When invoking XMLPost, include the following command before the classpath to ensure UTF-8 encoding: -Dfile.encoding=UTF-8.

    Note:

    • Check all .jar files for version number, which can differ from one WebCenter Sites patch to the next.

    • When creating a file encoded with UTF-8 for XML Post imports, ensure that it is created without BOM because the use of a BOM is neither required nor recommended for UTF-8. However, the use of BOM may be encountered where UTF-8 data is converted from other encoding forms that use BOM, or where BOM is used as a UTF-8 signature.

Running XMLPost from the Command Line

To run XMLPost:

  1. Place the configuration file and source files in a directory on a system that has WebCenter Sites installed.
  2. To get XMLPost up and running, set the following directories to classpath: <ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\*, <ORACLE_HOME>\oracle_common\modules\clients\*, <ORACLE_HOME>\oracle_common\modules\thirdparty\*, and <ORACLE_HOME>\wcsites\wcsites_common\lib\*.
  3. Run the following command (on a single command line) from that directory.

    This example uses Windows syntax, for UNIX-based systems including Linux and Solaris, the forward-slash (/) and colon (:) should be used as separators:

    Note:

    You are no longer allowed to give user credentials in the ini file. Only way you can provide them now is via command line.

    java -Xmx512m -Dfile.encoding=UTF-8 -Dhttpclient=true -classpath
    <ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\*;
    <ORACLE_HOME>\oracle_common\modules\clients\*;
    <ORACLE_HOME>\oracle_common\modules\thirdparty\*; 
    <ORACLE_HOME>\wcsites\wcsites_common\lib\*;
    <cs_app_dir>\WEB-INF\lib\servlet-api.jar;
    <Sites WLS Domain>\wcsites\wcsites\config\*
    COM.FutureTense.XML.Post.XMLPostMain -sSourcefile.xml -cConfigfile.ini
    -ufwadmin -pxceladmin 

    where:

    • -Xmx512m sets the maximum memory to use, which is needed with larger inserts.

    • <cs_app_dir> is the directory on your application server where the WebCenter Sites application has been deployed.

    Note that there are several options for designating the source file. See Identifying Source Files for information.

Note:

The j2ee.jar file is part of the J2EE SDK. You must install the SDK before running XMLPost.

In the command line, provide the path to the source files and configuration file that are not in the working directory. For example: -s/products/product.xml.

Identifying Source Files

The source parameter that you use to identify the source files to the XMLPost utility can point to any of the following:

  • A single file.

  • A directory of files. All the files in that directory that have the file extension (typically .xml) designated by the configuration file will be posted (imported).

  • A list file that provides a list of all the files that you want to import. It is similar to an .ini file but it has a file extension of .lst.

A Single File

To post the contents of one file, specify the name of that file in the command line. The following example instructs XMLPost to use a configuration file named articlepost.ini and one source file named article.xml.

This example uses Windows syntax, for UNIX-based systems including Linux and Solaris, the forward-slash (/) and colon (:) should be used as separators:

java -Xmx512m -Dfile.encoding=UTF-8 -Dhttpclient=true -Dsites.config=<Sites WLS Domain>\wcsites\wcsites\config -classpath  
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\apache-mime4j-0.5.jar; 
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\commons-codec-1.7.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\commons-fileupload-1.3.1.jar; 
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\commons-lang-2.5.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\commons-lang3-3.1.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\commons-logging-1.1.3.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\esapi-2.0.1.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\httpclient-4.3.6.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\httpcore-4.3.3.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\httpmime.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\log4j-1.2.17.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\sites-cache.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\sites-core.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\sites-cs.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\sites-msxml.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\sites-nio.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\sites-security.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\spring-beans-3.2.6.RELEASE.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\spring-context-3.2.6.RELEASE.jar; 
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\spring-core-3.2.6.RELEASE.jar; 
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\spring-expression-3.2.6.RELEASE.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\spring-web-3.2.6.RELEASE.jar;
<ORACLE_HOME>\oracle_common\modules\clients\com.oracle.jersey.fmw.client.jar; 
<ORACLE_HOME>\oracle_common\modules\clients\com.oracle.webservices.fmw.client.jar

COM.FutureTense.XML.Post.XMLPostMain -sSourcefile.xml -cConfigfile.ini
-ufwadmin -pxceladmin
A Directory of Files

To post all the files in a directory, specify the path to that directory in the command line. The following example instructs XMLPost to import the files in the xmlpostfiles directory.

This example uses Windows syntax, for UNIX-based systems including Linux and Solaris, the forward-slash (/) and colon (:) should be used as separators:

java -Xmx512m -Dfile.encoding=UTF-8 -Dhttpclient=true -Dsites.config=<Sites WLS Domain>\wcsites\wcsites\config -classpath  
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\apache-mime4j-0.5.jar; 
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\commons-codec-1.7.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\commons-fileupload-1.3.1.jar; 
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\commons-lang-2.5.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\commons-lang3-3.1.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\commons-logging-1.1.3.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\esapi-2.0.1.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\httpclient-4.3.6.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\httpcore-4.3.3.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\httpmime.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\log4j-1.2.17.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\sites-cache.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\sites-core.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\sites-cs.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\sites-msxml.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\sites-nio.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\sites-security.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\spring-beans-3.2.6.RELEASE.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\spring-context-3.2.6.RELEASE.jar; 
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\spring-core-3.2.6.RELEASE.jar; 
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\spring-expression-3.2.6.RELEASE.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\spring-web-3.2.6.RELEASE.jar;
<ORACLE_HOME>\oracle_common\modules\clients\com.oracle.jersey.fmw.client.jar; 
<ORACLE_HOME>\oracle_common\modules\clients\com.oracle.webservices.fmw.client.jar

COM.FutureTense.XML.Post.XMLPostMain -sxmlpostfiles -carticlepost.ini -ufwadmin -pxceladmin
A List File

As an alternative to specifying a directory, you can create a list file that uses the format of an .ini file and includes the following properties:

  • numfiles, which specifies how many files are included in the list.

  • fileN, which specifies the path to a file and its file name. The N stands for the file's order in the list file. The first file listed is file1, the second is file2, and so on.

    The value of N for the last fileN in the list must match the value specified by the numfiles property. XMLPost stops importing when it has imported as many files as it is told to expect by the numfiles property. XMLPost does not import more files than numfiles states.

The file extension for a list file must be .lst.

The following sample list file is named xmlpostfiles.lst:

numfiles: 3
file1: c:\xmlpost\article1.xml
file2: c:\xmlpost\article2.xml
file3: c:\xmlpost\article3.xml

To post the files referenced in this file list, specify the name of the list file in the command line. The following example instructs XMLPost to import the files specified in the xmlpostfiles.lst file.

This example uses Windows syntax, for UNIX-based systems including Linux and Solaris, the forward-slash (/) and colon (:) should be used as separators:

java -Xmx512m -Dfile.encoding=UTF-8 -Dhttpclient=true -Dsites.config=<Sites WLS Domain>\wcsites\wcsites\config -classpath  
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\apache-mime4j-0.5.jar; 
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\commons-codec-1.7.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\commons-fileupload-1.3.1.jar; 
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\commons-lang-2.5.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\commons-lang3-3.1.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\commons-logging-1.1.3.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\esapi-2.0.1.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\httpclient-4.3.6.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\httpcore-4.3.3.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\httpmime.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\log4j-1.2.17.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\sites-cache.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\sites-core.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\sites-cs.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\sites-msxml.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\sites-nio.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\sites-security.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\spring-beans-3.2.6.RELEASE.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\spring-context-3.2.6.RELEASE.jar; 
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\spring-core-3.2.6.RELEASE.jar; 
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\spring-expression-3.2.6.RELEASE.jar;
<ORACLE_HOME>\wcsites\webcentersites\sites-home\lib\spring-web-3.2.6.RELEASE.jar;
<ORACLE_HOME>\oracle_common\modules\clients\com.oracle.jersey.fmw.client.jar; 
<ORACLE_HOME>\oracle_common\modules\clients\com.oracle.webservices.fmw.client.jar

COM.FutureTense.XML.Post.XMLPostMain-sc:\xmlpostfiles.lst -carticlepost.ini -ufwadmin -pxceladmin

Running XMLPost as a Batch Process

When you import assets of multiple types, identify a unique configuration file for each asset type by running XMLPost individually for each type. You can run XMLPost either manually, or automatically from a batch file. In the batch file, include a command line statement for each asset type (the statement identifies the configuration file and the location of the source files). You can use any of the ways described in the preceding section to identify the source files.

Running XMLPost Programmatically

You can also invoke the XMLPost utility programmatically by creating an XMLPost object and calling the doIt method doIt(String[] args), where the input is a string array. The elements of the array are the same flags that you use when running XMLPost from the command line.

For example:

String args [] = {"-sSourcefile.xml","-cConfigfile.ini"};
COM.FutureTense.XML.Post.XMLPost poster = new
COM.FutureTense.XML.Post.XMLPost();
try {
  poster.doIt(args);
  } catch (Exception e) {
  e.printStackTrace();("error in XMLPost under program control");
}

Note that you must include the complete path to source files and configuration file.

Customizing RemoteContentPost and PreUpdate

If necessary, you can customize the XMLPost process by adding or modifying code in the RemoteContentPost element or the PreUpdate element for your asset types.

To import information about an asset to other tables, you must modify the PreUpdate element for that asset type.

This section provides two customization examples:

  • Customizing the PreUpdate element for the Article asset type so that it sets headline information in the description field. There is a description column in the Article table but the field in the New or Edit article form is called Headline.

  • Customizing the PreUpdate element for the Article asset type so that it can add associations to articles.

See these topics:

Setting a Field Value Programmatically

The article asset type has a field in the New and Edit forms called Headline, whose value is stored in the description column in the Article table. In order for headline text to be written to the correct column, when an Article asset is imported (that is, the description column), the PreUpdate element for the Article asset type is modified.

First, examine the sample configuration file named ArticlePost.ini that is located in the Xcelerate/Samples/XMLPost directory in your WebCenter Sites product kit. It has a tag specified for the Headline field:

# headline gets stored in the description field
postheadline: y

The following code in the PreUpdate element for the Article asset type writes the data that RemoteContentPost passes in as Variable.headline to the correct database column:

<if COND="IsVariable.headline=true">
  <then>
    <ASSET.SET NAME="theCurrentAsset" 
     FIELD="description" 
     VALUE="Variables.headline"/>
  </then>
</if>

This example uses a tag called ASSET.SET. This tag sets data in a field for the asset that is currently in memory. It takes three parameters:

  • NAME: (required). The name of the asset object that is in memory. This asset object must have been previously instantiated either with the ASSET.LOAD tag or the ASSET.CREATE tag. By convention, WebCenter Sites uses the name theCurrentAsset to refer to the current asset object.

  • FIELD: (required). The name of the field whose value you want to set. The name of this field must exactly match the name of a column in the storage table for assets of this type.

  • VALUE: (required). The data to be inserted in the column.

Setting an Asset Association

The information about association between assets is written to the AssetRelationTree table. Because the standard behavior of XMLPost is to write asset information to the primary storage table of the asset type only, you must modify the PreUpdate element for the asset type to specify asset associations. For example, the Article asset type has an association field named MainImageFile. When a content provider creates an article asset, she selects the appropriate imagefile asset in this field.

Examine the sample configuration file named ArticlePost.ini that is located in the Xcelerate/Samples/XMLPost directory in your WebCenter Sites product kit. It has a tag specified for the MainImageFile association field:

postMainImageFile-name: y

The following code in the PreUpdate element for the article asset type writes the data that RemoteContentPost passes in as Variable.mainimagefile to the correct database table:

<if COND="IsVariable.MainImageFile-name=true">
<then>
 <ASSET.LOAD NAME="anAssociatedImage" TYPE="ImageFile"
  FIELD="name" VALUE="Variables.MainImageFile-name"/>
  <if COND="IsError.Variables.errno=false">
    <then>
      <ASSET.GET NAME="anAssociatedImage" FIELD="id" OUTPUT="imageid"/>
      <ASSET.ADDCHILD NAME="theCurrentAsset" TYPE="ImageFile"
       CHILDID="Variables.imageid" CODE="MainImageFile"/>
    </then>
  </if>
</then>
</if>

Note:

The ASSET.ADDCHILD tag creates only the link between the two assets. It does not create the associated asset. In order for this code to work, the asset specified with the CHILDID parameter must exist in the WebCenter Sites database.

This example uses a tag named ASSET.ADDCHILD. This tag associates a child asset with the asset that is currently held in memory. It takes five parameters:

  • NAME (required). The name of the asset object that is in memory. This asset object must have been previously instantiated either with the ASSET.LOAD tag or the ASSET.CREATE tag. By convention, WebCenter Sites uses the name theCurrentAsset to refer to the current asset object.

  • TYPE (required). The asset type of the child asset.

  • CHILDID (required). The ID of the child asset.

  • CODE (optional). The name of the association. This value is written to the ncode column in the AssetRelationTree table.

  • RANK (optional). A numeric value to establish an order for the child assets. This value is written to the nrank column in the AssetRelationTree table.

For information about ASSET.GET and ASSET.LOAD, see the Tag Reference for Oracle WebCenter Sites Reference.

Troubleshooting XMLPost

Sometimes XMLPost doesn’t run, and it doesn’t create a log file. Sometimes, when you’re trying to save an asset, the error 105 is triggered. Read further to know more about XMLPost errors and debugging the Posting element.

This is a brief list of some possible problems that can occur when you run the XMLPost utility.

XMLPost Does Not Run and Does Not Create a Log File Message

There are two possible reasons for XMLPost to not start:

  • An invalid server name has been specified in the xmlpost.URL property setting in your configuration file.

  • WebCenter Sites is not running on the system you are importing to. Start it.

XMLPost Fails and there is a Missing Entity Statement in the Log File

This message means that there is invalid XML in the source file. Typically, your XML includes HTML code and that code includes special HTML characters that are not referred to by their character entity codes. For best coding practice, embed any HTML code in a <![CDATA[...]]> tag.

Error 105 is Triggered when XMLPost Tries to Save an Asset

There are several reasons why saving an asset can cause a database error. One common reason for a 105 error is XMLPost trying to save data that is too large for the column (field). Resolving this depends on your goals. If it is acceptable for XMLPost to truncate the data that doesn't fit into the column, you can add a trunctag property to the configuration file. For example, truncbody: 2000.

Another common reason for this error code is that an asset of that type with the same name exists. Try changing the name of the asset and importing the asset again.

Debugging the Posting Element

Use the XML Debugger utility to test the RemoteContentPost element if you have modified it or created your own posting element. To use XML Debugger, replace ContentServer with DebugServer in the xmlpost.url property setting. For example, change xmlpost.url: http://6ipjk/servlet/ContentServer to xmlpost.url: http://6ipjk/servlet/DebugServer

See XML Debugger utility in Introducing WebCenter Sites Tools and Utilities.