For some application migration that just introduced the filenet platform, some features of the original application have simple document storage. For example, in the template, there may be template attachments other than attributes, however, they are only a single content. For example, when a document is transmitted between Maximo and SAP, except that the attachment content and the unique identifier (such as the document number) are consistent, other business attributes are different, at this time, the management of documents on the basis of non-filenet is more complex, and there is often no version or true document management. Once the storage of documents is transferred to filenet, the necessity of transfer should be fully considered (the problem of original implementation should be distinguished) and future scalability. The following section describes the transfer of document content to a new document content when the document is updated under the same document, without considering the significance of using content management.
Connection conn = CEHelper.getConnection();CEHelper.pushSubject(conn, "Administrator", "filenet");ObjectStore os = CEHelper.getObjectStore(conn);Document doc0 = Factory.Document.fetchInstance(os, new Id("{320A3450-7F78-4B2A-B642-422282E2243D}"), null);if(!doc0.get_IsCurrentVersion()){doc0 = (Document)doc0.get_CurrentVersion();}Document doc = Factory.Document.createInstance(os, "Document");ContentElementList newCEL = Factory.ContentElement.createList();ContentTransfer ct = Factory.ContentTransfer.createInstance();try{ct.setCaptureSource(new FileInputStream("c:\\log4j1.log"));}catch(FileNotFoundException e){e.printStackTrace();}newCEL.add(ct);InputStream is = doc0.accessContentStream(0);ContentTransfer ct2 = Factory.ContentTransfer.createInstance();ct2.setCaptureSource(is);newCEL.add(ct2);InputStream is3 = doc0.accessContentStream(0);ContentTransfer ct3 = Factory.ContentTransfer.createInstance();ct3.setCaptureSource(is3);newCEL.add(ct3);doc.set_ContentElements(newCEL);doc.getProperties().putValue("DocumentTitle", "log4j_7");doc.save(RefreshMode.REFRESH);doc.checkin(AutoClassify.DO_NOT_AUTO_CLASSIFY, CheckinType.MAJOR_VERSION);doc.save(RefreshMode.REFRESH);Folder folder = Factory.Folder.fetchInstance(os,"/Test", null);ReferentialContainmentRelationship rcr = folder.file(doc, AutoUniqueName.AUTO_UNIQUE, null, DefineSecurityParentage.DO_NOT_DEFINE_SECURITY_PARENTAGE);rcr.save(RefreshMode.REFRESH);doc0.delete();doc0.save(RefreshMode.NO_REFRESH);CEHelper.popSubject();
The above code function is beyond review for a single function. However, from the perspective of the long-term requirements and business expansion of the customer, it is not conducive to providing the customer with a molding solution. What the customer initially needed was simple cross-platform document sharing, but it may only be a superficial requirement or cognition that affects the inefficiency of the original system, some adjustments should be made after full consideration. No matter which implementation is used, it does not affect the customer's use, but is not conducive to the thinking of the solution, and is not conducive to expanding the scope of service to the customer.