Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
891811a
#32238 adding new endpoint
jdotcms Jun 10, 2025
6b3ce60
#32238 adding final fixes after smoke qa, just about to do the postma…
jdotcms Jun 13, 2025
32c02de
#32238 adding final fixes after smoke qa, just about to do the postma…
jdotcms Jun 13, 2025
ef0e62a
#32238 adding postmans
jdotcms Jun 18, 2025
c8721c7
#32238 on usage filtering, pagination and sort is done in java
jdotcms Jun 19, 2025
aa8dceb
#32238 code after smoke test
jdotcms Jun 20, 2025
ad37244
Merge branch 'main' into issue-32238-content-types
jdotcms Jun 20, 2025
19ad8ef
#32238 fixing an unit test
jdotcms Jun 23, 2025
9e9553b
Merge branch 'issue-32238-content-types' of github.com:dotCMS/core in…
jdotcms Jun 23, 2025
c9a4014
#32238 adding more fixing for unit test
jdotcms Jun 23, 2025
a44d65a
#32238 adding fix for postman
jdotcms Jun 24, 2025
93e39cd
#32238 trying to fix 400 on ct test
jdotcms Jun 25, 2025
71e02a7
Merge branch 'main' into issue-32238-content-types
jdotcms Jun 25, 2025
a451479
Merge branch 'main' into issue-32238-content-types
jdotcms Jul 7, 2025
caf469a
Merge branch 'main' into issue-32238-content-types
erickgonzalez Jul 7, 2025
8d5508b
Merge branch 'main' into issue-32238-content-types
jdotcms Jul 8, 2025
ab6650b
#32238 fixing some content type postmans
jdotcms Jul 8, 2025
ff75d8e
Merge branch 'issue-32238-content-types' of github.com:dotCMS/core in…
jdotcms Jul 8, 2025
9d68c97
#32238 fixing some content type postmans
jdotcms Jul 9, 2025
201418d
#32238 adding postman fixes
jdotcms Jul 14, 2025
3514964
Merge branch 'main' into issue-32238-content-types
jdotcms Jul 14, 2025
e17d98f
Merge branch 'main' into issue-32238-content-types
jdotcms Jul 15, 2025
8845d2d
#32238 adding the swagger yaml
jdotcms Jul 15, 2025
2e7a64a
#32238 adding some swagger doc
jdotcms Jul 16, 2025
3eb5fa7
Merge branch 'main' into issue-32238-content-types
erickgonzalez Jul 17, 2025
ee0b8fa
#32238 adding fixes for ct postman
jdotcms Jul 17, 2025
bbaa536
Merge branch 'issue-32238-content-types' of github.com:dotCMS/core in…
jdotcms Jul 17, 2025
38bb43b
#32238 adding fixes for ct postman
jdotcms Jul 17, 2025
be2b77f
Merge branch 'main' into issue-32238-content-types
jdotcms Aug 5, 2025
1324ece
#32238 fixing postman issues
jdotcms Aug 5, 2025
075e43a
#32238 fixing postman issues
jdotcms Aug 5, 2025
5280f2c
#32238 fixing postman issues
jdotcms Aug 6, 2025
d08663a
#32238 fixing postman issues
jdotcms Aug 6, 2025
2427d29
Merge branch 'main' into issue-32238-content-types
dsilvam Aug 12, 2025
c0c6659
#32238 merge main done
jdotcms Aug 19, 2025
5440e1c
Merge branch 'main' into issue-32238-content-types
jdotcms Aug 19, 2025
24b5e83
#32238 reversing undesired changes on ct postman
jdotcms Aug 25, 2025
b65657a
Merge branch 'main' of github.com:dotCMS/core into issue-32238-conten…
jdotcms Aug 25, 2025
74c0cb8
#32238 the GH throws 400, so introducing a logout on the beginning in…
jdotcms Aug 26, 2025
8360b9b
Merge branch 'main' into issue-32238-content-types
jdotcms Aug 27, 2025
ea243b0
#32238 trying to fix the postman
jdotcms Aug 27, 2025
b3c912a
Merge branch 'issue-32238-content-types' of github.com:dotCMS/core in…
jdotcms Aug 27, 2025
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 @@ -389,7 +389,7 @@ public Optional<List<ContentType>> find(final List<String> varNames, final Strin
contentTypeList = this.contentTypeFactory.find(lowercaseVarNames, filter.toLowerCase(), offset, limit, orderBy);
} else if (offset > 0 || limit > 0) {
int adjustedLimit = offset + limit;
adjustedLimit = adjustedLimit > lowercaseVarNames.size() ? lowercaseVarNames.size() : limit;
adjustedLimit = adjustedLimit > lowercaseVarNames.size() ? lowercaseVarNames.size() : adjustedLimit;
final List<String> varNamesSubList = lowercaseVarNames.subList(offset, adjustedLimit);
contentTypeList = this.contentTypeFactory.find(varNamesSubList, null, internalOffset, internalLimit, orderBy);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public List<ContentType> find(final Collection<String> varNames, final String fi
final DotConnect dc = new DotConnect();
String sql = UtilMethods.isSet(filter) ? ContentTypeSql.SELECT_BY_VAR_NAMES_FILTERED : ContentTypeSql.SELECT_BY_VAR_NAMES;
sql = String.format(sql, String.join(COMMA, Collections.nCopies(varNames.size(), "?")));
if (UtilMethods.isSet(orderBy)) {
if (UtilMethods.isSet(orderBy) && !orderBy.contains(SQLUtil.DOT_NOT_SORT)) { // DOT_NOT_SORT is used to indicate no order by wanted
sql = UtilMethods.isSet(orderBy) ? sql + ContentTypeSql.ORDER_BY : sql;
final String sanitizedOrderBy = SQLUtil.sanitizeSortBy(orderBy);
sql = String.format(sql, sanitizedOrderBy);
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@
import com.dotmarketing.util.PaginatedArrayList;
import com.dotmarketing.util.UtilMethods;
import com.liferay.portal.model.User;
import com.liferay.util.StringPool;
import com.rainerhahnekamp.sneakythrow.Sneaky;
import io.vavr.control.Try;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;

Expand All @@ -39,11 +42,17 @@
*/
public class ContentTypesPaginator implements PaginatorOrdered<Map<String, Object>>{

private static final String N_ENTRIES_FIELD_NAME = "nEntries";
public static final String N_ENTRIES_FIELD_NAME = "nEntries";
public static final String TYPE_PARAMETER_NAME = "type";
public static final String TYPES_PARAMETER_NAME = "types";
public static final String HOST_PARAMETER_ID = "host";
public static final String SITES_PARAMETER_NAME = "sites";
public static final String COMPARATOR = "comparator";
public static final String ENTRIES_BY_CONTENT_TYPES = "entriesByContentTypes";
public static final String VARIABLE = "variable";
public static final String WORKFLOWS = "workflows";
public static final String SYSTEM_ACTION_MAPPINGS = "systemActionMappings";


private final ContentTypeAPI contentTypeAPI;
private final WorkflowAPI workflowAPI;
Expand Down Expand Up @@ -102,8 +111,12 @@ public PaginatedArrayList<Map<String, Object>> getItems(final User user, final S
final List<Map<String, Object>> contentTypesTransform = transformContentTypesToMap(contentTypes);
setEntriesAttribute(user, contentTypesTransform,
this.workflowAPI.findSchemesMapForContentType(contentTypes),
this.workflowAPI.findSystemActionsMapByContentType(contentTypes, user));
result.addAll(contentTypesTransform);
this.workflowAPI.findSystemActionsMapByContentType(contentTypes, user),
extraParams);

result.addAll(Objects.nonNull(extraParams) && extraParams.containsKey(COMPARATOR)?
contentTypesTransform.stream().sorted((Comparator<Map<String, Object>>) extraParams.get(COMPARATOR)).collect(Collectors.toList())
:contentTypesTransform);
return result;
} catch (final DotDataException | DotSecurityException e) {
final String errorMsg = String.format("An error occurred when retrieving paginated Content Types: " +
Expand All @@ -127,13 +140,15 @@ public PaginatedArrayList<Map<String, Object>> getItems(final User user, final S
*/
private void setEntriesAttribute(final User user, final List<Map<String, Object>> contentTypesTransform,
final Map<String, List<WorkflowScheme>> workflowSchemes,
final Map<String, List<SystemActionWorkflowActionMapping>> systemActionMappings) {
final Map<String, List<SystemActionWorkflowActionMapping>> systemActionMappings,
final Map<String, Object> extraParams) {

Map<String, Long> entriesByContentTypes = null;

try {
entriesByContentTypes = APILocator.getContentTypeAPI
(user, true).getEntriesByContentTypes();
entriesByContentTypes = Objects.nonNull(extraParams) && extraParams.containsKey(ENTRIES_BY_CONTENT_TYPES)?
(Map<String, Long>)extraParams.get(ENTRIES_BY_CONTENT_TYPES):
APILocator.getContentTypeAPI(user, true).getEntriesByContentTypes();
} catch (final DotStateException | DotDataException e) {
final String errorMsg = String.format("Error trying to retrieve total entries by Content Type: %s", e.getMessage());
Logger.error(ContentTypesPaginator.class, errorMsg, e);
Expand All @@ -142,25 +157,25 @@ private void setEntriesAttribute(final User user, final List<Map<String, Object>

for (final Map<String, Object> contentTypeEntry : contentTypesTransform) {

final String variable = (String) contentTypeEntry.get("variable");
final String variable = (String) contentTypeEntry.get(VARIABLE);
if (entriesByContentTypes != null) {

final String key = variable.toLowerCase();
final Long contentTypeEntriesNumber = entriesByContentTypes.get(key) == null ? 0l :
entriesByContentTypes.get(key);
contentTypeEntry.put(N_ENTRIES_FIELD_NAME, contentTypeEntriesNumber);
} else {
contentTypeEntry.put(N_ENTRIES_FIELD_NAME, "N/A");
contentTypeEntry.put(N_ENTRIES_FIELD_NAME, StringPool.NA);
}

if (workflowSchemes.containsKey(variable)) {

contentTypeEntry.put("workflows", workflowSchemes.get(variable));
contentTypeEntry.put(WORKFLOWS, workflowSchemes.get(variable));
}

if (systemActionMappings.containsKey(variable)) {

contentTypeEntry.put("systemActionMappings", workflowSchemes.get(variable));
contentTypeEntry.put(SYSTEM_ACTION_MAPPINGS, systemActionMappings.get(variable));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.dotmarketing.util.PaginatedArrayList;
import com.liferay.portal.model.User;

import java.util.Collections;
import java.util.Map;

/**
Expand Down Expand Up @@ -102,7 +103,7 @@ default PaginatedArrayList<T> getItems(final User user, final String filter, fin
* @return A {@link PaginatedArrayList} of items matching the specified search criteria.
*/
default PaginatedArrayList<T> getItems(final User user, final String filter, final int limit, final int offset, final String orderBy, final OrderDirection direction) {
return getItems(user, filter, limit, offset, orderBy, direction, null);
return getItems(user, filter, limit, offset, orderBy, direction, Collections.emptyMap());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public class SQLUtil {
private static final SecurityLoggerServiceAPI securityLoggerServiceAPI =
APILocator.getSecurityLogger();

// When you need to send a sort but do not want to actually sort by anything
public static final String DOT_NOT_SORT = "dotnosort";
public static final String ASC = "asc";
public static final String DESC = "desc";
public static final String _ASC = " " + ASC ;
Expand Down
2 changes: 1 addition & 1 deletion dotCMS/src/main/java/com/liferay/util/StringPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,5 +93,5 @@ public class StringPool {

public static final String UNKNOWN = "UNKNOWN";


public static final String NA = "N/A";
}
119 changes: 119 additions & 0 deletions dotCMS/src/main/webapp/WEB-INF/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ tags:
name: Containers
- description: Endpoints for managing content and contentlets
name: Content
- description: Returns the content types valid for a page based on the container/types
on the layout
name: getPagesContentTypes
- description: Endpoints for managing folder structure and organization
name: Folders
- description: Form management and processing
Expand Down Expand Up @@ -6713,6 +6716,122 @@ paths:
summary: Updates a content type
tags:
- Content Type
/v1/contenttype/page:
get:
description: Returns a list of content type objects based on the filtering criteria.
operationId: getPagesContentTypes
parameters:
- description: The URL or Identifier of the page to filter content types for
the palette
in: query
name: pagePathOrId
schema:
type: string
- description: Optional Language id
in: query
name: language
schema:
type: string
default: "-1"
- description: String to filter/search for specific content types; leave blank
to return all.
in: query
name: filter
schema:
type: string
- description: |-
Page number in response pagination.

Default: `1`
in: query
name: page
schema:
type: integer
format: int64
default: 1
- description: |-
Number of results per page for pagination.

Default: `10`
in: query
name: per_page
schema:
type: integer
format: int64
default: 10
- description: |-
Column(s) to sort the results. Multiple columns can be combined in a comma-separated list. Column names can also be set within a SQL string function, such as `upper()`.

Some possible values:

`name`, `velocity_var_name`, `mod_date`, `sort_order`

`description`, `structuretype`, `category`, `inode`
in: query
name: orderby
schema:
type: string
default: usage
- description: "Sort direction: choose between ascending or descending."
in: query
name: direction
schema:
type: string
default: ASC
enum:
- ASC
- DESC
- description: Filter by site identifier.
in: query
name: host
schema:
type: string
responses:
"200":
content:
application/json:
example:
entity:
- baseType: string
clazz: string
defaultType: true
description: string
fixed: true
folder: string
folderPath: string
host: string
iDate: 0
icon: string
id: string
layout: []
metadata: {}
modDate: 0
multilingualable: true
nEntries: 0
name: string
siteName: string
sortOrder: 0
system: true
variable: string
versionable: true
workflows: []
errors: []
i18nMessagesMap: {}
messages: []
pagination:
currentPage: 0
perPage: 0
totalEntries: 0
permissions: []
description: Content types retrieved successfully
"403":
description: Forbidden
"500":
description: Internal Server Error
summary: Retrieves a list of content types for a page
tags:
- getPagesContentTypes
- Content Type
/v1/contenttype/{baseVariableName}/_copy:
post:
description: |-
Expand Down
Loading