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

Commit 84b7632

Browse files
committed
#161 Can now export amps; added ResourceMapper too
1 parent b20d0cd commit 84b7632

36 files changed

+764
-308
lines changed

src/main/java/com/marklogic/appdeployer/ConfigDir.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
import java.util.List;
88

99
/**
10-
* Defines all of the directories where configuration files can be found. This is decoupled from the NounManager
11-
* classes, who don't need to care where to look for configuration files, they just need to care about how to load the
12-
* data in those files.
10+
* Defines all of the directories where configuration files can be found.
11+
*
12+
* TODO Eventually turn this into an interface.
1313
*/
1414
public class ConfigDir {
1515

@@ -76,10 +76,22 @@ public File getSecurityDir() {
7676
return new File(baseDir, "security");
7777
}
7878

79+
public File getAmpsDir() {
80+
return new File(getSecurityDir(), "amps");
81+
}
82+
83+
public File getPrivilegesDir() {
84+
return new File(getSecurityDir(), "privileges");
85+
}
86+
7987
public File getRolesDir() {
8088
return new File(getSecurityDir(), "roles");
8189
}
8290

91+
public File getUsersDir() {
92+
return new File(getSecurityDir(), "users");
93+
}
94+
8395
public File getServersDir() {
8496
return new File(baseDir, "servers");
8597
}

src/main/java/com/marklogic/appdeployer/command/security/DeployAmpsCommand.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package com.marklogic.appdeployer.command.security;
22

3-
import java.io.File;
4-
53
import com.marklogic.appdeployer.command.AbstractResourceCommand;
64
import com.marklogic.appdeployer.command.CommandContext;
75
import com.marklogic.appdeployer.command.SortOrderConstants;
86
import com.marklogic.mgmt.ResourceManager;
97
import com.marklogic.mgmt.security.AmpManager;
108

9+
import java.io.File;
10+
1111
public class DeployAmpsCommand extends AbstractResourceCommand {
1212

1313
public DeployAmpsCommand() {
@@ -17,7 +17,7 @@ public DeployAmpsCommand() {
1717

1818
@Override
1919
protected File[] getResourceDirs(CommandContext context) {
20-
return new File[] { new File(context.getAppConfig().getConfigDir().getSecurityDir(), "amps") };
20+
return new File[] { context.getAppConfig().getConfigDir().getAmpsDir() };
2121
}
2222

2323
@Override

src/main/java/com/marklogic/appdeployer/command/security/DeployPrivilegesCommand.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package com.marklogic.appdeployer.command.security;
22

3-
import java.io.File;
4-
53
import com.marklogic.appdeployer.command.AbstractResourceCommand;
64
import com.marklogic.appdeployer.command.CommandContext;
75
import com.marklogic.appdeployer.command.SortOrderConstants;
86
import com.marklogic.mgmt.ResourceManager;
97
import com.marklogic.mgmt.security.PrivilegeManager;
108

9+
import java.io.File;
10+
1111
public class DeployPrivilegesCommand extends AbstractResourceCommand {
1212

1313
public DeployPrivilegesCommand() {
@@ -17,7 +17,7 @@ public DeployPrivilegesCommand() {
1717

1818
@Override
1919
protected File[] getResourceDirs(CommandContext context) {
20-
return new File[] { new File(context.getAppConfig().getConfigDir().getSecurityDir(), "privileges") };
20+
return new File[] { context.getAppConfig().getConfigDir().getPrivilegesDir() };
2121
}
2222

2323
@Override

src/main/java/com/marklogic/appdeployer/command/security/DeployUsersCommand.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
package com.marklogic.appdeployer.command.security;
22

3-
import java.io.File;
4-
53
import com.marklogic.appdeployer.command.AbstractResourceCommand;
64
import com.marklogic.appdeployer.command.CommandContext;
75
import com.marklogic.appdeployer.command.SortOrderConstants;
86
import com.marklogic.mgmt.ResourceManager;
97
import com.marklogic.mgmt.security.UserManager;
108

9+
import java.io.File;
10+
1111
public class DeployUsersCommand extends AbstractResourceCommand {
1212

1313
public DeployUsersCommand() {
@@ -16,7 +16,7 @@ public DeployUsersCommand() {
1616
}
1717

1818
protected File[] getResourceDirs(CommandContext context) {
19-
return new File[] { new File(context.getAppConfig().getConfigDir().getSecurityDir(), "users") };
19+
return new File[] { context.getAppConfig().getConfigDir().getUsersDir() };
2020
}
2121

2222
@Override

src/main/java/com/marklogic/appdeployer/export/AbstractNamedResourceExporter.java

Lines changed: 0 additions & 121 deletions
This file was deleted.

src/main/java/com/marklogic/appdeployer/export/AbstractResourceExporter.java

Lines changed: 0 additions & 55 deletions
This file was deleted.

src/main/java/com/marklogic/appdeployer/export/ExportedResources.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@
55
import java.util.Arrays;
66
import java.util.List;
77

8+
/**
9+
* Captures the results of exporting one or more resources.
10+
*
11+
* The list of messages contains messages pertaining to the resources that were exported. These messages are
12+
* typically used to provide warnings or an explanation of how a particular resource or resource type was exported.
13+
*/
814
public class ExportedResources {
915

1016
private List<File> files;

src/main/java/com/marklogic/appdeployer/export/Exporter.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import com.marklogic.appdeployer.export.appservers.ServerExporter;
44
import com.marklogic.appdeployer.export.databases.DatabaseExporter;
5+
import com.marklogic.appdeployer.export.impl.CompositeResourceExporter;
6+
import com.marklogic.appdeployer.export.security.AmpExporter;
57
import com.marklogic.appdeployer.export.security.PrivilegeExporter;
68
import com.marklogic.appdeployer.export.security.RoleExporter;
79
import com.marklogic.appdeployer.export.security.UserExporter;
@@ -27,11 +29,12 @@ public static Exporter client(ManageClient manageClient) {
2729

2830
public Exporter(ManageClient manageClient) {
2931
this.manageClient = manageClient;
30-
compositeExporter = new CompositeResourceExporter(manageClient);
32+
compositeExporter = new CompositeResourceExporter();
3133
}
3234

3335
public Exporter select(ResourceSelector selector) {
3436
ResourceSelection selection = selector.selectResources(manageClient);
37+
amps(selection.getAmpUriRefs());
3538
databases(selection.getDatabaseNames());
3639
privilegesExecute(selection.getPrivilegeExecuteNames());
3740
privilegesUri(selection.getPrivilegeUriNames());
@@ -56,6 +59,10 @@ public Exporter add(ResourceExporter resourceExporter) {
5659
return this;
5760
}
5861

62+
public Exporter amps(String... ampUriRefs) {
63+
return add(new AmpExporter(manageClient, ampUriRefs));
64+
}
65+
5966
public Exporter databases(String... databaseNames) {
6067
return add(new DatabaseExporter(manageClient, databaseNames));
6168
}

src/main/java/com/marklogic/appdeployer/export/ResourceExporter.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
/**
66
* Interface for exporting one or more MarkLogic resources via the Management API to disk.
7+
*
8+
* This is located in the appdeployer package because of an assumed dependency on the ConfigDir class, which defines
9+
* where resources should be exported to.
710
*/
811
public interface ResourceExporter {
912

src/main/java/com/marklogic/appdeployer/export/appservers/ServerExporter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import com.fasterxml.jackson.databind.node.ObjectNode;
44
import com.marklogic.appdeployer.ConfigDir;
5-
import com.marklogic.appdeployer.export.AbstractNamedResourceExporter;
5+
import com.marklogic.appdeployer.export.impl.AbstractNamedResourceExporter;
66
import com.marklogic.appdeployer.export.ExportedResources;
77
import com.marklogic.appdeployer.export.databases.DatabaseExporter;
88
import com.marklogic.mgmt.ManageClient;

0 commit comments

Comments
 (0)