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

Issue 30291 osgi actionlet reinit failure #30292

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Changes from all commits
Commits
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 @@ -140,6 +140,7 @@
import io.vavr.control.Try;
import org.apache.commons.lang.time.StopWatch;
import org.apache.commons.lang3.concurrent.ConcurrentUtils;
import org.apache.felix.framework.OSGIUtil;
import org.elasticsearch.search.query.QueryPhaseExecutionException;
import org.osgi.framework.BundleContext;

Expand Down Expand Up @@ -367,16 +368,23 @@ private FriendClass getFriendClass () {
}

public void registerBundleService () {
if(System.getProperty(WebKeys.OSGI_ENABLED)!=null){
// Register main service
BundleContext context = HostActivator.instance().getBundleContext();
if (null != context) {
Hashtable<String, String> props = new Hashtable<>();
context.registerService(WorkflowAPIOsgiService.class.getName(), this, props);
} else {
Logger.error(this, "Bundle Context is null, WorkflowAPIOsgiService has been not registered");
}

// force init if not already done
OSGIUtil.getInstance().initializeFramework();
if (System.getProperty(WebKeys.OSGI_ENABLED) == null) {
// OSGI is not inited
throw new DotRuntimeException("Unable to register WorkflowAPIOsgiService as OSGI is not inited");
}

BundleContext context = HostActivator.instance().getBundleContext();
if (context == null) {
throw new DotRuntimeException("Bundle Context is null, WorkflowAPIOsgiService has been not registered");
}
if (context.getServiceReference(WorkflowAPIOsgiService.class.getName()) == null) {
Hashtable<String, String> props = new Hashtable<>();
context.registerService(WorkflowAPIOsgiService.class.getName(), this, props);
}

}

/**
Expand Down Expand Up @@ -1690,7 +1698,7 @@ public List<WorkflowAction> findAvailableActionsEditing(final Contentlet content

return this.findAvailableActions(contentlet, user, RenderMode.EDITING);
}

/**
* This method will return the list of workflows actions available to a user on any give
* piece of content, based on how and who has the content locked and what workflow step the content
Expand All @@ -1703,7 +1711,7 @@ public List<WorkflowAction> findAvailableActionsListing(final Contentlet content

return this.findAvailableActions(contentlet, user, RenderMode.LISTING);
}

/**
* This method will return the list of workflows actions available to a user on any give
* piece of content, based on how and who has the content locked and what workflow step the content
Expand Down Expand Up @@ -2224,13 +2232,13 @@ public void deleteActionClass(final WorkflowActionClass actionClass, final User
// Delete action class
final int orderOfActionClassToDelete = actionClass.getOrder();
workFlowFactory.deleteActionClass(actionClass);
// We don't need to get "complete" base action object from the database

// We don't need to get "complete" base action object from the database
// to retrieve all action classes from him. So, we can create the base action object
// with the "action id" contain in actionClass parameter.
WorkflowAction baseAction = new WorkflowAction();
baseAction.setId(actionClass.getActionId());

// Reorder the action classes in the database
final List<WorkflowActionClass> actionClasses = findActionClasses(baseAction);
if((actionClasses.size() > 1) && (actionClasses.size() != orderOfActionClassToDelete)) {
Expand Down Expand Up @@ -2273,12 +2281,12 @@ public void reorderActionClass(final WorkflowActionClass actionClass,

List<WorkflowActionClass> actionClasses = null;
try {
// We don't need to get "complete" base action object from the database
// We don't need to get "complete" base action object from the database
// to retrieve all action classes from him. So, we can create the base action object
// with the "action id" contain in actionClass parameter.
final WorkflowAction baseAction = new WorkflowAction();
baseAction.setId(actionClass.getActionId());

actionClasses = findActionClasses(baseAction);
} catch (Exception e) {
throw new DotDataException(e.getLocalizedMessage());
Expand Down