Thursday 13 November 2014

IBM Case Manager API (fetch P8Connection, Domain, Target Obbject Store)

//Establish ICM Connection

public static Connection getICMConnection(String uri,String userID,String password){
      
        try{
            //uri = "http://localhost:9080/wsi/FNCEWS40MTOM/";
            P8ConnectionCache connCache = new SimpleP8ConnectionCache();
            conn = connCache.getP8Connection(uri);
            log.info("ICM Connection: "+conn);
          
            Subject subject =   UserContext.createSubject(conn, userID, password, "FileNetP8WSI");
            uc = UserContext.get();
            uc.pushSubject(subject);
          
            origLocale = uc.getLocale();
            uc.setLocale(origLocale);
            origCmctx = CaseMgmtContext.set(new CaseMgmtContext(new SimpleVWSessionCache(), connCache));
        }catch(Exception ex){
            ex.printStackTrace();
            log.error("[ICMManager]getICMConnection():Exception found is :"+ex.getMessage());
        }
      
      
        return conn;
    }



//Domain References

public static DomainReference getDomainReference(Connection conn){
       
       
        try{
            Domain domain=Factory.Domain.fetchInstance(conn, null, null);
            log.info("[ICMManager]getDomainreference():Domain Name: "+domain.get_Name());
           
            domainReference=new DomainReference(domain);
        }catch(Exception ex){
            ex.printStackTrace();
            log.error("[ICMManager]getDomainreference():Exception found: "+ex,ex);
        }
        return domainReference;
       
    }


//Get Target Object Store

public static ObjectStoreReference getTargetOSReference(DomainReference domRef,String osName){
       
        try{
            targetObjectStoreReference=new ObjectStoreReference(domRef, osName);
            log.info("[ICMManager]getTargetOSReference():Target Object Store Reference: "+targetObjectStoreReference.toString());
        }catch(Exception ex){
            ex.printStackTrace();
            log.error("[ICMManager]getTargetOSReference():Exception found: "+ex,ex);
        }
        return targetObjectStoreReference;
       
    }


//Close ICM Connection

public static void closeICMObjects(){
        CaseMgmtContext.set(origCmctx);
        uc.setLocale(origLocale);
        uc.popSubject();
        targetObjectStoreReference=null;
        domainReference=null;
        conn=null;
       
    }















No comments:

Post a Comment