1

Rest service : http://host:8000/v1/config/resources/removeCollection?put:database=string&put:uris=string*

I want to deploy this REST service extension in MarkLogic using gradle. How can I deploy this?

Mads Hansen
  • 63,927
  • 12
  • 112
  • 147
ravi
  • 61
  • 6

3 Answers3

2

If you're already using ml-gradle, you can add your implemented interface to marklogic\src\main\ml-modules\services and deploy using the mlLoadModules task. The mlCreateResource task as part of the scaffolding would also add metadata in marklogic\src\main\ml-modules\services\metadata.

Shon
  • 690
  • 6
  • 22
  • In 'src\main\ml-modules\root\services',I kept my rest extension service example.xqy and In gradle.properties I kept resourceName=example resourceType=xqy But when I run task deploy(dependsOn: [ mlDeleteModuleTimestampsFile, mlDeploy, mlLoadSchemas, applyParameters, loadCpfModules,mlCreateResource, initSchemas]) {} It is creating example.xqy and metadata in this location 'src\main\ml-modules\services' and also the example.xqy contains default structure that contains all the methods and also the service extension example.xqy not created in modules database – ravi Sep 28 '20 at 13:08
  • Using gradle version : id 'com.marklogic.ml-gradle' version '3.17.0' – ravi Sep 28 '20 at 13:18
  • how can I pass parameter ?put:database=string&put:uris=string* along with rest extension service – ravi Sep 28 '20 at 13:37
  • 1
    I am almost certain you can provide metadata in a subfolder called metadata, with files called {extension}.xml, so src/main/ml-modules/services/example.xqy (no root/!), and src/main/ml-modules/services/metadata/example.xml. The metadata contains something as described here: https://stackoverflow.com/a/41860941/918496 – grtjn Sep 29 '20 at 10:50
1

I recommend looking at ml-gradle. You can easily hook it up in gradle by adding a few lines, most importantly being:

plugins { id "com.marklogic.ml-gradle" version "4.0.4" }

As described in the readme, you can optionally follow that with invoking the mlNewProject task, which will provide you with a useful scaffold structure for a typical ml-gradle project.

ML-gradle gives you access to all kinds of tasks, including one called mlLoadModules to deploy source, and rest extensions. There is also a built-in task for removing collections in any database, called mlDeleteCollections. You can look at the Task-reference to get a glimpse of all the tasks, or just run gradle tasks.

HTH!

grtjn
  • 20,254
  • 1
  • 24
  • 35
  • Actually ,I added the name (Remove collection) for just an example.Please Read the above comments – ravi Sep 29 '20 at 03:46
1

Two easy ways of plugin gradle to invoke REST API:

Method One: If you don’t have any Project just yet,

  1. create a gradle.properties file in which you define four parameters: host, mlUsername, mlPassword, RestPort
  2. create a build.gradle file in the same folder:
plugins { 
    id "com.marklogic.ml-gradle" version "4.0.4" 
}

task FCdeleteCollections(type: com.marklogic.gradle.task.datamovement.DeleteCollectionsTask) {
………………..
  collections = ["{collection-name}"]
}
  1. Invoke the gradle task:
[root@ ~] # gradle FCdeleteCollections

Method Two: If you already scaffolded the Project, in my opinion, it is safer to invoke one-time deletion task like this:

[root@ ~] # gradle -Pdatabase={db-name} mlDeleteCollections -Pcollections={collection-name}

My preference is to invoke such task through Java API | DMSDK.

Fiona Chen
  • 1,358
  • 5
  • 16