Skip to content

Commit 5c50bae

Browse files
committed
Merge branch 'release/1.0.0-rc.2'
2 parents d850216 + b73e606 commit 5c50bae

Some content is hidden

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

52 files changed

+578
-286
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
# Change Log
22

3-
## [v1.0.0-rc.1](https://github.com/marklogic/marklogic-data-hub/tree/v1.0.0-rc.1)
3+
## [v1.0.0-rc.2](https://github.com/marklogic/marklogic-data-hub/tree/v1.0.0-rc.2)
44

5+
[Full Changelog](https://github.com/marklogic/marklogic-data-hub/compare/v1.0.0-rc.1...v1.0.0-rc.2)
6+
7+
**Closed issues:**
8+
9+
- gradle isn't deploying modules properly [\#244](https://github.com/marklogic/marklogic-data-hub/issues/244)
10+
- Remove Tweets Example [\#234](https://github.com/marklogic/marklogic-data-hub/issues/234)
11+
12+
## [v1.0.0-rc.1](https://github.com/marklogic/marklogic-data-hub/tree/v1.0.0-rc.1) (2016-08-04)
513
[Full Changelog](https://github.com/marklogic/marklogic-data-hub/compare/v1.0.0-beta.6...v1.0.0-rc.1)
614

715
**Fixed bugs:**

marklogic-data-hub/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@ mlSchemasDbName=data-hub-SCHEMAS
3333

3434
hubModulesPath=examples/hr-hub/plugins
3535

36-
version=1.0.0-rc.1
36+
version=1.0.0-rc.2
3737

3838

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

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
import com.marklogic.client.extensions.ResourceManager;
4646
import com.marklogic.client.extensions.ResourceServices.ServiceResult;
4747
import com.marklogic.client.extensions.ResourceServices.ServiceResultIterator;
48+
import com.marklogic.client.helper.LoggingObject;
4849
import com.marklogic.client.io.JacksonHandle;
4950
import com.marklogic.client.util.RequestParameters;
5051
import com.marklogic.hub.commands.DeployHubDatabasesCommand;
@@ -58,8 +59,6 @@
5859
import com.marklogic.mgmt.databases.DatabaseManager;
5960
import com.marklogic.rest.util.Fragment;
6061
import com.marklogic.rest.util.ResourcesFragment;
61-
import org.slf4j.Logger;
62-
import org.slf4j.LoggerFactory;
6362
import org.springframework.web.client.ResourceAccessException;
6463

6564
import java.nio.file.Paths;
@@ -68,10 +67,7 @@
6867
import java.util.List;
6968
import java.util.Map;
7069

71-
public class DataHub {
72-
73-
static final private Logger LOGGER = LoggerFactory.getLogger(DataHub.class);
74-
70+
public class DataHub extends LoggingObject {
7571

7672
private ManageConfig config;
7773
private ManageClient client;
@@ -257,7 +253,7 @@ public void updateAppConfig(AppConfig config) {
257253
}
258254

259255
public void initProject() {
260-
LOGGER.info("Initializing the Hub Project");
256+
logger.info("Initializing the Hub Project");
261257

262258
HubProject hp = new HubProject(hubConfig);
263259
hp.init();
@@ -269,9 +265,8 @@ private DatabaseClient getDatabaseClient(int port) {
269265
config.setName(hubConfig.name);
270266
config.setRestAdminUsername(hubConfig.username);
271267
config.setRestAdminPassword(hubConfig.password);
272-
DatabaseClient client = DatabaseClientFactory.newClient(hubConfig.host, port, hubConfig.username, hubConfig.password,
268+
return DatabaseClientFactory.newClient(hubConfig.host, port, hubConfig.username, hubConfig.password,
273269
config.getRestAuthentication(), config.getRestSslContext(), config.getRestSslHostnameVerifier());
274-
return client;
275270
}
276271

277272
/**
@@ -282,9 +277,9 @@ public void installUserModules() {
282277
}
283278

284279
public void installUserModules(boolean force) {
285-
LOGGER.debug("Installing user modules into MarkLogic");
280+
logger.debug("Installing user modules into MarkLogic");
286281

287-
List<Command> commands = new ArrayList<Command>();
282+
List<Command> commands = new ArrayList<>();
288283
LoadUserModulesCommand lumc = new LoadUserModulesCommand(hubConfig);
289284
lumc.setForceLoad(force);
290285
commands.add(lumc);
@@ -297,7 +292,7 @@ public void installUserModules(boolean force) {
297292
}
298293

299294
public JsonNode validateUserModules() {
300-
LOGGER.debug("validating user modules");
295+
logger.debug("validating user modules");
301296

302297
DatabaseClient client = getDatabaseClient(hubConfig.stagingPort);
303298
EntitiesValidator ev = new EntitiesValidator(client);
@@ -307,10 +302,10 @@ public JsonNode validateUserModules() {
307302
}
308303

309304
private List<Command> getCommands(AppConfig config) {
310-
List<Command> commands = new ArrayList<Command>();
305+
List<Command> commands = new ArrayList<>();
311306

312307
// Security
313-
List<Command> securityCommands = new ArrayList<Command>();
308+
List<Command> securityCommands = new ArrayList<>();
314309
securityCommands.add(new DeployRolesCommand());
315310
securityCommands.add(new DeployUsersCommand());
316311
securityCommands.add(new DeployAmpsCommand());
@@ -339,52 +334,52 @@ private List<Command> getCommands(AppConfig config) {
339334
commands.add(new LoadHubModulesCommand(hubConfig));
340335

341336
// Alerting
342-
List<Command> alertCommands = new ArrayList<Command>();
337+
List<Command> alertCommands = new ArrayList<>();
343338
alertCommands.add(new DeployAlertConfigsCommand());
344339
alertCommands.add(new DeployAlertActionsCommand());
345340
alertCommands.add(new DeployAlertRulesCommand());
346341
commands.addAll(alertCommands);
347342

348343
// CPF
349-
List<Command> cpfCommands = new ArrayList<Command>();
344+
List<Command> cpfCommands = new ArrayList<>();
350345
cpfCommands.add(new DeployCpfConfigsCommand());
351346
cpfCommands.add(new DeployDomainsCommand());
352347
cpfCommands.add(new DeployPipelinesCommand());
353348
commands.addAll(cpfCommands);
354349

355350
// Flexrep
356-
List<Command> flexrepCommands = new ArrayList<Command>();
351+
List<Command> flexrepCommands = new ArrayList<>();
357352
flexrepCommands.add(new DeployConfigsCommand());
358353
flexrepCommands.add(new DeployTargetsCommand());
359354
flexrepCommands.add(new DeployFlexrepCommand());
360355
commands.addAll(flexrepCommands);
361356

362357
// Groups
363-
List<Command> groupCommands = new ArrayList<Command>();
358+
List<Command> groupCommands = new ArrayList<>();
364359
groupCommands.add(new DeployGroupsCommand());
365360
commands.addAll(groupCommands);
366361

367-
List<Command> mimetypeCommands = new ArrayList<Command>();
362+
List<Command> mimetypeCommands = new ArrayList<>();
368363
mimetypeCommands.add(new DeployMimetypesCommand());
369364
commands.addAll(mimetypeCommands);
370365

371366
// Forest replicas
372-
List<Command> replicaCommands = new ArrayList<Command>();
367+
List<Command> replicaCommands = new ArrayList<>();
373368
replicaCommands.add(new ConfigureForestReplicasCommand());
374369
commands.addAll(replicaCommands);
375370

376371
// Tasks
377-
List<Command> taskCommands = new ArrayList<Command>();
372+
List<Command> taskCommands = new ArrayList<>();
378373
taskCommands.add(new DeployScheduledTasksCommand());
379374
commands.addAll(taskCommands);
380375

381376
// Triggers
382-
List<Command> triggerCommands = new ArrayList<Command>();
377+
List<Command> triggerCommands = new ArrayList<>();
383378
triggerCommands.add(new DeployTriggersCommand());
384379
commands.addAll(triggerCommands);
385380

386381
// SQL Views
387-
List<Command> viewCommands = new ArrayList<Command>();
382+
List<Command> viewCommands = new ArrayList<>();
388383
viewCommands.add(new DeployViewSchemasCommand());
389384
commands.addAll(viewCommands);
390385

@@ -398,7 +393,7 @@ private List<Command> getCommands(AppConfig config) {
398393
public void install(StatusListener listener) {
399394
initProject();
400395

401-
LOGGER.info("Installing the Data Hub into MarkLogic");
396+
logger.info("Installing the Data Hub into MarkLogic");
402397

403398
AppConfig config = getAppConfig();
404399
HubAppDeployer deployer = new HubAppDeployer(client, adminManager, listener);
@@ -411,7 +406,7 @@ public void install(StatusListener listener) {
411406
* @param listener - the callback method to receive status updates
412407
*/
413408
public void uninstall(StatusListener listener) {
414-
LOGGER.debug("Uninstalling the Data Hub from MarkLogic");
409+
logger.debug("Uninstalling the Data Hub from MarkLogic");
415410

416411
AppConfig config = getAppConfig();
417412
HubAppDeployer deployer = new HubAppDeployer(client, adminManager, listener);

marklogic-data-hub/src/main/java/com/marklogic/hub/commands/LoadHubModulesCommand.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import com.marklogic.client.DatabaseClient;
1313
import com.marklogic.client.DatabaseClientFactory;
1414
import com.marklogic.client.modulesloader.impl.PropertiesModuleManager;
15+
import com.marklogic.hub.DataHub;
1516
import com.marklogic.hub.HubConfig;
1617
import org.apache.commons.io.IOUtils;
1718
import org.springframework.core.io.Resource;
@@ -45,7 +46,7 @@ public class LoadHubModulesCommand extends AbstractCommand {
4546
private Session activeSession;
4647

4748
private DefaultModulesLoader modulesLoader;
48-
private ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
49+
private ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(DataHub.class.getClassLoader());
4950
private DocumentFormatGetter documentFormatGetter = new DefaultDocumentFormatGetter();
5051
private PermissionsParser permissionsParser = new CommaDelimitedPermissionsParser();
5152

marklogic-data-hub/src/main/resources/ml-modules/root/com.marklogic.hub/lib/trace-lib.xqy

Lines changed: 71 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,28 @@ declare function trace:write-trace()
7171
let $format := map:get($current-trace-settings, "data-format")
7272
let $trace :=
7373
if ($format eq $FORMAT-JSON) then
74-
xdmp:to-json($current-trace)
74+
xdmp:to-json((
75+
map:new((
76+
map:entry("format", map:get($current-trace, "format")),
77+
map:entry("traceId", map:get($current-trace, "traceId")),
78+
map:entry("created", map:get($current-trace, "created")),
79+
map:entry("identifier", map:get($current-trace, "identifier")),
80+
map:entry("flowType", map:get($current-trace, "flowType")),
81+
map:entry("hasError", trace:has-errors()),
82+
for $key in ("collectorPlugin", "contentPlugin", "headersPlugin", "triplesPlugin", "writerPlugin")
83+
let $m := map:get($current-trace, $key)
84+
return
85+
if (fn:exists($m)) then
86+
map:entry($key, map:new((
87+
map:entry("pluginModuleUri", map:get($m, "pluginModuleUri")),
88+
map:entry("input", map:get($m, "input")),
89+
map:entry("output", map:get($m, "output")),
90+
map:entry("error", map:get($m, "error")),
91+
map:entry("duration", map:get($m, "duration"))
92+
)))
93+
else ()
94+
))
95+
))
7596
else
7697
element trace {
7798
element format { map:get($current-trace, "format") },
@@ -88,6 +109,7 @@ declare function trace:write-trace()
88109
element pluginModuleUri { map:get($m, "pluginModuleUri") },
89110
element input { map:get($m, "input") },
90111
element output { map:get($m, "output") },
112+
element error { map:get($m, "error") },
91113
element duration { map:get($m, "duration") }
92114
}
93115
else ()
@@ -195,6 +217,7 @@ declare function trace:_walk_json($nodes as node()* ,$o)
195217
<options xmlns="xdmp:quote">
196218
<indent>yes</indent>
197219
<indent-untyped>yes</indent-untyped>
220+
<omit-xml-declaration>yes</omit-xml-declaration>
198221
</options>
199222

200223
for $n in $nodes
@@ -205,31 +228,63 @@ declare function trace:_walk_json($nodes as node()* ,$o)
205228
return
206229
map:put($o, $name, xdmp:quote($n))
207230
case object-node() return
208-
let $oo := json:object()
231+
let $oo := map:new()
209232
let $name as xs:string := fn:string(fn:node-name($n))
210233
return
211234
if ($name = "input") then
212235
if ($n/node()) then
213236
let $_ :=
214237
for $x in $n/node()
238+
(: try to unquote xml for formatting :)
239+
let $unquoted :=
240+
if ($x instance of text()) then
241+
try {
242+
xdmp:quote(xdmp:unquote(fn:string($x)), $quote-options)
243+
}
244+
catch($ex) {
245+
$x
246+
}
247+
else
248+
$x
215249
let $nn := fn:string(fn:node-name($x))
216250
return
217-
map:put($oo, $nn, xdmp:quote($x, $quote-options))
251+
map:put($oo, $nn, $unquoted)
218252
return
219253
map:put($o, $name, $oo)
220254
else
221255
map:put($o, $name, null-node {})
222256
else if ($name = "output") then
223-
map:put($o, $name, xdmp:quote($n, $quote-options))
257+
(: try to unquote xml for formatting :)
258+
let $unquoted :=
259+
if ($n instance of text()) then
260+
try {
261+
xdmp:quote(xdmp:unquote(fn:string($n)), $quote-options)
262+
}
263+
catch($ex) {
264+
$n
265+
}
266+
else
267+
$n
268+
return
269+
map:put($o, $name, $unquoted)
224270
else
225271
let $_ := trace:_walk_json($n/node(), $oo)
226272
return
227273
map:put($o, $name, $oo)
228274
case number-node() |
229275
boolean-node() |
230-
null-node() |
231-
text() return
276+
null-node() return
232277
map:put($o, fn:string(fn:node-name($n)), fn:data($n))
278+
case text() return
279+
let $unquoted :=
280+
try {
281+
xdmp:quote(xdmp:unquote(fn:string($n)), $quote-options)
282+
}
283+
catch($ex) {
284+
$n
285+
}
286+
return
287+
map:put($o, fn:string(fn:node-name($n)), $unquoted)
233288
case element(input) return
234289
let $oo := json:object()
235290
let $_ :=
@@ -258,20 +313,17 @@ declare function trace:_walk_json($nodes as node()* ,$o)
258313

259314
declare function trace:trace-to-json($trace)
260315
{
261-
if ($trace instance of element()) then
262-
let $o := json:object()
263-
let $walk-me :=
264-
let $n := $trace/node()
265-
return
266-
if ($n instance of object-node()) then
267-
$n/node()
268-
else
269-
$n
270-
let $_ := trace:_walk_json($walk-me, $o)
316+
let $o := json:object()
317+
let $walk-me :=
318+
let $n := $trace/node()
271319
return
272-
$o
273-
else
274-
$trace
320+
if ($n instance of object-node()) then
321+
$n/node()
322+
else
323+
$n
324+
let $_ := trace:_walk_json($walk-me, $o)
325+
return
326+
$o
275327
};
276328

277329
declare function trace:trace-to-json-slim($trace)

marklogic-data-hub/src/main/resources/ml-modules/transforms/trace-json.xqy

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,13 @@ declare function transform(
1818
{
1919
perf:log('/transforms/trace-json:transform', function() {
2020

21+
map:put($context, "output-types", "application/json"),
2122
document {
22-
map:put($context, "output-types", "application/json"),
23-
xdmp:to-json(trace:trace-to-json($content/trace))
23+
if ($content/trace) then
24+
xdmp:to-json(trace:trace-to-json($content/trace))
25+
else if ($content/node() instance of object-node()) then
26+
xdmp:to-json(trace:trace-to-json($content/node()))
27+
else ()
2428
}
2529
})
2630
};

marklogic-data-hub/src/main/resources/ml-modules/transforms/trace-search.sjs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ function transform(contenxt, params, content) {
77
for (var i = 0; i < response.results.length; i++) {
88
var result = response.results[i];
99
var doc = cts.doc(result.uri).root;
10-
xdmp.log(doc);
1110
result.content = trace.traceToJson(doc);
1211
response.pageLength = response['page-length'];
1312
}

marklogic-data-hub/src/main/resources/scaffolding/build_gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44
id 'idea'
55
id 'net.saliman.properties' version '1.4.5'
66
id 'com.marklogic.ml-gradle' version '2.3.1'
7-
id 'com.marklogic.ml-data-hub' version '1.0.0-rc.1'
7+
id 'com.marklogic.ml-data-hub' version '1.0.0-rc.2'
88
}
99

1010
repositories {

ml-data-hub-plugin/gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version=1.0.0-rc.1
1+
version=1.0.0-rc.2
22
group=com.marklogic

ml-data-hub-plugin/src/main/groovy/com/marklogic/gradle/DataHubPlugin.groovy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ class DataHubPlugin implements Plugin<Project> {
4848
project.task("hubDisableDebugging", group: deployGroup, type: DisableDebuggingTask)
4949
project.task("hubEnableTracing", group: deployGroup, type: EnableTracingTask)
5050
project.task("hubDisableTracing", group: deployGroup, type: DisableTracingTask)
51+
project.task("hubInstallModules", type: DeployHubModulesTask)
5152

5253
String scaffoldGroup = "MarkLogic Data Hub Scaffolding"
5354
project.task("hubInit", group: scaffoldGroup, type: InitProjectTask)

0 commit comments

Comments
 (0)