【问题标题】:How to export both document's native and rendition content using IDfExportOperation in DFC documentum?如何在 DFC documentum 中使用 IDfExportOperation 导出文档的原生内容和再现内容?
【发布时间】:2020-07-27 17:16:42
【问题描述】:

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

【问题讨论】:

    标签: documentum dfc


    【解决方案1】:

    使用以下代码,您可以获得本机和再现内容。对于再现,您需要使用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.");
        }
    }
    

    【讨论】:

      【解决方案2】:

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

      将该 object_id 传递给 IDfExportOperation。

      【讨论】:

        猜你喜欢
        • 2012-09-02
        • 2014-04-10
        • 1970-01-01
        • 2011-04-06
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-03-21
        • 1970-01-01
        相关资源
        最近更新 更多