Skip to content
Open
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.dotcms.rest.api.v1.workflow;

import com.dotmarketing.portlets.workflows.model.WorkflowScheme;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List;
import org.immutables.value.Value;

@Value.Style(typeImmutable = "*", typeAbstract = "Abstract*")
@Value.Immutable
@JsonSerialize(as = ContentTypeWorkflowSchemesView.class)
@JsonDeserialize(as = ContentTypeWorkflowSchemesView.class)
@Schema(description = "Workflow schemes associated with a specific content type")
public interface AbstractContentTypeWorkflowSchemesView {

@JsonProperty("contentTypeId")
@Schema(
description = "Identifier of the content type",
requiredMode = Schema.RequiredMode.REQUIRED
)
String contentTypeId();

@JsonProperty("contentTypeSchemes")
@Schema(
description = "Workflow schemes associated with the content type",
requiredMode = Schema.RequiredMode.REQUIRED
)
List<WorkflowScheme> contentTypeSchemes();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.dotcms.rest.api.v1.workflow;

import com.dotcms.rest.ResponseEntityView;
import java.util.List;

public class ResponseEntityContentTypeWorkflowSchemesView extends
Comment thread
dario-daza marked this conversation as resolved.
ResponseEntityView<List<ContentTypeWorkflowSchemesView>> {

public ResponseEntityContentTypeWorkflowSchemesView(
final List<ContentTypeWorkflowSchemesView> contentTypeWorkflowSchemesView) {
super(contentTypeWorkflowSchemesView);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,77 @@ public final Response findAllSchemesAndSchemesByContentType(
}
} // findAllSchemesAndSchemesByContentType.

/**
* Returns workflow schemes grouped by content type for a list of content type identifiers.
* Returns 401 if the user does not have the required backend permissions.
*
* @param request {@link HttpServletRequest}
* @param response {@link HttpServletResponse}
* @param contentTypeIds comma-separated list of content type identifiers to look up
* @return {@link Response} containing a list of {@link ContentTypeWorkflowSchemesView},
* one entry per content type
*/
@GET
@Path("/content-types/schemes")
Comment thread
dario-daza marked this conversation as resolved.
Outdated
@JSONP
@NoCache
@Produces(MediaType.APPLICATION_JSON)
@Operation(operationId = "getWorkflowSchemesByContentTypeList",
summary = "Find workflow schemes for multiple content types",
description = "Returns workflow [schemes](https://www.dotcms.com/docs/latest/managing-workflows#Schemes) " +
"grouped by content type for a comma-separated list of content type identifiers. " +
"Each entry in the response maps a content type to its associated schemes.",
tags = {"Workflow"},
responses = {
@ApiResponse(responseCode = "200", description = "Schemes returned successfully",
content = @Content(mediaType = "application/json",
schema = @Schema(implementation = ResponseEntityContentTypeWorkflowSchemesView.class)
)
),
@ApiResponse(responseCode = "401", description = "User does not have permission")
Comment thread
dario-daza marked this conversation as resolved.
}
)
public final Response findAllSchemesByContentTypeList(
@Context final HttpServletRequest request,
@Context final HttpServletResponse response,
@QueryParam("contentTypeIds") @Parameter(
description = "Comma-separated list of content type identifiers, e.g. id1,id2,id3"
) final String contentTypeIds) {

final User user = new WebResource.InitBuilder(webResource)
.requiredBackendUser(true)
.requiredFrontendUser(false)
.requestAndResponse(request, response)
.rejectWhenNoUser(true)
.init()
.getUser();

try {

Logger.debug(this, "Getting the workflow schemes by content type list");

final List<ContentTypeWorkflowSchemesView> result = Arrays.stream(
UtilMethods.isSet(contentTypeIds) ? contentTypeIds.split(",") : new String[0])
.map(String::trim)
.filter(UtilMethods::isSet)
.map(contentTypeId -> ContentTypeWorkflowSchemesView.builder()
.contentTypeId(contentTypeId)
.contentTypeSchemes(this.workflowHelper.findSchemesByContentType(
contentTypeId, user))
Comment thread
dario-daza marked this conversation as resolved.
Outdated
.build())
.collect(Collectors.toList());

return Response.ok(new ResponseEntityContentTypeWorkflowSchemesView(result)).build();

} catch (Exception e) {

Logger.error(this.getClass(),
"Exception on findAllSchemesByContentTypeList: " + e.getMessage(), e);
return ResponseUtil.mapExceptionResponse(e);

}
} // findAllSchemesByContentTypeList.

/**
* Return Steps associated to the scheme, 404 if does not exists. 401 if the user does not have permission.
* @param request HttpServletRequest
Expand Down Expand Up @@ -3172,7 +3243,7 @@ public final Response fireActionDefaultSinglePart(@Context final HttpServletRequ
.requestAndResponse(request, response)
.requiredAnonAccess(AnonymousAccess.WRITE)
.init();

try {

Logger.debug(this, ()-> "On Fire Action: systemAction = " + systemAction + ", inode = " + inode +
Expand Down Expand Up @@ -4912,7 +4983,7 @@ private Contentlet populateContentlet(final FireActionForm fireActionForm, final
if(constant instanceof ConstantField)
contentlet.getMap().put(constant.variable(), constant.values());
}

return contentlet;
} // populateContentlet.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package com.dotmarketing.portlets.templates.design.bean;

import com.dotcms.rest.api.v1.workflow.SchemesAndSchemesContentTypeView;
import com.dotmarketing.business.APILocator;
import com.dotmarketing.exception.DotDataException;
import com.dotmarketing.exception.DotSecurityException;
Expand Down
88 changes: 88 additions & 0 deletions dotCMS/src/main/webapp/WEB-INF/openapi/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19155,6 +19155,36 @@ paths:
summary: Fire action by ID (multipart form)
tags:
- Workflow
/v1/workflow/content-types/schemes:
get:
description: "Returns workflow [schemes](https://www.dotcms.com/docs/latest/managing-workflows#Schemes)\
\ grouped by content type for a comma-separated list of content type identifiers.\
\ Each entry in the response maps a content type to its associated schemes."
operationId: getWorkflowSchemesByContentTypeList
parameters:
- description: "Comma-separated list of content type identifiers, e.g. id1,id2,id3"
in: query
name: contentTypeIds
schema:
type: string
responses:
"200":
content:
application/json:
schema:
$ref: "#/components/schemas/ResponseEntityContentTypeWorkflowSchemesView"
description: Schemes returned successfully
"401":
description: User does not have permission
"403":
description: Forbidden
"406":
description: Not Acceptable
"500":
description: Internal Server Error
summary: Find workflow schemes for multiple content types
tags:
- Workflow
/v1/workflow/contentlet/actions/_bulkfire:
post:
description: |-
Expand Down Expand Up @@ -24632,6 +24662,27 @@ components:
type: string
variable:
type: string
ContentTypeWorkflowSchemesView:
type: object
properties:
contentTypeId:
type: string
description: Identifier of the content type
contentTypeSchemes:
type: array
description: Workflow schemes associated with the content type
items:
$ref: "#/components/schemas/WorkflowScheme"
properties:
empty:
type: boolean
first:
$ref: "#/components/schemas/WorkflowScheme"
last:
$ref: "#/components/schemas/WorkflowScheme"
required:
- contentTypeId
- contentTypeSchemes
ContentView:
type: object
properties:
Expand Down Expand Up @@ -27603,6 +27654,18 @@ components:
$ref: "#/components/schemas/VariantResult"
last:
$ref: "#/components/schemas/VariantResult"
ImmutableListWorkflowScheme:
type: array
description: Workflow schemes associated with the content type
items:
$ref: "#/components/schemas/WorkflowScheme"
properties:
empty:
type: boolean
first:
$ref: "#/components/schemas/WorkflowScheme"
last:
$ref: "#/components/schemas/WorkflowScheme"
ImmutableMapDoubleQuantilePair:
type: object
additionalProperties:
Expand Down Expand Up @@ -30239,6 +30302,31 @@ components:
type: array
items:
type: string
ResponseEntityContentTypeWorkflowSchemesView:
type: object
properties:
entity:
type: array
items:
$ref: "#/components/schemas/ContentTypeWorkflowSchemesView"
errors:
type: array
items:
$ref: "#/components/schemas/ErrorEntity"
i18nMessagesMap:
type: object
additionalProperties:
type: string
messages:
type: array
items:
$ref: "#/components/schemas/MessageEntity"
pagination:
$ref: "#/components/schemas/Pagination"
permissions:
type: array
items:
type: string
ResponseEntityContentView:
type: object
properties:
Expand Down
Loading
Loading