如何在 DFC documentum 中使用 IDfExportOperation 导出文档的本机内容和再现内容?

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

我的任务是导出文档的原生内容和再现内容。我正在使用 IDfExportOperation 导出文档本机内容。但要求也是导出演绎格式。怎么做?你能帮帮我吗?

我使用 r_object_id 查询 dmr_content 对象,将 parent_id 匹配到 r-object_id,其中 full_format='redition-type'.

将 object_id 传递给 IDfExportOperation。

使用以下代码,您可以获得原生内容和再现内容。对于再现,您需要使用 IDfSysObjectgetRenditions() 方法。

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.");
    }
}