Search in sources :

Example 1 with MigrationJobException

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);
    }
}
Also used : Path(java.nio.file.Path) MelToDwExpressionMigrator(com.mulesoft.tools.migration.library.tools.MelToDwExpressionMigrator) MigrationJobException(com.mulesoft.tools.migration.engine.exception.MigrationJobException) AbstractMigrationTask(com.mulesoft.tools.migration.task.AbstractMigrationTask) ProjectType(com.mulesoft.tools.migration.project.ProjectType) ApplicationModel(com.mulesoft.tools.migration.project.model.ApplicationModel) MigrationTaskException(com.mulesoft.tools.migration.exception.MigrationTaskException)

Example 2 with MigrationJobException

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();
    }
}
Also used : ReportEntryModel(com.mulesoft.tools.migration.report.html.model.ReportEntryModel) JSONReport(com.mulesoft.tools.migration.report.json.JSONReport) MigrationJobException(com.mulesoft.tools.migration.engine.exception.MigrationJobException) MigrationJobException(com.mulesoft.tools.migration.engine.exception.MigrationJobException) MigrationTaskException(com.mulesoft.tools.migration.exception.MigrationTaskException) HTMLReport(com.mulesoft.tools.migration.report.html.HTMLReport)

Example 3 with MigrationJobException

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);
    }
}
Also used : SAXBuilder(org.jdom2.input.SAXBuilder) LocatedJDOMFactory(org.jdom2.located.LocatedJDOMFactory) MigrationJobException(com.mulesoft.tools.migration.engine.exception.MigrationJobException) Document(org.jdom2.Document) URISyntaxException(java.net.URISyntaxException) MigrationJobException(com.mulesoft.tools.migration.engine.exception.MigrationJobException) IOException(java.io.IOException)

Aggregations

MigrationJobException (com.mulesoft.tools.migration.engine.exception.MigrationJobException)3 MigrationTaskException (com.mulesoft.tools.migration.exception.MigrationTaskException)2 MelToDwExpressionMigrator (com.mulesoft.tools.migration.library.tools.MelToDwExpressionMigrator)1 ProjectType (com.mulesoft.tools.migration.project.ProjectType)1 ApplicationModel (com.mulesoft.tools.migration.project.model.ApplicationModel)1 HTMLReport (com.mulesoft.tools.migration.report.html.HTMLReport)1 ReportEntryModel (com.mulesoft.tools.migration.report.html.model.ReportEntryModel)1 JSONReport (com.mulesoft.tools.migration.report.json.JSONReport)1 AbstractMigrationTask (com.mulesoft.tools.migration.task.AbstractMigrationTask)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 Path (java.nio.file.Path)1 Document (org.jdom2.Document)1 SAXBuilder (org.jdom2.input.SAXBuilder)1 LocatedJDOMFactory (org.jdom2.located.LocatedJDOMFactory)1