Show TOC

Background documentationDelta Links Locate this document in the navigation structure

 

The PCD provides delta link information about objects, such as whether the object is a delta link, what attributes were changed, and what attributes were erased.

Most information is derived from an IDlModificationState object that you can derive from the IPcdContext interface, as follows:

Syntax Syntax

  1. Hashtable env = new Hashtable();
    
    env.put(Context.INITIAL_CONTEXT_FACTORY,
             IPcdContext.PCD_INITIAL_CONTEXT_FACTORY);
    env.put(Context.SECURITY_PRINCIPAL, request.getUser());
    env.put(Constants.REQUESTED_ASPECT, IPcdAttribute.PERSISTENCY_ASPECT);
    
    InitialContext   iCtx = null;
    
    String lookupObject = "portal_content/myFolder/myObject";
    
    try {
        iCtx = new InitialContext(env);
    
        IPcdContext myPcdContext =(IPcdContext) iCtx.lookup(lookupObject);
    
        IDlModificationState myDLState = myPcdContext
            .getDlModificationState("");
    }
    
End of the code.

If the object is not a delta link or inherited via a delta link, getDlModificationState() returns null.

Note Note

If an attribute's Inheritance meta-attribute is set to Locked in target objects (FINAL), the attribute cannot be modified in a delta link.

More information: Defining Property Attributes

End of the note.
Getting Delta Link Information

From an IDlModificationState object, you can perform the following tasks:

  • Get the source object of a delta link.

    Syntax Syntax

    1. response.write(myDLState.getSourceUrl());
    End of the code.
  • Get all attributes that were changed in a delta link.

    Syntax Syntax

    1. Iterator myMods = myDLState.getModifiedAttributeIds();
      while (myMods.hasNext()) {
          response.write("ID: " + myMods.next() + "<BR>");
      }
    End of the code.
  • Get the changes made to a specific attribute of a delta link.

    Syntax Syntax

    1. ModificationItem[] myMod =
          myDLState.getModifications("ForcedRequestLanguage");
      
      for (int i=0;i<myMod.length;i++){
          response.write(myMod[i].getAttribute().getID()+"<BR>");
          response.write(myMod[i].getModificationOp()+"<BR>");
      }
    End of the code.

    The getModificationOp() method returns one of the following constants:

    • DirContext.ADD_ATTRIBUTE

    • DirContext.REMOVE_ATTRIBUTE

    • DirContext.REPLACE_ATTRIBUTE

    For each attribute, a delta link stores all the changes made to the attribute, not just the final result.

Creating a Delta Link

The following creates a delta link:

Syntax Syntax

  1. Hashtable env = new Hashtable();
    
    env.put(Context.INITIAL_CONTEXT_FACTORY,
        IPcdContext.PCD_INITIAL_CONTEXT_FACTORY);
    env.put(Constants.REQUESTED_ASPECT, IPcdAttribute.PERSISTENCY_ASPECT);
    env.put(Context.SECURITY_PRINCIPAL, request.getUser());
    
    InitialContext iCtx = null;
    String myFolderName = "pcd:portal_content/myFolderB";
    
    try {
        iCtx = new InitialContext(env);
    
        IPcdContext myFolderB = (IPcdContext) iCtx.lookup(myFolderName);
    
        myFolderB.createDeltaLink(
            "myDL",null,"portal_content/myFolderA/myIView");
    }
    catch (Exception e) {}
    
End of the code.

The above creates a PCD object called myDL in myFolderB, which is a delta link to myIView in myFolderA.

Resetting Attributes

The following resets all attributes changed in a delta link object:

Syntax Syntax

  1. myPcdContext.removeModifications("");
End of the code.

The following resets a specific attribute (ForcedRequestLanguage) that was changed in a delta link object:

Syntax Syntax

  1. String myAttrsToDelete[] = {"ForcedRequestLanguage"};
  2. myPcdContext.removeAttributeModifications("",myAttrsToDelete);
End of the code.