ml-gradle
ml-gradle copied to clipboard
Using xccProtocol in a CorbTask results in XCC_PROTOCOL instead of XCC-PROTOCOL
We have enabled https on certain ports, and needed to switch CorbTask to use xccs. I first tried to use xccProtocol property inside the task, but that resulted in a 403. It took a while before I remembered that you get a 403 Forbidden if you hit an https port in MarkLogic with http. Looking more closely at the JavaExec commandline, I noticed all other properties like xccUsername, xccHostname are correctly translated to XCC-..., but not xccProtocol.
Workaround is to use System.setProperty('XCC-PROTOCOL', 'xccs').
We are using: mlDataHubVersion=5.5.5 mlCorbVersion=2.4.6
@hansenmc Would this require a code change, or does it just need a docs improvement to tell users how to do this? I'm having to do the docs change if so.
I suspect it is a CorbTask code issue.
Do you have an example project that demonstrates the issue?
A task such as this works for me and I can run ./gradlew corb
:
task corb(type: com.marklogic.gradle.task.CorbTask) {
xccProtocol="xccs"
xccHostname="localhost"
xccUsername="admin"
xccPassword="admin"
xccPort=9001
urisModule="test/uris.xqy|ADHOC"
processModule="test/process.xqy|ADHOC"
}
I have noted some issues trying to set -PcorbXccProtocol
and had to resort to using -DXCC-PROTOCOL
. I suspect it's due to some ambiguity with other project properties setting XCC-PROTOCOL values that "win" when normalizing properties and collecting the properties from project and system variables and then setting the system properties.
Trying to think back, but unsure. We do have multiple tasks, and some use a different protocol than others. Maybe that is part of the issue. This seems to work though. Note that we switched to systemProperty
rather than System.setProperty
:
class DhfCorbTask extends com.marklogic.gradle.task.CorbTask {
DhfCorbTask() {
if (!project.ext.mlHosts || project.ext.mlHosts[0] == 'marklogic.tvm') {
// Running against docker, hostnames unreliable
xccHostname = project.ext.mlHost
} else {
xccHostname = project.ext.mlHosts.join(',')
}
xccUsername = project.ext.mlUsername
xccPassword = project.ext.mlPassword.replace('"', '\\"')
// [GJo] I wanted to use modulesDatabase = project.ext.mlModulesDbName,
// but that only tells where to install modules. Xcc does not have
// a modules-db feature, like xdmp:eval et al has.
// [GJo] Using multiple ports instead, too many imports in old corb tasks
systemProperty ('DISK-QUEUE', 'true')
}
}
class AppServicesCorbTask extends DhfCorbTask {
// for use without imports. Use xccDatabase to point to particular content db
AppServicesCorbTask() {
if (project.ext.mlAppServicesSimpleSsl == "true") {
systemProperty ('XCC-PROTOCOL', 'xccs')
} else {
systemProperty ('XCC-PROTOCOL', 'xcc')
}
xccPort = project.ext.mlAppServicesPort.toInteger()
}
}
class FinalCorbTask extends DhfCorbTask {
// for use with imports, against Final
FinalCorbTask() {
if (project.ext.mlFinalSimpleSsl == "true") {
systemProperty ('XCC-PROTOCOL', 'xccs')
} else {
systemProperty ('XCC-PROTOCOL', 'xcc')
}
xccPort = project.ext.mlFinalPort.toInteger()
}
}
class StagingCorbTask extends DhfCorbTask {
// for use with imports, against Staging
StagingCorbTask() {
if (project.ext.mlStagingSimpleSsl == "true") {
systemProperty ('XCC-PROTOCOL', 'xccs')
} else {
systemProperty ('XCC-PROTOCOL', 'xcc')
}
xccPort = project.ext.mlStagingPort.toInteger()
}
}
class SetCollectionPermissionsCorbTask extends AppServicesCorbTask {
SetCollectionPermissionsCorbTask() {
// no imports
urisModule = "src/corb/set-collection-permissions-uris.xqy|ADHOC"
processModule = "src/corb/set-collection-permissions-xform.xqy|ADHOC"
threadCount = "${project.ext.CorbThreadCount}"
batchSize = 200
optionsFile="src/corb/options.properties"
exportFileName="setCollectionPermissions.csv"
processTask="com.marklogic.developer.corb.ExportBatchToFileTask"
}
}