Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public void execute(CommandContext context) {
return;
}

final List<MarkLogicHttpEndpoint> endpoints = readEndpointDefinitionsFromFiles(pdcConfigPaths);
final List<MarkLogicHttpEndpoint> endpoints = readEndpointDefinitionsFromFiles(context, pdcConfigPaths);
if (!endpoints.isEmpty()) {
if (!StringUtils.hasText(context.getAppConfig().getCloudApiKey())) {
logger.warn("Found configuration for {} MarkLogic endpoint(s), but not deploying them because no cloud API key has been specified.", endpoints.size());
Expand All @@ -49,7 +49,7 @@ public void execute(CommandContext context) {
}
}

private List<MarkLogicHttpEndpoint> readEndpointDefinitionsFromFiles(List<String> pdcConfigPaths) {
private List<MarkLogicHttpEndpoint> readEndpointDefinitionsFromFiles(CommandContext context, List<String> pdcConfigPaths) {
List<MarkLogicHttpEndpoint> endpoints = new ArrayList<>();

for (String pdcConfigPath : pdcConfigPaths) {
Expand All @@ -69,7 +69,7 @@ private List<MarkLogicHttpEndpoint> readEndpointDefinitionsFromFiles(List<String
try (Stream<Path> paths = Files.walk(endpointsDir.toPath())) {
paths.filter(Files::isRegularFile)
.filter(path -> path.toString().endsWith(".json"))
.forEach(path -> endpoints.add(buildEndpointFromFile(path.toFile())));
.forEach(path -> endpoints.add(buildEndpointFromFile(context, path.toFile())));
} catch (IOException e) {
throw new RuntimeException("Failed to read MarkLogic endpoint configuration files from: " +
endpointsDir.getAbsolutePath(), e);
Expand All @@ -79,9 +79,10 @@ private List<MarkLogicHttpEndpoint> readEndpointDefinitionsFromFiles(List<String
return endpoints;
}

private MarkLogicHttpEndpoint buildEndpointFromFile(File endpointFile) {
private MarkLogicHttpEndpoint buildEndpointFromFile(CommandContext context, File endpointFile) {
try {
MarkLogicHttpEndpoint endpoint = OBJECT_MAPPER.readValue(endpointFile, MarkLogicHttpEndpoint.class);
String content = readResourceFromFile(context, endpointFile);
MarkLogicHttpEndpoint endpoint = OBJECT_MAPPER.readValue(content, MarkLogicHttpEndpoint.class);
if (logger.isDebugEnabled()) {
logger.debug("Built MarkLogic endpoint: name={}, displayName={}, port={}, type={}, path={}",
endpoint.getName(), endpoint.getDisplayName(), endpoint.getPort(),
Expand Down