Skip to content

Commit

Permalink
fix(osgi) force load OSGIActionletService when trying to register act…
Browse files Browse the repository at this point in the history
…ionlets via plugin

ref: #30291
  • Loading branch information
wezell committed Oct 8, 2024
1 parent 89df267 commit add1952
Showing 1 changed file with 46 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2375,49 +2375,55 @@ public WorkflowProcessor fireWorkflowPreCheckin(final Contentlet contentlet, fin
return fireWorkflowPreCheckin(contentlet, user, null);
}

private WorkflowProcessor fireWorkflowPreCheckin(final Contentlet contentlet, final User user, final ConcurrentMap<String,Object> context) throws DotDataException, DotWorkflowException, DotContentletValidationException {
WorkflowProcessor processor = new WorkflowProcessor(contentlet, user, context);
if (!processor.inProcess()) {
return processor;
}

List<WorkflowActionClass> actionClasses = processor.getActionClasses();
boolean isPublish = actionClasses.stream()
.anyMatch(wac -> wac.getClazz().equals(PublishContentActionlet.class.getName()));
contentlet.setProperty(Contentlet.TO_BE_PUBLISH, isPublish);

for (WorkflowActionClass actionClass : actionClasses) {
WorkFlowActionlet actionlet = actionClass.getActionlet();
if (actionlet != null) {
Map<String, WorkflowActionClassParameter> params = findParamsForActionClass(actionClass);
actionlet.executePreAction(processor, params);
if (actionlet.stopProcessing()) {
break;
}
} else {
handleNullActionlet(actionClass);
}
}
private WorkflowProcessor fireWorkflowPreCheckin(final Contentlet contentlet, final User user,
final ConcurrentMap<String, Object> context)
throws DotDataException, DotWorkflowException, DotContentletValidationException {
WorkflowProcessor processor = new WorkflowProcessor(contentlet, user, context);
if (!processor.inProcess()) {
return processor;
}

List<WorkflowActionClass> actionClasses = processor.getActionClasses();
boolean isPublish = actionClasses.stream()
.anyMatch(wac -> wac.getClazz().equals(PublishContentActionlet.class.getName()));
contentlet.setProperty(Contentlet.TO_BE_PUBLISH, isPublish);

for (WorkflowActionClass actionClass : actionClasses) {
WorkFlowActionlet actionlet = actionClass.getActionlet();
if (actionlet != null) {
Map<String, WorkflowActionClassParameter> params = findParamsForActionClass(actionClass);
actionlet.executePreAction(processor, params);
if (actionlet.stopProcessing()) {
break;
}
} else {
handleNullActionlet(actionClass);
}
}

return processor;
}
return processor;
}

private void handleNullActionlet(WorkflowActionClass actionClass) throws DotWorkflowException {
if (Config.getBooleanProperty("ALLOW_WORKFLOW_ACTIONLET_NULL", true)) {
logWarning(actionClass);
} else {
throw new DotWorkflowException("Actionlet '" + actionClass.getName() + "' is null. Check if the Plugin is installed and running.");
}
}
private void handleNullActionlet(WorkflowActionClass actionClass) throws DotWorkflowException {
if (Config.getBooleanProperty("ALLOW_WORKFLOW_ACTIONLET_NULL", true)) {
logWarning(actionClass);
} else {
throw new DotWorkflowException(
"Actionlet '" + actionClass.getName() + "' is null. Check if the Plugin is installed and running.");
}
}

private void logWarning(WorkflowActionClass actionClass) {
SystemMessageBuilder messageBuilder = new SystemMessageBuilder()
.setMessage("Workflow Actionlet class not found/loaded. Please check your workflow actions and/or providing plugin: " + actionClass)
.setSeverity(MessageSeverity.WARNING)
.setLife(10000);
Try.run(()->APILocator.getSystemEventsAPI().pushAsync(SystemEventType.MESSAGE, new Payload(messageBuilder.create())));
Logger.warn(this, "Actionlet '" + actionClass + "' is null. Will be skipping this actionlet");
}
private void logWarning(WorkflowActionClass actionClass) {
SystemMessageBuilder messageBuilder = new SystemMessageBuilder()
.setMessage(
"Workflow Actionlet class not found/loaded. Please check your workflow actions and/or providing plugin: "
+ actionClass)
.setSeverity(MessageSeverity.WARNING)
.setLife(10000);
Try.run(() -> APILocator.getSystemEventsAPI()
.pushAsync(SystemEventType.MESSAGE, new Payload(messageBuilder.create())));
Logger.warn(this, "Actionlet '" + actionClass + "' is null. Will be skipping this actionlet");
}


@WrapInTransaction
Expand Down

0 comments on commit add1952

Please sign in to comment.