use of org.kie.internal.task.api.UserInfo in project jbpm by kiegroup.
the class LDAPUserInfoImplTest method testUsersOneLevelScopeEngContext.
@Test
public void testUsersOneLevelScopeEngContext() {
UserInfo ldapUserInfo = createLdapUserInfoWithUserCtx(ONELEVEL_SCOPE, "ou=ENG,ou=People,dc=jbpm,dc=org");
assertUsers(ldapUserInfo, false, false, true, false);
}
use of org.kie.internal.task.api.UserInfo in project jbpm by kiegroup.
the class LDAPUserInfoImplTest method testHasEmail.
private void testHasEmail(Group group, boolean hasEmail, boolean customAttribute) {
Properties properties = createUserInfoProperties();
if (customAttribute) {
properties.setProperty(LDAPUserInfoImpl.EMAIL_ATTR_ID, "email");
}
if (group.getId().startsWith("cn=")) {
properties.setProperty(LDAPUserInfoImpl.IS_ENTITY_ID_DN, "true");
}
UserInfo ldapUserInfo = new LDAPUserInfoImpl(properties);
Assertions.assertThat(ldapUserInfo.hasEmail(group)).isEqualTo(hasEmail);
}
use of org.kie.internal.task.api.UserInfo in project jbpm by kiegroup.
the class LDAPUserInfoImplTest method testUsersInvalidScope.
@Test
public void testUsersInvalidScope() {
Properties properties = createUserInfoProperties();
properties.setProperty(LDAPUserInfoImpl.SEARCH_SCOPE, "xyz");
UserInfo ldapUserInfo = createLdapUserInfoUid(properties);
assertUsers(ldapUserInfo, true, true, false, false);
}
use of org.kie.internal.task.api.UserInfo in project jbpm by kiegroup.
the class ExecuteDeadlinesCommand method execute.
@SuppressWarnings("unchecked")
@Override
public Void execute(Context context) {
TaskContext ctx = (TaskContext) context;
UserInfo userInfo = (UserInfo) context.get(EnvironmentName.TASK_USER_INFO);
TaskPersistenceContext persistenceContext = ctx.getPersistenceContext();
try {
Task task = persistenceContext.findTask(taskId);
Deadline deadline = persistenceContext.findDeadline(deadlineId);
if (task == null || deadline == null) {
return null;
}
TaskData taskData = task.getTaskData();
if (taskData != null) {
// check if task is still in valid status
if (type.isValidStatus(taskData.getStatus())) {
Map<String, Object> variables = null;
Content content = persistenceContext.findContent(taskData.getDocumentContentId());
if (content != null) {
ContentMarshallerContext mContext = ctx.getTaskContentService().getMarshallerContext(task);
Object objectFromBytes = ContentMarshallerHelper.unmarshall(content.getContent(), mContext.getEnvironment(), mContext.getClassloader());
if (objectFromBytes instanceof Map) {
variables = (Map<String, Object>) objectFromBytes;
} else {
variables = new HashMap<String, Object>();
variables.put("content", objectFromBytes);
}
} else {
variables = Collections.emptyMap();
}
if (deadline == null || deadline.getEscalations() == null) {
return null;
}
TaskEventSupport taskEventSupport = ctx.getTaskEventSupport();
for (Escalation escalation : deadline.getEscalations()) {
// run reassignment first to allow notification to be send to new potential owners
if (!escalation.getReassignments().isEmpty()) {
taskEventSupport.fireBeforeTaskReassigned(task, ctx);
// get first and ignore the rest.
Reassignment reassignment = escalation.getReassignments().get(0);
logger.debug("Reassigning to {}", reassignment.getPotentialOwners());
((InternalTaskData) task.getTaskData()).setStatus(Status.Ready);
List<OrganizationalEntity> potentialOwners = new ArrayList<OrganizationalEntity>(reassignment.getPotentialOwners());
((InternalPeopleAssignments) task.getPeopleAssignments()).setPotentialOwners(potentialOwners);
((InternalTaskData) task.getTaskData()).setActualOwner(null);
// use assignment service to directly assign actual owner if enabled
AssignmentService assignmentService = AssignmentServiceProvider.get();
if (assignmentService.isEnabled()) {
assignmentService.assignTask(task, ctx);
}
taskEventSupport.fireAfterTaskReassigned(task, ctx);
}
for (Notification notification : escalation.getNotifications()) {
if (notification.getNotificationType() == NotificationType.Email) {
taskEventSupport.fireBeforeTaskNotified(task, ctx);
logger.debug("Sending an Email");
NotificationListenerManager.get().broadcast(new NotificationEvent(notification, task, variables), userInfo);
taskEventSupport.fireAfterTaskNotified(task, ctx);
}
}
}
}
}
deadline.setEscalated(true);
persistenceContext.updateDeadline(deadline);
persistenceContext.updateTask(task);
} catch (Exception e) {
logger.error("Error when executing deadlines", e);
}
return null;
}
use of org.kie.internal.task.api.UserInfo in project jbpm by kiegroup.
the class ExecuteReminderCommand method execute.
@Override
public Void execute(Context context) {
TaskContext ctx = (TaskContext) context;
UserInfo userInfo = (UserInfo) context.get(EnvironmentName.TASK_USER_INFO);
TaskPersistenceContext persistenceContext = ctx.getPersistenceContext();
try {
Task task = persistenceContext.findTask(taskId);
TaskData taskData = task.getTaskData();
List<DeadlineSummary> resultList = null;
resultList = getAlldeadlines(persistenceContext, taskData);
TaskEventSupport taskEventSupport = ctx.getTaskEventSupport();
if (resultList == null || resultList.size() == 0) {
if (taskData.getActualOwner() == null)
return null;
if (taskData != null) {
// check if task is still in valid status
if (DeadlineType.START.isValidStatus(taskData.getStatus()) || DeadlineType.END.isValidStatus(taskData.getStatus())) {
taskEventSupport.fireBeforeTaskNotified(task, ctx);
logger.debug("Sending an Email");
Map<String, Object> variables = getVariables(ctx, persistenceContext, task, taskData);
Notification notification = buildDefaultNotification(taskData, task);
NotificationListenerManager.get().broadcast(new NotificationEvent(notification, task, variables), userInfo);
taskEventSupport.fireAfterTaskNotified(task, ctx);
}
}
} else {
for (DeadlineSummary deadlineSummary : resultList) {
executedeadLine(ctx, persistenceContext, task, deadlineSummary, taskData);
}
}
} catch (Exception e) {
logger.error("Error when executing deadlines", e);
}
return null;
}
Aggregations