Source:
<code>private MigrationReport doImport( Path exportDirectory, Set<String> mandatoryMigratables, Optional<Consumer<MigrationMessage>> consumer) { Validate.notNull(exportDirectory, ConfigurationMigrationManager.INVALID_NULL_EXPORT_DIR); final MigrationReportImpl report = new MigrationReportImpl(MigrationOperation.IMPORT, consumer); MigrationZipFile zip = null; try { zip = newZipFileFor(exportDirectory); if (!zip.isValidChecksum()) { throw new MigrationException(Messages.IMPORT_ZIP_CHECKSUM_INVALID, zip.getZipPath()); } delegateToImportMigrationManager(report, zip, mandatoryMigratables); } catch (MigrationException e) { report.record(e); } catch (SecurityException e) { report.record( new MigrationException( <START> Messages.IMPORT_SECURITY_ERROR, zip == null ? exportDirectory : zip.getZipPath(), e)); <END> } catch (RuntimeException e) { report.record( new MigrationException( Messages.IMPORT_INTERNAL_ERROR, zip == null ? exportDirectory : zip.getZipPath(), e)); } report.end(); if ((zip == null) || report.hasErrors()) { SecurityLogger.audit( "Errors importing configuration settings from file {}", zip == null ? exportDirectory : zip.getZipPath()); report.record( new MigrationException( Messages.IMPORT_FAILURE, zip == null ? exportDirectory : zip.getZipPath())); } else if (report.hasWarnings()) { SecurityLogger.audit( "Warnings importing configuration settings from file {}", zip.getZipPath()); zip.deleteQuitetly(); report.record(new MigrationWarning(Messages.IMPORT_SUCCESS_WITH_WARNINGS, zip.getZipPath())); report.record(new MigrationWarning(Messages.RESTART_SYSTEM_WHEN_WARNINGS)); } else { SecurityLogger.audit("Exported configuration settings from file {}", zip.getZipPath()); zip.deleteQuitetly(); report.record(new MigrationSuccessfulInformation(Messages.IMPORT_SUCCESS, zip.getZipPath())); restart(report); } return report; }</code><technical_language>simply create a temp variable of type Path beginning exact logic variable opposed duplicating in X places? This reduce complexity of method</technical_language>

Target:
private MigrationReport doImport( Path exportDirectory, Set<String> mandatoryMigratables, Optional<Consumer<MigrationMessage>> consumer) { Validate.notNull(exportDirectory, ConfigurationMigrationManager.INVALID_NULL_EXPORT_DIR); final MigrationReportImpl report = new MigrationReportImpl(MigrationOperation.IMPORT, consumer); MigrationZipFile zip = null; Path exportPath = exportDirectory; try { zip = newZipFileFor(exportDirectory); exportPath = zip.getZipPath(); if (!zip.isValidChecksum()) { throw new MigrationException(Messages.IMPORT_ZIP_CHECKSUM_INVALID, exportPath); } delegateToImportMigrationManager(report, zip, mandatoryMigratables); } catch (MigrationException e) { report.record(e); } catch (SecurityException e) { report.record(new MigrationException(Messages.IMPORT_SECURITY_ERROR, exportPath, e)); } catch (RuntimeException e) { report.record(new MigrationException(Messages.IMPORT_INTERNAL_ERROR, exportPath, e)); } report.end(); if ((zip == null) || report.hasErrors()) { SecurityLogger.audit("Errors importing configuration settings from file {}", exportPath); report.record(new MigrationException(Messages.IMPORT_FAILURE, exportPath)); } else if (report.hasWarnings()) { SecurityLogger.audit("Warnings importing configuration settings from file {}", exportPath); zip.deleteQuitetly(); report.record(new MigrationWarning(Messages.IMPORT_SUCCESS_WITH_WARNINGS, exportPath)); report.record(new MigrationWarning(Messages.RESTART_SYSTEM_WHEN_WARNINGS)); } else { SecurityLogger.audit("Exported configuration settings from file {}", exportPath); zip.deleteQuitetly(); report.record(new MigrationSuccessfulInformation(Messages.IMPORT_SUCCESS, exportPath)); restart(report); } return report; }