-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#423 Can now delete a database via mlDeleteDatabase
- Loading branch information
Showing
2 changed files
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
src/main/groovy/com/marklogic/gradle/task/databases/DeleteDatabaseTask.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.marklogic.gradle.task.databases | ||
|
||
import com.marklogic.gradle.task.AbstractConfirmableTask | ||
import com.marklogic.mgmt.resource.databases.DatabaseManager | ||
import org.gradle.api.GradleException | ||
|
||
class DeleteDatabaseTask extends AbstractConfirmableTask { | ||
|
||
@Override | ||
void executeIfConfirmed() { | ||
if (project.hasProperty("database")) { | ||
String db = project.property("database") | ||
DatabaseManager mgr = new DatabaseManager(getManageClient()) | ||
mgr.setForestDelete(DatabaseManager.DELETE_FOREST_DATA) | ||
println "Deleting primary and replica forests for database: " + db | ||
mgr.deleteForestsAndReplicas(db) | ||
println "Deleting database: " + db | ||
mgr.deleteByName(db) | ||
println "Finished deleting database: " + db | ||
} else { | ||
throw new GradleException("The property 'database' must be specified") | ||
} | ||
} | ||
} |