use of org.apache.beam.repackaged.core.org.apache.commons.lang3.tuple.Pair in project syncope by apache.
the class CamelUserProvisioningManager method update.
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
@SuppressWarnings("unchecked")
public Pair<UserPatch, List<PropagationStatus>> update(final UserPatch userPatch, final ProvisioningReport result, final Boolean enabled, final Set<String> excludedResources, final boolean nullPriorityAsync) {
PollingConsumer pollingConsumer = getConsumer("direct:updateInPullPort");
Map<String, Object> props = new HashMap<>();
props.put("key", userPatch.getKey());
props.put("result", result);
props.put("enabled", enabled);
props.put("excludedResources", excludedResources);
props.put("nullPriorityAsync", nullPriorityAsync);
sendMessage("direct:updateUserInPull", userPatch, props);
Exchange exchange = pollingConsumer.receive();
Exception ex = (Exception) exchange.getProperty(Exchange.EXCEPTION_CAUGHT);
if (ex != null) {
LOG.error("Update of user {} failed, trying to pull its status anyway (if configured)", nullPriorityAsync, ex);
result.setStatus(ProvisioningReport.Status.FAILURE);
result.setMessage("Update failed, trying to pull status anyway (if configured)\n" + ex.getMessage());
WorkflowResult<Pair<UserPatch, Boolean>> updated = new WorkflowResult<>(Pair.of(userPatch, false), new PropagationByResource(), new HashSet<>());
sendMessage("direct:userInPull", updated, props);
exchange = pollingConsumer.receive();
}
return exchange.getIn().getBody(Pair.class);
}
use of org.apache.beam.repackaged.core.org.apache.commons.lang3.tuple.Pair in project syncope by apache.
the class CreateProducer method process.
@SuppressWarnings("unchecked")
@Override
public void process(final Exchange exchange) throws Exception {
if ((exchange.getIn().getBody() instanceof WorkflowResult)) {
Object actual = exchange.getProperty("actual");
Set<String> excludedResources = exchange.getProperty("excludedResources", Set.class);
Boolean nullPriorityAsync = exchange.getProperty("nullPriorityAsync", Boolean.class);
if (actual instanceof UserTO) {
WorkflowResult<Pair<String, Boolean>> created = (WorkflowResult<Pair<String, Boolean>>) exchange.getIn().getBody();
List<PropagationTaskTO> tasks = getPropagationManager().getUserCreateTasks(created.getResult().getKey(), ((UserTO) actual).getPassword(), created.getResult().getValue(), created.getPropByRes(), ((UserTO) actual).getVirAttrs(), excludedResources);
PropagationReporter propagationReporter = getPropagationTaskExecutor().execute(tasks, nullPriorityAsync);
exchange.getOut().setBody(Pair.of(created.getResult().getKey(), propagationReporter.getStatuses()));
} else if (actual instanceof AnyTO) {
WorkflowResult<String> created = (WorkflowResult<String>) exchange.getIn().getBody();
if (actual instanceof GroupTO && isPull()) {
Map<String, String> groupOwnerMap = exchange.getProperty("groupOwnerMap", Map.class);
Optional<AttrTO> groupOwner = ((GroupTO) actual).getPlainAttr(StringUtils.EMPTY);
if (groupOwner.isPresent()) {
groupOwnerMap.put(created.getResult(), groupOwner.get().getValues().iterator().next());
}
List<PropagationTaskTO> tasks = getPropagationManager().getCreateTasks(AnyTypeKind.GROUP, created.getResult(), created.getPropByRes(), ((AnyTO) actual).getVirAttrs(), excludedResources);
getPropagationTaskExecutor().execute(tasks, nullPriorityAsync);
exchange.getOut().setBody(Pair.of(created.getResult(), null));
} else {
List<PropagationTaskTO> tasks = getPropagationManager().getCreateTasks(actual instanceof AnyObjectTO ? AnyTypeKind.ANY_OBJECT : AnyTypeKind.GROUP, created.getResult(), created.getPropByRes(), ((AnyTO) actual).getVirAttrs(), excludedResources);
PropagationReporter propagationReporter = getPropagationTaskExecutor().execute(tasks, nullPriorityAsync);
exchange.getOut().setBody(Pair.of(created.getResult(), propagationReporter.getStatuses()));
}
}
}
}
use of org.apache.beam.repackaged.core.org.apache.commons.lang3.tuple.Pair in project syncope by apache.
the class UpdateProducer method process.
@SuppressWarnings("unchecked")
@Override
public void process(final Exchange exchange) throws Exception {
if ((exchange.getIn().getBody() instanceof WorkflowResult)) {
Object actual = exchange.getProperty("actual");
Boolean nullPriorityAsync = exchange.getProperty("nullPriorityAsync", Boolean.class);
Set<String> excludedResources = exchange.getProperty("excludedResources", Set.class);
if (actual instanceof UserPatch || isPull()) {
WorkflowResult<Pair<UserPatch, Boolean>> updated = (WorkflowResult<Pair<UserPatch, Boolean>>) exchange.getIn().getBody();
List<PropagationTaskTO> tasks;
if (isPull()) {
boolean passwordNotNull = updated.getResult().getKey().getPassword() != null;
tasks = getPropagationManager().getUserUpdateTasks(updated, passwordNotNull, excludedResources);
} else {
tasks = getPropagationManager().getUserUpdateTasks(updated);
}
PropagationReporter propagationReporter = getPropagationTaskExecutor().execute(tasks, nullPriorityAsync);
exchange.getOut().setBody(Pair.of(updated.getResult().getLeft(), propagationReporter.getStatuses()));
} else if (actual instanceof AnyPatch) {
WorkflowResult<? extends AnyPatch> updated = (WorkflowResult<? extends AnyPatch>) exchange.getIn().getBody();
List<PropagationTaskTO> tasks = getPropagationManager().getUpdateTasks(actual instanceof AnyObjectPatch ? AnyTypeKind.ANY_OBJECT : AnyTypeKind.GROUP, updated.getResult().getKey(), false, null, updated.getPropByRes(), ((AnyPatch) actual).getVirAttrs(), excludedResources);
PropagationReporter propagationReporter = getPropagationTaskExecutor().execute(tasks, nullPriorityAsync);
exchange.getOut().setBody(Pair.of(updated.getResult(), propagationReporter.getStatuses()));
}
}
}
use of org.apache.beam.repackaged.core.org.apache.commons.lang3.tuple.Pair in project syncope by apache.
the class ResourceWizardBuilder method buildModelSteps.
@Override
protected WizardModel buildModelSteps(final Serializable modelObject, final WizardModel wizardModel) {
ResourceTO resourceTO = ResourceTO.class.cast(modelObject);
wizardModel.add(new ResourceDetailsPanel(resourceTO, createFlag));
wizardModel.add(new ResourceConnConfPanel(resourceTO, createFlag) {
private static final long serialVersionUID = -1128269449868933504L;
@Override
protected Pair<Boolean, String> check(final AjaxRequestTarget target) {
return resourceRestClient.check(modelObject);
}
@Override
protected void onComponentTag(final ComponentTag tag) {
tag.append("class", "scrollable-tab-content", " ");
}
});
wizardModel.add(new ResourceConnCapabilitiesPanel(resourceTO, connectorRestClient.read(resourceTO.getConnector()).getCapabilities()));
wizardModel.add(new ResourceSecurityPanel(resourceTO));
return wizardModel;
}
use of org.apache.beam.repackaged.core.org.apache.commons.lang3.tuple.Pair in project syncope by apache.
the class NotificationManagerImpl method createTasks.
@Override
public List<NotificationTask> createTasks(final AuditElements.EventCategoryType type, final String category, final String subcategory, final String event, final Result condition, final Object before, final Object output, final Object... input) {
Any<?> any = null;
if (before instanceof UserTO) {
any = userDAO.find(((UserTO) before).getKey());
} else if (output instanceof UserTO) {
any = userDAO.find(((UserTO) output).getKey());
} else if (output instanceof Pair && ((Pair) output).getRight() instanceof UserTO) {
any = userDAO.find(((UserTO) ((Pair) output).getRight()).getKey());
} else if (output instanceof ProvisioningResult && ((ProvisioningResult) output).getEntity() instanceof UserTO) {
any = userDAO.find(((ProvisioningResult) output).getEntity().getKey());
} else if (before instanceof AnyObjectTO) {
any = anyObjectDAO.find(((AnyObjectTO) before).getKey());
} else if (output instanceof AnyObjectTO) {
any = anyObjectDAO.find(((AnyObjectTO) output).getKey());
} else if (output instanceof ProvisioningResult && ((ProvisioningResult) output).getEntity() instanceof AnyObjectTO) {
any = anyObjectDAO.find(((ProvisioningResult) output).getEntity().getKey());
} else if (before instanceof GroupTO) {
any = groupDAO.find(((GroupTO) before).getKey());
} else if (output instanceof GroupTO) {
any = groupDAO.find(((GroupTO) output).getKey());
} else if (output instanceof ProvisioningResult && ((ProvisioningResult) output).getEntity() instanceof GroupTO) {
any = groupDAO.find(((ProvisioningResult) output).getEntity().getKey());
}
AnyType anyType = any == null ? null : any.getType();
LOG.debug("Search notification for [{}]{}", anyType, any);
List<NotificationTask> notifications = new ArrayList<>();
for (Notification notification : notificationDAO.findAll()) {
if (LOG.isDebugEnabled()) {
notification.getAbouts().forEach(about -> {
LOG.debug("Notification about {} defined: {}", about.getAnyType(), about.get());
});
}
if (notification.isActive()) {
String currentEvent = AuditLoggerName.buildEvent(type, category, subcategory, event, condition);
if (!notification.getEvents().contains(currentEvent)) {
LOG.debug("No events found about {}", any);
} else if (anyType == null || any == null || !notification.getAbout(anyType).isPresent() || searchDAO.matches(any, SearchCondConverter.convert(notification.getAbout(anyType).get().get()))) {
LOG.debug("Creating notification task for event {} about {}", currentEvent, any);
final Map<String, Object> model = new HashMap<>();
model.put("type", type);
model.put("category", category);
model.put("subcategory", subcategory);
model.put("event", event);
model.put("condition", condition);
model.put("before", before);
model.put("output", output);
model.put("input", input);
if (any instanceof User) {
model.put("user", userDataBinder.getUserTO((User) any, true));
} else if (any instanceof Group) {
model.put("group", groupDataBinder.getGroupTO((Group) any, true));
} else if (any instanceof AnyObject) {
model.put("group", anyObjectDataBinder.getAnyObjectTO((AnyObject) any, true));
}
NotificationTask notificationTask = getNotificationTask(notification, any, model);
notificationTask = taskDAO.save(notificationTask);
notifications.add(notificationTask);
}
} else {
LOG.debug("Notification {} is not active, task will not be created", notification.getKey());
}
}
return notifications;
}
Aggregations