-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pull and extract the content package set in distro.prop #286
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
System.out.println(artifactId); | ||
System.out.println(getParam(key)); | ||
System.out.println(Artifact.GROUP_CONTENT); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we can remove these System.out.println
s during clean up after all the reviews
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was this change intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @nravilla. Because of the number of formatting changes, this is a really hard PR to review. I've left a few pointers on things that stuck out to me, but I'll need more time to review the remaining files in any detail.
this.pluginManager = pluginManager; | ||
} | ||
|
||
public void downloadContent(File configurationDir, File tempContentDir, Artifact contentArtifact, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
public void downloadContent(File configurationDir, File tempContentDir, Artifact contentArtifact, | |
public void downloadContent(File configurationDir, File contentDir, Artifact contentArtifact, |
File targetDirectory = new File(configDir, "temp_content"); | ||
targetDirectory.mkdir(); | ||
|
||
List<Artifact> contents = distroProperties.getContentArtifacts(distroHelper, targetDirectory); | ||
if (!contents.isEmpty()) { | ||
wizard.showMessage("Downloading Contents...\n"); | ||
for (Artifact content : contents) { | ||
wizard.showMessage("Downloading Content: " + content); | ||
contentHelper.downloadContent(configDir, targetDirectory, content, moduleInstaller); | ||
} | ||
} | ||
FileUtils.deleteQuietly(targetDirectory); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this should be wrapped in something like:
File targetDirectory = new File(configDir, "temp_content"); | |
targetDirectory.mkdir(); | |
List<Artifact> contents = distroProperties.getContentArtifacts(distroHelper, targetDirectory); | |
if (!contents.isEmpty()) { | |
wizard.showMessage("Downloading Contents...\n"); | |
for (Artifact content : contents) { | |
wizard.showMessage("Downloading Content: " + content); | |
contentHelper.downloadContent(configDir, targetDirectory, content, moduleInstaller); | |
} | |
} | |
FileUtils.deleteQuietly(targetDirectory); | |
File targetDirectory = new File(configDir, "temp_content"); | |
targetDirectory.mkdir(); | |
try { | |
List<Artifact> contents = distroProperties.getContentArtifacts(distroHelper, targetDirectory); | |
if (!contents.isEmpty()) { | |
wizard.showMessage("Downloading Contents...\n"); | |
for (Artifact content : contents) { | |
wizard.showMessage("Downloading Content: " + content); | |
contentHelper.downloadContent(configDir, targetDirectory, content, moduleInstaller); | |
} | |
} | |
} finally { | |
FileUtils.deleteQuietly(targetDirectory); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, I always think that we should use Files.createTempDirectory()
to create a temporary directory.
|
||
List<Artifact> contents = distroProperties.getContentArtifacts(distroHelper, targetDirectory); | ||
if (!contents.isEmpty()) { | ||
wizard.showMessage("Downloading Contents...\n"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wizard.showMessage("Downloading Contents...\n"); | |
wizard.showMessage("Downloading content packages...\n"); |
if (!contents.isEmpty()) { | ||
wizard.showMessage("Downloading Contents...\n"); | ||
for (Artifact content : contents) { | ||
wizard.showMessage("Downloading Content: " + content); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wizard.showMessage("Downloading Content: " + content); | |
wizard.showMessage("Downloading content package: " + content); |
|
||
private void installContents(Server server, DistroProperties distroProperties) throws MojoExecutionException { | ||
if (distroProperties != null) { | ||
File tempContentDir = new File(server.getServerDirectory(), "temp-content"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comments here as before
if (backendConfigs == null || backendConfigs.listFiles().length == 0) { | ||
throw new MojoExecutionException("No directories to process under content configuration directories"); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no way that backendConfigs
could be null
here.
throw new MojoExecutionException("No directories to process under content configuration directories"); | ||
} | ||
|
||
for (File backendConfig : backendConfigs.listFiles()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (File backendConfig : backendConfigs.listFiles()) { | |
for (File configDir : backendConfigs.listFiles()) { |
if (!matchingConfigurationDir.exists() && !matchingConfigurationDir.isDirectory()) { | ||
//this folder is from content zip | ||
artifactDir = matchingConfigurationDir; | ||
} else { | ||
// Create a new folder with the artifactId under the matching output directory | ||
artifactDir = new File(matchingConfigurationDir, artifactId); | ||
if (!artifactDir.exists()) { | ||
artifactDir.mkdirs(); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Am I reading the logic here correctly? It says "if matchingConfigurationDir does not exist and it is not a directory, set artifactDir to matchingConfigurationDir, otherwise create a new subfolder"?
Assuming I'm reading that correctly:
- Under what circumstance can the
if
branch be true? - We always want to ensure that we are writing to a subfolder of the configuration directory, right?
} | ||
|
||
// Copy the content from inputDir to the newly created artifactDir | ||
copyDirectory(backendConfig, artifactDir); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FileUtils.copyDirectory()
can be used here.
executionEnvironment(mavenProject, mavenSession, pluginManager) | ||
); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't love all the reformatting in this PR. It makes it very hard to review and know if anything has changed and if so, what.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't commit files you haven't touched other than reformatting. If there are any changes here, can you please use GitHub comments to indicate what those are?
@ibacher @mherman22 Unable to resolve the formatting issues, will close this and create a new branch |
Description of what I changed
Modified classes to download and extract and move content packages (just the backend content)
Issue I worked on
https://openmrs.atlassian.net/browse/O3-3640
Checklist: I completed these to help reviewers :)
My IDE is configured to follow the code style of this project.
Acceptance tests (setup and build-distro was tested and it works
I ran
mvn clean install
right before creating this pull request andadded all formatting changes to my commit.
All existing tests passed.
My pull request is based on the latest changes of the master branch.