Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit 8fa31c7

Browse files
author
Rob Rudin
committed
Making it easier to select types to include
1 parent 09fe318 commit 8fa31c7

File tree

6 files changed

+27
-13
lines changed

6 files changed

+27
-13
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ repositories {
2828
}
2929

3030
dependencies {
31-
compile 'com.marklogic:ml-javaclient-util:2.13.0'
31+
compile 'com.marklogic:ml-javaclient-util:DEV'
3232
compile 'jaxen:jaxen:1.1.6'
3333
compile 'org.apache.httpcomponents:httpclient:4.3.5'
3434
compile 'org.springframework:spring-web:4.3.5.RELEASE'

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
group=com.marklogic
22
javadocsDir=../gh-pages-marklogic-java/javadocs
3-
version=159
3+
version=DEV

src/main/java/com/marklogic/mgmt/selector/AbstractNameMatchingResourceSelector.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.marklogic.rest.util.ResourcesFragment;
1212

1313
import java.util.ArrayList;
14+
import java.util.Arrays;
1415
import java.util.List;
1516

1617
public abstract class AbstractNameMatchingResourceSelector implements ResourceSelector {
@@ -72,9 +73,15 @@ protected void select(MapResourceSelection selection, ResourceManager mgr, Strin
7273
}
7374
}
7475

75-
public void setIncludeTypes(String... includeTypes) {
76+
public void setIncludeTypesAsString(String commaDelimitedTypes) {
77+
if (commaDelimitedTypes != null) {
78+
setIncludeTypes(commaDelimitedTypes.split(","));
79+
}
80+
}
81+
82+
public void setIncludeTypes(String... types) {
7683
this.includeTypes = new ArrayList<>();
77-
for (String type : includeTypes) {
84+
for (String type : types) {
7885
// Make it easy to specify the two types of privileges
7986
if ("privileges".equals(type)) {
8087
this.includeTypes.add(MapResourceSelection.PRIVILEGES_EXECUTE);

src/main/java/com/marklogic/mgmt/selector/MapResourceSelection.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,6 @@
77

88
public class MapResourceSelection implements ResourceSelection {
99

10-
public final static String DATABASES = "databases";
11-
public final static String PRIVILEGES_EXECUTE = "privilegesExecute";
12-
public final static String PRIVILEGES_URI = "privilegesUri";
13-
public final static String ROLES = "roles";
14-
public final static String SERVERS = "servers";
15-
public final static String TASKS = "tasks";
16-
public final static String USERS = "users";
17-
1810
private Map<String, List<String>> selections = new HashMap<>();
1911

2012
public void select(String type, String name) {

src/main/java/com/marklogic/mgmt/selector/ResourceSelection.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22

33
public interface ResourceSelection {
44

5+
String DATABASES = "databases";
6+
String PRIVILEGES_EXECUTE = "privilegesExecute";
7+
String PRIVILEGES_URI = "privilegesUri";
8+
String ROLES = "roles";
9+
String SERVERS = "servers";
10+
String TASKS = "tasks";
11+
String USERS = "users";
12+
513
String[] getDatabaseNames();
614

715
String[] getPrivilegeExecuteNames();

src/test/java/com/marklogic/appdeployer/export/ExportTasksTest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
package com.marklogic.appdeployer.export;
22

33
import com.marklogic.appdeployer.command.tasks.DeployScheduledTasksCommand;
4+
import com.marklogic.mgmt.selector.MapResourceSelection;
45
import com.marklogic.mgmt.selector.PrefixResourceSelector;
6+
import com.marklogic.mgmt.selector.ResourceSelection;
57
import com.marklogic.mgmt.tasks.TaskManager;
68
import org.junit.After;
79
import org.junit.Test;
@@ -19,7 +21,12 @@ public void test() {
1921
deploySampleApp();
2022

2123
String taskPath = "/path/to/query.xqy";
22-
ExportedResources resources = new Exporter(manageClient).select(new PrefixResourceSelector("/path")).export(exportDir);
24+
25+
// Get some test coverage of selectors, even though we don't care about users here
26+
PrefixResourceSelector selector = new PrefixResourceSelector("/path");
27+
selector.setIncludeTypesAsString(ResourceSelection.TASKS + "," + ResourceSelection.USERS);
28+
29+
ExportedResources resources = new Exporter(manageClient).select(selector).export(exportDir);
2330
assertEquals(1, resources.getFiles().size());
2431
assertEquals("query.xqy.json", resources.getFiles().get(0).getName());
2532

0 commit comments

Comments
 (0)