Filenet P8 5.1 and 5.2 deleting / replacing document content with new content

One of the requirements is updating the document with new content, as well as deleting the old document. The document identifier and other properties of the previous document should point to a new document with new content.

There is some sample fragment there to do the same.

+4
source share
1 answer

I did not quite understand if I needed to create a new document or a new version of an existing document. Properties can be copied automatically for the newly created version, so version control looks more natural. For this:

// check out the document 
Document currentVersion = .. // reference to existing document 
currentVersion.checkout(ReservationType.EXCLUSIVE, null, null, null);
currentVersion.save(RefreshMode.REFRESH);

// obtain the reservation object (new version in progress)
newVersion = (com.filenet.api.core.Document) documentObject.get_Reservation();

// set content
InputStream inputStream = .. // obtain input stream with content
ContentElementList contentElements = Factory.ContentElement.createList();
ContentTransfer contentTransfer = Factory.ContentTransfer.createInstance();
contentTransfer.setCaptureSource(inputStream);
contentTransfer.set_RetrievalName("content name");
contentTransfer.set_ContentType("proper MIME type");
contentElements.add(contentTransfer);
newVersion.set_ContentElements(contentElements);
newVersion.checkin(AutoClassify.DO_NOT_AUTO_CLASSIFY, CheckinType.MINOR_VERSION);
newVersion.save(RefreshMode.NO_REFRESH);

// deleting obsolete version
currentVersion.delete();
currentVersion.save(RefreshMode.NO_REFRESH);

, ( , ), , .

, , , . , ( ).

, , :

  • JTA ( EJB-)

: , - .

, , .

+6

Source: https://habr.com/ru/post/1525100/


All Articles