Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using xccProtocol in a CorbTask results in XCC_PROTOCOL instead of XCC-PROTOCOL #627

Open
grtjn opened this issue Oct 5, 2022 · 4 comments

Comments

@grtjn
Copy link

grtjn commented Oct 5, 2022

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

@rjrudin
Copy link
Contributor

rjrudin commented Oct 5, 2022

@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.

@grtjn
Copy link
Author

grtjn commented Jul 1, 2023

I suspect it is a CorbTask code issue.

@hansenmc
Copy link
Contributor

hansenmc commented Jul 2, 2023

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.

@grtjn
Copy link
Author

grtjn commented Jul 6, 2023

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"
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants