Skip to content

Commit

Permalink
Changed Content to ContentConfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
nravilla committed Sep 9, 2024
1 parent 776b404 commit 89120ef
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,9 @@ private String buildDistro(File targetDirectory, Artifact distroArtifact, Distro

File owasDir = new File(tempDir, "bundledOwas");
owasDir.mkdir();
downloadOWAs(targetDirectory, distroProperties, owasDir);
downloadContents(web, distroProperties);
downloadOWAs(targetDirectory, distroProperties, owasDir);
spaInstaller.installFromDistroProperties(tempDir, distroProperties, ignorePeerDependencies, overrideReuseNodeCache);
installContentConfiguration(web, distroProperties);
File frontendDir = new File(tempDir, "frontend");
if(frontendDir.exists()) {
frontendDir.renameTo(new File(tempDir, "bundledFrontend"));
Expand Down Expand Up @@ -325,7 +325,7 @@ private String buildDistro(File targetDirectory, Artifact distroArtifact, Distro
File configDir = new File(web, SDKConstants.OPENMRS_SERVER_CONFIGURATION);
configDir.mkdir();
setConfigFolder(configDir, distroProperties, distroArtifact);
downloadContents(web, distroProperties);
installContentConfiguration(web, distroProperties);
spaInstaller.installFromDistroProperties(web, distroProperties, ignorePeerDependencies, overrideReuseNodeCache);

File owasDir = new File(web, "owa");
Expand Down Expand Up @@ -622,7 +622,7 @@ public boolean accept(File dir, String name) {
}
}

private void downloadContents(File web, DistroProperties distroProperties) throws MojoExecutionException {
private void installContentConfiguration(File web, DistroProperties distroProperties) throws MojoExecutionException {

ContentHelper contentHelper = new ContentHelper(web);
File tempContentDirectory = new File(web, "temp_content");
Expand Down
23 changes: 21 additions & 2 deletions maven-plugin/src/main/java/org/openmrs/maven/plugins/Setup.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import org.openmrs.maven.plugins.model.DistroProperties;
import org.openmrs.maven.plugins.model.Server;
import org.openmrs.maven.plugins.model.Version;
import org.openmrs.maven.plugins.utility.ContentHelper;
import org.openmrs.maven.plugins.utility.DBConnector;
import org.openmrs.maven.plugins.utility.DistroHelper;
import org.openmrs.maven.plugins.utility.SDKConstants;
Expand Down Expand Up @@ -279,6 +280,7 @@ public void setup(Server server, DistroProperties distroProperties) throws MojoE
distroHelper.parseContentProperties(distroProperties);
moduleInstaller.installModulesForDistro(server, distroProperties, distroHelper);
setConfigFolder(server, distroProperties);
installContentConfiguration(server, distroProperties);
if (spaInstaller != null) {
spaInstaller.installFromDistroProperties(server.getServerDirectory(), distroProperties, ignorePeerDependencies, overrideReuseNodeCache);
}
Expand Down Expand Up @@ -330,7 +332,7 @@ private void installOWAs(Server server, DistroProperties distroProperties) throw
owasDir.mkdir();
downloadOWAs(server.getServerDirectory(), distroProperties, owasDir);
}
}
}

private void downloadOWAs(File targetDirectory, DistroProperties distroProperties, File owasDir)
throws MojoExecutionException {
Expand All @@ -343,7 +345,24 @@ private void downloadOWAs(File targetDirectory, DistroProperties distroPropertie
}
}
}


private void installContentConfiguration(Server server, DistroProperties distroProperties) throws MojoExecutionException {
if (distroProperties != null) {
File tempContentDir = new File(server.getServerDirectory(), "temp-content");
tempContentDir.mkdir();
List<Artifact> contents = distroProperties.getContentArtifacts(distroHelper, tempContentDir);
ContentHelper contentHelper = new ContentHelper(server.getServerDirectory());

if (!contents.isEmpty()) {
for (Artifact content : contents) {
wizard.showMessage("Downloading Content: " + content + "\n");
contentHelper.downloadContent(content, moduleInstaller, tempContentDir);
}
}
FileUtils.deleteQuietly(tempContentDir);
}
}

/**
* Sets the configuration folder for the specified server using the provided distro properties.
*
Expand Down

0 comments on commit 89120ef

Please sign in to comment.