Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Remove the map, imap, mapEntries methods from CollectionUtils #28192 #28193

Merged
merged 19 commits into from
Apr 25, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import com.dotcms.content.elasticsearch.util.RestHighLevelClientProvider;
import com.dotcms.enterprise.ESSeachAPI;
import com.dotcms.enterprise.priv.util.SearchSourceBuilderUtil;
import com.dotcms.util.CollectionsUtils;
import com.dotmarketing.business.APILocator;
import com.dotmarketing.business.DotStateException;
import com.dotmarketing.business.Role;
Expand All @@ -66,10 +65,6 @@
import com.dotmarketing.util.json.JSONException;
import com.dotmarketing.util.json.JSONObject;
import com.liferay.portal.model.User;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
Expand All @@ -78,6 +73,11 @@
import org.elasticsearch.search.SearchHit;
import org.elasticsearch.search.builder.SearchSourceBuilder;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import static com.dotcms.content.elasticsearch.business.ESIndexAPI.INDEX_OPERATIONS_TIMEOUT_IN_MS;

/**
Expand Down Expand Up @@ -198,12 +198,11 @@ public SearchResponse esSearchRelated(final Contentlet contentlet,
try {
if (pullParents) {
criteriaMap.put("_source", "identifier");
criteriaMap.put("query", new JSONObject().put("match", CollectionsUtils
.map(relationshipName.toLowerCase(), contentlet.getIdentifier())));
criteriaMap.put("query", new JSONObject().put("match",
Map.of(relationshipName.toLowerCase(), contentlet.getIdentifier())));
} else {
criteriaMap.put("_source", relationshipName.toLowerCase());
criteriaMap.put("query", new JSONObject().put("match", CollectionsUtils
.map("inode", contentlet.getInode())));
criteriaMap.put("query", new JSONObject().put("match", Map.of("inode", contentlet.getInode())));
}
completeQueryJSON = new JSONObject(criteriaMap.toString());
} catch (JSONException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,18 @@

package com.dotcms.enterprise.publishing.remote.bundler;

import java.io.*;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

import com.dotcms.business.CloseDBIfOpened;
import com.dotcms.enterprise.LicenseUtil;
import com.dotcms.enterprise.license.LicenseLevel;
import com.dotcms.publisher.business.DotPublisherException;
import com.dotcms.publisher.pusher.PushPublisherConfig;
import com.dotcms.publisher.pusher.wrapper.WorkflowWrapper;
import com.dotcms.publishing.*;
import com.dotcms.publishing.BundlerStatus;
import com.dotcms.publishing.BundlerUtil;
import com.dotcms.publishing.DotBundleException;
import com.dotcms.publishing.IBundler;
import com.dotcms.publishing.IPublisher;
import com.dotcms.publishing.PublisherConfig;
import com.dotcms.publishing.output.BundleOutput;
import com.dotmarketing.business.APILocator;
import com.dotmarketing.business.PermissionAPI;
Expand All @@ -68,14 +65,28 @@
import com.dotmarketing.exception.DotDataException;
import com.dotmarketing.exception.DotSecurityException;
import com.dotmarketing.portlets.contentlet.business.ContentletAPI;
import com.dotmarketing.portlets.workflows.model.*;
import com.dotmarketing.portlets.workflows.model.SystemActionWorkflowActionMapping;
import com.dotmarketing.portlets.workflows.model.WorkflowAction;
import com.dotmarketing.portlets.workflows.model.WorkflowActionClass;
import com.dotmarketing.portlets.workflows.model.WorkflowActionClassParameter;
import com.dotmarketing.portlets.workflows.model.WorkflowScheme;
import com.dotmarketing.portlets.workflows.model.WorkflowStep;
import com.dotmarketing.util.Config;
import com.dotmarketing.util.Logger;
import com.dotmarketing.util.PushPublishLogger;
import com.liferay.portal.model.User;
import com.liferay.util.StringPool;

import static com.dotcms.util.CollectionsUtils.map;
import java.io.File;
import java.io.FileFilter;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
* This class is in charge of generates the xml with the workflow information in order to be PP.
Expand Down Expand Up @@ -235,7 +246,7 @@ private List<WorkflowStep> collectWorkflowSteps(final WorkflowScheme workflow,
// action by step
for (final WorkflowAction workflowAction : stepActions) {

actionStepsListMap.add(map(ACTION_ID, workflowAction.getId(),
actionStepsListMap.add(Map.of(ACTION_ID, workflowAction.getId(),
STEP_ID, workflowStep.getId(),
ACTION_ORDER, String.valueOf(actionOrder++)));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
package com.dotcms.api.system.user;

import static com.dotcms.util.CollectionsUtils.getMapValue;
import static com.dotcms.util.CollectionsUtils.map;
import static com.dotcms.util.ConversionUtils.toBoolean;
import static com.dotcms.util.ConversionUtils.toInt;

import com.dotcms.rest.api.v1.authentication.ResetPasswordTokenUtil;
import com.dotcms.rest.api.v1.authentication.url.UrlStrategy;
import com.dotcms.util.MessageAPI;
Expand All @@ -27,15 +22,19 @@
import com.liferay.portal.model.Company;
import com.liferay.portal.model.User;
import com.liferay.util.Validator;
import org.apache.commons.lang.StringUtils;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.apache.commons.lang.StringUtils;

import static com.dotcms.util.CollectionsUtils.getMapValue;
import static com.dotcms.util.ConversionUtils.toBoolean;
import static com.dotcms.util.ConversionUtils.toInt;

/**
* This factory creates a singleton instance of the {@link UserService} class.
Expand Down Expand Up @@ -241,7 +240,7 @@ public Map<String, Object> perform() {
int pageSize = realUserCount;
list = new ArrayList<>(pageSize);
for (User aUser : users) {
final Map<String, String> aRecord = map(
final Map<String, String> aRecord = Map.of(
"id", aUser.getUserId(),
"type", USER_TYPE_VALUE,
"name", UtilMethods.isSet(aUser.getFullName()) ? aUser.getFullName() : " ",
Expand Down Expand Up @@ -402,7 +401,7 @@ public void sendResetPassword(final String companyId,
company = CompanyUtil.findByPrimaryKey(companyId);

url = UrlStrategyUtil.getURL(company,
map(UrlStrategy.USER, user, UrlStrategy.TOKEN, token, UrlStrategy.LOCALE, locale),
Map.of(UrlStrategy.USER, user, UrlStrategy.TOKEN, token, UrlStrategy.LOCALE, locale),
resetPasswordUrlStrategy);
body = LanguageUtil.format(locale, "reset-password-email-body", url, false);
subject = LanguageUtil.get(locale, "reset-password-email-subject");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;

import static com.dotcms.util.CollectionsUtils.map;

/**
* Factory for concurrent {@link Executor} & {@link DotSubmitter}
* @author jsanca
Expand Down Expand Up @@ -215,7 +213,7 @@ public Map<String, Object> getStats(final String name) {

return (null != dotConcurrent)?
(dotConcurrent instanceof DotConcurrentImpl)?
map(
Map.of(
"name", name,
"threadPool", DotConcurrentImpl.class.cast(dotConcurrent).getThreadPoolExecutor().toString(),
"maxPoolSize", DotConcurrentImpl.class.cast(dotConcurrent).getThreadPoolExecutor().getMaximumPoolSize(),
Expand All @@ -227,7 +225,7 @@ public Map<String, Object> getStats(final String name) {
"queue", toString(DotConcurrentImpl.class.cast(dotConcurrent).getThreadPoolExecutor().getQueue()),
"isShutdown", DotConcurrentImpl.class.cast(dotConcurrent).shutdown
):
map(
Map.of(
"name", name,
"threadPool", "noInfo",
"maxPoolSize", dotConcurrent.getMaxPoolSize(),
Expand All @@ -239,7 +237,7 @@ public Map<String, Object> getStats(final String name) {
"queue", "noInfo",
"isShutdown", dotConcurrent.isAborting()
)
:map(
:Map.of(
"name", name,
"threadPool", "noInfo",
"maxPoolSize", -1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5136,7 +5136,7 @@ private void checkOrSetContentType(final Contentlet contentletIn, final User use

final Optional<ContentType> contentTypeOpt = typeStrategy.get()
.apply(baseContentType,
CollectionsUtils.map("user", user, "host", host,
Map.of("user", user, "host", host,
"contentletMap", contentletIn.getMap(), "accessingList",
accessingList));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ private Set<String> addCustomMappingFromFieldVariables(final String... indexes)
field = fieldFactory.byId(fieldVariable.fieldId());
type = contentTypeAPI.find(field.contentTypeId());

putContentTypeMapping(type, CollectionsUtils.map(field.variable().toLowerCase(),
putContentTypeMapping(type, Map.of(field.variable().toLowerCase(),
new JSONObject(fieldVariable.value())), indexes);

//Adds to the set the mapped already set for this field
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,33 @@
package com.dotcms.contenttype.transform.field;

import static com.dotcms.util.CollectionsUtils.map;

import com.dotcms.contenttype.model.field.ContentTypeFieldProperties;
import com.dotcms.contenttype.model.field.ImmutableRelationshipField;
import com.dotmarketing.business.RelationshipAPI;
import com.dotmarketing.portlets.structure.model.Relationship;
import com.dotmarketing.util.UtilMethods;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.dotcms.contenttype.model.field.Field;
import com.dotcms.contenttype.model.field.FieldVariable;
import com.dotcms.contenttype.model.field.ImmutableCategoryField;
import com.dotcms.contenttype.model.field.ImmutableFieldVariable;
import com.dotcms.contenttype.model.field.ImmutableRelationshipField;
import com.dotcms.contenttype.transform.JsonTransformer;
import com.google.common.collect.ImmutableList;
import com.dotmarketing.business.APILocator;
import com.dotmarketing.business.DotStateException;
import com.dotmarketing.exception.DotSecurityException;
import com.dotmarketing.portlets.categories.model.Category;
import com.dotmarketing.portlets.structure.model.Relationship;
import com.dotmarketing.util.Logger;
import com.dotmarketing.util.UtilMethods;
import com.dotmarketing.util.json.JSONArray;
import com.dotmarketing.util.json.JSONException;
import com.dotmarketing.util.json.JSONObject;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.google.common.collect.ImmutableList;
import com.liferay.portal.language.LanguageUtil;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class JsonFieldTransformer implements FieldTransformer, JsonTransformer {

private static final String CATEGORIES_PROPERTY_NAME = "categories";
Expand Down Expand Up @@ -190,12 +187,12 @@ public Map<String, Object> mapObject() {
final Relationship relationship = APILocator.getRelationshipAPI()
.getRelationshipFromField(field, APILocator.getLoginServiceAPI().getLoggedInUser());
if (null != relationship){
fieldMap.put(ContentTypeFieldProperties.RELATIONSHIPS.getName(), map(
fieldMap.put(ContentTypeFieldProperties.RELATIONSHIPS.getName(), Map.of(
"cardinality", Integer.parseInt(cardinality), "velocityVar", relationType,
"isParentField", relationship.getParentStructureInode().equals(field.contentTypeId())
));
} else{
fieldMap.put(ContentTypeFieldProperties.RELATIONSHIPS.getName(), map(
fieldMap.put(ContentTypeFieldProperties.RELATIONSHIPS.getName(), Map.of(
"cardinality", Integer.parseInt(cardinality), "velocityVar", relationType
));
}
Expand Down
5 changes: 2 additions & 3 deletions dotCMS/src/main/java/com/dotcms/cube/CubeJSClient.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package com.dotcms.cube;

import static com.dotcms.util.CollectionsUtils.map;

import com.dotcms.analytics.helper.AnalyticsHelper;
import com.dotcms.analytics.model.AccessToken;
import com.dotcms.exception.AnalyticsException;
import com.dotcms.http.CircuitBreakerUrl;
import com.dotcms.http.CircuitBreakerUrl.Method;
import com.dotcms.http.CircuitBreakerUrl.Response;
import com.dotcms.metrics.timing.TimeMetric;
import com.dotcms.util.CollectionsUtils;
import com.dotcms.util.DotPreconditions;
import com.dotcms.util.JsonUtil;
import com.dotmarketing.util.Logger;
Expand Down Expand Up @@ -89,7 +88,7 @@ public CubeJSResultSet send(final CubeJSQuery query) {
.setMethod(Method.GET)
.setHeaders(cubeJsHeaders(accessToken))
.setUrl(cubeJsUrl)
.setParams(map("query", queryAsString))
.setParams(new HashMap<>(Map.of("query", queryAsString)))
.setTimeout(4000)
.setThrowWhenNot2xx(false)
.build();
Expand Down
10 changes: 7 additions & 3 deletions dotCMS/src/main/java/com/dotcms/cube/filters/LogicalFilter.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.dotcms.cube.filters;

import static com.dotcms.util.CollectionsUtils.map;

import com.dotcms.cube.filters.SimpleFilter.Operator;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -72,10 +72,14 @@ private LogicalFilter(final Type type, final Filter[] filters) {
public Map<String, Object> asMap() {
final String logicalOperator = type.name().toLowerCase();

return map(logicalOperator,
final Map<String, Object> map = new HashMap<>();

map.put(logicalOperator,
Arrays.stream(filters)
.map(filter -> filter.asMap())
.collect(Collectors.toList()));

return map;
}

@Override
Expand Down
15 changes: 10 additions & 5 deletions dotCMS/src/main/java/com/dotcms/cube/filters/SimpleFilter.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.dotcms.cube.filters;

import static com.dotcms.util.CollectionsUtils.map;

import com.dotcms.cube.filters.Filter;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

Expand Down Expand Up @@ -72,8 +70,15 @@ public String[] getValues() {
}

@Override
public Map<String, Object> asMap(){
return map("member", member, "operator", operator.getKey(), "values", values);
public Map<String, Object> asMap() {

final Map<String, Object> map = new HashMap<>();

map.put("member", member);
map.put("operator", operator.getKey());
map.put("values", values);

return map;
}

public enum Operator {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
package com.dotcms.experiments.business.result;

import static com.dotcms.util.CollectionsUtils.map;

import com.dotcms.analytics.metrics.MetricType;
import com.dotcms.cube.CubeJSQuery;
import com.dotcms.cube.filters.Filter;
import com.dotcms.cube.filters.SimpleFilter.Operator;
import com.dotcms.experiments.model.AbstractExperiment.Status;
import com.dotcms.experiments.model.Goal;
import com.dotcms.experiments.model.Experiment;
import com.dotcms.experiments.model.Goal;
import com.dotcms.experiments.model.Goals;
import com.dotcms.util.DotPreconditions;
import io.vavr.Lazy;

import java.util.Map;

/**
Expand Down Expand Up @@ -67,7 +66,7 @@ public enum ExperimentResultsQueryFactory {


private static Map<MetricType, MetricExperimentResultsQuery> createHelpersMap() {
return map(
return Map.of(
MetricType.EXIT_RATE, new ExitRateResultQuery(),
MetricType.REACH_PAGE, new ReachTargetAfterExperimentPageResultQuery(),
MetricType.BOUNCE_RATE, new BounceRateResultQuery(),
Expand Down
Loading
Loading