Show TOC

Creating a Single Change OperationLocate this document in the navigation structure

Use

The following example shows how to create a single change operation from a set of related changes:

            //Get the IChangeRecordingInfo for the parent folder       
        Hashtable env = new Hashtable();
        env.put(Context.INITIAL_CONTEXT_FACTORY, IPcdContext.PCD_INITIAL_CONTEXT_FACTORY);
        env.put(Context.SECURITY_PRINCIPAL, user);
        env.put(AspectSupport.REQUESTED_ASPECT, PcmConstants.ASPECT_ADMINISTRATION);
        InitialContext initialContext = new InitialContext(env);
        IAdminBase objAdminBase = (IAdminBase) initialContext.lookup(folderPath);
        IChangeRecordingInfo crInfo = (IChangeRecordingInfo) objAdminBase.getImplementation(IAdminBase.CHANGE_RECORDING_INFO);

//Create a new change operation with descriptive text
        LocalizedText operationText = new LocalizedText("Example Operation", Locale.ENGLISH);
        String changeOperationId = crInfo.createChangeOperation(new LocalizedText[]{operationText});
        
//Add the new change operation ID to the JNDI environment before performing the change operation
        initialContext.addToEnvironment(IChangeRecordingInfo.CHANGE_RECORDING_OPERATION_ID, changeOperationId);
        
//The change operation - adding an attribute to two children of the parent folder
        IAdminBase childA = initialContext.lookup(folderPath + "/childA");
        IAttributeSet attrSetA = (IAttributeSet) childA.getImplementation(IAdminBase.ATTRIBUTE_SET);
        attrSetA.putAttribute("exampleAttribute", "example");
        attrSetA.save();
        
        IAdminBase childB = initialContext.lookup(folderPath + "/childB");
        IAttributeSet attrSetB = (IAttributeSet) childB.getImplementation(IAdminBase.ATTRIBUTE_SET);
        attrSetB.putAttribute("exampleAttribute", "example");
        attrSetB.save();

         
More Information