How to change Filenet document MimeType using com.filenet.wcm.api

1.3k views Asked by At

I am new to FileNet. We are using P8 Content Engine - 5.1.0.2 I need to change MimeType for existing document using Filenet WCM API. Workuround is to download the document, change the MimeType and re-upload the document but in this case the documnet Id will be changed. I prefer to update existing document instead of re-uploading the document.

Basically I need to do same thing that described in Changing the content element MIME type programmatically throught Filenet WCM API.

the code is

public boolean changeDocumnetMimeType(String documentId, String docMimeType) throws IOException {

    com.filenet.wcm.api.TransportInputStream in1 = null;
    com.filenet.wcm.api.ObjectStore docObjectStore;
    com.filenet.wcm.api.Session session;

    try {

        session = ObjectFactory.getSession(this.applicationId, null, this.user,this.password);
        session.setRemoteServerUrl(this.remoteServerUrl);
        session.setRemoteServerUploadUrl(this.remoteServerUploadUrl);
        session.setRemoteServerDownloadUrl(this.remoteServerDownloadUrl);

        docObjectStore = ObjectFactory.getObjectStore(this.objectStoreName, session);
        Document doc = (Document) docObjectStore.getObject(BaseObject.TYPE_DOCUMENT, documentId);
        in1 = doc.getContent();
        System.out.println("documnet MIME type is : " + in1.getMimeType());
        //how to Update mimeType for the document???

    } catch (Exception ex) {
        ex.printStackTrace();
    }

    if (in1 != null) {
        in1.close();
    }

    return true;
}

Thank you in advance.

1

There are 1 answers

1
Christopher Powell On BEST ANSWER

FileNet is an EDMS system that structures it's records in a OOP fashion.

FileNet Document objects are instantiated from the FileNet Document Class. Regardless of the API used, FileNet will not allow an update to occur on MimeType. This is a constraint of the MimeType property.

IBM FileNet MimeType Properties

The link above defines the MimeType property, and displays its contraints: The key point here is : Settability: SETTABLE_ONLY_BEFORE_CHECKIN

This means that the MimeType property can only be set during the RESERVATION state of a Versionable object. Non-Versionable objects (like Annotations) are not able to have this constraint.