How to export both document's native and rendition content using IDfExportOperation in DFC documentum?

1.7k Views Asked by At

I have a task to export both document's native and rendition content. I'm using IDfExportOperation to export document native content. But the requirement is also to export the rendition format. How to do that? Can you please help me?

2

There are 2 best solutions below

0
On BEST ANSWER

With the following code you can get both native and rendition content. For rendition you need to use getRenditions() method of IDfSysObject.

public void execute(IDfSession dfSession, String objectId) throws DfException {
    boolean result;

    // Use the factory method to create an IDfExportOperation instance
    IDfExportOperation exportOperation = clientX.getExportOperation();

    IDfSysObject sysObject = (IDfSysObject) dfSession.getObject(new DfId(objectId));

    if (sysObject != null) {
        exportOperation.setDestinationDirectory("C:/path/to/folder");
        IDfDocument document = (IDfDocument) sysObject;
        // set the document name format
        document.setObjectName("[" + document.getVersionLabel(0) + "]" + "-" + document.getObjectName());

        IDfExportNode exportNode;

        if (document.isVirtualDocument()) {
            IDfVirtualDocument virtualDocument = document.asVirtualDocument("CURRENT", false);
            exportOperation.setDestinationDirectory("C:/path/to/folder");
            // Create an export node, adding the document/sysObject to the export operation object.
            exportNode = (IDfExportNode) exportOperation.add(virtualDocument);
        } else {
            // Create an export node, adding the document/sysObject to the export operation object.
            exportNode = (IDfExportNode) exportOperation.add(document);
        }
        // Get the document's format
        exportNode.setFormat(document.getContentType());
        result = exportOperation.execute();

        if (!result) {
            IDfList errors = exportOperation.getErrors();
            for (int i = 0; i < errors.getCount(); i++) {
                IDfOperationError operationError = (IDfOperationError) errors.get(i);
                System.out.println.error("Error in export operation :( with error code: " + operationError
                        .getErrorCode() + " and error message: " + operationError.getMessage());
            }
        } else {
            System.out.println.info("Exported document successfully :) with doc id: " + objectId + " having format "
                    + document.getContentType());
        }
        System.out.println.info("Processing rendition for the doc " + objectId);
        // get rendition
        IDfCollection dfCollection = document.getRenditions("r_object_id,rendition,full_format");
        try {
            while (dfCollection.next()) {
                String rendition = dfCollection.getString("rendition");

                if (Integer.parseInt(rendition) > 0) {
                    String format= dfCollection.getString("full_format");
                    if (format != null) {
                        String fileName = "C:/path/to/folder" + document.getObjectName() + "."
                                + format;
                        if (format.equalsIgnoreCase("pdf"))
                            sysObject.getFileEx(fileName, format, 0, false);
                            System.out.println.info("Rendition exported successfully for doc id:" + objectId);
                        }
                    }
                }
            }
        } catch (DfException dfe) {
            dfe.printStackTrace();
        } finally {
            if (dfCollection != null) {
                dfCollection.close();
            }
        }
    } else {
        System.out.println.info("Could not find doc id " + objectId + " in repository.");
    }
}
0
On

I have used the r_object_id to query the dmr_content object, matching the parent_id to the r-object_id, where full_format='redition-type'.

Pass that object_id to the IDfExportOperation.