Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 2d32afe

Browse files
committed
#340 New support for installing plugins
1 parent a660981 commit 2d32afe

File tree

12 files changed

+735
-8
lines changed

12 files changed

+735
-8
lines changed

src/main/java/com/marklogic/appdeployer/AppConfig.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ public class AppConfig {
237237
private File projectDir;
238238

239239
private DataConfig dataConfig;
240+
private PluginConfig pluginConfig;
240241

241242
public AppConfig() {
242243
this(null);
@@ -246,6 +247,7 @@ public AppConfig(File projectDir) {
246247
this.projectDir = projectDir;
247248

248249
dataConfig = new DataConfig(projectDir);
250+
pluginConfig = new PluginConfig(projectDir);
249251

250252
modulePaths = new ArrayList<>();
251253
String path = projectDir != null ? new File(projectDir, DEFAULT_MODULES_PATH).getAbsolutePath() : DEFAULT_MODULES_PATH;
@@ -1325,4 +1327,12 @@ public DataConfig getDataConfig() {
13251327
public void setDataConfig(DataConfig dataConfig) {
13261328
this.dataConfig = dataConfig;
13271329
}
1330+
1331+
public PluginConfig getPluginConfig() {
1332+
return pluginConfig;
1333+
}
1334+
1335+
public void setPluginConfig(PluginConfig pluginConfig) {
1336+
this.pluginConfig = pluginConfig;
1337+
}
13281338
}

src/main/java/com/marklogic/appdeployer/DefaultAppConfigFactory.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,7 @@ public void initialize() {
690690
});
691691

692692
registerDataLoadingProperties();
693+
registerPluginProperties();
693694
}
694695

695696
protected void registerDataLoadingProperties() {
@@ -739,6 +740,33 @@ protected void registerDataLoadingProperties() {
739740
});
740741
}
741742

