-2

Im new to IBM filenet. I just got the webservice url of the CMIS filenet.

My requirement is to store a PDF document got from one system using apache camel route to filenet. Tried importing the wsdl in SOAP UI and i can see set of APIs like createDocument, createFolder etc., Is there a simple way of testing these APIs. First at least i want to simple test in java at least to store a document in filenet. Please help me out in understanding.

WiredCoder
  • 916
  • 1
  • 11
  • 39
Balaji Kannan
  • 407
  • 6
  • 24

2 Answers2

3

To add any kind of document you need to check-in that document to any specific folder of FileNet ObjectStore.

For this all you need a document path or its byteArray, to create fileinputstream, which you want to insert in ObjectStore.

Code to create document,

  1. Create Connection to your content engine
  2. Ref code may it will help you

public static void insertDocument(Connection conn, String domainName) {
    // Get domain.
    Domain domain = Factory.Domain.fetchInstance(conn, domainName, null);
    ObjectStoreSet osColl = domain.get_ObjectStores();

    // Get each object store.
    Iterator iterator = osColl.iterator();
    while (iterator.hasNext()) {
        // Get next object store.
        ObjectStore objStore = (ObjectStore) iterator.next();

        // Get the display name of the object store.
        String objStoreName = objStore.get_DisplayName();
        System.out.println("Object store name = " + objStoreName);

        // Create a document instance.
        Document doc = Factory.Document.createInstance(objStore, ClassNames.DOCUMENT);

        // Set document properties.
        doc.getProperties().putValue("DocumentTitle", "New Document via Java API");
        doc.set_MimeType("text/plain"); // if its your pdf then set mimetype for PDF

        doc.save(RefreshMode.NO_REFRESH);

        // Check in the document.
        doc.checkin(AutoClassify.DO_NOT_AUTO_CLASSIFY, CheckinType.MAJOR_VERSION);
        doc.save(RefreshMode.NO_REFRESH);

        // File the document.
        Folder folder = Factory.Folder.getInstance(objStore, ClassNames.FOLDER, new Id("{42A3FC29-D635-4C37-8C86-84BAC73FFA3F}")); // id of folder to which you want to store document.
        ReferentialContainmentRelationship rcr = folder.file(doc, AutoUniqueName.AUTO_UNIQUE, "New Document via Java API",
                DefineSecurityParentage.DO_NOT_DEFINE_SECURITY_PARENTAGE);
        rcr.save(RefreshMode.NO_REFRESH);
    }
}
Bhavik vora
  • 274
  • 1
  • 3
  • 10
0

In order to troubleshoot the CMIS, I usually follow the general steps that I compiled for you below. saying this, I would highly advise you to create unit tests for each of your operations as you go and I promise it will save you a lot of time and effort

  1. Start Fiddler [a].
  2. Start CMIS Workbench. 0.8.0 [b] and later automatically proxies requests, at least on Windows 7.
  3. Logon to a repository
  4. Optionally navigate to a folder.
  5. Create Document. Leave the Generate content field at 0 bytes if creating a doc without a content stream. Select Email or other type.
  6. Go to Fiddler and find the POST (status code will be 201).

The request should have Content-Type: application/atom+xml;type=entry, and the properties, cmis:name and cmis:objectTypeid, in the cmisra:object element.

a. http://www.fiddler2.com/fiddler2/ b. http://chemistry.apache.org/java/download.html

Community
  • 1
  • 1
WiredCoder
  • 916
  • 1
  • 11
  • 39