Skip to content

Commit 33614c6

Browse files
committed
Merge branch 'feature/entity-services' into develop
2 parents 457ebcb + 6b6bdb8 commit 33614c6

File tree

89 files changed

+755
-404
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

89 files changed

+755
-404
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
### Welcome Hub enthusiast!
2+
3+
Let's get the most out of this ticket.
4+
5+
#### The issue
6+
7+
Short description of the problem:
8+
9+
What behavior are you expecting?
10+
11+
#### Tech details
12+
13+
Which Operating System are you using?
14+
15+
Which version of MarkLogic are you using?
16+
17+
Which version of the Data Hub Framework are you using?
18+
19+
Is this a QuickStart UI bug? If so, which browser are you using?
20+
21+
#### The devil is in the details...
22+
23+
If possible, rerun the command with -d for debugging output and attach the output:
24+
25+
**for quickstart:**
26+
`java -jar quickstart.war -d > myoutput.txt`
27+
28+
**for gradle:**
29+
`gradle mlYourCommand -d > myoutput.txt`

marklogic-data-hub/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ dependencies {
2222
compile 'org.springframework.batch:spring-batch-core:3.0.6.RELEASE'
2323
compile 'org.springframework:spring-jdbc:4.2.6.RELEASE'
2424
compile 'com.marklogic:java-client-api:3.0.5'
25-
compile 'com.marklogic:ml-javaclient-util:2.9.1'
25+
compile 'com.marklogic:ml-javaclient-util:2.10.0'
2626
compile 'com.marklogic:ml-app-deployer:2.3.0'
2727
compile 'com.marklogic:marklogic-spring-batch-core:0.7.0'
2828
compile 'commons-io:commons-io:2.4'

marklogic-data-hub/src/main/java/com/marklogic/hub/DataHub.java

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,12 @@
5151
import com.marklogic.client.helper.LoggingObject;
5252
import com.marklogic.client.io.JacksonHandle;
5353
import com.marklogic.client.util.RequestParameters;
54-
import com.marklogic.hub.commands.DeployHubDatabasesCommand;
55-
import com.marklogic.hub.commands.LoadHubModulesCommand;
56-
import com.marklogic.hub.commands.LoadUserModulesCommand;
54+
import com.marklogic.hub.deploy.commands.DeployHubDatabasesCommand;
55+
import com.marklogic.hub.deploy.commands.LoadHubModulesCommand;
56+
import com.marklogic.hub.deploy.commands.LoadUserModulesCommand;
57+
import com.marklogic.hub.deploy.HubAppDeployer;
58+
import com.marklogic.hub.deploy.util.HubDeployStatusListener;
59+
import com.marklogic.hub.error.ServerValidationException;
5760
import com.marklogic.mgmt.ManageClient;
5861
import com.marklogic.mgmt.ManageConfig;
5962
import com.marklogic.mgmt.admin.AdminConfig;
@@ -94,19 +97,24 @@ public DataHub(String host, String username, String password) {
9497

9598
private void init(HubConfig hubConfig) {
9699
this.hubConfig = hubConfig;
97-
config = new ManageConfig(hubConfig.host, 8002, hubConfig.username, hubConfig.password);
98-
client = new ManageClient(config);
99-
databaseManager = new DatabaseManager(client);
100-
serverManager = new ServerManager(client);
101-
102-
AdminConfig adminConfig = new AdminConfig();
103-
adminConfig.setHost(hubConfig.host);
104-
adminConfig.setUsername(hubConfig.username);
105-
adminConfig.setPassword(hubConfig.password);
106-
adminManager = new AdminManager(adminConfig);
100+
if (hubConfig.username != null && hubConfig.password != null) {
101+
config = new ManageConfig(hubConfig.host, 8002, hubConfig.username, hubConfig.password);
102+
client = new ManageClient(config);
103+
databaseManager = new DatabaseManager(client);
104+
serverManager = new ServerManager(client);
105+
106+
AdminConfig adminConfig = new AdminConfig();
107+
adminConfig.setHost(hubConfig.host);
108+
adminConfig.setUsername(hubConfig.adminUsername);
109+
adminConfig.setPassword(hubConfig.adminPassword);
110+
adminManager = new AdminManager(adminConfig);
111+
}
112+
else {
113+
logger.info("Missing username and/or password.");
114+
}
107115
}
108116

109-
public void setAdminManager(AdminManager manager) {
117+
void setAdminManager(AdminManager manager) {
110118
this.adminManager = manager;
111119
}
112120

@@ -203,6 +211,10 @@ private AppConfig getAppConfig() {
203211
return config;
204212
}
205213

214+
/**
215+
* Updates the given AppConfig with values from this DataHub
216+
* @param config - the AppConfig instance to update
217+
*/
206218
public void updateAppConfig(AppConfig config) {
207219
config.setHost(hubConfig.host);
208220
config.setRestPort(hubConfig.stagingPort);
@@ -253,6 +265,10 @@ public void updateAppConfig(AppConfig config) {
253265
customTokens.put("%%mlModulesDbName%%", hubConfig.modulesDbName);
254266
customTokens.put("%%mlTriggersDbName%%", hubConfig.triggersDbName);
255267
customTokens.put("%%mlSchemasDbName%%", hubConfig.schemasDbName);
268+
269+
customTokens.put("%%mlHubUserName%%", hubConfig.hubUserName);
270+
customTokens.put("%%mlHubUserPassword%%", hubConfig.hubUserPassword);
271+
customTokens.put("%%mlHubUserRole%%", hubConfig.hubUserRole);
256272
}
257273

258274
public void initProject() {
@@ -426,17 +442,26 @@ private List<Command> getCommands(AppConfig config) {
426442

427443
// SQL Views
428444
List<Command> viewCommands = new ArrayList<>();
429-
viewCommands.add(new DeployViewSchemasCommand());
445+
DeployViewSchemasCommand deployViewSchemasCommand = new DeployViewSchemasCommand();
446+
deployViewSchemasCommand.setDatabaseIdOrName(hubConfig.finalDbName);
447+
viewCommands.add(deployViewSchemasCommand);
430448
commands.addAll(viewCommands);
431449

432450
return commands;
433451
}
434452

453+
/**
454+
* Installs the data hub configuration and server-side modules into MarkLogic
455+
*/
456+
public void install() {
457+
install(null);
458+
}
459+
435460
/**
436461
* Installs the data hub configuration and server-side modules into MarkLogic
437462
* @param listener - the callback method to receive status updates
438463
*/
439-
public void install(StatusListener listener) {
464+
public void install(HubDeployStatusListener listener) {
440465
initProject();
441466

442467
logger.info("Installing the Data Hub into MarkLogic");
@@ -447,11 +472,18 @@ public void install(StatusListener listener) {
447472
deployer.deploy(config);
448473
}
449474

475+
/**
476+
* Uninstalls the data hub configuration and server-side modules from MarkLogic
477+
*/
478+
public void uninstall() {
479+
uninstall(null);
480+
}
481+
450482
/**
451483
* Uninstalls the data hub configuration and server-side modules from MarkLogic
452484
* @param listener - the callback method to receive status updates
453485
*/
454-
public void uninstall(StatusListener listener) {
486+
public void uninstall(HubDeployStatusListener listener) {
455487
logger.debug("Uninstalling the Data Hub from MarkLogic");
456488

457489
AppConfig config = getAppConfig();

marklogic-data-hub/src/main/java/com/marklogic/hub/Debugging.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public Debugging(DatabaseClient client) {
1616
}
1717

1818
/**
19-
* Enables tracing
19+
* Enables debugging
2020
*/
2121
public void enable() {
2222
RequestParameters params = new RequestParameters();
@@ -25,7 +25,7 @@ public void enable() {
2525
}
2626

2727
/**
28-
* Disables tracing
28+
* Disables debugging
2929
*/
3030
public void disable() {
3131
RequestParameters params = new RequestParameters();
@@ -34,7 +34,7 @@ public void disable() {
3434
}
3535

3636
/**
37-
* Determines if the hub has tracing enabled or not
37+
* Determines if the hub has debugging enabled or not
3838
*
3939
* @return - true if enabled, false otherwise
4040
*/

marklogic-data-hub/src/main/java/com/marklogic/hub/FinishedListener.java

Lines changed: 0 additions & 5 deletions
This file was deleted.

marklogic-data-hub/src/main/java/com/marklogic/hub/FlowManager.java

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.marklogic.client.io.DOMHandle;
2424
import com.marklogic.client.util.RequestParameters;
2525
import com.marklogic.hub.flow.Flow;
26+
import com.marklogic.hub.flow.FlowComplexity;
2627
import com.marklogic.hub.flow.FlowType;
2728
import com.marklogic.hub.flow.SimpleFlow;
2829
import com.marklogic.spring.batch.hub.FlowConfig;
@@ -51,21 +52,10 @@ public class FlowManager extends ResourceManager {
5152
private DatabaseClient client;
5253
private HubConfig hubConfig;
5354

54-
private DatabaseClient getClient() {
55-
DatabaseClientFactory.Authentication authMethod = DatabaseClientFactory.Authentication
56-
.valueOf(hubConfig.authMethod.toUpperCase());
57-
58-
return DatabaseClientFactory.newClient(
59-
hubConfig.host,
60-
hubConfig.stagingPort,
61-
hubConfig.username,
62-
hubConfig.password, authMethod);
63-
}
64-
6555
public FlowManager(HubConfig hubConfig) {
6656
super();
6757
this.hubConfig = hubConfig;
68-
this.client = getClient();
58+
this.client = hubConfig.newStagingClient();
6959
this.client.init(NAME, this);
7060
}
7161

marklogic-data-hub/src/main/java/com/marklogic/hub/HubConfig.java

Lines changed: 73 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,18 @@
1616
package com.marklogic.hub;
1717

1818
import com.fasterxml.jackson.annotation.JsonIgnore;
19+
import com.marklogic.client.DatabaseClient;
20+
import com.marklogic.client.DatabaseClientFactory;
1921
import com.marklogic.client.helper.LoggingObject;
2022

2123
import java.io.File;
2224
import java.io.FileInputStream;
2325
import java.io.InputStream;
2426
import java.util.Properties;
2527

28+
/**
29+
* A class for passing around the Data Hub's Configuration
30+
*/
2631
public class HubConfig extends LoggingObject {
2732

2833
public static final String DEFAULT_HOST = "localhost";
@@ -35,13 +40,16 @@ public class HubConfig extends LoggingObject {
3540
public static final String DEFAULT_TRIGGERS_DB_NAME = "data-hub-TRIGGERS";
3641
public static final String DEFAULT_SCHEMAS_DB_NAME = "data-hub-SCHEMAS";
3742

43+
public static final String DEFAULT_HUB_USER_ROLE = "data-hub-user";
44+
public static final String DEFAULT_HUB_USER_NAME = "data-hub-user";
45+
3846
public static final Integer DEFAULT_STAGING_PORT = 8010;
3947
public static final Integer DEFAULT_FINAL_PORT = 8011;
4048
public static final Integer DEFAULT_TRACE_PORT = 8012;
4149
public static final Integer DEFAULT_JOB_PORT = 8013;
4250

4351
public static final String DEFAULT_APP_NAME = "data-hub";
44-
public static final String DEFAULT_MODULES_PATH = "src/data-hub";
52+
public static final String DEFAULT_PROJECT_DIR = ".";
4553

4654
public static final String DEFAULT_AUTH_METHOD = "digest";
4755

@@ -55,6 +63,10 @@ public class HubConfig extends LoggingObject {
5563
@JsonIgnore
5664
public String password;
5765

66+
public String adminUsername;
67+
@JsonIgnore
68+
public String adminPassword;
69+
5870
public String host = DEFAULT_HOST;
5971

6072
public String stagingDbName = DEFAULT_STAGING_NAME;
@@ -81,12 +93,16 @@ public class HubConfig extends LoggingObject {
8193
public String triggersDbName = DEFAULT_TRIGGERS_DB_NAME;
8294
public String schemasDbName = DEFAULT_SCHEMAS_DB_NAME;
8395

96+
public String hubUserName = DEFAULT_HUB_USER_NAME;
97+
public String hubUserPassword = DEFAULT_HUB_USER_NAME;
98+
public String hubUserRole = DEFAULT_HUB_USER_ROLE;
99+
84100
public String authMethod = DEFAULT_AUTH_METHOD;
85101

86102
public String projectDir;
87103

88104
public HubConfig() {
89-
this(DEFAULT_MODULES_PATH);
105+
this(DEFAULT_PROJECT_DIR);
90106
}
91107

92108
public HubConfig(String projectDir) {
@@ -116,7 +132,7 @@ private Properties getProperties(String environment) {
116132
return environmentProperties;
117133
}
118134

119-
public void loadConfigurationFromProperties(Properties environmentProperties) {
135+
private void loadConfigurationFromProperties(Properties environmentProperties) {
120136
name = getEnvPropString(environmentProperties, "mlAppName", name);
121137

122138
host = getEnvPropString(environmentProperties, "mlHost", host);
@@ -151,6 +167,58 @@ public void loadConfigurationFromProperties(Properties environmentProperties) {
151167
password = getEnvPropString(environmentProperties, "mlAdminPassword", password);
152168
}
153169

170+
/**
171+
* Creates a new DatabaseClient for accessing the Staging database
172+
* @return - a DatabaseClient
173+
*/
174+
public DatabaseClient newStagingClient() {
175+
return DatabaseClientFactory.newClient(
176+
host,
177+
stagingPort,
178+
username,
179+
password,
180+
DatabaseClientFactory.Authentication.valueOf(authMethod.toUpperCase()));
181+
}
182+
183+
/**
184+
* Creates a new DatabaseClient for accessing the Final database
185+
* @return - a DatabaseClient
186+
*/
187+
public DatabaseClient newFinalClient() {
188+
return DatabaseClientFactory.newClient(
189+
host,
190+
finalPort,
191+
username,
192+
password,
193+
DatabaseClientFactory.Authentication.valueOf(authMethod.toUpperCase()));
194+
}
195+
196+
/**
197+
* Creates a new DatabaseClient for accessing the Job database
198+
* @return - a DatabaseClient
199+
*/
200+
public DatabaseClient newJobDbClient() {
201+
return DatabaseClientFactory.newClient(
202+
host,
203+
jobPort,
204+
username,
205+
password,
206+
DatabaseClientFactory.Authentication.valueOf(authMethod.toUpperCase()));
207+
}
208+
209+
/**
210+
* Creates a new DatabaseClient for accessing the Trace database
211+
* @return - a DatabaseClient
212+
*/
213+
public DatabaseClient newTraceDbClient() {
214+
return DatabaseClientFactory.newClient(
215+
host,
216+
tracePort,
217+
username,
218+
password,
219+
DatabaseClientFactory.Authentication.valueOf(authMethod.toUpperCase()));
220+
}
221+
154222
private String getEnvPropString(Properties environmentProperties, String key, String fallback) {
155223
String value = environmentProperties.getProperty(key);
156224
if (value == null) {
@@ -172,7 +240,7 @@ private int getEnvPropInteger(Properties environmentProperties, String key, int
172240
}
173241

174242
private void loadConfigurationFromFile(Properties configProperties, String fileName) {
175-
InputStream is = null;
243+
InputStream is;
176244
try {
177245
File file = new File(this.projectDir, fileName);
178246
if(file.exists()) {
@@ -182,7 +250,7 @@ private void loadConfigurationFromFile(Properties configProperties, String fileN
182250
}
183251
}
184252
catch ( Exception e ) {
185-
is = null;
253+
e.printStackTrace();
186254
}
187255
}
188256

0 commit comments

Comments
 (0)