The folder and content item descriptors must define properties that represent the name or path of the items. These properties need to be mapped directly to columns of the database so that queries can be performed against them.

You can use one of three different techniques to specify how path information is stored in the database:

Regardless of how you store path information in the database, you can get the path of an item with this method in the atg.repository.content.FolderItem interface (which is extended by the ContentRepositoryItem interfaces):

public String getItemPath()

This method returns the path of this item, represented as a relative path from the repository’s root folder

use-id-for-path

This is the simplest mechanism. In this mode, the relative path name of the item is used as the ID of the repository item. Your database must then include an ID column that is a string large enough to hold the entire relative path name of each folder item and content item. Put this ID column in your primary table and set the id-column-name attribute of the primary table to point to this column. You then set use-id-for-path="true" for that item descriptor. For example:

<item-descriptor name="folder" folder="true"
  use-id-for-path="true" folder-id-property="folder-id">
    <table name="folder" id-column-name="id">
      <property name="id" column-names="id"/>
      <property name="folder-id" column-names="folder_id"/>
...
    </table>
</item-descriptor>
<item-descriptor name="article" content="true"
  use-id-for-path="true" folder-id-property="folder-id">
    <table name="articles" id-column-names="id">
      <property name="id" column-names="id"/>
      <property name="folder-id" column-names="folder_id"/>
...
    </table>
</item-descriptor>

The use-id-for-path mode may not work if you have an existing database schema that does not follow this format. This approach also might not work if path names in your repository could be longer than the size of varchar you can efficiently store and query against in your database. Some databases impose a 255-character limit on the size of queryable columns. This may be too small to hold the entire path for some content repositories.

Note that even though you put the entire path name in the property designated by the id-column-names attribute, you still need to use the folder-id-property attribute to designate a property that holds the name of the parent folder of the item. In the preceding example, the folder-id property holds the name of the folder.

content-name-property

You can set the item descriptor’s content-name-property attribute. In this case, you can store just the name of the repository item itself (rather than the entire path name) in one property of the repository item and use the content-name-property to designate the name of this property. The content-name-property specifies the property representing the name of the folder item or content item, while the folder-id-property specifies the property representing the parent folder of the folder item or content item. From these two pieces of information, we can compute the path for a given item by walking up the content hierarchy.

The operation of computing the path for this item will be more expensive in this mode, since we have to query up the folder hierarchy to compute the path for an item rather than getting the path from a single property. However, this mode can overcome the problem of the size limitation on queryable columns. Now your column size for the content name limits the size of each individual component of the file name, not the size of the entire path.

A folder-id-property is required for all content repositories, whichever method they use to specify how path information is stored in the database. The data-type of the folder-id-property can be either data-type="string" (or whatever type you define your repository IDs to be), or you can specify that its item-type is the name of the folder item descriptor. This enables you to conveniently access folder information from the item itself. For example:

<item-descriptor name="folder" folder="true"
  content-name-property="filename" folder-id-property="folder-id">
    <table name="folder" id-column-names="id">
      <property name="filename" data-type="string"/>
      <property name="folder-id" item-type="folder"/>
...
    </table>
</item-descriptor>

Since this content-name property is not guaranteed to be unique across the repository, you have a separate column for the ID of this repository

content-path-property

You might not be able to use the repository item’s path as its repository ID. If that is the case, perhaps due to references to these rows from other tables, and if you can store the entire path name of the item as a column in your table, then you can use a third alternative. In this mode, you can set the content-path-property to refer to a property that holds the path name of the item. You would then use a separate property and column in your table to refer to the ID for this item. For example:

<item-descriptor name="folder" folder="true"
  content-path-property="pathname">
    <table name="folder" id-column-names="id">
      <property name="id" data-type="long"/>
      <property name="pathname" data-type="string"/>
...
    </table>
</item-descriptor>
 
loading table of contents...