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

fix(core): Workflow Action Endpoint does not return the contentlet metadata #28338 #28369

Merged
merged 8 commits into from
May 10, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
import com.dotmarketing.portlets.contentlet.model.ContentletDependencies;
import com.dotmarketing.portlets.contentlet.model.IndexPolicy;
import com.dotmarketing.portlets.contentlet.model.IndexPolicyProvider;
import com.dotmarketing.portlets.contentlet.transform.DotTransformerBuilder;
import com.dotmarketing.portlets.structure.model.ContentletRelationships;
import com.dotmarketing.portlets.workflows.actionlet.WorkFlowActionlet;
import com.dotmarketing.portlets.workflows.business.WorkflowAPI;
Expand Down Expand Up @@ -142,6 +143,7 @@
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.CompletionService;
Expand Down Expand Up @@ -1613,15 +1615,14 @@ private Response fireAction(final HttpServletRequest request,

//Empty collection implies removal, so only when a value is present we must pass the collection
categories.ifPresent(formBuilder::categories);

final Contentlet basicContentlet = fireCommandOpt.isPresent()?
fireCommandOpt.get().fire(contentlet, this.needSave(fireActionForm), formBuilder.build()):
this.workflowAPI.fireContentWorkflow(contentlet, formBuilder.build());
final Contentlet hydratedContentlet = Objects.nonNull(basicContentlet)?
new DotTransformerBuilder().contentResourceOptions(false)
.content(basicContentlet).build().hydrate().get(0): basicContentlet;
return Response.ok(
new ResponseEntityView(
this.workflowHelper.contentletToMap(
fireCommandOpt.isPresent()?
fireCommandOpt.get().fire(contentlet,
this.needSave(fireActionForm), formBuilder.build()):
this.workflowAPI.fireContentWorkflow(contentlet, formBuilder.build()))
)
new ResponseEntityView<>(this.workflowHelper.contentletToMap(hydratedContentlet))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ghetto - why is this done in the workflowHelper and not the DotTransformer? Seems like we need this information in every response, no?

).build(); // 200
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.EnumSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -132,7 +133,9 @@ public List<Contentlet> hydrate() {
*/
private Contentlet copy(final Contentlet contentlet) {
final Contentlet newContentlet = new Contentlet();
newContentlet.getMap().putAll(Try.of(contentlet::getMap).getOrElse(Map.of()));
if (Objects.nonNull(contentlet)) {
newContentlet.getMap().putAll(Try.of(contentlet::getMap).getOrElse(Map.of()));
}
return newContentlet;
}

Expand Down