use of io.automatiko.engine.api.runtime.process.HumanTaskWorkItem in project automatiko-engine by automatiko-io.
the class HumanTaskNodeInstance method triggerCompleted.
public void triggerCompleted(WorkItem workItem) {
String swimlaneName = getHumanTaskNode().getSwimlane();
SwimlaneContextInstance swimlaneContextInstance = getSwimlaneContextInstance(swimlaneName);
if (swimlaneContextInstance != null) {
String newActorId = (workItem instanceof HumanTaskWorkItem) ? ((HumanTaskWorkItem) workItem).getActualOwner() : (String) workItem.getParameter(ACTOR_ID);
if (newActorId != null) {
swimlaneContextInstance.setActorId(swimlaneName, newActorId);
}
}
super.triggerCompleted(workItem);
}
use of io.automatiko.engine.api.runtime.process.HumanTaskWorkItem in project automatiko-engine by automatiko-io.
the class WebSocketEventPublisher method publish.
@Override
public void publish(DataEvent<?> event) {
if (event instanceof ProcessInstanceDataEvent && !config.instance().orElse(true)) {
LOGGER.debug("Skipping process instance event as the publisher should not deal with instances");
return;
} else if (event instanceof UserTaskInstanceDataEvent && !config.tasks().orElse(true)) {
LOGGER.debug("Skipping user task event as the publisher should not deal with tasks");
return;
}
String text;
try {
text = json.writeValueAsString(event);
for (Session session : sessions.values()) {
String filter = (String) session.getUserProperties().get("atk_filter");
if (filter != null && !filter.matches(event.getType())) {
continue;
}
boolean allowed = true;
IdentityProvider identityProvider = (IdentityProvider) session.getUserProperties().get("atk_identity");
if (event instanceof ProcessInstanceDataEvent) {
List<String> visibleTo = ((ProcessInstanceDataEvent) event).getData().getVisibleTo();
allowed = visibleTo.isEmpty() || visibleTo.contains(identityProvider.getName()) || visibleTo.stream().anyMatch(item -> identityProvider.getRoles().contains(item));
} else if (event instanceof UserTaskInstanceDataEvent) {
HumanTaskWorkItem workItem = ((UserTaskInstanceDataEvent) event).getData().sourceInstance();
allowed = workItem.enforce(SecurityPolicy.of(identityProvider));
}
if (allowed) {
session.getAsyncRemote().sendText(text);
}
}
} catch (Exception e) {
LOGGER.error("Unexpected error when publishing websocket event", e);
}
}
Aggregations