Skip to content

Commit

Permalink
Merge pull request #416 from akshaysonvane/dev
Browse files Browse the repository at this point in the history
Delete user schemas from user schemas database only
  • Loading branch information
rjrudin authored Jan 8, 2019
2 parents 92c9d07 + cabc11f commit f7f557e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip
20 changes: 14 additions & 6 deletions src/main/groovy/com/marklogic/gradle/task/MarkLogicTask.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,29 @@ class MarkLogicTask extends DefaultTask {
project.hasProperty("mlAdminPassword") ? project.property("mlAdminPassword") : project.property("mlPassword")
}

DatabaseClient newClient() {
newClient(null)
}

/**
* If the "database" property is set, then the DatabaseClient that's returned will use the App-Services port
* (defaults to 8000) to connect to the given database. Otherwise, the DatabaseClient will try to connect to the
* REST API server defined by mlRestPort.
* If the "database" property is set or is passed as a parameter, then the DatabaseClient that's returned will use
* the App-Services port (defaults to 8000) to connect to the given database. Otherwise, the DatabaseClient will
* try to connect to the REST API server defined by mlRestPort.
* @return
*/
DatabaseClient newClient() {
if (project.hasProperty("database")) {
DatabaseClient newClient(String database) {
if (database != null){
println "Connecting via the App-Services port to database: " + database
return getAppConfig().newAppServicesDatabaseClient(database)
}
else if (project.hasProperty("database")) {
println "Connecting via the App-Services port to database: " + project.property("database")
return getAppConfig().newAppServicesDatabaseClient(project.property("database"))
}
else {
getAppConfig().newDatabaseClient()
}
}
}

void deployWithCommandListProperty(String propertyName) {
deployWithCommands(getProject().property(propertyName))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class DeleteUserSchemasTask extends MarkLogicTask {
String fullQuery = "cts:uris((), (), " + xquery + ") ! xdmp:document-delete(.)"
println "Deleting user schemas in database '" + database + "' via : " + fullQuery

def client = newClient()
def client = newClient(database)
try {
client.newServerEval().xquery(fullQuery).eval()
} finally {
Expand Down

0 comments on commit f7f557e

Please sign in to comment.