@@ -118,7 +118,6 @@ public class ApprovalTaskServiceImpl implements ApprovalTaskService {
118118 private static final String CLAIM_MOBILE = "http://wso2.org/claims/mobile" ;
119119 private static final String PARAM_NOTIFICATION = "Notification" ;
120120 private static final String Q_NAME_APPROVER_CHANNELS_PREFIX = "NotificationForApprovers-channels" ;
121- private static final String APPROVER_TYPE_ROLES = "roles" ;
122121 private static final String NOTIFICATION_EVENT_NAME_PREFIX = "TRIGGER_" ;
123122 private static final String NOTIFICATION_EVENT_NAME_SUFFIX = "_NOTIFICATION" ;
124123 private static final String NOTIFICATION_EVENT_NAME_SUFFIX_LOCAL = "_LOCAL" ;
@@ -251,7 +250,7 @@ public void updateApprovalTaskStatus(String approvalTaskId, StateDTO nextState)
251250 * @return The claim value.
252251 * @throws WorkflowEngineServerException If claim retrieval fails.
253252 */
254- private static String getUserClaimValue (int tenantId , String userId , String claimUri )
253+ private String getUserClaimValue (int tenantId , String userId , String claimUri )
255254 throws WorkflowEngineServerException {
256255
257256 try {
@@ -290,7 +289,7 @@ private String getUserClaimValueByUsername(int tenantId, String username, String
290289 * @param notificationChannel Notification channel
291290 * @return Resolved event name
292291 */
293- public static String resolveEventName (String notificationChannel ) {
292+ private String resolveEventName (String notificationChannel ) {
294293
295294 if (NotificationChannels .SMS_CHANNEL .getChannelType ().equalsIgnoreCase (notificationChannel )) {
296295 return NOTIFICATION_EVENT_NAME_PREFIX + NotificationChannels .SMS_CHANNEL .getChannelType () +
@@ -300,7 +299,7 @@ public static String resolveEventName(String notificationChannel) {
300299 }
301300 }
302301
303- private static WorkflowRequest buildWorkflowRequest (String workflowRequestId ) {
302+ private WorkflowRequest buildWorkflowRequest (String workflowRequestId ) {
304303
305304 WorkflowRequest workflowRequest = new WorkflowRequest ();
306305 RequestParameter requestParameter = new RequestParameter ();
@@ -365,8 +364,15 @@ public void addApprovalTasksForWorkflowRequest(WorkflowRequest workflowRequest,
365364 approverIdentifier , WorkflowEngineConstants .TaskStatus .READY .toString ());
366365
367366 // Collect approvers for notification after all parameters are processed.
368- if (APPROVER_TYPE_ROLES .equalsIgnoreCase (approverType )) {
369- List <String > assignedUserIds = getAssignedUserIds (approverIdentifier , tenantDomain );
367+ if (WorkflowEngineConstants .APPROVER_TYPE_ROLES .equalsIgnoreCase (approverType )) {
368+ List <String > assignedUserIds = new ArrayList <>();
369+ try {
370+ assignedUserIds = getAssignedUserIds (approverIdentifier , tenantDomain );
371+ } catch (WorkflowEngineException e ) {
372+ log .error ("Error while retrieving assigned user IDs for role: {} in tenant: {}. " +
373+ "Continuing without adding notifications for this role." ,
374+ approverIdentifier , tenantDomain , e );
375+ }
370376 if (CollectionUtils .isEmpty (assignedUserIds )) {
371377 if (log .isDebugEnabled ()) {
372378 log .debug ("Role approver '{}' in tenant '{}' has no assigned users. " +
@@ -773,15 +779,17 @@ private List<String> getAssignedUserIds(String roleId, String tenantDomain) thro
773779 try {
774780 List <UserBasicInfo > userIdList = WorkflowEngineServiceDataHolder .getInstance ().getRoleManagementService ().
775781 getUserListOfRole (roleId , tenantDomain );
782+ if (log .isDebugEnabled ()) {
783+ log .debug ("Retrieved users for role: {} in tenant: {}. User count: {}" , roleId , tenantDomain ,
784+ userIdList .size ());
785+ }
776786 List <String > userIds = new ArrayList <>();
777787 for (UserBasicInfo userBasicInfo : userIdList ) {
778788 userIds .add (userBasicInfo .getId ());
779789 }
780790 return userIds ;
781791 } catch (IdentityRoleManagementException e ) {
782- throw new WorkflowEngineException (
783- WorkflowEngineConstants .ErrorMessages .ERROR_OCCURRED_WHILE_RETRIEVING_APPROVAL_TASKS_FOR_USER .
784- getDescription (), e );
792+ throw new WorkflowEngineException ("Error occurred while retrieving users assigned to role." , e );
785793 }
786794 }
787795
0 commit comments