try
{
// Update the definition source to be the location from which the file is saved
final ResourceManager resourceManager = report.getResourceManager();
final Resource bundleResource = resourceManager.createDirectly(target, DocumentBundle.class);
final DocumentBundle bundle = (DocumentBundle) bundleResource.getResource();
final ResourceKey bundleKey = bundle.getBundleKey();
report.setDefinitionSource(bundleKey);
report.setContentBase(bundleKey);
report.setBundle(bundle);
report.setResourceManager(bundle.getResourceManager());
activeContext.resetChangeTracker();
}
catch (ResourceException e)
{
UncaughtExceptionsModel.getInstance().addException(e);