Example: Java API Context

With the correct context, a UserContext can be established in the calling thread before calling IBM® Case Manager Java™ API methods or directly calling Content Platform Engine Java API methods.
The general structure necessary to call the Content Platform Engine Java API includes establishing both a UserContext and a CaseMgmtContext. The UserContext is established by using the Content Platform Engine Java API, and the CaseMgmtContext is established by using the workflow Java API. For example, in a stand-alone environment, the overall structure might look like:
    P8ConnectionCache connCache = new SimpleP8ConnectionCache();
    Connection conn = connCache.getP8Connection(CE_URI);
    Subject subject = 
        UserContext.createSubject(conn, USER_NAME, 
                                  PASSWORD, "FileNetP8WSI");
    UserContext uc = UserContext.get();
    uc.pushSubject(subject);
    Locale origLocale = uc.getLocale();
    uc.setLocale(1);
    CaseMgmtContext origCmctx = 
        CaseMgmtContext.set(
            new CaseMgmtContext(
                new SimpleVWSessionCache(), connCache()
            )
        );
    try {
        // Code that calls the Case Java API or 
        // directly calls the CE Java API
        ...
    }
    finally {
        CaseMgmtContext.set(origCmctx);
        uc.setLocale(origLocale);
        uc.popSubject();
    }
Note: To create custom applications by using the Case Manager Java API interacting with Business Automation Workflow on containers or in Cloud Pak for Business Automation, see Configure your environment to use Case Manager Java API from IBM Cloud Pak® for Business Automation External link opens a new window or tab.