Hi All,
I am trying to find a solution for uploading files into the folders inside cabinets programaticaly.Having referred the DFC documentation i found an example featuring IDfImportOperation functionality.The following is the Java code described there:
package com.emc.tutorial;
import com.documentum.com.DfClientX;
import com.documentum.com.IDfClientX;
import com.documentum.fc.client.IDfFolder;
import com.documentum.fc.client.IDfSession;
import com.documentum.fc.client.IDfSessionManager;
import com.documentum.fc.common.DfException;
import com.documentum.operations.IDfFile;
import com.documentum.operations.IDfImportNode;
import com.documentum.operations.IDfImportOperation;
public class TutorialImport
{
public TutorialImport()
{}
public String importExample(IDfSessionManager sessionManager,String repositoryName,String destinationDirectory,String sourceFilePath){IDfSession mySession = null;
try
{
mySession = sessionManager.getSession(repositoryName);
// Create a new client instance.
IDfClientX clientx = new DfClientX();
// Use the factory method to create an IDfImportOperation instance.
IDfImportOperation opi = clientx.getImportOperation();
// You must explicitly set the session for an import operation.
opi.setSession(mySession);
// Create an instance of the target folder.
IDfFolder folder = mySession.getFolderByPath(destinationDirectory);
// Create a file instance for the local file.
IDfFile file = clientx.getFile(sourceFilePath);
if (!file.exists())
return ("File does not exist.");
// Set the destination folder.
opi.setDestinationFolderId(folder.getObjectId());
// Create the import node, adding the file to the import operation.
IDfImportNode node = (IDfImportNode) opi.add(file);
if (node == null)
return ("Node is null.");
// Execute the import operation and return the results.
if (opi.execute())
{
String resultString =
("Item" + opi.getNewObjects().toString() +
" imported successfully.");
return resultString;
}
else
{
return ("Error during import operation.");
}
// Handle any exceptions.
}
catch (Exception ex)
{
ex.printStackTrace();
return "Exception has been thrown: " + ex;
}
// Always, always, release the session in the "finally" clause.
finally
{
sessionManager.release(mySession);
}
}}
Two of my queries are:
1) What should be passed as a parameter for "destinationDirectory" ? Should it be the r_object_id of the destination folder of choice?
2) What should be passed as a parameter for "sourceFilePath" ? Is it the absolute path?
If i want to pass a bytearray instead of sourceFilePath. How can i achieve it?
I modified the above code to pass a ByteArrayInputStream instead of the sourceFilePath.
IDfFolder folder = mySession.getFolderByPath(destinationDirectory);// Create a file instance for the local file.String filea = clientx.ByteArrayInputStreamToString(bytearr);IDfFile file = clientx.getFile(filea);
Is this a correct approach to direct content to the folder if it is available only in the form of bytearray.In my case the file comes from a webservice in the form of Byte Array
I hope i will get your guidance as always.
Thank You
Regards