1

I'm in a need to duplicate a file on filenet using APIs and update a properties from the existing file, after making a search with , I made the below sample but getting an error

row = (RepositoryRow) it.next();
            Id id = row.getProperties().get("Id").getIdValue();
            Document document = Factory.Document.fetchInstance(os, id, null);

            System.out.println("current document is : "+document.get_Name());

            Document docCopy = (Document)Factory.Document.fetchInstance(os, id, null); 

            Properties prop = docCopy.getProperties();
                prop.putValue("PT_DocumentNumber", newDocNo);

            docCopy.checkin(AutoClassify.DO_NOT_AUTO_CLASSIFY, CheckinType.MAJOR_VERSION);
            docCopy.save(RefreshMode.NO_REFRESH);

            // file into folder
            folder = Factory.Folder.getInstance(os, ClassNames.FOLDER, new Id("myFOlder"));
            ReferentialContainmentRelationship rcr = folder.file(docCopy, AutoUniqueName.AUTO_UNIQUE, "New Document via Webservice", DefineSecurityParentage.DO_NOT_DEFINE_SECURITY_PARENTAGE);
            rcr.save(RefreshMode.NO_REFRESH);

the error I'm getting as the following

[2/28/19 12:31:58:721 AST] 000000bc SystemErr     R com.filenet.api.exception.EngineRuntimeException: FNRCE0042E: E_NOT_SUPPORTED: This method is not supported in the context of this session or object. Checkin must be performed on a reservation object. failedBatchItem=0 errorStack={
at com.filenet.engine.persist.VersionablePersister.validateCheckin(VersionablePersister.java:558)
at 
ᄂ ᄀ
  • 5,669
  • 6
  • 43
  • 57
gasser
  • 279
  • 1
  • 4
  • 16
  • [Setting a Document's Content](https://www.ibm.com/support/knowledgecenter/en/SSNW2F_5.5.0/com.ibm.p8.ce.dev.ce.doc/document_procedures.htm#document_procedures__doc_procedures_set_content) – ᄂ ᄀ Mar 14 '19 at 21:44
  • wat is it that you are trying to achieve. A new version of the document or an actual copy in a new version series. The current code just fetches the document twice. The checkin will fail because the document is not checked out so it gives an error because you can only do a checkin on a reservation. – Robert vd S May 03 '19 at 12:49

1 Answers1

1

Simply put, what you are doing is that you get the ID

Id id = row.getProperties().get("Id").getIdValue();

Then you get the source document

Document document = Factory.Document.fetchInstance(os, id, null);

Then you get the same source document, with just a different reference variable

Document docCopy = (Document)Factory.Document.fetchInstance(os, id, null); 

Both are the same document, no copy was done here! and hence when you try to check in the document using:

docCopy.checkin(AutoClassify.DO_NOT_AUTO_CLASSIFY, CheckinType.MAJOR_VERSION);
docCopy.save(RefreshMode.NO_REFRESH);

The Engine throws an error since the document was not checked out in the first place (and hence no reservation object captured to do your changes on).

Checkin must be performed on a reservation object.
WiredCoder
  • 916
  • 1
  • 11
  • 39