Include related actions in your asset purge function if you need to perform additional steps when deleting repository items. See Related Conditions and Actions.
To configure a related condition component:
Create a component based on the
atg.purge.condition.SimpleRelatedCondition
class. See Property Configuration for Related Action Components.Include the Nucleus path to your related action component in the
relatedConditions
property value for yourPurgeConfiguration
component. See PurgeConfiguration Component.Create a pipeline processor component to perform the related action for each repository item that is handled by the asset purge function. Base the component on a subclass of
atg.purge.pipeline.processor.RepositoryItemPurgeProcessor
. Override therunProcess
method and include your own action in the method body. See Adding a Pipeline Processor for Related Actions.Include your new pipeline processor component in the asset purge pipeline. See Configuring the Asset Purge Pipeline.
Property Configuration for Related Action Components
Include the properties described in the following table for a related action component:
Property | Description |
---|---|
| The user-interface label that describes the related action. The label includes a text box to display or edit the parameter value. Include the variable If you need to localize the Dynamo Server Admin user interface, you can supply the resource bundle key for this label in the |
| The key for the parameter in the |
| The value of the parameter in the The asset purge user interface displays the parameter value along with the label for the related action. The value appears in a text box at the end of the label. You can move the text box into the label string by including the Note: the label for a related action always contains a text box to display the parameter value, even if you do not specify or use the value. Users can enter or make changes to the parameter value if the |
| Controls whether users can enter or make changes to the parameter value. See the description of the |
| Controls whether the related action is selected in the user interface by default. |
The following example configuration file sets the property values for a related action component.
$class=atg.purge.condition.SimpleRelatedCondition # A user-interface label that describes the related action defaultName=Delete organization credit cards # The key for the parameter associated with this action in the # Map of parameters for the PurgeItem parameterName=creditCards # In this example, the parameter does not need a value. The asset purge feature # will perform the related action if the parameter is present. A user can # deselect the related action and omit the parameter. In that case, the # asset purge feature will not perform the related action. # See the Java code that checks for the presence of the parameter in # Adding a Pipeline Processor for Related Actions. # Determines whether the end user can alter the parameter value editable=false # Determines whether the related action is selected by default enabled=true
Adding a Pipeline Processor for Related Actions
Create a pipeline processor component for the related actions that you add to your asset purge function. The asset purge feature invokes your new processor for each repository item that passes through the pipeline.
Base your pipeline processor component on a subclass of atg.purge.pipeline.processor.RepositoryItemPurgeProcessor
. Override the runProcess
method and include your own action in the method body. When your related action is complete, return an integer value to indicate success. The integer values are defined by the atg.purge.pipeline.ProcessorConstants
interface. The RepositoryItemPurgeProcessor
class implements ProcessorConstants
and has access to its constant values. For example, return one of the following:
return RETCODE_OK;
return RETCODE_NOT_OK;
The following example component configuration file and Java class show how to override the runProcess
method. This example corresponds to the related action component configuration shown in Property Configuration for Related Action Components.
$class=mycompany.MyNewProcessor # The Nucleus path of the repository that holds the # repository items that are being purged repository=/atg/userprofiling/ProfileAdapterRepository # The type of the repository items that are being purged itemDescriptorName=organization
This Java class overrides the runProcess
method.
package mycompany; import java.util.ArrayList; import java.util.Iterator; import java.util.Map; import atg.beans.DynamicBeans; import atg.purge.PurgeItem; import atg.purge.pipeline.processor.RepositoryItemPurgeProcessor; import atg.repository.MutableRepositoryItem; import atg.repository.RepositoryItem; import atg.service.pipeline.PipelineResult; public class MyNewProcessor extends RepositoryItemPurgeProcessor { @Override public int runProcess(Object pParam, PipelineResult pResult) throws Exception { // Get the repository item that is currently being handled PurgeItem item = (PurgeItem) DynamicBeans.getPropertyValue(pParam, PURGE_ITEM); RepositoryItem organization = getRepository().getItem(item.getId(), item.getItemType()); // Perform additional actions based on parameters if they are present. // This example deletes credit card repository items that are associated // an organization. The organization repository item is the PurgeItem. // The related action component configuration adds a parameter named // "creditCards" to the PurgeItem if (item.getParameters().get("creditCards") != null) { // Get the credit cards associated with the current organization. Map creditcardmap = (Map) organization.getPropertyValue("creditCards"); Iterator iterator = creditcardmap.entrySet().iterator(); ArrayList<RepositoryItem> creditcards = new ArrayList<RepositoryItem>(); while (iterator.hasNext()) { Map.Entry entry = (Map.Entry) iterator.next(); RepositoryItem card = (RepositoryItem) entry.getValue(); creditcards.add(card); } // Set the creditCards property to null. MutableRepositoryItem mutableorganization = getRepository().getItemForUpdate(item.getId(), item.getItemType()); mutableorganization.setPropertyValue("creditCards", null); getRepository().updateItem(mutableorganization); // Delete each credit card repository item. for (RepositoryItem card : creditcards) { getRepository().removeItem(card.getRepositoryId(), "credit-card"); } } // Return an atg.purge.pipeline.ProcessorConstants constant value to // indicate success. return RETCODE_OK; } }