sessionManager无法解决使用documentum导出操作中java摆动的问题



我在处理documentum **代码2**中的导出操作时面临一个问题。这里代码1是Jbuttons和Jtext的代码,代码3是导出操作的代码。在引起问题的部分中:-

jLabel_messages.setText(te.exportExample(sessionManager,repository,docId,targetLocalDirectory));,我得到第一个参数 sessionManager 的错误消息,该消息说:"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:导出操作的操作处理程序代码:

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:EXPORT Code:

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

您没有提供太多细节,我也没有太多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);

最新更新