Search in sources :

Example 1 with MuleArtifactJsonModel

use of com.mulesoft.tools.migration.project.model.artifact.MuleArtifactJsonModel in project mule-migration-assistant by mulesoft.

the class ApplicationPersister method persistMuleArtifactJson.

private void persistMuleArtifactJson() throws IOException {
    Optional<MuleArtifactJsonModel> muleArtifactJsonModel = appModel.getMuleArtifactJsonModel();
    if (muleArtifactJsonModel.isPresent() && projectOutput instanceof MuleFourApplication) {
        String jsonContent = appModel.getMuleArtifactJsonModel().get().toString();
        File outputFile = ((MuleFourApplication) projectOutput).muleArtifactJson().toFile();
        try (FileWriter fileWriter = new FileWriter(outputFile)) {
            fileWriter.write(jsonContent);
        }
    }
}
Also used : FileWriter(java.io.FileWriter) MuleArtifactJsonModel(com.mulesoft.tools.migration.project.model.artifact.MuleArtifactJsonModel) File(java.io.File) MuleFourApplication(com.mulesoft.tools.migration.engine.project.structure.mule.four.MuleFourApplication)

Example 2 with MuleArtifactJsonModel

use of com.mulesoft.tools.migration.project.model.artifact.MuleArtifactJsonModel in project mule-migration-assistant by mulesoft.

the class SetSecurePropertiesTest method execute.

@Test
public void execute() throws IOException {
    setSecureProperties.execute(projectBasePath, report.getReport());
    MuleArtifactJsonModel model = MuleArtifactJsonModelUtils.buildMuleArtifactJson(muleArtifactJsonFile.toPath());
    assertThat("Secure properties were not created successfully", model.getSecureProperties().get(), equalTo(newArrayList("lala", "pepe")));
    Properties properties = new Properties();
    properties.load(new FileInputStream(muleAppProperties));
    assertThat("Secure properties should not exist", properties.containsKey("secure.properties"), is(false));
}
Also used : MuleArtifactJsonModel(com.mulesoft.tools.migration.project.model.artifact.MuleArtifactJsonModel) Properties(java.util.Properties) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Example 3 with MuleArtifactJsonModel

use of com.mulesoft.tools.migration.project.model.artifact.MuleArtifactJsonModel in project mule-migration-assistant by mulesoft.

the class SetSecureProperties method execute.

@Override
public void execute(Path projectBasePath, MigrationReport report) throws RuntimeException {
    try {
        List<String> secureProperties = resolveSecureProperties(projectBasePath);
        if (!secureProperties.isEmpty()) {
            MuleArtifactJsonModel currentModel = MuleArtifactJsonModelUtils.buildMuleArtifactJson(projectBasePath.resolve(MULE_ARTIFACT_JSON));
            MuleArtifactJsonModel updatedModel = MuleArtifactJsonModelUtils.buildMinimalMuleArtifactJson(currentModel.getMinMuleVersion(), secureProperties);
            FileUtils.write(projectBasePath.resolve(MULE_ARTIFACT_JSON).toFile(), updatedModel.toString(), MULE_ARTIFACT_DEFAULT_CHARSET);
        }
    } catch (IOException e) {
        throw new MigrationStepException("Could not update secureProperties based on mule-app.properties", e);
    }
}
Also used : MigrationStepException(com.mulesoft.tools.migration.exception.MigrationStepException) MuleArtifactJsonModel(com.mulesoft.tools.migration.project.model.artifact.MuleArtifactJsonModel) IOException(java.io.IOException)

Aggregations

MuleArtifactJsonModel (com.mulesoft.tools.migration.project.model.artifact.MuleArtifactJsonModel)3 MuleFourApplication (com.mulesoft.tools.migration.engine.project.structure.mule.four.MuleFourApplication)1 MigrationStepException (com.mulesoft.tools.migration.exception.MigrationStepException)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 Properties (java.util.Properties)1 Test (org.junit.Test)1