This repository was archived by the owner on Sep 16, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +55
-0
lines changed
appdeployer/command/admin
test/java/com/marklogic/appdeployer/command/admin Expand file tree Collapse file tree 3 files changed +55
-0
lines changed Original file line number Diff line number Diff line change 1+ package com .marklogic .appdeployer .command .admin ;
2+
3+ import com .marklogic .appdeployer .command .AbstractCommand ;
4+ import com .marklogic .appdeployer .command .CommandContext ;
5+
6+ /**
7+ * Version 2.+ of ml-app-deployer requires at least version 8.x of MarkLogic. There are features in ml-app-deployer 2.x
8+ * - such as support for alerts and triggers - that require a certain version of 8, but we at least want to make sure
9+ * that no one tries to run this against ML 7 or an older version.
10+ */
11+ public class RequireAtLeastMl8Command extends AbstractCommand {
12+
13+ @ Override
14+ public void execute (CommandContext context ) {
15+ int major = 0 ;
16+ try {
17+ String version = context .getAdminManager ().getServerVersion ();
18+ if (logger .isInfoEnabled ()) {
19+ logger .info ("Verifying MarkLogic version is at least 8 or higher; version: " + version );
20+ }
21+ major = Integer .parseInt (version .split ("\\ ." )[0 ]);
22+ } catch (Exception e ) {
23+ logger .warn ("Unable to verify MarkLogic version is 8 or higher, will continue with deployment; error: "
24+ + e .getMessage ());
25+ major = 8 ;
26+ }
27+ if (major < 8 ) {
28+ throw new RuntimeException ("Only MarkLogic versions 8 and higher are supported" );
29+ }
30+ }
31+
32+ }
Original file line number Diff line number Diff line change 1212import org .springframework .web .client .RestTemplate ;
1313
1414import com .marklogic .mgmt .AbstractManager ;
15+ import com .marklogic .rest .util .Fragment ;
1516import com .marklogic .rest .util .RestTemplateUtil ;
1617
1718public class AdminManager extends AbstractManager {
@@ -197,6 +198,14 @@ public boolean execute() {
197198 });
198199 }
199200
201+ public Fragment getServerConfig () {
202+ return new Fragment (restTemplate .getForObject (adminConfig .getBaseUrl () + "/admin/v1/server-config" , String .class ));
203+ }
204+
205+ public String getServerVersion () {
206+ return getServerConfig ().getElementValue ("/m:host/m:version" );
207+ }
208+
200209 public void setWaitForRestartCheckInterval (int waitForRestartCheckInterval ) {
201210 this .waitForRestartCheckInterval = waitForRestartCheckInterval ;
202211 }
Original file line number Diff line number Diff line change 1+ package com .marklogic .appdeployer .command .admin ;
2+
3+ import org .junit .Test ;
4+
5+ import com .marklogic .appdeployer .AbstractAppDeployerTest ;
6+
7+ public class RequireAtLeastMl8Test extends AbstractAppDeployerTest {
8+
9+ @ Test
10+ public void testThatNoExceptionIsThrown () {
11+ initializeAppDeployer (new RequireAtLeastMl8Command ());
12+ appDeployer .deploy (appConfig );
13+ }
14+ }
You can’t perform that action at this time.
0 commit comments