Skip to content

Commit

Permalink
Allowing for sort order to be overridden
Browse files Browse the repository at this point in the history
  • Loading branch information
rjrudin committed Jul 5, 2015
1 parent b230bb9 commit 91b858f
Show file tree
Hide file tree
Showing 19 changed files with 51 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
import com.marklogic.clientutil.LoggingObject;

/**
* Abstract base class that provides some convenience methods for implementing a command. Requires that the Spring
* Ordered interface be implemented so that the implementor takes into account when this particular command should be
* executed relative to other commands.
* Abstract base class that provides some convenience methods for implementing a command. Subclasses will typically override
* the default sort order within the subclass constructor.
*/
public abstract class AbstractCommand extends LoggingObject implements Command {

protected TokenReplacer tokenReplacer = new DefaultTokenReplacer();

protected int executeSortOrder = Integer.MAX_VALUE;

protected String copyFileToString(File f) {
try {
return new String(FileCopyUtils.copyToByteArray(f));
Expand All @@ -37,4 +38,13 @@ public TokenReplacer getTokenReplacer() {
return tokenReplacer;
}

@Override
public Integer getExecuteSortOrder() {
return this.executeSortOrder;
}

public void setExecuteSortOrder(int executeSortOrder) {
this.executeSortOrder = executeSortOrder;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@

public class CreateCpfConfigsCommand extends AbstractCpfResourceCommand {

@Override
public Integer getExecuteSortOrder() {
return SortOrderConstants.CREATE_CPF_CONFIGS_ORDER;
public CreateCpfConfigsCommand() {
setExecuteSortOrder(SortOrderConstants.CREATE_CPF_CONFIGS_ORDER);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@

public class CreateDomainsCommand extends AbstractCpfResourceCommand {

@Override
public Integer getExecuteSortOrder() {
return SortOrderConstants.CREATE_DOMAINS_ORDER;
public CreateDomainsCommand() {
setExecuteSortOrder(SortOrderConstants.CREATE_DOMAINS_ORDER);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@

public class CreatePipelinesCommand extends AbstractCpfResourceCommand {

@Override
public Integer getExecuteSortOrder() {
return SortOrderConstants.CREATE_PIPELINES_ORDER;
public CreatePipelinesCommand() {
setExecuteSortOrder(SortOrderConstants.CREATE_PIPELINES_ORDER);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,14 @@

public class LoadDefaultPipelinesCommand extends AbstractCommand {

public LoadDefaultPipelinesCommand() {
setExecuteSortOrder(SortOrderConstants.LOAD_DEFAULT_PIPELINES);
}

@Override
public void execute(CommandContext context) {
new PipelineManager(context.getManageClient()).loadDefaultPipelines(context.getAppConfig()
.getTriggersDatabaseName());
}

@Override
public Integer getExecuteSortOrder() {
return SortOrderConstants.LOAD_DEFAULT_PIPELINES;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@

public class CreateTriggersDatabaseCommand extends AbstractCommand implements UndoableCommand {

@Override
public Integer getExecuteSortOrder() {
return SortOrderConstants.CREATE_TRIGGERS_DATABASE_ORDER;
public CreateTriggersDatabaseCommand() {
setExecuteSortOrder(SortOrderConstants.CREATE_TRIGGERS_DATABASE_ORDER);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@

public class UpdateContentDatabasesCommand extends AbstractCommand {

@Override
public Integer getExecuteSortOrder() {
return SortOrderConstants.UPDATE_CONTENT_DATABASES_ORDER;
public UpdateContentDatabasesCommand() {
setExecuteSortOrder(SortOrderConstants.UPDATE_CONTENT_DATABASES_ORDER);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ public class LoadAssetsViaXccCommand extends AbstractCommand {

public LoadAssetsViaXccCommand(String... assetPaths) {
this.assetPaths = assetPaths;
}

@Override
public Integer getExecuteSortOrder() {
return SortOrderConstants.LOAD_MODULES_ORDER - 10;
setExecuteSortOrder(SortOrderConstants.LOAD_MODULES_ORDER - 10);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ public class LoadModulesCommand extends AbstractCommand {
private String defaultAssetRolesAndCapabilities = "rest-admin,read,rest-admin,update,rest-extension-user,execute";
private String customAssetRolesAndCapabilities;

@Override
public Integer getExecuteSortOrder() {
return SortOrderConstants.LOAD_MODULES_ORDER;
public LoadModulesCommand() {
setExecuteSortOrder(SortOrderConstants.LOAD_MODULES_ORDER);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ public class CreateRestApiServersCommand extends AbstractCommand implements Undo
private boolean includeModules = true;
private boolean includeContent = true;

@Override
public Integer getExecuteSortOrder() {
return SortOrderConstants.CREATE_REST_API_SERVERS_ORDER;
public CreateRestApiServersCommand() {
setExecuteSortOrder(SortOrderConstants.CREATE_REST_API_SERVERS_ORDER);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@

public class CreateAmpsCommand extends AbstractResourceCommand {

@Override
public Integer getExecuteSortOrder() {
return SortOrderConstants.CREATE_AMPS;
public CreateAmpsCommand() {
setExecuteSortOrder(SortOrderConstants.CREATE_AMPS);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@

public class CreateCertificateTemplatesCommand extends AbstractResourceCommand {

@Override
public Integer getExecuteSortOrder() {
return SortOrderConstants.CREATE_CERTIFICATE_TEMPLATES;
public CreateCertificateTemplatesCommand() {
setExecuteSortOrder(SortOrderConstants.CREATE_CERTIFICATE_TEMPLATES);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@

public class CreateExternalSecurityCommand extends AbstractResourceCommand {

@Override
public Integer getExecuteSortOrder() {
return SortOrderConstants.CREATE_EXTERNAL_SECURITY;
public CreateExternalSecurityCommand() {
setExecuteSortOrder(SortOrderConstants.CREATE_EXTERNAL_SECURITY);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@

public class CreatePrivilegesCommand extends AbstractResourceCommand {

@Override
public Integer getExecuteSortOrder() {
return SortOrderConstants.CREATE_PRIVILEGES;
public CreatePrivilegesCommand() {
setExecuteSortOrder(SortOrderConstants.CREATE_PRIVILEGES);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@

public class CreateProtectedCollectionsCommand extends AbstractResourceCommand {

@Override
public Integer getExecuteSortOrder() {
return SortOrderConstants.CREATE_PROTECTED_COLLECTIONS;
public CreateProtectedCollectionsCommand() {
setExecuteSortOrder(SortOrderConstants.CREATE_PROTECTED_COLLECTIONS);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,16 @@

import java.io.File;

import com.marklogic.appdeployer.command.CommandContext;
import com.marklogic.appdeployer.command.AbstractResourceCommand;
import com.marklogic.appdeployer.command.CommandContext;
import com.marklogic.appdeployer.command.SortOrderConstants;
import com.marklogic.rest.mgmt.ResourceManager;
import com.marklogic.rest.mgmt.security.RoleManager;

public class CreateRolesCommand extends AbstractResourceCommand {

@Override
public Integer getExecuteSortOrder() {
return SortOrderConstants.CREATE_ROLES;
public CreateRolesCommand() {
setExecuteSortOrder(SortOrderConstants.CREATE_ROLES);
}

protected File getResourcesDir(CommandContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@

public class CreateUsersCommand extends AbstractResourceCommand {

@Override
public Integer getExecuteSortOrder() {
return SortOrderConstants.CREATE_USERS;
public CreateUsersCommand() {
setExecuteSortOrder(SortOrderConstants.CREATE_USERS);
}

protected File getResourcesDir(CommandContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@

public class UpdateRestApiServersCommand extends AbstractCommand {

@Override
public Integer getExecuteSortOrder() {
return SortOrderConstants.UPDATE_REST_API_SERVERS_ORDER;
public UpdateRestApiServersCommand() {
setExecuteSortOrder(SortOrderConstants.UPDATE_REST_API_SERVERS_ORDER);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ public class CreateScheduledTasksCommand extends AbstractResourceCommand {

private String groupName;

@Override
public Integer getExecuteSortOrder() {
return SortOrderConstants.CREATE_SCHEDULED_TASKS;
public CreateScheduledTasksCommand() {
setExecuteSortOrder(SortOrderConstants.CREATE_SCHEDULED_TASKS);
}

@Override
Expand Down

0 comments on commit 91b858f

Please sign in to comment.