sessionManager cannot be resolved issueaction handler of java swings in export operations using documentum

909 Views Asked by At

I am facing an issue in my action handler code to handle the export operation in documentum ** code 2**. Here code 1 is the code for Jbuttons and Jtext and code 3 is the code for the export operations. Here in the section that is causing problem:-

jLabel_messages.setText(te.exportExample(sessionManager,repository,docId,targetLocalDirectory)); ,I am getting an error message for the first parameter sessionManger that says: "sessionManager cannot be resolved". I tried to instantiate the sessionManager as well in the code like IDFsessionManager sessionManager = null; but it didn't solve the issue and the error still occurred.

Can anyone help me or suggest me the changes I need to do for my below code to rectify this issue?

Code1: Button of export invoking the 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 code for the export operation:

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

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

There are 1 best solutions below

0
On

You didn't provide much details, and I don't have much experience with Java Swing, but, it seems to me that you are trying to use variable sessionManager before you have instantiated it.

Code for instantiating Documentum session manager in your custom app via DFC is something like:

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