|
| 1 | +///usr/bin/env jbang "$0" "$@" ; exit $? |
| 2 | +//REPOS mavencentral,github=https://maven.pkg.github.com/4PointSolutions/* |
| 3 | +//DEPS info.picocli:picocli:4.7.6 |
| 4 | +//DEPS com._4point.aem:aem-package-manager-api:0.0.1-SNAPSHOT |
| 5 | +//DEPS org.slf4j:slf4j-simple:2.0.17 |
| 6 | +//JAVA 21+ |
| 7 | + |
| 8 | +import picocli.CommandLine; |
| 9 | +import picocli.CommandLine.Command; |
| 10 | +import picocli.CommandLine.Parameters; |
| 11 | + |
| 12 | +import java.nio.file.Path; |
| 13 | +import java.util.concurrent.Callable; |
| 14 | + |
| 15 | +import com._4point.aem.package_manager.FormsAndDocumentsClient; |
| 16 | +import com._4point.aem.package_manager.PackageManagerClient; |
| 17 | + |
| 18 | +@Command(name = "deploy_it_assets", mixinStandardHelpOptions = true, version = "deploy_it_assets 0.1", |
| 19 | + description = "deploy_it_assets made with jbang") |
| 20 | +class deploy_it_assets implements Callable<Integer> { |
| 21 | + private static final String AF_TEST_FORMS_GROUP = "fd/export"; |
| 22 | + private static final String AEM_SERVER_NAME = "localhost"; |
| 23 | + private static final Integer AEM_SERVER_PORT = 4502; |
| 24 | + private static final String AEM_SERVER_USER = "admin"; |
| 25 | + private static final String AEM_SERVER_PASSWORD = "admin"; |
| 26 | + private static final Path REST_SERVICES_PROJECT_DIR = Path.of(".."); |
| 27 | + private static final Path SAMPLES_DIR = REST_SERVICES_PROJECT_DIR.resolve(Path.of("it.tests", "src", "test", "resources")); |
| 28 | + private static final Path AF_TEST_FORMS_PATH = SAMPLES_DIR.resolve("sample00002test.zip"); |
| 29 | + private static final Path OF_TEST_FORMS_PATH = SAMPLES_DIR.resolve("SampleForm.xdp"); |
| 30 | + |
| 31 | + |
| 32 | + // | These are integration tests so, in order for these tests to run, there needs to be a running AEM instance locally on |
| 33 | + // | port 4502 (or non-locally if you're willing to modify the TEST_MACHINE and TEST_MACHINE_PORT values in TestUtils.java). |
| 34 | + // | |
| 35 | + // | The testing instance must have the SampleForm.xdp uploaded into a directory named sample-forms that resides directly under the |
| 36 | + // | FormsAndDocuments within the CRX repository. Without this, all the crx-related tests will fail. |
| 37 | + // | |
| 38 | + // | The testing instance must have the sample0002test.zip and sampleForm_JSON.zip packages uploaded amd installed. |
| 39 | + // | These packages contain adaptive forms that reside directly under theFormsAndDocuments called sample0002test and sample-json-adaptive-form-1. |
| 40 | + // | Without these forms, all the adaptive forms tests will fail. |
| 41 | + // | |
| 42 | + // | Protected mode must be turned off, per this: https://experienceleague.adobe.com/docs/experience-manager-65/forms/html5-forms/preview-xdp-forms-html.html?lang=en#disable-protected-mode |
| 43 | + // | |
| 44 | + // | Also, the testing instance must have a ReaderExtensions credential installed under admin using an alias of "recred" in order for |
| 45 | + // | all the SecureDocument/testReaderExtendPDF tests to pass. |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | + @Parameters(index = "0", description = "The greeting to print", defaultValue = "World!") |
| 50 | + private String greeting; |
| 51 | + |
| 52 | + public static void main(String... args) { |
| 53 | + int exitCode = new CommandLine(new deploy_it_assets()).execute(args); |
| 54 | + System.exit(exitCode); |
| 55 | + } |
| 56 | + |
| 57 | + @Override |
| 58 | + public Integer call() throws Exception { // your business logic goes here... |
| 59 | + |
| 60 | + System.out.println("ProjectDir = '" + REST_SERVICES_PROJECT_DIR.toRealPath().toAbsolutePath() + "'"); |
| 61 | + var pmClient = PackageManagerClient.builder() |
| 62 | + // By commenting the server name, port, user, and password lines out, the location defaults to locahost:4502 and admin/admin. |
| 63 | + .serverName(AEM_SERVER_NAME) |
| 64 | + .port(AEM_SERVER_PORT) |
| 65 | + .user(AEM_SERVER_USER) |
| 66 | + .password(AEM_SERVER_PASSWORD) |
| 67 | + // .password("admin") |
| 68 | + .logger(System.out::println) |
| 69 | + .buildEx(); |
| 70 | + |
| 71 | + |
| 72 | + // Un-install the current package(s) on the AEM server instance before uploading and installing any new packages... |
| 73 | + pmClient.uninstallAndDeletePackages(pkg->AF_TEST_FORMS_GROUP.equals(pkg.group())); |
| 74 | + |
| 75 | + // Upload and install the Sample Adaptive Forms package... |
| 76 | + pmClient.uploadPackage(AF_TEST_FORMS_PATH); |
| 77 | + pmClient.installPackage(AF_TEST_FORMS_GROUP, "DownloadedFormsPackage_525101667060900.zip"); |
| 78 | + |
| 79 | + System.out.println("AF Installed!"); |
| 80 | + |
| 81 | + |
| 82 | + var fadClient = FormsAndDocumentsClient.builder() |
| 83 | + // By commenting the server name, port, user, and password lines out, the location defaults to locahost:4502 and admin/admin. |
| 84 | + .serverName(AEM_SERVER_NAME) |
| 85 | + .port(AEM_SERVER_PORT) |
| 86 | + .user(AEM_SERVER_USER) |
| 87 | + .password(AEM_SERVER_PASSWORD) |
| 88 | + //.password("admin") |
| 89 | + .logger(System.out::println) |
| 90 | + .buildEx(); |
| 91 | + |
| 92 | + fadClient.upload(OF_TEST_FORMS_PATH, "sample-forms"); |
| 93 | + |
| 94 | + |
| 95 | + System.out.println("Sample forms deployed!"); |
| 96 | + |
| 97 | + return 0; |
| 98 | + } |
| 99 | +} |
0 commit comments