use of com.mulesoft.tools.migration.engine.exception.MigrationJobException in project mule-migration-assistant by mulesoft.
the class MigrationJob method execute.
@Override
public void execute(MigrationReport report) throws Exception {
ApplicationModel applicationModel = generateSourceApplicationModel(project);
report.initialize(applicationModel.getProjectType(), project.getFileName().toString());
Path sourceProjectBasePath = applicationModel.getProjectBasePath();
persistApplicationModel(applicationModel);
ProjectType targetProjectType = applicationModel.getProjectType().getTargetType();
applicationModel = generateTargetApplicationModel(outputProject, targetProjectType, sourceProjectBasePath, projectParentGAV, projectGAV);
try {
for (AbstractMigrationTask task : migrationTasks) {
if (task.getApplicableProjectTypes().contains(targetProjectType)) {
task.setApplicationModel(applicationModel);
task.setExpressionMigrator(new MelToDwExpressionMigrator(report, applicationModel));
try {
task.execute(report);
persistApplicationModel(applicationModel);
applicationModel = generateTargetApplicationModel(outputProject, targetProjectType, sourceProjectBasePath, projectParentGAV, projectGAV);
} catch (MigrationTaskException ex) {
if (cancelOnError) {
throw ex;
} else {
logger.error("Failed to apply task, rolling back and continuing with the next one.", ex);
}
} catch (RuntimeException e) {
throw new MigrationJobException("Failed to continue executing migration: " + e.getClass().getName() + ": " + e.getMessage(), e);
}
}
}
} finally {
generateReport(report, applicationModel);
}
}
use of com.mulesoft.tools.migration.engine.exception.MigrationJobException in project mule-migration-assistant by mulesoft.
the class MigrationJob method generateReport.
private void generateReport(MigrationReport<ReportEntryModel> report, ApplicationModel applicationModel) throws Exception {
List<ReportEntryModel> reportEntries = report.getReportEntries();
for (ReportEntryModel entry : reportEntries) {
try {
entry.setElementLocation();
} catch (Exception ex) {
throw new MigrationJobException("Failed to generate report.", ex);
}
}
HTMLReport htmlReport = new HTMLReport(report, reportPath.toFile(), this.getRunnerVersion());
htmlReport.printReport();
if (jsonReportEnabled) {
applicationModel.getPomModel().ifPresent(p -> report.addConnectors(p));
JSONReport jsonReport = new JSONReport(report, reportPath.toFile(), outputProject);
jsonReport.printReport();
}
}
use of com.mulesoft.tools.migration.engine.exception.MigrationJobException in project mule-migration-assistant by mulesoft.
the class ReportEntryModel method setElementLocation.
public void setElementLocation() throws Exception {
try {
SAXBuilder saxBuilder = new SAXBuilder();
saxBuilder.setJDOMFactory(new LocatedJDOMFactory());
if (filePath != null) {
Document document = saxBuilder.build(Paths.get(filePath).toFile());
setElementLocation(document);
}
} catch (Exception ex) {
throw new MigrationJobException("Failed to obtain new element location.", ex);
}
}
Aggregations