Show TOC

Accessing the PCD from a J2EE ApplicationLocate this document in the navigation structure

Use

J2EE applications can access content stored in the Portal Content Directory (PCD) using JNDI.

In the following example, a Web Dynpro application accesses an object in the PCD. The content of the PCD is protected against impermissible access. Therefore, the SAP UME user must be put in the JNDI environment to identify the current user. In the example below this user is obtained from the Web Dynpro specific user.

The example shows the lookup of the data only. The IntialContext is a javax.naming class.

            import com.sap.tc.webdynpro.services.sal.um.api.WDClientUser;
            import com.sap.security.api.IUser;
             
            // class implementation
             
               // method implementation
             
                  // getting the SAP user.
                  IUser currentUser = WDClientUser.getCurrentUser().getSAPUser();
             
                  Hashtable env = new Hashtable();
                  env.put(Context.SECURITY_PRINCIPAL, currentUser);
             
                  try {
                     InitialContext context = new InitialContext(env);
             
                     Object obj = context.lookup(
                     "pcd:/com.sap.portal.system/applications/
                      com.sap.portal.ivs.global/services/producer");
             
                  } catch (NamingException e) {
                     // handle the exception
                  }