After you have determined your data design, created your asset types, tested them on your development system, and moved them to your management system, the next step is to import assets (content) from their current source in to the database on the management system.For example, you could be using a wire feed service or some other source of remotely generated content, and need to import that content into the WebCenter Sites database on your management system.
To import any data into the WebCenter Sites database, you can use 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.
This chapter describes the general process of importing assets with the XMLPost utility. You use the information in this chapter for importing assets of all types. Chapter 21, "Importing Flex Assets,"provides additional information that you need to import your assets when you are using the flex asset data model.
This chapter contains the following sections:
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 Chapter 21, "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.
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, 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 can rename the RemoteContentPost
page to prevent attempts to hack into the system.
This section provides a brief overview of the steps that the developer completes before invoking the XMLPost utility and what the XMLPost utility does.
When you import assets into your WebCenter Sites database, you perform four general steps:
You 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 Chapter 21, "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.
You create the source files for the data that you want to import. Note that you create a separate source file for each individual asset.
You place the source and configuration files in a directory on the management system.
From that directory, you 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, this is what happens next, as shown in the following diagram and list of steps:
The XMLPost utility parses the configuration file.
XMLPost parses the source file and creates name/value pairs for each field value specified in the source file.
XMLPost invokes the FormPoster Java class by posting (HTTP POST) the name/value pairs as ICS variables to the page name passed in from the configuration file. When you are importing basic asset types, that pagename is:
OpenMarket/Xcelerate/Actions/RemoteContentPost
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
).
The RemoteContentPost
element passes the data from the source files as variables to the PreUpdate
element for assets of that type.
The PreUpdate
element for assets of that type sets the variable values for that asset and then returns to the RemoteContentPost
element.
The RemoteContentPost
element creates the asset.
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.
If the asset type of the asset that you are importing uses a search engine, RemoteContentPost
indexes the new element.
If you set a certain parameter in the configuration file, RemoteContentPost
deletes the source files for the assets that were successfully imported.
There are three types of properties in a configuration file for XMLPost:
Properties that provide information to XMLPost about the database and environment. These properties remain the same even if you create your own posting element.
Properties that provide configuration values for the posting (importing) process. This chapter describes the 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, if you have only one content management site or if all of the assets that you are importing belong to the same site, specify the name of the site in the configuration section so you do not have to repeat that information in each source file. If your system has more than one content management site, specify which sites an asset belongs to in the individual source files.
This section contains the following topics:
Section 20.2.2, "Configuration Properties for the Posting Element"
Section 20.2.3, "Configuration Properties for the Source Files"
The following table lists the properties that specify database connection information and other general configuration instructions that the XMLPost utility needs:
Table 20-1 Configuration Properties for XMLPost
Property | Description |
---|---|
|
Required. The file extension for your source files. Typically set to For example:
|
|
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:
|
|
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:
|
|
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 The value that you set for this property should use the following convention:
For example:
|
|
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 For example:
|
|
Optional. The string to look for in the response to determine if the post was a success. For example:
|
|
Optional. The string to look for in the response to determine if the post was a failure. For example:
|
|
Optional. Whether to delete the source files after they have been successfully imported into the WebCenter Sites database. Valid settings are For example:
|
The following 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; they can be in any order in the configuration file:
Table 20-2 Configuration Properties for the Posting Element
Property | Description |
---|---|
|
Required. There are several required variables that the configuration file passes to XMLPost as name/value pairs attached to the URL, the primary of which is the page name. Use this property ( For example:
Note that you can also specify your own custom variables with these name/value pairs. |
|
Required. The pagename for the For example:
|
|
Required. The asset type of the assets that are defined in the source files. Typically, For example:
Note that the value for the |
|
Required. The user name that you want XMLPost to use to log in to the WebCenter Sites database that you are importing the assets into. Typically, For example:
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.) |
|
Required. The password for the user that XMLPost logs in as to the WebCenter Sites database that you are importing the assets into. Typically, For example:
|
|
Optional Whether or not to include debugging information with the results information that is written to the XMLPost log file identified with the You can set this property to any value. For example:
Note: Be sure to include a value for the |
|
Optional. The name of the For example:
|
|
Optional. Athough 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:
If your system uses more than one content management site, you must specify the value for site for each asset in the individual source files. See Section 20.2.3, "Configuration Properties for the Source Files" for more information. |
|
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:
If you have more than one workflow for assets of this type, you must specify the value for the Start Menu shortcut for each asset in the individual source files. See Section 20.2.3, "Configuration Properties for the Source Files" for more information. |
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 contains the following topics:
In addition to the tags that pertain to your asset types, there are four tags that you can use with all asset types to specify certain site configuration properties, that is, which sites an asset should be associated with and which workflow it should use. This table lists the site tags:
Site tag property | Value | Description |
---|---|---|
|
(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 |
|
(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 |
|
(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 |
|
(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 |
Remember that if the site or the workflow is the same for all of the assets that you are importing, you can 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.
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.
The following table describes how to specify the tags that are specific to your asset types:
Table 20-4 Asset Type Properties
Tag property | Value | Description |
---|---|---|
|
(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:
|
|
(integer) |
Optional. Whether to truncate the data in the source file marked by this tag. For example:
By setting this property for the tag, if XMLPost finds a string in the |
|
(yes or no) |
Optional. Whether to trim the white space at the beginning or end of the tag. If you do not want the white space trimmed, set this property to For example:
If you do not specify this property, XMLPost trims the white space for the tag by default. |
|
or
|
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. If you set it to If you set it to For example, for a
|
|
|
Required when 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 For example:
|
|
(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 For example, the imagefile asset type from the Burlington Financial sample site has an upload field named
Then, in the source file for an imagefile asset, you specify the value for the
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). |
Here is a sample configuration file named imagefile.ini
, used to import imagefile assets for the Burlington Financial sample site.
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: BurlingtonFinancial 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
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 in that it defines the tags that will be 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 a Burlington Financial imagefile asset uses tags named name
, caption
, picutureurl
, and so on.
This chapter 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 chapter describes what needs to be in your source files and what XMLPost does with them.
This section contains the following topics:
Here is a sample source file for a Burlington Financial imagefile asset. Its tags are defined in the sample configuration file in Section 20.2.4, "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".
If the data in a source file does not use the WebCenter Sites system's default file encoding but the database can accommodate that character set, you can 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" ?>
You can invoke the XMLPost utility in one of many ways:
From the command line
From a script or batch file
From a program
No matter how you start XMLPost, you must provide the following pieces of 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
This section contains the following topics:
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, to use XMLPost to set the value of an association field requires custom code. See Section 20.5, "Customizing RemoteContentPost and PreUpdate" for more information.
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.
Complete the following steps:
Place the configuration file and source files in a directory on a system that has WebCenter Sites installed.
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:
java -Xmx512m -Dfile.encoding=UTF-8 -classpath <cs_app_dir>\WEB-INF\lib\apache-mime4j-0.5.jar; <cs_app_dir>\WEB-INF\lib\commons-lang-2.4.jar; <cs_app_dir>\WEB-INF\lib\commons-codec-1.4.jar; <cs_app_dir>\WEB-INF\lib\commons-logging-1.1.1.jar; <cs_app_dir>\WEB-INF\lib\cs.jar; <cs_app_dir>\WEB-INF\lib\cs-core.jar; <cs_app_dir>\WEB-INF\lib\httpclient-4.1.2.jar; <cs_app_dir>\WEB-INF\lib\httpcore-4.1.2.jar; <cs_app_dir>\WEB-INF\lib\httpmime-4.1.2.jar;< cs_app_dir>\WEB-INF\lib\MSXML.jar; <cs_app_dir>\WEB-INF\lib\servlet-api.jar; <cs_app_dir>\WEB-INF\lib\spring-2.5.5.jar; <cs_app_dir>\WEB-INF\lib\sites-security-11.1.1.8.0.jar; <cs_app_dir>\WEB-INF\lib\esapi-2.0.1.jar; <cs_app_dir>\WEB-INF\lib\log4j-1.2.16.jar;<j2eeSDK_dir>\j2ee.jar; <cs_app_dir>\WEB-INF\classes COM.FutureTense.XML.Post.XMLPostMain-sSourcefile.xml -cConfigfile.ini
where:
-Xmx512m
sets the maximum memory to use, which is needed with larger inserts
<cs_install_dir>
is the directory where WebCenter Sites is installed.
<cs_app_dir>
is the directory on your application server where the WebCenter Sites application has been deployed.
<j2eeSDK_dir>
is the directory where your J2EE SDK is installed.
Note that there are several options for designating the source file. See Section 20.4.3, "Options for Identifying Source Files" for information.
Note:
The j2ee.jar
file is part of the J2EE SDK. You must install the SDK before running XMLPost.
If the source files and configuration file are not in the directory that you are working in, you must provide the path to those files in the command line. For example: -s/products/product.xml
.
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
.
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 -classpath< cs_app_dir>\WEB-INF\lib\apache-mime4j-0.5.jar; <cs_app_dir>\WEB-INF\lib\commons-lang-2.4.jar; <cs_app_dir>\WEB-INF\lib\commons-codec-1.4.jar; <cs_app_dir>\WEB-INF\lib\commons-logging-1.1.1.jar; <cs_app_dir>\WEB-INF\lib\cs.jar; <cs_app_dir>\WEB-INF\lib\cs-core.jar; <cs_app_dir>\WEB-INF\lib\httpclient-4.1.2.jar; <cs_app_dir>\WEB-INF\lib\httpcore-4.1.2.jar; <cs_app_dir>\WEB-INF\lib\httpmime-4.1.2.jar; <cs_app_dir>\WEB-INF\lib\MSXML.jar; <cs_app_dir>\WEB-INF\lib\servlet-api.jar; <cs_app_dir>\WEB-INF\lib\spring-2.5.5.jar; <cs_app_dir>\WEB-INF\lib\sites-security-11.1.1.8.0.jar; <cs_app_dir>\WEB-INF\lib\esapi-2.0.1.jar; <cs_app_dir>\WEB-INF\lib\log4j-1.2.16.jar;<j2eeSDK_dir>\j2ee.jar; <cs_app_dir>\WEB-INF\classes COM.FutureTense.XML.Post.XMLPostMain-sarticle.xml -carticlepost.ini
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 -classpath <cs_app_dir>\WEB-INF\lib\apache-mime4j-0.5.jar; <cs_app_dir>\WEB-INF\lib\commons-lang-2.4.jar; <cs_app_dir>\WEB-INF\lib\commons-codec-1.4.jar; <cs_app_dir>\WEB-INF\lib\commons-logging-1.1.1.jar; <cs_app_dir>\WEB-INF\lib\cs.jar; <cs_app_dir>\WEB-INF\lib\cs-core.jar; <cs_app_dir>\WEB-INF\lib\httpclient-4.1.2.jar; <cs_app_dir>\WEB-INF\lib\httpcore-4.1.2.jar; <cs_app_dir>\WEB-INF\lib\httpmime-4.1.2.jar; <cs_app_dir>\WEB-INF\lib\MSXML.jar; <cs_app_dir>\WEB-INF\lib\servlet-api.jar; <cs_app_dir>\WEB-INF\lib\spring-2.5.5.jar; <cs_app_dir>\WEB-INF\lib\sites-security-11.1.1.8.0.jar; <cs_app_dir>\WEB-INF\lib\esapi-2.0.1.jar; <cs_app_dir>\WEB-INF\lib\log4j-1.2.16.jar;<j2eeSDK_dir>\j2ee.jar; <cs_app_dir>\WEB-INF\classes COM.FutureTense.XML.Post.XMLPostMain-sxmlpostfiles -carticlepost.ini
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.
file
N, 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 file
N 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. If you have included more files than numfiles
states, XMLPost does not import them.
The file extension for a list file must be .lst
.
Here is an example list file, 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 -classpath< cs_app_dir>\WEB-INF\lib\apache-mime4j-0.5.jar; <cs_app_dir>\WEB-INF\lib\commons-lang-2.4.jar; <cs_app_dir>\WEB-INF\lib\commons-codec-1.4.jar; <cs_app_dir>\WEB-INF\lib\commons-logging-1.1.1.jar; <cs_app_dir>\WEB-INF\lib\cs.jar; <cs_app_dir>\WEB-INF\lib\cs-core.jar; <cs_app_dir>\WEB-INF\lib\httpclient-4.1.2.jar; <cs_app_dir>\WEB-INF\lib\httpcore-4.1.2.jar; <cs_app_dir>\WEB-INF\lib\httpmime-4.1.2.jar; <cs_app_dir>\WEB-INF\lib\MSXML.jar; <cs_app_dir>\WEB-INF\lib\servlet-api.jar; <cs_app_dir>\WEB-INF\lib\spring-2.5.5.jar; <cs_app_dir>\WEB-INF\lib\sites-security-11.1.1.8.0.jar; <cs_app_dir>\WEB-INF\lib\esapi-2.0.1.jar; <cs_app_dir>\WEB-INF\lib\log4j-1.2.16.jar;<j2eeSDK_dir>\j2ee.jar; <cs_app_dir>\WEB-INF\classes COM.FutureTense.XML.Post.XMLPostMain-sc:\xmlpostfiles.lst -carticlepost.ini
When you want to import assets of more than one type, you must identify a unique configuration file for each asset type and therefore run XMLPost individually for each asset 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.
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 the source files and the configuration file.
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.
If you want 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.
This section contains the following topics:
The article asset type has a special condition: it has a field in the New and Edit forms called Headline, but the value for Headline is stored in the description
column in the Article
table. In order for headline text to be written to the correct column in the Article
table when an article asset is imported (that is, the description
column), the PreUpdate
element for the article asset type was 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.
If an asset has an association with another asset, that information 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 if you want 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 already 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 Oracle Fusion Middleware WebCenter Sites Tag Reference.
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
When you see this message in the log file, it 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 trunc
tag 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 already exists. Try changing the name of the asset and importing the asset again.
If you have modified the RemoteContentPost
element in any way or have created your own posting element, you can use the XML Debugger utility to test it before you use it.
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
For more information about the XML Debugger utility, see Chapter 8, "WebCenter Sites Tools and Utilities."