743+
protected void registerPluginProperties() {
744+
propertyConsumerMap.put("mlPluginDatabaseName", (config, prop) -> {
745+
logger.info("Database that plugins will be loaded into and installed from: " + prop);
746+
config.getPluginConfig().setDatabaseName(prop);
747+
});
748+
749+
propertyConsumerMap.put("mlPluginInstallationEnabled", (config, prop) -> {
750+
logger.info("Whether plugins will be installed: " + prop);
751+
config.getPluginConfig().setEnabled(Boolean.parseBoolean(prop));
752+
});
753+
754+
propertyConsumerMap.put("mlPluginPaths", (config, prop) -> {
755+
logger.info("Paths that plugins will be installed from: " + prop);
756+
List<String> paths = new ArrayList<>();
757+
for (String s : prop.split(",")) {
758+
String path = this.projectDir != null ? new File(projectDir, s).getAbsolutePath() : s;
759+
paths.add(path);
760+
}
761+
config.getPluginConfig().setPluginPaths(paths);
762+
});
763+
764+
propertyConsumerMap.put("mlPluginUriPrefix", (config, prop) -> {
765+
logger.info("URI prefix for plugins: " + prop);
766+
config.getPluginConfig().setUriPrefix(prop);
767+
});
768+
}
769+
742770
protected ConfigDir buildConfigDir(String path) {
743771
File baseDir = this.projectDir != null ? new File(this.projectDir, path) : new File(path);
744772
return new ConfigDir(baseDir);
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
package com.marklogic.appdeployer;
2+
3+
import java.io.File;
4+
import java.util.ArrayList;
5+
import java.util.List;
6+
7+
/**
8+
* This is for installing MarkLogic plugins, not Data Hub Framework plugins.
9+
*/
10+
public class PluginConfig {
11+
12+
public final static String DEFAULT_PLUGIN_PATH = "src/main/ml-plugins";
13+
public final static String DEFAULT_PLUGIN_URI_PREFIX = "/com.marklogic/plugins/";
14+
15+
public final static String DEFAULT_INSTALL_SCRIPT = "import module namespace plugin = 'http://marklogic.com/extension/plugin' at 'MarkLogic/plugin/plugin.xqy'; " +
16+
"declare variable $uri external; " +
17+
"declare variable $scope external; " +
18+
"plugin:install-from-zip($scope, fn:doc($uri)/node())";
19+
20+
public final static String DEFAULT_UNINSTALL_SCRIPT = "import module namespace plugin = 'http://marklogic.com/extension/plugin' at 'MarkLogic/plugin/plugin.xqy'; " +
21+
"declare variable $scope external; " +
22+
"plugin:uninstall($scope)";
23+
24+
private List<String> pluginPaths;
25+
private boolean enabled = true;
26+
private String databaseName;
27+
private String uriPrefix = DEFAULT_PLUGIN_URI_PREFIX;
28+
private String installScript = DEFAULT_INSTALL_SCRIPT;
29+
private String uninstallScript = DEFAULT_UNINSTALL_SCRIPT;
30+
private String makeCommand = "make";
31+
private String scope = "native";
32+
33+
private File projectDir;
34+
35+
public PluginConfig(File projectDir) {
36+
this.projectDir = projectDir;
37+
38+
pluginPaths = new ArrayList<>();
39+
String path = projectDir != null ? new File(projectDir, DEFAULT_PLUGIN_PATH).getAbsolutePath() : DEFAULT_PLUGIN_PATH;
40+
pluginPaths.add(path);
41+
}
42+
43+
public List<String> getPluginPaths() {
44+
return pluginPaths;
45+
}
46+
47+
public void setPluginPaths(List<String> pluginPaths) {
48+
this.pluginPaths = pluginPaths;
49+
}
50+
51+
public boolean isEnabled() {
52+
return enabled;
53+
}
54+
55+
public void setEnabled(boolean enabled) {
56+
this.enabled = enabled;
57+
}
58+
59+
public String getDatabaseName() {
60+
return databaseName;
61+
}
62+
63+
public void setDatabaseName(String databaseName) {
64+
this.databaseName = databaseName;
65+
}
66+
67+
public String getUriPrefix() {
68+
return uriPrefix;
69+
}
70+
71+
public void setUriPrefix(String uriPrefix) {
72+
this.uriPrefix = uriPrefix;
73+
}
74+
75+
public String getInstallScript() {
76+
return installScript;
77+
}
78+
79+
public void setInstallScript(String installScript) {
80+
this.installScript = installScript;
81+
}
82+
83+
public String getMakeCommand() {
84+
return makeCommand;
85+
}
86+
87+
public void setMakeCommand(String makeCommand) {
88+
this.makeCommand = makeCommand;
89+
}
90+
91+
public String getScope() {
92+
return scope;
93+
}
94+
95+
public void setScope(String scope) {
96+
this.scope = scope;
97+
}
98+
99+
public String getUninstallScript() {
100+
return uninstallScript;
101+
}
102+
103+
public void setUninstallScript(String uninstallScript) {
104+
this.uninstallScript = uninstallScript;
105+
}
106+
107+
public File getProjectDir() {
108+
return projectDir;
109+
}
110+
}

src/main/java/com/marklogic/appdeployer/command/SortOrderConstants.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ public abstract class SortOrderConstants {
7777

7878
public static Integer LOAD_DATA = 1300;
7979

80+
public static Integer INSTALL_PLUGINS = 1400;
81+
8082
public static Integer DELETE_MIMETYPES = 8500;
8183

8284
public static Integer UNASSIGN_HOSTS_FROM_GROUPS = 8590;
@@ -117,4 +119,6 @@ public abstract class SortOrderConstants {
117119
public static Integer DELETE_AMPS = 2000;
118120

119121
public static Integer DELETE_SCHEDULED_TASKS = 1000;
122+
123+
public static Integer UNINSTALL_PLUGINS = 500;
120124
}

0 commit comments

Comments
 (0)