
com.liferay.headless.delivery.internal.resource.v1_0.BaseMessageBoardSectionResourceImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com.liferay.headless.delivery.impl
Show all versions of com.liferay.headless.delivery.impl
Liferay Headless Delivery Implementation
The newest version!
/**
* SPDX-FileCopyrightText: (c) 2000 Liferay, Inc. https://liferay.com
* SPDX-License-Identifier: LGPL-2.1-or-later OR LicenseRef-Liferay-DXP-EULA-2.0.0-2023-06
*/
package com.liferay.headless.delivery.internal.resource.v1_0;
import com.liferay.headless.delivery.dto.v1_0.DefaultValue;
import com.liferay.headless.delivery.dto.v1_0.MessageBoardSection;
import com.liferay.headless.delivery.resource.v1_0.MessageBoardSectionResource;
import com.liferay.petra.function.UnsafeBiConsumer;
import com.liferay.petra.function.UnsafeConsumer;
import com.liferay.petra.function.UnsafeFunction;
import com.liferay.petra.function.transform.TransformUtil;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.model.Resource;
import com.liferay.portal.kernel.model.ResourceAction;
import com.liferay.portal.kernel.model.ResourceConstants;
import com.liferay.portal.kernel.model.ResourcePermission;
import com.liferay.portal.kernel.security.permission.ActionKeys;
import com.liferay.portal.kernel.security.permission.resource.ModelResourcePermission;
import com.liferay.portal.kernel.service.GroupLocalService;
import com.liferay.portal.kernel.service.PermissionServiceUtil;
import com.liferay.portal.kernel.service.ResourceActionLocalService;
import com.liferay.portal.kernel.service.ResourceLocalServiceUtil;
import com.liferay.portal.kernel.service.ResourcePermissionLocalService;
import com.liferay.portal.kernel.service.RoleLocalService;
import com.liferay.portal.kernel.service.permission.ModelPermissions;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.GroupThreadLocal;
import com.liferay.portal.kernel.util.HashMapBuilder;
import com.liferay.portal.kernel.util.LocaleUtil;
import com.liferay.portal.kernel.util.SetUtil;
import com.liferay.portal.kernel.util.StringUtil;
import com.liferay.portal.kernel.util.Validator;
import com.liferay.portal.odata.entity.EntityModel;
import com.liferay.portal.odata.filter.ExpressionConvert;
import com.liferay.portal.odata.filter.FilterParser;
import com.liferay.portal.odata.filter.FilterParserProvider;
import com.liferay.portal.odata.sort.SortField;
import com.liferay.portal.odata.sort.SortParser;
import com.liferay.portal.odata.sort.SortParserProvider;
import com.liferay.portal.vulcan.accept.language.AcceptLanguage;
import com.liferay.portal.vulcan.batch.engine.VulcanBatchEngineTaskItemDelegate;
import com.liferay.portal.vulcan.batch.engine.resource.VulcanBatchEngineExportTaskResource;
import com.liferay.portal.vulcan.batch.engine.resource.VulcanBatchEngineImportTaskResource;
import com.liferay.portal.vulcan.crud.VulcanCRUDItemDelegate;
import com.liferay.portal.vulcan.pagination.Page;
import com.liferay.portal.vulcan.pagination.Pagination;
import com.liferay.portal.vulcan.permission.ModelPermissionsUtil;
import com.liferay.portal.vulcan.permission.Permission;
import com.liferay.portal.vulcan.resource.EntityModelResource;
import com.liferay.portal.vulcan.util.ActionUtil;
import com.liferay.portal.vulcan.util.UriInfoUtil;
import jakarta.annotation.Generated;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.ws.rs.NotSupportedException;
import jakarta.ws.rs.core.MultivaluedHashMap;
import jakarta.ws.rs.core.MultivaluedMap;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.UriInfo;
import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
/**
* @author Javier Gamarra
* @generated
*/
@Generated("")
@jakarta.ws.rs.Path("/v1.0")
public abstract class BaseMessageBoardSectionResourceImpl
implements EntityModelResource, MessageBoardSectionResource,
VulcanBatchEngineTaskItemDelegate,
VulcanCRUDItemDelegate {
/**
* Invoke this method with the command line:
*
* curl -X 'DELETE' 'http://localhost:8080/o/headless-delivery/v1.0/message-board-sections/{messageBoardSectionId}' -u '[email protected]:test'
*/
@io.swagger.v3.oas.annotations.Operation(
description = "Deletes the message board section and returns a 204 if the operation succeeds."
)
@io.swagger.v3.oas.annotations.Parameters(
value = {
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.PATH,
name = "messageBoardSectionId"
)
}
)
@io.swagger.v3.oas.annotations.tags.Tags(
value = {
@io.swagger.v3.oas.annotations.tags.Tag(
name = "MessageBoardSection"
)
}
)
@jakarta.ws.rs.DELETE
@jakarta.ws.rs.Path("/message-board-sections/{messageBoardSectionId}")
@jakarta.ws.rs.Produces({"application/json", "application/xml"})
@Override
public void deleteMessageBoardSection(
@io.swagger.v3.oas.annotations.Parameter(hidden = true)
@jakarta.validation.constraints.NotNull
@jakarta.ws.rs.PathParam("messageBoardSectionId")
Long messageBoardSectionId)
throws Exception {
}
/**
* Invoke this method with the command line:
*
* curl -X 'DELETE' 'http://localhost:8080/o/headless-delivery/v1.0/message-board-sections/batch' -u '[email protected]:test'
*/
@io.swagger.v3.oas.annotations.Parameters(
value = {
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "callbackURL"
)
}
)
@io.swagger.v3.oas.annotations.tags.Tags(
value = {
@io.swagger.v3.oas.annotations.tags.Tag(
name = "MessageBoardSection"
)
}
)
@jakarta.ws.rs.Consumes("application/json")
@jakarta.ws.rs.DELETE
@jakarta.ws.rs.Path("/message-board-sections/batch")
@jakarta.ws.rs.Produces("application/json")
@Override
public Response deleteMessageBoardSectionBatch(
@io.swagger.v3.oas.annotations.Parameter(hidden = true)
@jakarta.ws.rs.QueryParam("callbackURL")
String callbackURL,
Object object)
throws Exception {
vulcanBatchEngineImportTaskResource.setContextAcceptLanguage(
contextAcceptLanguage);
vulcanBatchEngineImportTaskResource.setContextCompany(contextCompany);
vulcanBatchEngineImportTaskResource.setContextHttpServletRequest(
contextHttpServletRequest);
vulcanBatchEngineImportTaskResource.setContextUriInfo(contextUriInfo);
vulcanBatchEngineImportTaskResource.setContextUser(contextUser);
Response.ResponseBuilder responseBuilder = Response.accepted();
return responseBuilder.entity(
vulcanBatchEngineImportTaskResource.deleteImportTask(
MessageBoardSection.class.getName(), callbackURL, object)
).build();
}
/**
* Invoke this method with the command line:
*
* curl -X 'GET' 'http://localhost:8080/o/headless-delivery/v1.0/message-board-sections/{messageBoardSectionId}' -u '[email protected]:test'
*/
@io.swagger.v3.oas.annotations.Operation(
description = "Retrieves the message board section."
)
@io.swagger.v3.oas.annotations.Parameters(
value = {
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.PATH,
name = "messageBoardSectionId"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "fields"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "nestedFields"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "restrictFields"
)
}
)
@io.swagger.v3.oas.annotations.tags.Tags(
value = {
@io.swagger.v3.oas.annotations.tags.Tag(
name = "MessageBoardSection"
)
}
)
@jakarta.ws.rs.GET
@jakarta.ws.rs.Path("/message-board-sections/{messageBoardSectionId}")
@jakarta.ws.rs.Produces({"application/json", "application/xml"})
@Override
public MessageBoardSection getMessageBoardSection(
@io.swagger.v3.oas.annotations.Parameter(hidden = true)
@jakarta.validation.constraints.NotNull
@jakarta.ws.rs.PathParam("messageBoardSectionId")
Long messageBoardSectionId)
throws Exception {
return new MessageBoardSection();
}
/**
* Invoke this method with the command line:
*
* curl -X 'GET' 'http://localhost:8080/o/headless-delivery/v1.0/message-board-sections/{parentMessageBoardSectionId}/message-board-sections' -u '[email protected]:test'
*/
@io.swagger.v3.oas.annotations.Operation(
description = "Retrieves the parent message board section's subsections. Results can be paginated, filtered, searched, and sorted."
)
@io.swagger.v3.oas.annotations.Parameters(
value = {
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.PATH,
name = "parentMessageBoardSectionId"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "aggregationTerms"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "fields"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "filter"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "nestedFields"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "page"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "pageSize"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "restrictFields"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "search"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "sort"
)
}
)
@io.swagger.v3.oas.annotations.tags.Tags(
value = {
@io.swagger.v3.oas.annotations.tags.Tag(
name = "MessageBoardSection"
)
}
)
@jakarta.ws.rs.GET
@jakarta.ws.rs.Path(
"/message-board-sections/{parentMessageBoardSectionId}/message-board-sections"
)
@jakarta.ws.rs.Produces({"application/json", "application/xml"})
@Override
public Page
getMessageBoardSectionMessageBoardSectionsPage(
@io.swagger.v3.oas.annotations.Parameter(hidden = true)
@jakarta.validation.constraints.NotNull
@jakarta.ws.rs.PathParam("parentMessageBoardSectionId")
Long parentMessageBoardSectionId,
@io.swagger.v3.oas.annotations.Parameter(hidden = true)
@jakarta.ws.rs.QueryParam("search")
String search,
@jakarta.ws.rs.core.Context
com.liferay.portal.vulcan.aggregation.Aggregation
aggregation,
@jakarta.ws.rs.core.Context
com.liferay.portal.kernel.search.filter.Filter filter,
@jakarta.ws.rs.core.Context Pagination pagination,
@jakarta.ws.rs.core.Context
com.liferay.portal.kernel.search.Sort[] sorts)
throws Exception {
return Page.of(Collections.emptyList());
}
/**
* Invoke this method with the command line:
*
* curl -X 'GET' 'http://localhost:8080/o/headless-delivery/v1.0/message-board-sections/{messageBoardSectionId}/permissions' -u '[email protected]:test'
*/
@io.swagger.v3.oas.annotations.Parameters(
value = {
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.PATH,
name = "messageBoardSectionId"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "fields"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "nestedFields"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "restrictFields"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "roleNames"
)
}
)
@io.swagger.v3.oas.annotations.tags.Tags(
value = {
@io.swagger.v3.oas.annotations.tags.Tag(
name = "MessageBoardSection"
)
}
)
@jakarta.ws.rs.GET
@jakarta.ws.rs.Path(
"/message-board-sections/{messageBoardSectionId}/permissions"
)
@jakarta.ws.rs.Produces({"application/json", "application/xml"})
@Override
public Page getMessageBoardSectionPermissionsPage(
@io.swagger.v3.oas.annotations.Parameter(hidden = true)
@jakarta.validation.constraints.NotNull
@jakarta.ws.rs.PathParam("messageBoardSectionId")
Long messageBoardSectionId,
@io.swagger.v3.oas.annotations.Parameter(hidden = true)
@jakarta.ws.rs.QueryParam("roleNames")
String roleNames)
throws Exception {
String resourceName = getPermissionCheckerResourceName(
messageBoardSectionId);
Long resourceId = getPermissionCheckerResourceId(messageBoardSectionId);
PermissionServiceUtil.checkPermission(
getPermissionCheckerGroupId(messageBoardSectionId), resourceName,
resourceId);
return toPermissionPage(
HashMapBuilder.put(
"get",
addAction(
ActionKeys.PERMISSIONS,
"getMessageBoardSectionPermissionsPage", resourceName,
resourceId)
).put(
"replace",
addAction(
ActionKeys.PERMISSIONS,
"putMessageBoardSectionPermissionsPage", resourceName,
resourceId)
).build(),
resourceId, resourceName, roleNames);
}
/**
* Invoke this method with the command line:
*
* curl -X 'GET' 'http://localhost:8080/o/headless-delivery/v1.0/sites/{siteId}/message-board-section/by-friendly-url-path/{friendlyUrlPath}' -u '[email protected]:test'
*/
@io.swagger.v3.oas.annotations.Parameters(
value = {
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.PATH,
name = "siteId"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.PATH,
name = "friendlyUrlPath"
)
}
)
@io.swagger.v3.oas.annotations.tags.Tags(
value = {
@io.swagger.v3.oas.annotations.tags.Tag(
name = "MessageBoardSection"
)
}
)
@jakarta.ws.rs.GET
@jakarta.ws.rs.Path(
"/sites/{siteId}/message-board-section/by-friendly-url-path/{friendlyUrlPath: .+}"
)
@jakarta.ws.rs.Produces({"application/json", "application/xml"})
@Override
public MessageBoardSection getSiteMessageBoardSectionByFriendlyUrlPath(
@io.swagger.v3.oas.annotations.Parameter(hidden = true)
@jakarta.validation.constraints.NotNull
@jakarta.ws.rs.PathParam("siteId")
Long siteId,
@io.swagger.v3.oas.annotations.Parameter(hidden = true)
@jakarta.validation.constraints.NotNull
@jakarta.ws.rs.PathParam("friendlyUrlPath")
String friendlyUrlPath)
throws Exception {
return new MessageBoardSection();
}
/**
* Invoke this method with the command line:
*
* curl -X 'GET' 'http://localhost:8080/o/headless-delivery/v1.0/sites/{siteId}/message-board-sections/permissions' -u '[email protected]:test'
*/
@io.swagger.v3.oas.annotations.Parameters(
value = {
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.PATH,
name = "siteId"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "fields"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "nestedFields"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "restrictFields"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "roleNames"
)
}
)
@io.swagger.v3.oas.annotations.tags.Tags(
value = {
@io.swagger.v3.oas.annotations.tags.Tag(
name = "MessageBoardSection"
)
}
)
@jakarta.ws.rs.GET
@jakarta.ws.rs.Path("/sites/{siteId}/message-board-sections/permissions")
@jakarta.ws.rs.Produces({"application/json", "application/xml"})
@Override
public Page getSiteMessageBoardSectionPermissionsPage(
@io.swagger.v3.oas.annotations.Parameter(hidden = true)
@jakarta.validation.constraints.NotNull
@jakarta.ws.rs.PathParam("siteId")
Long siteId,
@io.swagger.v3.oas.annotations.Parameter(hidden = true)
@jakarta.ws.rs.QueryParam("roleNames")
String roleNames)
throws Exception {
String portletName = getPermissionCheckerPortletName(siteId);
PermissionServiceUtil.checkPermission(siteId, portletName, siteId);
return toPermissionPage(
HashMapBuilder.put(
"get",
addAction(
ActionKeys.PERMISSIONS,
"getSiteMessageBoardSectionPermissionsPage", portletName,
siteId)
).put(
"replace",
addAction(
ActionKeys.PERMISSIONS,
"putSiteMessageBoardSectionPermissionsPage", portletName,
siteId)
).build(),
siteId, portletName, roleNames);
}
/**
* Invoke this method with the command line:
*
* curl -X 'GET' 'http://localhost:8080/o/headless-delivery/v1.0/sites/{siteId}/message-board-sections' -u '[email protected]:test'
*/
@io.swagger.v3.oas.annotations.Operation(
description = "Retrieves the site's message board sections. Results can be paginated, filtered, searched, flattened, and sorted."
)
@io.swagger.v3.oas.annotations.Parameters(
value = {
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.PATH,
name = "siteId"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "aggregationTerms"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "fields"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "filter"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "flatten"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "nestedFields"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "page"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "pageSize"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "restrictFields"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "search"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "sort"
)
}
)
@io.swagger.v3.oas.annotations.tags.Tags(
value = {
@io.swagger.v3.oas.annotations.tags.Tag(
name = "MessageBoardSection"
)
}
)
@jakarta.ws.rs.GET
@jakarta.ws.rs.Path("/sites/{siteId}/message-board-sections")
@jakarta.ws.rs.Produces({"application/json", "application/xml"})
@Override
public Page getSiteMessageBoardSectionsPage(
@io.swagger.v3.oas.annotations.Parameter(hidden = true)
@jakarta.validation.constraints.NotNull
@jakarta.ws.rs.PathParam("siteId")
Long siteId,
@io.swagger.v3.oas.annotations.Parameter(hidden = true)
@jakarta.ws.rs.QueryParam("flatten")
Boolean flatten,
@io.swagger.v3.oas.annotations.Parameter(hidden = true)
@jakarta.ws.rs.QueryParam("search")
String search,
@jakarta.ws.rs.core.Context
com.liferay.portal.vulcan.aggregation.Aggregation aggregation,
@jakarta.ws.rs.core.Context
com.liferay.portal.kernel.search.filter.Filter filter,
@jakarta.ws.rs.core.Context Pagination pagination,
@jakarta.ws.rs.core.Context com.liferay.portal.kernel.search.Sort[]
sorts)
throws Exception {
return Page.of(Collections.emptyList());
}
/**
* Invoke this method with the command line:
*
* curl -X 'PATCH' 'http://localhost:8080/o/headless-delivery/v1.0/message-board-sections/{messageBoardSectionId}' -d $'{"customFields": ___, "description": ___, "friendlyUrlPath": ___, "parentMessageBoardSectionId": ___, "title": ___, "viewableBy": ___}' --header 'Content-Type: application/json' -u '[email protected]:test'
*/
@io.swagger.v3.oas.annotations.Operation(
description = "Updates only the fields received in the request body, leaving any other fields untouched."
)
@io.swagger.v3.oas.annotations.Parameters(
value = {
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.PATH,
name = "messageBoardSectionId"
)
}
)
@io.swagger.v3.oas.annotations.tags.Tags(
value = {
@io.swagger.v3.oas.annotations.tags.Tag(
name = "MessageBoardSection"
)
}
)
@jakarta.ws.rs.Consumes({"application/json", "application/xml"})
@jakarta.ws.rs.PATCH
@jakarta.ws.rs.Path("/message-board-sections/{messageBoardSectionId}")
@jakarta.ws.rs.Produces({"application/json", "application/xml"})
@Override
public MessageBoardSection patchMessageBoardSection(
@io.swagger.v3.oas.annotations.Parameter(hidden = true)
@jakarta.validation.constraints.NotNull
@jakarta.ws.rs.PathParam("messageBoardSectionId")
Long messageBoardSectionId,
MessageBoardSection messageBoardSection)
throws Exception {
MessageBoardSection existingMessageBoardSection =
getMessageBoardSection(messageBoardSectionId);
if (messageBoardSection.getCustomFields() != null) {
existingMessageBoardSection.setCustomFields(
messageBoardSection.getCustomFields());
}
if (messageBoardSection.getDescription() != null) {
existingMessageBoardSection.setDescription(
messageBoardSection.getDescription());
}
if (messageBoardSection.getFriendlyUrlPath() != null) {
existingMessageBoardSection.setFriendlyUrlPath(
messageBoardSection.getFriendlyUrlPath());
}
if (messageBoardSection.getParentMessageBoardSectionId() != null) {
existingMessageBoardSection.setParentMessageBoardSectionId(
messageBoardSection.getParentMessageBoardSectionId());
}
if (messageBoardSection.getTitle() != null) {
existingMessageBoardSection.setTitle(
messageBoardSection.getTitle());
}
if (messageBoardSection.getViewableBy() != null) {
existingMessageBoardSection.setViewableBy(
messageBoardSection.getViewableBy());
}
preparePatch(messageBoardSection, existingMessageBoardSection);
return putMessageBoardSection(
messageBoardSectionId, existingMessageBoardSection);
}
/**
* Invoke this method with the command line:
*
* curl -X 'POST' 'http://localhost:8080/o/headless-delivery/v1.0/message-board-sections/{parentMessageBoardSectionId}/message-board-sections' -d $'{"customFields": ___, "description": ___, "friendlyUrlPath": ___, "parentMessageBoardSectionId": ___, "title": ___, "viewableBy": ___}' --header 'Content-Type: application/json' -u '[email protected]:test'
*/
@io.swagger.v3.oas.annotations.Operation(
description = "Creates a new message board section in the parent section."
)
@io.swagger.v3.oas.annotations.Parameters(
value = {
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.PATH,
name = "parentMessageBoardSectionId"
)
}
)
@io.swagger.v3.oas.annotations.tags.Tags(
value = {
@io.swagger.v3.oas.annotations.tags.Tag(
name = "MessageBoardSection"
)
}
)
@jakarta.ws.rs.Consumes({"application/json", "application/xml"})
@jakarta.ws.rs.Path(
"/message-board-sections/{parentMessageBoardSectionId}/message-board-sections"
)
@jakarta.ws.rs.POST
@jakarta.ws.rs.Produces({"application/json", "application/xml"})
@Override
public MessageBoardSection postMessageBoardSectionMessageBoardSection(
@io.swagger.v3.oas.annotations.Parameter(hidden = true)
@jakarta.validation.constraints.NotNull
@jakarta.ws.rs.PathParam("parentMessageBoardSectionId")
Long parentMessageBoardSectionId,
MessageBoardSection messageBoardSection)
throws Exception {
return new MessageBoardSection();
}
/**
* Invoke this method with the command line:
*
* curl -X 'POST' 'http://localhost:8080/o/headless-delivery/v1.0/sites/{siteId}/message-board-sections' -d $'{"customFields": ___, "description": ___, "friendlyUrlPath": ___, "parentMessageBoardSectionId": ___, "title": ___, "viewableBy": ___}' --header 'Content-Type: application/json' -u '[email protected]:test'
*/
@io.swagger.v3.oas.annotations.Operation(
description = "Creates a new message board section."
)
@io.swagger.v3.oas.annotations.Parameters(
value = {
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.PATH,
name = "siteId"
)
}
)
@io.swagger.v3.oas.annotations.tags.Tags(
value = {
@io.swagger.v3.oas.annotations.tags.Tag(
name = "MessageBoardSection"
)
}
)
@jakarta.ws.rs.Consumes({"application/json", "application/xml"})
@jakarta.ws.rs.Path("/sites/{siteId}/message-board-sections")
@jakarta.ws.rs.POST
@jakarta.ws.rs.Produces({"application/json", "application/xml"})
@Override
public MessageBoardSection postSiteMessageBoardSection(
@io.swagger.v3.oas.annotations.Parameter(hidden = true)
@jakarta.validation.constraints.NotNull
@jakarta.ws.rs.PathParam("siteId")
Long siteId,
MessageBoardSection messageBoardSection)
throws Exception {
return new MessageBoardSection();
}
/**
* Invoke this method with the command line:
*
* curl -X 'POST' 'http://localhost:8080/o/headless-delivery/v1.0/sites/{siteId}/message-board-sections/batch' -u '[email protected]:test'
*/
@io.swagger.v3.oas.annotations.Parameters(
value = {
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.PATH,
name = "siteId"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "callbackURL"
)
}
)
@io.swagger.v3.oas.annotations.tags.Tags(
value = {
@io.swagger.v3.oas.annotations.tags.Tag(
name = "MessageBoardSection"
)
}
)
@jakarta.ws.rs.Consumes("application/json")
@jakarta.ws.rs.Path("/sites/{siteId}/message-board-sections/batch")
@jakarta.ws.rs.POST
@jakarta.ws.rs.Produces("application/json")
@Override
public Response postSiteMessageBoardSectionBatch(
@io.swagger.v3.oas.annotations.Parameter(hidden = true)
@jakarta.validation.constraints.NotNull
@jakarta.ws.rs.PathParam("siteId")
Long siteId,
@io.swagger.v3.oas.annotations.Parameter(hidden = true)
@jakarta.ws.rs.QueryParam("callbackURL")
String callbackURL,
Object object)
throws Exception {
vulcanBatchEngineImportTaskResource.setContextAcceptLanguage(
contextAcceptLanguage);
vulcanBatchEngineImportTaskResource.setContextCompany(contextCompany);
vulcanBatchEngineImportTaskResource.setContextHttpServletRequest(
contextHttpServletRequest);
vulcanBatchEngineImportTaskResource.setContextUriInfo(contextUriInfo);
vulcanBatchEngineImportTaskResource.setContextUser(contextUser);
Response.ResponseBuilder responseBuilder = Response.accepted();
return responseBuilder.entity(
vulcanBatchEngineImportTaskResource.postImportTask(
MessageBoardSection.class.getName(), callbackURL, null, object)
).build();
}
/**
* Invoke this method with the command line:
*
* curl -X 'POST' 'http://localhost:8080/o/headless-delivery/v1.0/sites/{siteId}/message-board-sections/export-batch' -u '[email protected]:test'
*/
@io.swagger.v3.oas.annotations.Parameters(
value = {
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.PATH,
name = "siteId"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "filter"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "search"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "sort"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "callbackURL"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "contentType"
),
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "fieldNames"
)
}
)
@io.swagger.v3.oas.annotations.tags.Tags(
value = {
@io.swagger.v3.oas.annotations.tags.Tag(
name = "MessageBoardSection"
)
}
)
@jakarta.ws.rs.Consumes("application/json")
@jakarta.ws.rs.Path("/sites/{siteId}/message-board-sections/export-batch")
@jakarta.ws.rs.POST
@jakarta.ws.rs.Produces("application/json")
@Override
public Response postSiteMessageBoardSectionsPageExportBatch(
@io.swagger.v3.oas.annotations.Parameter(hidden = true)
@jakarta.validation.constraints.NotNull
@jakarta.ws.rs.PathParam("siteId")
Long siteId,
@io.swagger.v3.oas.annotations.Parameter(hidden = true)
@jakarta.ws.rs.QueryParam("search")
String search,
@jakarta.ws.rs.core.Context
com.liferay.portal.kernel.search.filter.Filter filter,
@jakarta.ws.rs.core.Context com.liferay.portal.kernel.search.Sort[]
sorts,
@io.swagger.v3.oas.annotations.Parameter(hidden = true)
@jakarta.ws.rs.QueryParam("callbackURL")
String callbackURL,
@io.swagger.v3.oas.annotations.Parameter(hidden = true)
@jakarta.ws.rs.DefaultValue("JSON")
@jakarta.ws.rs.QueryParam("contentType")
String contentType,
@io.swagger.v3.oas.annotations.Parameter(hidden = true)
@jakarta.ws.rs.QueryParam("fieldNames")
String fieldNames)
throws Exception {
vulcanBatchEngineExportTaskResource.setContextAcceptLanguage(
contextAcceptLanguage);
vulcanBatchEngineExportTaskResource.setContextCompany(contextCompany);
vulcanBatchEngineExportTaskResource.setContextHttpServletRequest(
contextHttpServletRequest);
vulcanBatchEngineExportTaskResource.setContextUriInfo(contextUriInfo);
vulcanBatchEngineExportTaskResource.setContextUser(contextUser);
vulcanBatchEngineExportTaskResource.setGroupLocalService(
groupLocalService);
Response.ResponseBuilder responseBuilder = Response.accepted();
return responseBuilder.entity(
vulcanBatchEngineExportTaskResource.postExportTask(
MessageBoardSection.class.getName(), callbackURL, contentType,
fieldNames)
).build();
}
/**
* Invoke this method with the command line:
*
* curl -X 'PUT' 'http://localhost:8080/o/headless-delivery/v1.0/message-board-sections/{messageBoardSectionId}' -d $'{"customFields": ___, "description": ___, "friendlyUrlPath": ___, "parentMessageBoardSectionId": ___, "title": ___, "viewableBy": ___}' --header 'Content-Type: application/json' -u '[email protected]:test'
*/
@io.swagger.v3.oas.annotations.Operation(
description = "Replaces the message board section with the information sent in the request body. Any missing fields are deleted, unless they are required."
)
@io.swagger.v3.oas.annotations.Parameters(
value = {
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.PATH,
name = "messageBoardSectionId"
)
}
)
@io.swagger.v3.oas.annotations.tags.Tags(
value = {
@io.swagger.v3.oas.annotations.tags.Tag(
name = "MessageBoardSection"
)
}
)
@jakarta.ws.rs.Consumes({"application/json", "application/xml"})
@jakarta.ws.rs.Path("/message-board-sections/{messageBoardSectionId}")
@jakarta.ws.rs.Produces({"application/json", "application/xml"})
@jakarta.ws.rs.PUT
@Override
public MessageBoardSection putMessageBoardSection(
@io.swagger.v3.oas.annotations.Parameter(hidden = true)
@jakarta.validation.constraints.NotNull
@jakarta.ws.rs.PathParam("messageBoardSectionId")
Long messageBoardSectionId,
MessageBoardSection messageBoardSection)
throws Exception {
return new MessageBoardSection();
}
/**
* Invoke this method with the command line:
*
* curl -X 'PUT' 'http://localhost:8080/o/headless-delivery/v1.0/message-board-sections/batch' -u '[email protected]:test'
*/
@io.swagger.v3.oas.annotations.Parameters(
value = {
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.QUERY,
name = "callbackURL"
)
}
)
@io.swagger.v3.oas.annotations.tags.Tags(
value = {
@io.swagger.v3.oas.annotations.tags.Tag(
name = "MessageBoardSection"
)
}
)
@jakarta.ws.rs.Consumes("application/json")
@jakarta.ws.rs.Path("/message-board-sections/batch")
@jakarta.ws.rs.Produces("application/json")
@jakarta.ws.rs.PUT
@Override
public Response putMessageBoardSectionBatch(
@io.swagger.v3.oas.annotations.Parameter(hidden = true)
@jakarta.ws.rs.QueryParam("callbackURL")
String callbackURL,
Object object)
throws Exception {
vulcanBatchEngineImportTaskResource.setContextAcceptLanguage(
contextAcceptLanguage);
vulcanBatchEngineImportTaskResource.setContextCompany(contextCompany);
vulcanBatchEngineImportTaskResource.setContextHttpServletRequest(
contextHttpServletRequest);
vulcanBatchEngineImportTaskResource.setContextUriInfo(contextUriInfo);
vulcanBatchEngineImportTaskResource.setContextUser(contextUser);
Response.ResponseBuilder responseBuilder = Response.accepted();
return responseBuilder.entity(
vulcanBatchEngineImportTaskResource.putImportTask(
MessageBoardSection.class.getName(), callbackURL, object)
).build();
}
/**
* Invoke this method with the command line:
*
* curl -X 'PUT' 'http://localhost:8080/o/headless-delivery/v1.0/message-board-sections/{messageBoardSectionId}/permissions' -u '[email protected]:test'
*/
@io.swagger.v3.oas.annotations.Parameters(
value = {
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.PATH,
name = "messageBoardSectionId"
)
}
)
@io.swagger.v3.oas.annotations.tags.Tags(
value = {
@io.swagger.v3.oas.annotations.tags.Tag(
name = "MessageBoardSection"
)
}
)
@jakarta.ws.rs.Consumes({"application/json", "application/xml"})
@jakarta.ws.rs.Path(
"/message-board-sections/{messageBoardSectionId}/permissions"
)
@jakarta.ws.rs.Produces({"application/json", "application/xml"})
@jakarta.ws.rs.PUT
@Override
public Page putMessageBoardSectionPermissionsPage(
@io.swagger.v3.oas.annotations.Parameter(hidden = true)
@jakarta.validation.constraints.NotNull
@jakarta.ws.rs.PathParam("messageBoardSectionId")
Long messageBoardSectionId,
Permission[] permissions)
throws Exception {
String resourceName = getPermissionCheckerResourceName(
messageBoardSectionId);
Long resourceId = getPermissionCheckerResourceId(messageBoardSectionId);
PermissionServiceUtil.checkPermission(
getPermissionCheckerGroupId(messageBoardSectionId), resourceName,
resourceId);
ModelPermissions modelPermissions =
ModelPermissionsUtil.toModelPermissions(
contextCompany.getCompanyId(), permissions, resourceId,
resourceName, resourceActionLocalService,
resourcePermissionLocalService, roleLocalService);
Collection roleNames = modelPermissions.getRoleNames();
for (ResourcePermission resourcePermission :
resourcePermissionLocalService.getResourcePermissions(
contextCompany.getCompanyId(), resourceName,
ResourceConstants.SCOPE_INDIVIDUAL,
String.valueOf(resourceId))) {
com.liferay.portal.kernel.model.Role role =
roleLocalService.fetchRole(resourcePermission.getRoleId());
if ((role == null) || roleNames.contains(role.getName())) {
continue;
}
for (ResourceAction resourceAction :
resourceActionLocalService.getResourceActions(
resourceName)) {
resourcePermissionLocalService.removeResourcePermission(
contextCompany.getCompanyId(), resourceName,
ResourceConstants.SCOPE_INDIVIDUAL,
String.valueOf(resourceId), role.getRoleId(),
resourceAction.getActionId());
}
}
resourcePermissionLocalService.updateResourcePermissions(
contextCompany.getCompanyId(),
getPermissionCheckerGroupId(messageBoardSectionId), resourceName,
String.valueOf(resourceId), modelPermissions);
return toPermissionPage(
HashMapBuilder.put(
"get",
addAction(
ActionKeys.PERMISSIONS,
"getMessageBoardSectionPermissionsPage", resourceName,
resourceId)
).put(
"replace",
addAction(
ActionKeys.PERMISSIONS,
"putMessageBoardSectionPermissionsPage", resourceName,
resourceId)
).build(),
resourceId, resourceName, null);
}
/**
* Invoke this method with the command line:
*
* curl -X 'PUT' 'http://localhost:8080/o/headless-delivery/v1.0/message-board-sections/{messageBoardSectionId}/subscribe' -u '[email protected]:test'
*/
@io.swagger.v3.oas.annotations.Parameters(
value = {
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.PATH,
name = "messageBoardSectionId"
)
}
)
@io.swagger.v3.oas.annotations.tags.Tags(
value = {
@io.swagger.v3.oas.annotations.tags.Tag(
name = "MessageBoardSection"
)
}
)
@jakarta.ws.rs.Path(
"/message-board-sections/{messageBoardSectionId}/subscribe"
)
@jakarta.ws.rs.Produces({"application/json", "application/xml"})
@jakarta.ws.rs.PUT
@Override
public void putMessageBoardSectionSubscribe(
@io.swagger.v3.oas.annotations.Parameter(hidden = true)
@jakarta.validation.constraints.NotNull
@jakarta.ws.rs.PathParam("messageBoardSectionId")
Long messageBoardSectionId)
throws Exception {
}
/**
* Invoke this method with the command line:
*
* curl -X 'PUT' 'http://localhost:8080/o/headless-delivery/v1.0/message-board-sections/{messageBoardSectionId}/unsubscribe' -u '[email protected]:test'
*/
@io.swagger.v3.oas.annotations.Parameters(
value = {
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.PATH,
name = "messageBoardSectionId"
)
}
)
@io.swagger.v3.oas.annotations.tags.Tags(
value = {
@io.swagger.v3.oas.annotations.tags.Tag(
name = "MessageBoardSection"
)
}
)
@jakarta.ws.rs.Path(
"/message-board-sections/{messageBoardSectionId}/unsubscribe"
)
@jakarta.ws.rs.Produces({"application/json", "application/xml"})
@jakarta.ws.rs.PUT
@Override
public void putMessageBoardSectionUnsubscribe(
@io.swagger.v3.oas.annotations.Parameter(hidden = true)
@jakarta.validation.constraints.NotNull
@jakarta.ws.rs.PathParam("messageBoardSectionId")
Long messageBoardSectionId)
throws Exception {
}
/**
* Invoke this method with the command line:
*
* curl -X 'PUT' 'http://localhost:8080/o/headless-delivery/v1.0/sites/{siteId}/message-board-sections/permissions' -u '[email protected]:test'
*/
@io.swagger.v3.oas.annotations.Parameters(
value = {
@io.swagger.v3.oas.annotations.Parameter(
in = io.swagger.v3.oas.annotations.enums.ParameterIn.PATH,
name = "siteId"
)
}
)
@io.swagger.v3.oas.annotations.tags.Tags(
value = {
@io.swagger.v3.oas.annotations.tags.Tag(
name = "MessageBoardSection"
)
}
)
@jakarta.ws.rs.Consumes({"application/json", "application/xml"})
@jakarta.ws.rs.Path("/sites/{siteId}/message-board-sections/permissions")
@jakarta.ws.rs.Produces({"application/json", "application/xml"})
@jakarta.ws.rs.PUT
@Override
public Page putSiteMessageBoardSectionPermissionsPage(
@io.swagger.v3.oas.annotations.Parameter(hidden = true)
@jakarta.validation.constraints.NotNull
@jakarta.ws.rs.PathParam("siteId")
Long siteId,
Permission[] permissions)
throws Exception {
String portletName = getPermissionCheckerPortletName(siteId);
PermissionServiceUtil.checkPermission(siteId, portletName, siteId);
ModelPermissions modelPermissions =
ModelPermissionsUtil.toModelPermissions(
contextCompany.getCompanyId(), permissions, siteId, portletName,
resourceActionLocalService, resourcePermissionLocalService,
roleLocalService);
Collection roleNames = modelPermissions.getRoleNames();
for (ResourcePermission resourcePermission :
resourcePermissionLocalService.getResourcePermissions(
contextCompany.getCompanyId(), portletName,
ResourceConstants.SCOPE_INDIVIDUAL,
String.valueOf(siteId))) {
com.liferay.portal.kernel.model.Role role =
roleLocalService.fetchRole(resourcePermission.getRoleId());
if ((role == null) || roleNames.contains(role.getName())) {
continue;
}
for (ResourceAction resourceAction :
resourceActionLocalService.getResourceActions(
portletName)) {
resourcePermissionLocalService.removeResourcePermission(
contextCompany.getCompanyId(), portletName,
ResourceConstants.SCOPE_INDIVIDUAL, String.valueOf(siteId),
role.getRoleId(), resourceAction.getActionId());
}
}
resourcePermissionLocalService.updateResourcePermissions(
contextCompany.getCompanyId(), siteId, portletName,
String.valueOf(siteId), modelPermissions);
return toPermissionPage(
HashMapBuilder.put(
"get",
addAction(
ActionKeys.PERMISSIONS,
"getSiteMessageBoardSectionPermissionsPage", portletName,
siteId)
).put(
"replace",
addAction(
ActionKeys.PERMISSIONS,
"putSiteMessageBoardSectionPermissionsPage", portletName,
siteId)
).build(),
siteId, portletName, null);
}
@Override
@SuppressWarnings("PMD.UnusedLocalVariable")
public void create(
Collection messageBoardSections,
Map parameters)
throws Exception {
UnsafeFunction
messageBoardSectionUnsafeFunction = null;
String createStrategy = (String)parameters.getOrDefault(
"createStrategy", "INSERT");
if (StringUtil.equalsIgnoreCase(createStrategy, "INSERT")) {
if (parameters.containsKey("siteId")) {
messageBoardSectionUnsafeFunction =
messageBoardSection -> postSiteMessageBoardSection(
(Long)parameters.get("siteId"), messageBoardSection);
}
else {
throw new NotSupportedException(
"One of the following parameters must be specified: [siteId]");
}
}
if (messageBoardSectionUnsafeFunction == null) {
throw new NotSupportedException(
"Create strategy \"" + createStrategy +
"\" is not supported for MessageBoardSection");
}
if (contextBatchUnsafeBiConsumer != null) {
contextBatchUnsafeBiConsumer.accept(
messageBoardSections, messageBoardSectionUnsafeFunction);
}
else if (contextBatchUnsafeConsumer != null) {
contextBatchUnsafeConsumer.accept(
messageBoardSections, messageBoardSectionUnsafeFunction::apply);
}
else {
for (MessageBoardSection messageBoardSection :
messageBoardSections) {
messageBoardSectionUnsafeFunction.apply(messageBoardSection);
}
}
}
@Override
public void delete(
Collection messageBoardSections,
Map parameters)
throws Exception {
UnsafeFunction
messageBoardSectionUnsafeFunction = messageBoardSection -> {
deleteMessageBoardSection(messageBoardSection.getId());
return messageBoardSection;
};
if (contextBatchUnsafeBiConsumer != null) {
contextBatchUnsafeBiConsumer.accept(
messageBoardSections, messageBoardSectionUnsafeFunction);
}
else if (contextBatchUnsafeConsumer != null) {
contextBatchUnsafeConsumer.accept(
messageBoardSections, messageBoardSectionUnsafeFunction::apply);
}
else {
for (MessageBoardSection messageBoardSection :
messageBoardSections) {
messageBoardSectionUnsafeFunction.apply(messageBoardSection);
}
}
}
public Set getAvailableCreateStrategies() {
return SetUtil.fromArray("INSERT");
}
public Set getAvailableUpdateStrategies() {
return SetUtil.fromArray("PARTIAL_UPDATE", "UPDATE");
}
@Override
public EntityModel getEntityModel(Map> multivaluedMap)
throws Exception {
return getEntityModel(
new MultivaluedHashMap(multivaluedMap));
}
@Override
public EntityModel getEntityModel(MultivaluedMap multivaluedMap)
throws Exception {
return null;
}
public String getResourceName() {
return "MessageBoardSection";
}
public String getVersion() {
return "v1.0";
}
@Override
public Page read(
com.liferay.portal.kernel.search.filter.Filter filter,
Pagination pagination,
com.liferay.portal.kernel.search.Sort[] sorts,
Map parameters, String search)
throws Exception {
if (parameters.containsKey("siteId")) {
return getSiteMessageBoardSectionsPage(
(Long)parameters.get("siteId"),
_parseBoolean((String)parameters.get("flatten")), search, null,
filter, pagination, sorts);
}
else {
throw new NotSupportedException(
"One of the following parameters must be specified: [siteId]");
}
}
@Override
public void setLanguageId(String languageId) {
this.contextAcceptLanguage = new AcceptLanguage() {
@Override
public List getLocales() {
return null;
}
@Override
public String getPreferredLanguageId() {
return languageId;
}
@Override
public Locale getPreferredLocale() {
return LocaleUtil.fromLanguageId(languageId);
}
};
}
@Override
public void update(
Collection messageBoardSections,
Map parameters)
throws Exception {
UnsafeFunction
messageBoardSectionUnsafeFunction = null;
String updateStrategy = (String)parameters.getOrDefault(
"updateStrategy", "UPDATE");
if (StringUtil.equalsIgnoreCase(updateStrategy, "PARTIAL_UPDATE")) {
messageBoardSectionUnsafeFunction =
messageBoardSection -> patchMessageBoardSection(
messageBoardSection.getId(), messageBoardSection);
}
if (StringUtil.equalsIgnoreCase(updateStrategy, "UPDATE")) {
messageBoardSectionUnsafeFunction =
messageBoardSection -> putMessageBoardSection(
messageBoardSection.getId(), messageBoardSection);
}
if (messageBoardSectionUnsafeFunction == null) {
throw new NotSupportedException(
"Update strategy \"" + updateStrategy +
"\" is not supported for MessageBoardSection");
}
if (contextBatchUnsafeBiConsumer != null) {
contextBatchUnsafeBiConsumer.accept(
messageBoardSections, messageBoardSectionUnsafeFunction);
}
else if (contextBatchUnsafeConsumer != null) {
contextBatchUnsafeConsumer.accept(
messageBoardSections, messageBoardSectionUnsafeFunction::apply);
}
else {
for (MessageBoardSection messageBoardSection :
messageBoardSections) {
messageBoardSectionUnsafeFunction.apply(messageBoardSection);
}
}
}
private Boolean _parseBoolean(String value) {
if (value != null) {
return Boolean.parseBoolean(value);
}
return null;
}
@Override
public MessageBoardSection getItem(Long id) throws Exception {
return getMessageBoardSection(id);
}
protected String getPermissionCheckerActionsResourceName(Object id)
throws Exception {
return getPermissionCheckerResourceName(id);
}
protected Long getPermissionCheckerGroupId(Object id) throws Exception {
throw new UnsupportedOperationException(
"This method needs to be implemented");
}
protected String getPermissionCheckerPortletName(Object id)
throws Exception {
throw new UnsupportedOperationException(
"This method needs to be implemented");
}
protected Long getPermissionCheckerResourceId(Object id) throws Exception {
return GetterUtil.getLong(id);
}
protected String getPermissionCheckerResourceName(Object id)
throws Exception {
throw new UnsupportedOperationException(
"This method needs to be implemented");
}
protected Page toPermissionPage(
Map> actions, long id,
String resourceName, String roleNames)
throws Exception {
List resourceActions =
resourceActionLocalService.getResourceActions(resourceName);
if (Validator.isNotNull(roleNames)) {
return Page.of(
actions,
_getPermissions(
contextCompany.getCompanyId(), resourceActions, id,
resourceName, StringUtil.split(roleNames)));
}
return Page.of(
actions,
_getPermissions(
contextCompany.getCompanyId(), resourceActions, id,
resourceName, null));
}
/**
* @see com.liferay.portal.vulcan.permission.PermissionUtil#getPermissions(long, List, long, String, String[])
*/
private Collection _getPermissions(
long companyId, List resourceActions,
long resourceId, String resourceName, String[] roleNames)
throws Exception {
Map permissions = new HashMap<>();
int count = resourcePermissionLocalService.getResourcePermissionsCount(
companyId, resourceName, ResourceConstants.SCOPE_INDIVIDUAL,
String.valueOf(resourceId));
if (count == 0) {
ResourceLocalServiceUtil.addResources(
companyId, resourceId, 0, resourceName,
String.valueOf(resourceId), false, true, true);
}
List actionIds = transform(
resourceActions, resourceAction -> resourceAction.getActionId());
Set resourcePermissions = new HashSet<>();
resourcePermissions.addAll(
resourcePermissionLocalService.getResourcePermissions(
companyId, resourceName, ResourceConstants.SCOPE_COMPANY,
String.valueOf(companyId)));
resourcePermissions.addAll(
resourcePermissionLocalService.getResourcePermissions(
companyId, resourceName, ResourceConstants.SCOPE_GROUP,
String.valueOf(GroupThreadLocal.getGroupId())));
resourcePermissions.addAll(
resourcePermissionLocalService.getResourcePermissions(
companyId, resourceName, ResourceConstants.SCOPE_GROUP_TEMPLATE,
"0"));
resourcePermissions.addAll(
resourcePermissionLocalService.getResourcePermissions(
companyId, resourceName, ResourceConstants.SCOPE_INDIVIDUAL,
String.valueOf(resourceId)));
List resources = transform(
resourcePermissions,
resourcePermission -> ResourceLocalServiceUtil.getResource(
resourcePermission.getCompanyId(), resourcePermission.getName(),
resourcePermission.getScope(),
resourcePermission.getPrimKey()));
Set roles = new HashSet<>();
if (roleNames != null) {
for (String roleName : roleNames) {
roles.add(roleLocalService.getRole(companyId, roleName));
}
}
else {
for (ResourcePermission resourcePermission : resourcePermissions) {
com.liferay.portal.kernel.model.Role role =
roleLocalService.getRole(resourcePermission.getRoleId());
roles.add(role);
}
}
for (com.liferay.portal.kernel.model.Role role : roles) {
Set actionsIdsSet = new HashSet<>();
for (Resource resource : resources) {
actionsIdsSet.addAll(
resourcePermissionLocalService.
getAvailableResourcePermissionActionIds(
resource.getCompanyId(), resource.getName(),
ResourceConstants.SCOPE_COMPANY,
String.valueOf(resource.getCompanyId()),
role.getRoleId(), actionIds));
actionsIdsSet.addAll(
resourcePermissionLocalService.
getAvailableResourcePermissionActionIds(
resource.getCompanyId(), resource.getName(),
ResourceConstants.SCOPE_GROUP,
String.valueOf(GroupThreadLocal.getGroupId()),
role.getRoleId(), actionIds));
actionsIdsSet.addAll(
resourcePermissionLocalService.
getAvailableResourcePermissionActionIds(
resource.getCompanyId(), resource.getName(),
ResourceConstants.SCOPE_GROUP_TEMPLATE, "0",
role.getRoleId(), actionIds));
actionsIdsSet.addAll(
resourcePermissionLocalService.
getAvailableResourcePermissionActionIds(
resource.getCompanyId(), resource.getName(),
resource.getScope(), resource.getPrimKey(),
role.getRoleId(), actionIds));
}
if (actionsIdsSet.isEmpty()) {
continue;
}
Permission permission = new Permission() {
{
actionIds = actionsIdsSet.toArray(new String[0]);
roleName = role.getName();
}
};
permissions.put(role.getName(), permission);
}
return permissions.values();
}
public void setContextAcceptLanguage(AcceptLanguage contextAcceptLanguage) {
this.contextAcceptLanguage = contextAcceptLanguage;
}
public void setContextBatchUnsafeBiConsumer(
UnsafeBiConsumer
,
UnsafeFunction
,
Exception> contextBatchUnsafeBiConsumer) {
this.contextBatchUnsafeBiConsumer = contextBatchUnsafeBiConsumer;
}
public void setContextBatchUnsafeConsumer(
UnsafeBiConsumer
,
UnsafeConsumer, Exception>
contextBatchUnsafeConsumer) {
this.contextBatchUnsafeConsumer = contextBatchUnsafeConsumer;
}
public void setContextCompany(
com.liferay.portal.kernel.model.Company contextCompany) {
this.contextCompany = contextCompany;
}
public void setContextHttpServletRequest(
HttpServletRequest contextHttpServletRequest) {
this.contextHttpServletRequest = contextHttpServletRequest;
}
public void setContextHttpServletResponse(
HttpServletResponse contextHttpServletResponse) {
this.contextHttpServletResponse = contextHttpServletResponse;
}
public void setContextUriInfo(UriInfo contextUriInfo) {
this.contextUriInfo = UriInfoUtil.getVulcanUriInfo(
getApplicationPath(), contextUriInfo);
}
public void setContextUser(
com.liferay.portal.kernel.model.User contextUser) {
this.contextUser = contextUser;
}
public void setExpressionConvert(
ExpressionConvert
expressionConvert) {
this.expressionConvert = expressionConvert;
}
public void setFilterParserProvider(
FilterParserProvider filterParserProvider) {
this.filterParserProvider = filterParserProvider;
}
public void setGroupLocalService(GroupLocalService groupLocalService) {
this.groupLocalService = groupLocalService;
}
public void setResourceActionLocalService(
ResourceActionLocalService resourceActionLocalService) {
this.resourceActionLocalService = resourceActionLocalService;
}
public void setResourcePermissionLocalService(
ResourcePermissionLocalService resourcePermissionLocalService) {
this.resourcePermissionLocalService = resourcePermissionLocalService;
}
public void setRoleLocalService(RoleLocalService roleLocalService) {
this.roleLocalService = roleLocalService;
}
public void setSortParserProvider(SortParserProvider sortParserProvider) {
this.sortParserProvider = sortParserProvider;
}
protected String getApplicationPath() {
return "headless-delivery";
}
public void setVulcanBatchEngineExportTaskResource(
VulcanBatchEngineExportTaskResource
vulcanBatchEngineExportTaskResource) {
this.vulcanBatchEngineExportTaskResource =
vulcanBatchEngineExportTaskResource;
}
public void setVulcanBatchEngineImportTaskResource(
VulcanBatchEngineImportTaskResource
vulcanBatchEngineImportTaskResource) {
this.vulcanBatchEngineImportTaskResource =
vulcanBatchEngineImportTaskResource;
}
@Override
public com.liferay.portal.kernel.search.filter.Filter toFilter(
String filterString, Map> multivaluedMap) {
try {
EntityModel entityModel = getEntityModel(multivaluedMap);
FilterParser filterParser = filterParserProvider.provide(
entityModel);
com.liferay.portal.odata.filter.Filter oDataFilter =
new com.liferay.portal.odata.filter.Filter(
filterParser.parse(filterString));
return expressionConvert.convert(
oDataFilter.getExpression(),
contextAcceptLanguage.getPreferredLocale(), entityModel);
}
catch (Exception exception) {
_log.error("Invalid filter " + filterString, exception);
return null;
}
}
@Override
public com.liferay.portal.kernel.search.Sort[] toSorts(String sortString) {
if (Validator.isNull(sortString)) {
return null;
}
try {
SortParser sortParser = sortParserProvider.provide(
getEntityModel(Collections.emptyMap()));
if (sortParser == null) {
return null;
}
com.liferay.portal.odata.sort.Sort oDataSort =
new com.liferay.portal.odata.sort.Sort(
sortParser.parse(sortString));
List sortFields = oDataSort.getSortFields();
com.liferay.portal.kernel.search.Sort[] sorts =
new com.liferay.portal.kernel.search.Sort[sortFields.size()];
for (int i = 0; i < sortFields.size(); i++) {
SortField sortField = sortFields.get(i);
sorts[i] = new com.liferay.portal.kernel.search.Sort(
sortField.getSortableFieldName(
contextAcceptLanguage.getPreferredLocale()),
!sortField.isAscending());
}
return sorts;
}
catch (Exception exception) {
_log.error("Invalid sort " + sortString, exception);
return new com.liferay.portal.kernel.search.Sort[0];
}
}
protected Map addAction(
String actionName,
com.liferay.portal.kernel.model.GroupedModel groupedModel,
String methodName) {
return ActionUtil.addAction(
actionName, getClass(), groupedModel, methodName,
contextScopeChecker, contextUriInfo);
}
protected Map addAction(
String actionName, Long id, String methodName, Long ownerId,
String permissionName, Long siteId) {
return ActionUtil.addAction(
actionName, getClass(), id, methodName, contextScopeChecker,
ownerId, permissionName, siteId, contextUriInfo);
}
protected Map addAction(
String actionName, Long id, String methodName,
ModelResourcePermission modelResourcePermission) {
return ActionUtil.addAction(
actionName, getClass(), id, methodName, contextScopeChecker,
modelResourcePermission, contextUriInfo);
}
protected Map addAction(
String actionName, String methodName, String permissionName,
Long siteId) {
return addAction(
actionName, siteId, methodName, null, permissionName, siteId);
}
protected void preparePatch(
MessageBoardSection messageBoardSection,
MessageBoardSection existingMessageBoardSection) {
}
protected List transform(
Collection collection, UnsafeFunction unsafeFunction) {
return TransformUtil.transform(collection, unsafeFunction);
}
protected R[] transform(
T[] array, UnsafeFunction unsafeFunction,
Class extends R> clazz) {
return TransformUtil.transform(array, unsafeFunction, clazz);
}
protected R[] transformToArray(
Collection collection, UnsafeFunction unsafeFunction,
Class extends R> clazz) {
return TransformUtil.transformToArray(
collection, unsafeFunction, clazz);
}
protected List transformToList(
T[] array, UnsafeFunction unsafeFunction) {
return TransformUtil.transformToList(array, unsafeFunction);
}
protected long[] transformToLongArray(
Collection collection, UnsafeFunction unsafeFunction) {
return TransformUtil.transformToLongArray(collection, unsafeFunction);
}
protected List unsafeTransform(
Collection collection, UnsafeFunction unsafeFunction)
throws E {
return TransformUtil.unsafeTransform(collection, unsafeFunction);
}
protected R[] unsafeTransform(
T[] array, UnsafeFunction unsafeFunction,
Class extends R> clazz)
throws E {
return TransformUtil.unsafeTransform(array, unsafeFunction, clazz);
}
protected R[] unsafeTransformToArray(
Collection collection, UnsafeFunction unsafeFunction,
Class extends R> clazz)
throws E {
return TransformUtil.unsafeTransformToArray(
collection, unsafeFunction, clazz);
}
protected List unsafeTransformToList(
T[] array, UnsafeFunction unsafeFunction)
throws E {
return TransformUtil.unsafeTransformToList(array, unsafeFunction);
}
protected long[] unsafeTransformToLongArray(
Collection collection, UnsafeFunction unsafeFunction)
throws E {
return TransformUtil.unsafeTransformToLongArray(
collection, unsafeFunction);
}
protected AcceptLanguage contextAcceptLanguage;
protected UnsafeBiConsumer
,
UnsafeFunction,
Exception> contextBatchUnsafeBiConsumer;
protected UnsafeBiConsumer
,
UnsafeConsumer, Exception>
contextBatchUnsafeConsumer;
protected com.liferay.portal.kernel.model.Company contextCompany;
protected HttpServletRequest contextHttpServletRequest;
protected HttpServletResponse contextHttpServletResponse;
protected Object contextScopeChecker;
protected UriInfo contextUriInfo;
protected com.liferay.portal.kernel.model.User contextUser;
protected ExpressionConvert
expressionConvert;
protected FilterParserProvider filterParserProvider;
protected GroupLocalService groupLocalService;
protected ResourceActionLocalService resourceActionLocalService;
protected ResourcePermissionLocalService resourcePermissionLocalService;
protected RoleLocalService roleLocalService;
protected SortParserProvider sortParserProvider;
protected VulcanBatchEngineExportTaskResource
vulcanBatchEngineExportTaskResource;
protected VulcanBatchEngineImportTaskResource
vulcanBatchEngineImportTaskResource;
private static final com.liferay.portal.kernel.log.Log _log =
LogFactoryUtil.getLog(BaseMessageBoardSectionResourceImpl.class);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy