Skip to content
Merged
Show file tree
Hide file tree
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
26 changes: 19 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright (c) 2015-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.

// Defines common configuration for each of the 3 subprojects.
subprojects {
apply plugin: "java-library"
Expand All @@ -14,7 +16,7 @@ subprojects {
mavenCentral()
mavenLocal()
maven {
url "https://bed-artifactory.bedford.progress.com:443/artifactory/ml-maven-snapshots/"
url = "https://bed-artifactory.bedford.progress.com:443/artifactory/ml-maven-snapshots/"
}
}

Expand All @@ -32,15 +34,25 @@ subprojects {
testImplementation 'org.slf4j:slf4j-api:2.0.17'
}

javadoc.failOnError = false
// Allows for quickly identifying compiler warnings.
tasks.withType(JavaCompile) {
options.compilerArgs += ["-Xlint:unchecked", "-Xlint:deprecation"]
options.deprecation = true
options.warnings = true
}

javadoc {
failOnError = false
}

// Ignores warnings on params that don't have descriptions, which is a little too noisy
javadoc.options.addStringOption('Xdoclint:none', '-quiet')

test {
useJUnitPlatform()
testLogging {
events 'started','passed', 'skipped', 'failed'
exceptionFormat 'full'
exceptionFormat = 'full'
}
}

Expand Down Expand Up @@ -89,17 +101,17 @@ subprojects {
maven {
if (project.hasProperty("mavenUser")) {
credentials {
username mavenUser
password mavenPassword
username = mavenUser
password = mavenPassword
}
url publishUrl
allowInsecureProtocol = true
} else {
name = "central"
url = mavenCentralUrl
credentials {
username mavenCentralUsername
password mavenCentralPassword
username = mavenCentralUsername
password = mavenCentralPassword
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion examples/local-testing-project/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// Copyright (c) 2015-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.

buildscript {
repositories {
mavenLocal()
maven {
url "https://bed-artifactory.bedford.progress.com:443/artifactory/ml-maven-snapshots/"
url = "https://bed-artifactory.bedford.progress.com:443/artifactory/ml-maven-snapshots/"
}
mavenCentral()
}
Expand Down
4 changes: 3 additions & 1 deletion examples/marklogic-cloud-project/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// Copyright (c) 2015-2025 Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.

buildscript {
repositories {
mavenLocal()
maven {
url "https://bed-artifactory.bedford.progress.com:443/artifactory/ml-maven-snapshots/"
url = "https://bed-artifactory.bedford.progress.com:443/artifactory/ml-maven-snapshots/"
}
mavenCentral()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,13 @@ protected boolean resourceMergingIsSupported(CommandContext context) {
*/
protected void storeResourceInCommandContextMap(CommandContext context, File resourceFile, String payload) {
final String contextKey = getContextKeyForResourcesToSave();
List<ResourceReference> references = (List<ResourceReference>) context.getContextMap().get(contextKey);
if (references == null) {
Object referencesObj = context.getContextMap().get(contextKey);
List<ResourceReference> references;
if (referencesObj != null) {
@SuppressWarnings("unchecked")
List<ResourceReference> existingReferences = (List<ResourceReference>) referencesObj;
references = existingReferences;
} else {
references = new ArrayList<>();
context.getContextMap().put(contextKey, references);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,17 @@ public void execute(CommandContext context) {
}

if (mergeResourcesBeforeSaving) {
List<ResourceReference> references = (List<ResourceReference>) context.getContextMap().get(getContextKeyForResourcesToSave());
if (references != null && !references.isEmpty()) {
List<ResourceReference> mergedReferences = mergeResources(references);
if (useCmaForDeployingResources(context)) {
saveMergedResourcesViaCma(context, mergedReferences);
} else {
saveMergedResources(context, getResourceManager(context), mergedReferences);
Object referencesObj = context.getContextMap().get(getContextKeyForResourcesToSave());
if (referencesObj != null) {
@SuppressWarnings("unchecked")
List<ResourceReference> references = (List<ResourceReference>) referencesObj;
if (!references.isEmpty()) {
List<ResourceReference> mergedReferences = mergeResources(references);
if (useCmaForDeployingResources(context)) {
saveMergedResourcesViaCma(context, mergedReferences);
} else {
saveMergedResources(context, getResourceManager(context), mergedReferences);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,15 @@ public Map<String, List<Forest>> getMapOfPrimaryForests() {
if (!appConfig.getCmaConfig().isDeployForests()) {
return null;
}

final String key = "ml-app-deployer-mapOfPrimaryForests";
if (contextMap.containsKey(key)) {
return (Map<String, List<Forest>>) contextMap.get(key);
if (contextMap.containsKey(key) && contextMap.get(key) instanceof Map) {
Object mapObj = contextMap.get(key);
@SuppressWarnings("unchecked")
Map<String, List<Forest>> forestMap = (Map<String, List<Forest>>) mapObj;
return forestMap;
}

Logger logger = LoggerFactory.getLogger(getClass());
try {
logger.info("Retrieving all forest details via CMA");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ private TestResult testManageAppServer(ManageClient client) {
String version = new ClusterManager(client).getVersion();
return new TestResult(client.getManageConfig(), true, "MarkLogic version: " + version);
} catch (Exception ex) {
if (ex instanceof HttpClientErrorException && ((HttpClientErrorException) ex).getRawStatusCode() == 404) {
if (ex instanceof HttpClientErrorException && ((HttpClientErrorException) ex).getStatusCode().value() == 404) {
return new TestResult(client.getManageConfig(), false,
"Unable to access /manage/v2; received 404; unexpected response: " + ex.getMessage());
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void execute(CommandContext context) {

protected DatabaseClient buildDatabaseClient(AppConfig appConfig) {
String db = appConfig.getModelsDatabase();
if (StringUtils.isEmpty(db)) {
if (!StringUtils.hasText(db)) {
db = appConfig.getContentDatabaseName();
}
if (logger.isInfoEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ private void delete(RestTemplate restTemplate, String path, String... headerName
*/
public HttpEntity<String> buildJsonEntity(String json) {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
headers.setContentType(MediaType.APPLICATION_JSON);
if (manageConfig != null && manageConfig.isCleanJsonPayloads()) {
json = cleanJsonPayload(json);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public List<ObjectNode> sortObjectNodes(List<ObjectNode> objectNodes) {
// This is to resolve bug #441, where capability-query's are being dropped because the Role class doesn't
// support them. It may be better to refactor this to not deserialize into Role instances so that ObjectNodes
// are used the entire time, even though we'd lose some of the convenience methods provided by the Role class.
final Map<String, ObjectNode> roleMap = new HashMap();
final Map<String, ObjectNode> roleMap = new HashMap<>();

ObjectReader reader = ObjectMapperFactory.getObjectMapper().readerFor(Role.class);
for (ObjectNode objectNode : objectNodes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,9 @@ public <T extends Resource> T readResource(String payload, Class<T> resourceType
}
jaxbContextMap.put(resourceType, context);
}
resource = (T) context.createUnmarshaller().unmarshal(new StringReader(payload));
@SuppressWarnings("unchecked")
T unmarshalledResource = (T) context.createUnmarshaller().unmarshal(new StringReader(payload));
resource = unmarshalledResource;
}
if (api != null && resource != null) {
resource.setApi(api);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void addDefaultPropertyValue(String propertyName, Object value) {
public Resource buildTemplate(Map<String, Object> propertyMap) {
Resource r;
try {
r = (Resource) this.resourceClass.newInstance();
r = (Resource) this.resourceClass.getDeclaredConstructor().newInstance();
} catch (Exception ex) {
throw new RuntimeException(ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,6 @@ public HttpStatus getStatusCode() {
return HttpStatus.OK;
}

@Override
public int getRawStatusCode() {
return 200;
}

@Override
public String getStatusText() {
return "OK";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,15 @@
public abstract class SpringWebUtil {

public static int getHttpStatusCode(ResponseEntity<?> response) {
// This method is deprecated in Spring 6.0 and slated to be removed in Spring 7.0. But it can be safely used
// by both Spring 5.x and 6.x. We'll need to revisit this when we want to support ml-gradle when Spring 7.0 is
// on the classpath as well.
return response.getStatusCodeValue();
return response.getStatusCode().value();
}

public static HttpStatus getHttpStatus(ResponseEntity<?> response) {
return HttpStatus.valueOf(getHttpStatusCode(response));
}

public static int getHttpStatusCode(RestClientResponseException ex) {
// This method is deprecated in Spring 6.0 and slated to be removed in Spring 7.0. But it can be safely used
// by both Spring 5.x and 6.x. We'll need to revisit this when we want to support ml-gradle when Spring 7.0 is
// on the classpath as well.
return ex.getRawStatusCode();
return ex.getStatusCode().value();
}

public static HttpStatus getHttpStatus(RestClientResponseException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public URI getURI() {
}

@Override
@SuppressWarnings("removal")
protected ClientHttpResponse executeInternal(HttpHeaders headers, @Nullable Body body) throws IOException {

RequestBody requestBody;
Expand All @@ -57,7 +56,7 @@ protected ClientHttpResponse executeInternal(HttpHeaders headers, @Nullable Body
} else if (okhttp3.internal.http.HttpMethod.requiresRequestBody(getMethod().name())) {
String header = headers.getFirst(HttpHeaders.CONTENT_TYPE);
MediaType contentType = (header != null) ? MediaType.parse(header) : null;
requestBody = RequestBody.create(contentType, new byte[0]);
requestBody = RequestBody.create(new byte[0], contentType);
} else {
requestBody = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

public class DefaultAppConfigFactoryTest {
class DefaultAppConfigFactoryTest {

private DefaultAppConfigFactory factory;

Expand Down Expand Up @@ -211,7 +211,7 @@ public void dataConfigProperties() {
assertEquals(new File(projectDir, "src/main/more-data").getAbsolutePath(), config.getDataPaths().get(1));
assertEquals("apple", config.getCollections()[0]);
assertEquals("banana", config.getCollections()[1]);
assertEquals(new Integer(123), config.getBatchSize());
assertEquals(123, config.getBatchSize());
assertEquals("Documents", config.getDatabaseName());
assertEquals("manage-user,read,manage-user,update", config.getPermissions());
assertFalse(config.isReplaceTokensInData());
Expand Down Expand Up @@ -497,8 +497,8 @@ public void mostProperties() {
assertEquals("dev-.*", config.getResourceFilenamesExcludePattern().pattern());
assertEquals("qa-.*", config.getResourceFilenamesIncludePattern().pattern());

assertEquals(new Integer(1), config.getDatabaseNamesAndReplicaCounts().get("Documents"));
assertEquals(new Integer(2), config.getDatabaseNamesAndReplicaCounts().get("Security"));
assertEquals(1, config.getDatabaseNamesAndReplicaCounts().get("Documents"));
assertEquals(2, config.getDatabaseNamesAndReplicaCounts().get("Security"));

Set<String> set = config.getDatabasesWithForestsOnOneHost();
assertEquals(2, set.size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class WriteServerTest extends AbstractResourceWriterTest {
class WriteServerTest extends AbstractResourceWriterTest {

@Test
public void defaultValues() {
void defaultValues() {
initializeAppDeployer(new DeployOtherServersCommand());

buildResourceAndDeploy(new ServerTemplateBuilder());

Server s = api.server("CHANGEME-name-of-server");
assertEquals(new Integer(8099), s.getPort());
assertEquals(8099, s.getPort());
assertEquals("Modules", s.getModulesDatabase());
assertEquals("Documents", s.getContentDatabase());
assertEquals("digest", s.getAuthentication());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

import static org.junit.jupiter.api.Assertions.assertEquals;

public class WriteTaskTest extends AbstractResourceWriterTest {
class WriteTaskTest extends AbstractResourceWriterTest {

@Test
public void defaultValues() {
void defaultValues() {
initializeAppDeployer(new DeployScheduledTasksCommand());

buildResourceAndDeploy(new TaskTemplateBuilder());
Expand All @@ -26,7 +26,7 @@ public void defaultValues() {
assertEquals("/CHANGEME-path-to-module.sjs", task.getTaskPath());
assertEquals("/", task.getTaskRoot());
assertEquals("daily", task.getTaskType());
assertEquals(new Integer(1), task.getTaskPeriod());
assertEquals(1, task.getTaskPeriod());
assertEquals("01:00:00", task.getTaskStartTime());
assertEquals("Documents", task.getTaskDatabase());
assertEquals("Modules", task.getTaskModules());
Expand Down
4 changes: 2 additions & 2 deletions ml-gradle/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ gradlePlugin {
id = 'com.marklogic.ml-gradle'
displayName = 'ml-gradle for MarkLogic'
description = 'Gradle plugin for configuring and deploying applications to MarkLogic'
tags.set(['marklogic', 'progress'])
implementationClass = 'com.marklogic.gradle.MarkLogicPlugin'
tags = ['marklogic', 'progress']
implementationClass = 'com.marklogic.gradle.MarkLogicPlugin'
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@

import com.marklogic.client.document.DocumentWriteOperation;
import com.marklogic.client.ext.helper.LoggingObject;
import org.springframework.core.task.AsyncListenableTaskExecutor;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.core.task.SyncTaskExecutor;
import org.springframework.core.task.TaskExecutor;
import org.springframework.scheduling.concurrent.ExecutorConfigurationSupport;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.util.concurrent.ListenableFuture;
import org.springframework.util.concurrent.ListenableFutureCallback;

import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CompletionException;

/**
* Support class for BatchWriter implementations that uses Spring's TaskExecutor interface for parallelizing writes to
Expand Down Expand Up @@ -74,24 +74,22 @@ protected void initializeDefaultTaskExecutor() {
}

/**
* Will use the WriteListener if the TaskExecutor is an instance of AsyncListenableTaskExecutor. The WriteListener
* Will use the WriteListener if the TaskExecutor is an instance of AsyncTaskExecutor. The WriteListener
* will then be used to listen for failures.
*
* @param runnable
* @param items
*/
protected void executeRunnable(Runnable runnable, final List<? extends DocumentWriteOperation> items) {
if (writeListener != null && taskExecutor instanceof AsyncListenableTaskExecutor) {
AsyncListenableTaskExecutor asyncListenableTaskExecutor = (AsyncListenableTaskExecutor)taskExecutor;
ListenableFuture<?> future = asyncListenableTaskExecutor.submitListenable(runnable);
future.addCallback(new ListenableFutureCallback<Object>() {
@Override
public void onFailure(Throwable ex) {
if (writeListener != null && taskExecutor instanceof AsyncTaskExecutor asyncTaskExecutor) {
CompletableFuture<?> future = asyncTaskExecutor.submitCompletable(runnable);
future.whenComplete((result, ex) -> {
if (ex != null) {
if (ex instanceof CompletionException ce && ce.getCause() != null) {
ex = ce.getCause();
}
writeListener.onWriteFailure(ex, items);
}
@Override
public void onSuccess(Object result) {
}
});
} else {
taskExecutor.execute(runnable);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class SimpleExportJob extends AbstractQueryBatcherJob {

private ExportListener exportListener;

@SafeVarargs
public SimpleExportJob(Consumer<DocumentRecord>... consumers) {
exportListener = new ExportListener();
for (Consumer<DocumentRecord> consumer : consumers) {
Expand Down
Loading