This repository has been archived by the owner on Sep 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#74 New command for verifying server version
- Loading branch information
Showing
3 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
src/main/java/com/marklogic/appdeployer/command/admin/RequireAtLeastMl8Command.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.marklogic.appdeployer.command.admin; | ||
|
||
import com.marklogic.appdeployer.command.AbstractCommand; | ||
import com.marklogic.appdeployer.command.CommandContext; | ||
|
||
/** | ||
* Version 2.+ of ml-app-deployer requires at least version 8.x of MarkLogic. There are features in ml-app-deployer 2.x | ||
* - such as support for alerts and triggers - that require a certain version of 8, but we at least want to make sure | ||
* that no one tries to run this against ML 7 or an older version. | ||
*/ | ||
public class RequireAtLeastMl8Command extends AbstractCommand { | ||
|
||
@Override | ||
public void execute(CommandContext context) { | ||
int major = 0; | ||
try { | ||
String version = context.getAdminManager().getServerVersion(); | ||
if (logger.isInfoEnabled()) { | ||
logger.info("Verifying MarkLogic version is at least 8 or higher; version: " + version); | ||
} | ||
major = Integer.parseInt(version.split("\\.")[0]); | ||
} catch (Exception e) { | ||
logger.warn("Unable to verify MarkLogic version is 8 or higher, will continue with deployment; error: " | ||
+ e.getMessage()); | ||
major = 8; | ||
} | ||
if (major < 8) { | ||
throw new RuntimeException("Only MarkLogic versions 8 and higher are supported"); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
src/test/java/com/marklogic/appdeployer/command/admin/RequireAtLeastMl8Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.marklogic.appdeployer.command.admin; | ||
|
||
import org.junit.Test; | ||
|
||
import com.marklogic.appdeployer.AbstractAppDeployerTest; | ||
|
||
public class RequireAtLeastMl8Test extends AbstractAppDeployerTest { | ||
|
||
@Test | ||
public void testThatNoExceptionIsThrown() { | ||
initializeAppDeployer(new RequireAtLeastMl8Command()); | ||
appDeployer.deploy(appConfig); | ||
} | ||
} |