Update the content of a new version of document

Source: Internet
Author: User

Document is a version object. When we first create and check in a new document, we initialize a new version, after editing this version check out, we get a new version of this document. The following describes how to add the document content and retain the content of the previous version document during the document version change process. [Java] <span style = "font-size: 12px;"> </span> <span style = "font-size: 14px;"> Connection conn = CEHelper. getConnection (); CEHelper. pushSubject (conn, "Administrator", "filenet"); ObjectStore OS = CEHelper. getObjectStore (conn); Document doc = Factory. document. fetchInstance (OS, new Id ("{1FC02DF6-7EDE-49BE-998A-801BB6012C75}"), null); Document doc0 = Factory. document. fetchInstance (OS, new Id ("{1FC02DF6-7E DE-49BE-998A-801BB6012C75} "), null); logger.info (! Doc. get_IsReserved (); if (! Doc. get_IsCurrentVersion () {doc = (Document) doc. get_CurrentVersion (); doc0 = (Document) doc. get_CurrentVersion ();} logger.info (! Doc. get_IsReserved (); if (! Doc. get_IsReserved () {doc. checkout (ReservationType. EXCLUSIVE, null, null, doc. getProperties (); doc. save (RefreshMode. REFRESH);} doc = (Document) doc. get_Reservation (); logger.info (! Doc. get_IsReserved (); ContentElementList oldCEL = doc. get_ContentElements (); logger.info (String. valueOf (oldCEL. size (); 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); logger.info (do C0.get _ ContentElements (). size (); InputStream is = doc0.accessContentStream (0); ContentTransfer ct2 = Factory. contentTransfer. createInstance (); ct2.setCaptureSource (is); newCEL. add (ct2); InputStream is3 = doc0.accessContentStream (1); ContentTransfer ct3 = Factory. contentTransfer. createInstance (); ct3.setCaptureSource (is3); newCEL. add (ct3); InputStream is4 = doc0.accessContentStream (1); ContentTran Sfer ct4 = Factory. contentTransfer. createInstance (); ct4.setCaptureSource (is4); newCEL. add (ct4); doc. set_ContentElements (newCEL); doc. save (RefreshMode. REFRESH); doc. checkin (AutoClassify. DO_NOT_AUTO_CLASSIFY, CheckinType. MAJOR_VERSION); doc. save (RefreshMode. REFRESH); CEHelper. popSubject (); </span> during the preceding operations, you must obtain the current version of the document and check it out to the Reservation version to change its content ). When obtaining the content of a previous version, do not directly reference its ContentTransfer, but retrieve its accessContentStream to recreate ContentTransfer to complete the setting of the document content.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.