The atg.repository.RepositoryUtils class includes a method you can use to clone a repository item. This creates a copy of a repository item in a repository without adding the item to the repository. A copy can be a deep copy or a shallow copy. Furthermore, you can specify a list of properties to exclude from the copy.

The full signature of the cloneItem method is:

public static MutableRepositoryItem cloneItem(RepositoryItem pItem,
                                              boolean pDeepCopy,
                                              Map pPropExceptions,
                                              Map pExcludedProperties,
                                              MutableRepository pDestRepository,
                                              String pId)
                                       throws RepositoryException,
                                              DuplicateIdException

The cloneItem method’s parameters are as follows:

Parameter

Description

pItem

Item to copy.

pDeepCopy

Boolean, specifies the mode of the copy:

true: The method creates a deep copy of the item and its properties.

false: The method creates a shallow copy, only getting references of child RepositoryItems.

Shallow copying only works if the source and destination repositories are the same.

pPropExceptions
(optional)

Hierarchical map of property name exceptions to the above mode. Keys are property names, while values are null or, if the property is another repository item, another Map. For example, if you clone a product item using pDeepCopy=true, you can add the key parentCategory with a null value into pPropExceptions. This results in a shallow copy of the product.parentCategory.

Alternatively, you can add the key parentCategory but set the value to another map of exceptions that included the key/value pair keywords=null. This results in a deep copy of product.parentCategory but a shallow copy of the product.parentCategory.keywords.

pExcludedProperties
(optional)

Properties to exclude from the clone. Keys are item descriptor names and the values are collections of property names to exclude..

pDestRepository
(optional)

Repository to copy the new item into. If the source and destination repositories are the same, properties that are items are cloned to the repository of the source item-property.

If this parameter is omitted, the new item is copied to source repository.

pId
(optional)

Repository ID to use in the copy of the item. If this parameter is omitted, a unique ID is automatically generated.


Copyright © 1997, 2013 Oracle and/or its affiliates. All rights reserved. Legal Notices