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);
}
}
}
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));
}
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);
}
}
Aggregations