How PCD Lookups are Performed
In the PCD, all objects are simply contexts with a set of attributes.
One attribute is the object class ( com.sap.portal.pcd.gl.ObjectClass ), which indicates the type of object. When a lookup is performed on an object, the PCD checks the object class attribute to determine which object provider to use for creating a Java object from the set of attributes.
The object class com.sap.portal.pcd.gl.GlContext indicates a folder object, which does not have a special object provider. All other values specify a semantic object.
Process Flow
The following describes how PCD lookups are performed:
-
A portal component or service creates a PCD initial context, including specifying the following environment variables:
-
Initial Context Factory
-
Aspect: Indicates to the object factory what type of Java object to return.
For more information, see Aspects .
-
User: PCD checks if this user has permissions to perform this lookup.
-
Personalization: Indicates whether to get a personalized object and, if so, for which user. This variable is optional.
For more information, see Personalization .
The following is an example of setting the environment variables ( env is a Hashtable that holds the environment variables, and request is the IPortalComponentRequest for the current request):
-
import javax.naming.Context;
import com.sapportals.portal.pcd.gl.IPcdContext;
import com.sap.portal.directory.Constants;
import com.sapportals.portal.pcd.gl.IPcdAttribute;
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());
env.put(IPcdContext.PCD_PERSONALIZATION_PRINCIPAL, request.getUser());
With the PCD initial context, the application requests a lookup, by calling lookup() on the initial context and providing a PCD name. For more information, see PCD Name .
-
The PCD checks that the name is valid.
-
The PCD finds the object type of the object being looked up, and calls the appropriate object provider for that type of object. For more information, see Semantic Objects .
If the aspect was set to IPcdAttribute.PERSISTENCY_ASPECT , the PCD does not call the object provider but, instead, creates and returns a IPcdContext object, and the process stops here.
-
The object provider checks the aspect, and creates the appropriate object for that aspect.
-
The object is returned to the PCD provider, which returns it to the calling application.