0

我在处理 documentum ** 代码 2** 中的导出操作的操作处理程序代码中遇到问题。这里代码 1是 Jbuttons 和 Jtext 的代码,代码 3是导出操作的代码。在导致问题的部分中:-

jLabel_messages.setText(te.exportExample(sessionManager,repository,docId,targetLocalDirectory));,我收到第一个参数sessionManger的错误消息,上面写着:“sessionManager 无法解析”。我也尝试在代码中实例化 sessionManager ,IDFsessionManager sessionManager = null;但它没有解决问题并且错误仍然发生。

任何人都可以帮助我或建议我对以下代码进行更改以纠正此问题吗?

Code1:调用actionevent的导出按钮

jTextField_localDirectory.setBounds(new Rectangle(470, 49, 85, 20));
    jLabel_exportFolder.setText("Export Documents: ");
    jLabel_exportFolder.setBounds(new Rectangle(365, 55, 85, 15));
    jLabel_exportFolder.setHorizontalAlignment(SwingConstants.LEFT);
    jButton_export.setText("Export Files");
    jButton_export.setBounds(new Rectangle(560, 45, 125, 20));
    jButton_export.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    jButton_export_actionPerformed(e);
                }
            });

Code2:导出操作的Action Handler代码:

private void jButton_export_actionPerformed(ActionEvent e)
{

String repository = jTextField_repositoryName.getText();
String docId =m_fileIDs.elementAt(list_id.getSelectedIndex()).toString();
String targetLocalDirectory = jTextField_localDirectory.getText();
TutorialExport te = new TutorialExport(); jLabel_messages.setText(te.exportExample(sessionManager,repository,docId,targetLocalDirectory));
}

代码 3:出口代码:

import com.documentum.com.DfClientX;
import com.documentum.com.IDfClientX;
import com.documentum.fc.client.IDfDocument;
import com.documentum.fc.client.IDfFormat;
import com.documentum.fc.client.IDfSession;
import com.documentum.fc.client.IDfSessionManager;
import com.documentum.fc.client.IDfSysObject;
import com.documentum.fc.common.DfId;
import com.documentum.fc.common.IDfId;
import com.documentum.operations.IDfExportNode;
import com.documentum.operations.IDfExportOperation;
public class TutorialExport
{
public TutorialExport()
{}
public String exportExample(
IDfSessionManager sessionManager,
String repository,
String docId,
String targetLocalDirectory
)
{
    IDfSession mySession = null;
    StringBuffer sb = new StringBuffer("");
    try
    {
    mySession = sessionManager.getSession(repository);
    IDfId idObj =
    mySession.getIdByQualification(
    "dm_sysobject where r_object_id='" + docId + "'"
    );
    IDfSysObject sysObj = (IDfSysObject) mySession.getObject(idObj);
    IDfClientX clientx = new DfClientX();
    IDfExportOperation eo = clientx.getExportOperation();
    IDfDocument doc =(IDfDocument) mySession.getObject(new DfId(docId));
    IDfExportNode node = (IDfExportNode) eo.add(doc);
    IDfFormat format = doc.getFormat();
    if (targetLocalDirectory.lastIndexOf("/") !=
    targetLocalDirectory.length() - 1
    &&
    targetLocalDirectory.lastIndexOf("\\") !=
    targetLocalDirectory.length()- 1 )
    {
    targetLocalDirectory += "/";
    }
    node.setFilePath(targetLocalDirectory + doc.getObjectName() + "." +
    format.getDOSExtension());

    if (eo.execute())
    {
    return "Export operation successful." + "\n" + sb.toString();
    }
    else
    {
    return "Export operation failed.";
    }
    }
    catch (Exception ex)
    {
    ex.printStackTrace();
    return "Exception has been thrown: " + ex;
    }

    finally
    {
    sessionManager.release(mySession);
    }
    }
    }
4

1 回答 1

0

您没有提供太多细节,而且我对 Java Swing 也没有太多经验,但是在我看来,您在实例化之前尝试使用变量 sessionManager。

通过 DFC 在您的自定义应用程序中实例化 Documentum 会话管理器的代码类似于:

//instantiating client
IDfClient myClient = DfClient.getLocalClient();
// create login info
IDfLoginInfo myLoginInfo = new DfLoginInfo();
myLoginInfo.setUser("user");
myLoginInfo.setPassword("pwd");
// create session manager
IDfSessionManager mySessionManager = myClient.newSessionManager();
mySessionManager.setIdentity("repositoryName", myLoginInfo);
于 2014-05-28T22:33:24.410 回答