mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
Resolving #695:Fix for Policy Delegation task is not starting for tenants in distributed setup
This commit is contained in:
parent
0eeef0a568
commit
273be79ca2
@ -144,33 +144,35 @@ public class PolicyAdministratorPointImpl implements PolicyAdministratorPoint {
|
|||||||
//Check whether the TaskType is already registered. If not we'll register it here.
|
//Check whether the TaskType is already registered. If not we'll register it here.
|
||||||
if (!registeredTaskTypes.contains(PolicyManagementConstants.DELEGATION_TASK_TYPE)) {
|
if (!registeredTaskTypes.contains(PolicyManagementConstants.DELEGATION_TASK_TYPE)) {
|
||||||
taskService.registerTaskType(PolicyManagementConstants.DELEGATION_TASK_TYPE);
|
taskService.registerTaskType(PolicyManagementConstants.DELEGATION_TASK_TYPE);
|
||||||
TaskInfo registeredTaskInfo = null;
|
}
|
||||||
// getTask method will throw a TaskException if the task is not registered. Hence we'll handle the
|
|
||||||
// exception and register the task.
|
TaskInfo registeredTaskInfo = null;
|
||||||
try {
|
// getTask method will throw a TaskException if the task is not registered. Hence we'll handle the
|
||||||
registeredTaskInfo = taskManager.getTask(taskName);
|
// exception and register the task.
|
||||||
} catch (TaskException e) {
|
try {
|
||||||
|
registeredTaskInfo = taskManager.getTask(taskName);
|
||||||
|
} catch (TaskException e) {
|
||||||
// No need of any specific logic to handle this exception as it is thrown if the task is not registered.
|
// No need of any specific logic to handle this exception as it is thrown if the task is not registered.
|
||||||
} finally {
|
} finally {
|
||||||
// If registeredTaskInfo is null that means there's no registered delegation-task.
|
// If registeredTaskInfo is null that means there's no registered delegation-task.
|
||||||
if (registeredTaskInfo == null) {
|
if (registeredTaskInfo == null) {
|
||||||
TaskInfo taskInfo = new TaskInfo(taskName, PolicyManagementConstants.DELEGATION_TASK_CLAZZ,
|
|
||||||
properties, triggerInfo);
|
|
||||||
taskManager.registerTask(taskInfo);
|
|
||||||
taskManager.scheduleTask(taskInfo.getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!taskManager.isTaskScheduled(taskName)) {
|
|
||||||
TaskInfo taskInfo = new TaskInfo(taskName, PolicyManagementConstants.DELEGATION_TASK_CLAZZ,
|
TaskInfo taskInfo = new TaskInfo(taskName, PolicyManagementConstants.DELEGATION_TASK_CLAZZ,
|
||||||
properties, triggerInfo);
|
properties, triggerInfo);
|
||||||
|
taskManager.registerTask(taskInfo);
|
||||||
taskManager.scheduleTask(taskInfo.getName());
|
taskManager.scheduleTask(taskInfo.getName());
|
||||||
} else {
|
} else {
|
||||||
throw new PolicyManagementException("There is a task already running for policy changes. Please try " +
|
if (!taskManager.isTaskScheduled(taskName)) {
|
||||||
"to apply " +
|
TaskInfo taskInfo = new TaskInfo(taskName, PolicyManagementConstants.DELEGATION_TASK_CLAZZ,
|
||||||
"changes after few minutes.");
|
properties, triggerInfo);
|
||||||
|
taskManager.scheduleTask(taskInfo.getName());
|
||||||
|
} else {
|
||||||
|
throw new PolicyManagementException("There is a task already running for policy changes. Please try " +
|
||||||
|
"to apply " +
|
||||||
|
"changes after few minutes.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (TaskException e) {
|
} catch (TaskException e) {
|
||||||
String msg = "Error occurred while creating the policy delegation task for tenant " +
|
String msg = "Error occurred while creating the policy delegation task for tenant " +
|
||||||
PrivilegedCarbonContext.
|
PrivilegedCarbonContext.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user