转载于http://www.ibm.com/developerworks/cn/data/library/techarticles/dm-0812liuwei/index.html
本文样例是基于企业内部的文档管理流程的一个片断。在该流程中,秘书可以上传和更新某些文档资料;公司的管理者可以检查上传的文件;上述三个 活动,代表了对文档的创建、查询和更新操作,文档被存储到 FileNet Ce 中,并通过 PE 的“引用”,可以被流程中每个任务活动所共享。
在操作 CE 之前,需要获取与 CE 的连接。 FileNet 提供了两种连接方式:EJB transport 和 Web services transport 。如果,使用 EJB transport 连接 CE,所必需的 JAAS context 常常已经建立 (例如:如果使用的应用服务器是 Websphere Application Server, 可以配置相关的 JAAS), 因此不需要使用代码建立 JAAS context:
// Need setup parameters of JVM to login; parameters include url and jaas config // … … // Get the connection String uri = "http://CEServer:9080/wsi/FNCEWS40DIME/"; Connection conn = Factory.Connection.getConnection(uri); // Get the default domain Domain domain = Factory.Domain.getInstance(conn, null); // Get an object store ObjectStore os = Factory.ObjectStore.fetchInstance(domain, "ObjectStoreName", null); |
如果使用一般的 JAVA 应用程序或者 Web services transport 连接 CE,需要额外增加下列方法建立一个 JAAS context:
// conn: CE connection; Subject subject = UserContext.createSubject(conn, user, password, null); UserContext uc = UserContext.get(); uc.pushSubject(subject); |
当释放 CE 的联接,需要使用“ UserContext.get().popSubject() ”,将当前登录用户的主题对象从用户上下文中清除掉;否则,如果另外用户登陆到 PE 和 CE 中,进行相应的操作,可能会出现下列异常:
[Err=d56d0044] Security attributes disallow access at filenet.pe.peorb.client.ORBUtility.mapServerExc |