Sample ImportList interface usage
Use the ImportList interface to create an import list container object to hold the names, types, and action modes of the objects that are in a given compressed file that was created in the export environment of the source instance of Product Master.
You use the import list container object to create new compressed files that contain only the objects that you specify for import into the target instance of Product Master.
See IBM® Javadoc Documentation to view all of the available information on the parameters, returns, exceptions, and syntax for the ImportList class.
This sample code shows the getObjectTypes() method that is being used to retrieve all the objects from the import list container object, then uses the removeObject(ExportList.Type type, java.lang.String objectName) method to remove the object of type Type.CATALOG with name MyCatalog from the import list container object. The removeObjects(ExportList.Type type) method is also used to remove all objects of type Type.CATALOG_CONTENT. The createZip(java.lang.String documentPath) method is then used to create a compressed file that contains only the objects that remain in the import list container object and stores the compressed file in the /data/wpc.zip directory in the document store.
Context ctx = null;
EnvironmentImporter envImporter = null;
ImportList importList = null;
try
{
ctx = PIMContextFactory.getContext("Admin","xxx","MyCompany");
envImporter = ctx.getEnvironmentImporter();
Document archiveDocument = ctx.getDocstoreManager().getDocument("/data/wpc.zip");
importList=envImporter.getImportList(archiveDocument);
Set<Type> objTyps=importList.getObjectTypes();
importList.removeObject(Type.CATALOG, "MyCatalog");
importList.removeObjects(Type.CATALOG_CONTENT);
importList.createZip("/data/wpc.zip");
}
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());
}