Sample EnvironmentExporter interface usage

Use the EnvironmentExporter interface to create an export list container object that holds the names of objects to be exported and the action modes that each object uses during import. The interface also defines methods for exporting objects of a specified export list container object into a compressed file in the document store.

See IBM® Javadoc Documentation to view all the available information about the parameters, returns, exceptions, and syntax for the EnvironmentExporter class.

This sample code uses the export(ExportList exportList, java.lang.String documentPath, boolean checkForRequisites) method to export all the objects in the export list container object, exportList, to the /data/wpc directory. If the export fails, another export will be attempted only after the export list container object is updated to include all dependent objects.

Context ctx = null;
EnvironmentExporter envExporter = null;
ExportList exportList = null;
try
{
    ctx = PIMContextFactory.getContext("Admin","xxx","MyCompany");
    envExporter= ctx.getEnvironmentExporter();
    exportList=envExporter.createExportList();
    //Add objects to the exportList
    try{
        envExporter.export(exportList, "/data/wpc.zip", true);   
    }
    catch (PIMInternalException exc)
    {
        exportList.addAllRequisites();
        envExporter.export(exportList, "/data/wpc.zip", true);
        //Modify the exportList to include required objects and retry the 
        //export
    }

}
catch (PIMAuthorizationException ae)
{
    // Expected a failure
    System.out.println("Authorization Failure");
    return;
}
catch(PIMInternalException ie)
{
    System.out.println("Internal Error");
    return;
}
catch(Exception e)
{
    System.out.println(e.getMessage());
}
This sample code uses the export(ExportList exportList, java.lang.String documentPath, boolean checkForRequisites, java.lang.String mappingPath) method to export all the objects in the export list container object, exportList, to the /data/wpc directory. It creates the file names inside the compressed file package according to the name mapping provided in the XML file at mappingPath.
Context ctx = null;
EnvironmentExporter envExporter = null;
ExportList exportList = null;
try
{
    ctx = PIMContextFactory.getContext("Admin","xxx","MyCompany");
    envExporter= ctx.getEnvironmentExporter();
    exportList=envExporter.createExportList();
    //Add objects to the exportList
    try{
        envExporter.export(exportList, "/data/wpc.zip", true, "/config/namemapping.xml");   
    }
    catch (PIMInternalException exc)
    {
        exportList.addAllRequisites();
        envExporter.export(exportList, "/data/wpc.zip", true, "/config/namemapping.xml");
        //Modify the exportList to include required objects and retry the 
        //export
    }

}
catch (PIMAuthorizationException ae)
{
    // Expected a failure
    System.out.println("Authorization Failure");
    return;
}
catch(PIMInternalException ie)
{
    System.out.println("Internal Error");
    return;
}
catch(Exception e)
{
    System.out.println(e.getMessage());
}