|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectatg.repository.RepositoryUtils
public class RepositoryUtils
This utility class is home to methods that can be used to operate against repositories, repository items and properties.
Nested Class Summary | |
---|---|
static interface |
RepositoryUtils.RepositoryPropertyCallback
Return repository property callback. |
static class |
RepositoryUtils.Service
A generic service to expose the repository callbacks to Nucleus. |
Field Summary | |
---|---|
static java.lang.String |
CLASS_VERSION
Class version string |
Constructor Summary | |
---|---|
RepositoryUtils()
|
Method Summary | |
---|---|
protected static void |
addItemDescriptors(RepositoryItemDescriptor pDescriptor,
java.util.Collection pItemDescriptors)
This method determines if the RepositoryItemDescriptor has any subtypes (if its a RepositoryItemDescriptorContainer) and then adds all subtype item-descriptors and the item-descriptor passed to this method to the collection of item-descriptors passed to this method. |
static void |
addRepositoryPropertyCallback(RepositoryUtils.RepositoryPropertyCallback pCallback)
Add the specified repository property callback. |
static boolean |
anyReferencesToItem(RepositoryItem pItem)
Query whether any cross-references to a repository item exist within the repository that contains that item. |
static java.lang.String |
buildUriForRepositoryItem(java.lang.String pRepositoryName,
java.lang.String pItemDescriptorName,
java.lang.String pRepositoryId)
Return a JNDI "atgrep:" URI given a repository name, an item descriptor, and a repository ID. |
static MutableRepositoryItem |
cloneItem(RepositoryItem pSource,
boolean pDeepCopy,
java.util.Map pPropExceptions,
java.util.Map pExcludedProperties,
MutableRepository pDestRepository,
java.lang.String pId)
Create a copy of a RepositoryItem in a repository without >adding the item. |
static MutableRepositoryItem |
cloneItem(RepositoryItem pSource,
boolean pDeepCopy,
java.util.Map pPropExceptions,
MutableRepository pDestRepository,
java.lang.String pId)
Create a copy of a RepositoryItem in a repository without >adding the item. |
static java.lang.String |
convertValueToString(DynamicPropertyDescriptor pPropDesc,
java.lang.Object pValue)
Converts an Object value with an optional property descriptor to a string value, which gets returned. |
static java.util.Collection<RepositoryItemDescriptor> |
getAllSubtypeItemDescriptors(atg.repository.RepositoryItemDescriptorContainer pItemDescriptor)
Returns a collection of item-descriptors that are subtypes of the item-descriptor passed to this method. |
static RepositoryItemDescriptor |
getBaseItemDescriptor(RepositoryItemDescriptor pItemDesc)
Return the base item descriptor, if one exists. |
static java.lang.String |
getItemDisplayPropertyName(RepositoryItemDescriptor pDesc)
Get the name of the display property for the given item descriptor, translating it using FirstWithLocale, if applicable and returning null if the property is not queryable. |
static java.lang.String |
getItemDisplayPropertyName(RepositoryItemDescriptor pDesc,
boolean pMustBeQueryable)
Get the name of the display property for the given item descriptor, translating it using FirstWithLocale, if applicable. |
static java.lang.String |
getItemDisplayPropertyPath(RepositoryItemDescriptor pDesc)
Get the DynamicBeans path of the display name property for the given item descriptor. |
static MutableRepositoryItem |
getMutableRepositoryItem(MutableRepository pRepository,
java.lang.String pItemId,
java.lang.String pItemType)
Get a mutable repository item based on the repository, item ID and item type provided. |
static MutableRepositoryItem |
getMutableRepositoryItem(RepositoryItem pItem)
Get a mutable version of the repository item provided. |
static RepositoryItemDescriptor |
getParentItemDescriptor(RepositoryItemDescriptor pItemDesc)
Return the parent item descriptor, if any. |
static java.lang.String |
getUriForRepositoryItem(RepositoryItem pItem)
Return a JNDI "atgrep:" URI given a repository item. |
static boolean |
isTypeOfItemDesc(RepositoryItemDescriptor pItemDesc,
RepositoryItemDescriptor pSuper)
Returns whether pItemDesc is a subtype (or equal to) pSuper. |
static boolean |
isTypeOfItemDesc(RepositoryItem pItem,
RepositoryItemDescriptor pSuper)
Returns whether pItem is of the same type, or a subtype, of pSuper |
static boolean |
isTypeOfItemDesc(RepositoryItem pItem,
java.lang.String pSuperDescriptorName)
Returns whether pItem is of the same type, or a subtype, of the type identified by pSuperDescriptorName |
static void |
notifyGetPropertyValue(java.lang.String pPropertyName,
RepositoryItem pItem)
Notify on fetching property value. |
static void |
notifySetPropertyValue(java.lang.String pPropertyName,
MutableRepositoryItem pItem,
java.lang.Object pValue)
Notify on fetching setting value. |
static java.lang.String |
printPropertyMap(java.util.Map pPropertyMap)
Prints a map with the key as the PropertyDescriptor and the value as the property value |
static void |
removeReferencesToItem(RepositoryItem pItem)
Removes any references to a given from others items in its repository. |
static boolean |
removeRepositoryPropertyCallback(RepositoryUtils.RepositoryPropertyCallback pCallback)
Remove the specified repository property callback. |
static RepositoryItemDescriptor |
unwrapItemDescriptor(RepositoryItemDescriptor pDesc)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static java.lang.String CLASS_VERSION
Constructor Detail |
---|
public RepositoryUtils()
Method Detail |
---|
protected static void addItemDescriptors(RepositoryItemDescriptor pDescriptor, java.util.Collection pItemDescriptors) throws RepositoryException
pDescriptor
- the item-descriptor that should be checked
for subtypes and then added to the itemDescriptors collectionpItemDescriptors
- a collection of item-descriptors
RepositoryException
public static java.util.Collection<RepositoryItemDescriptor> getAllSubtypeItemDescriptors(atg.repository.RepositoryItemDescriptorContainer pItemDescriptor) throws RepositoryException
pItemDescriptor
- item-descriptor to discover subtypes for.
If there are no subtypes associated with the item-descriptor passed,
then null will be returned
RepositoryException
public static MutableRepositoryItem cloneItem(RepositoryItem pSource, boolean pDeepCopy, java.util.Map pPropExceptions, java.util.Map pExcludedProperties, MutableRepository pDestRepository, java.lang.String pId) throws RepositoryException, DuplicateIdException
pSource
- Item to copy.pDeepCopy
- The mode of the copy. If true, default to a deep copy
of the item and its properties. Otherwise, default to a shallow copy, only
getting references of child RepositoryItems. Note that shallow coping will
only work if the source and destination and repositories are the same.pPropExceptions
- Hierarchical map of property name exceptions to the
above mode. Keys are property names while values are null or another Map
if the property is an item. For example, if you clone a product using
pDeepCopy=true, you could add the key "parentCategory" with a null value
into pPropExceptions to cause a shallow copy of the product.parentCategory.
Alternatively, you could add the key "parentCategory" but set the value to
another map of exceptions that included the key/value pair "keywords"/null
to do a deep copy of product.parentCategory but a shallow copy of the
product.parentCategory.keywords. Optional.pExcludedProperties
- Properties to exclude from clone. Keys are
item-type names and the values are collections of property names to
exclude. Optional.pDestRepository
- Repository to copy the item to. If source and
destination repositories are the same, properties that are items will be
cloned to the repository of the source item-property. Optional - If
null, copy to source repository.pId
- Id to use in copy of item. Optional - if null, a unique Id
will automatically be generated.
RepositoryException
- Thrown if the item could not be created.
DuplicateIdException
- Thrown if the specified Id is already in
use.public static MutableRepositoryItem cloneItem(RepositoryItem pSource, boolean pDeepCopy, java.util.Map pPropExceptions, MutableRepository pDestRepository, java.lang.String pId) throws RepositoryException, DuplicateIdException
pSource
- Item to copy.pDeepCopy
- The mode of the copy. If true, default to a deep copy
of the item and its properties. Otherwise, default to a shallow copy, only
getting references of child RepositoryItems. Note that shallow coping will
only work if the source and destination and repositories are the same.pPropExceptions
- Hierarchical map of property name exceptions to the
above mode. Keys are property names while values are null or another Map
if the property is an item. For example, if you clone a product using
pDeepCopy=true, you could add the key "parentCategory" with a null value
into pPropExceptions to cause a shallow copy of the product.parentCategory.
Alternatively, you could add the key "parentCategory" but set the value to
another map of exceptions that included the key/value pair "keywords"/null
to do a deep copy of product.parentCategory but a shallow copy of the
product.parentCategory.keywords. Optional.pDestRepository
- Repository to copy the item to. If source and
destination repositories are the same, properties that are items will be
cloned to the repository of the source item-property. Optional - If
null, copy to source repository.pId
- Id to use in copy of item. Optional - if null, a unique Id
will automatically be generated.
RepositoryException
- Thrown if the item could not be created.
DuplicateIdException
- Thrown if the specified Id is already in
use.public static boolean anyReferencesToItem(RepositoryItem pItem) throws RepositoryException
Calling this method will generate multiple repository queries per call, one for each property descriptor that might refer to pItem. For example, if pItem's type is "contact-info", one query will be performed for each property descriptor whose type is either contact-info or any multi-valued type that might contain a list of items of type contact-info. (The queries will each fetch at most one item from the repository, so the effect on the repository's cache should be minimal.)
pItem
- Any repository item.
RepositoryException
public static void removeReferencesToItem(RepositoryItem pItem) throws RepositoryException
Calling this method will generate multiple repository queries per call, one for each property descriptor that might refer to pItem. For example, if pItem's type is "contact-info", one query will be performed for each property descriptor whose type is either contact-info or any multi-valued type that might contain a list of items of type contact-info.
pItem
- Any repository item.
RepositoryException
public static MutableRepositoryItem getMutableRepositoryItem(RepositoryItem pItem) throws RepositoryException
pItem
- the repository itempRepository
- the mutable repository where the item resides
RepositoryException
- on repository errorpublic static MutableRepositoryItem getMutableRepositoryItem(MutableRepository pRepository, java.lang.String pItemId, java.lang.String pItemType) throws RepositoryException
pRepository
- - the mutable repository where the item residespItemId
- - the repository item's idpItemType
- - the repository item's type
-
- RepositoryException on repository error
RepositoryException
public static java.lang.String printPropertyMap(java.util.Map pPropertyMap)
public static java.lang.String convertValueToString(DynamicPropertyDescriptor pPropDesc, java.lang.Object pValue)
public static java.lang.String getUriForRepositoryItem(RepositoryItem pItem) throws RepositoryException
pItem
- the repository item
RepositoryException
public static java.lang.String buildUriForRepositoryItem(java.lang.String pRepositoryName, java.lang.String pItemDescriptorName, java.lang.String pRepositoryId) throws RepositoryException
pRepositoryName
- the repository namepItemDescriptor
- the item descriptor namepRepositoryId
- the repository id
RepositoryException
public static boolean isTypeOfItemDesc(RepositoryItemDescriptor pItemDesc, RepositoryItemDescriptor pSuper)
pItemDesc
- The (presumably child) item descriporpSuper
- The item descriptor to test for parent-hood.
public static boolean isTypeOfItemDesc(RepositoryItem pItem, RepositoryItemDescriptor pSuper) throws RepositoryException
pItem
- The (presumably child) itempSuper
- The item descriptor to test for parent-hood.
RepositoryException
public static boolean isTypeOfItemDesc(RepositoryItem pItem, java.lang.String pSuperDescriptorName) throws RepositoryException
pItem
- The (presumably child) itempSuperDescriptorName
- The item descriptor name to test for parent-hood.
RepositoryException
public static RepositoryItemDescriptor getParentItemDescriptor(RepositoryItemDescriptor pItemDesc)
public static RepositoryItemDescriptor getBaseItemDescriptor(RepositoryItemDescriptor pItemDesc)
public static java.lang.String getItemDisplayPropertyPath(RepositoryItemDescriptor pDesc) throws RepositoryException
RepositoryException
public static java.lang.String getItemDisplayPropertyName(RepositoryItemDescriptor pDesc) throws RepositoryException
RepositoryException
public static java.lang.String getItemDisplayPropertyName(RepositoryItemDescriptor pDesc, boolean pMustBeQueryable) throws RepositoryException
pDesc
- the RepositoryItemDescriptor for which to get the display name propertypMustBeQueryable
- if true, return null if the property is not queryable
RepositoryException
public static RepositoryItemDescriptor unwrapItemDescriptor(RepositoryItemDescriptor pDesc) throws RepositoryException
RepositoryException
public static void notifySetPropertyValue(java.lang.String pPropertyName, MutableRepositoryItem pItem, java.lang.Object pValue)
public static void notifyGetPropertyValue(java.lang.String pPropertyName, RepositoryItem pItem)
pPropertyName
- the property descriptor for the item.pItem
- the item whose property value is being fetched.public static void addRepositoryPropertyCallback(RepositoryUtils.RepositoryPropertyCallback pCallback)
public static boolean removeRepositoryPropertyCallback(RepositoryUtils.RepositoryPropertyCallback pCallback)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |