@Override public long size() { return application.getPrivileges().size(); }
@Override public Iterator<PrivilegeTO> iterator(final long first, final long count) { List<PrivilegeTO> list = application.getPrivileges(); Collections.sort(list, comparator); return list.subList((int) first, (int) first + (int) count).iterator(); }
@Override public void populateItem( final Item<ICellPopulator<ApplicationTO>> item, final String componentId, final IModel<ApplicationTO> rowModel) { item.add(new Label(componentId, "[" + rowModel.getObject().getPrivileges().stream(). map(EntityTO::getKey).collect(Collectors.joining(", ")) + "]")); } });
@Override protected List<String> load() { return applicationRestClient.list().stream(). flatMap(application -> application.getPrivileges().stream()). map(EntityTO::getKey).collect(Collectors.toList()); } };
@Override protected Serializable onApplyInternal(final PrivilegeTO modelObject) { application.getPrivileges().removeIf(privilege -> privilege.getKey().equals(modelObject.getKey())); application.getPrivileges().add(modelObject); restClient.update(application); return modelObject; }
@Override public ApplicationTO getApplicationTO(final Application application) { ApplicationTO applicationTO = new ApplicationTO(); applicationTO.setKey(application.getKey()); applicationTO.setDescription(application.getDescription()); applicationTO.getPrivileges().addAll( application.getPrivileges().stream().map(privilege -> getPrivilegeTO(privilege)). collect(Collectors.toList())); return applicationTO; }
public Privileges(final RoleTO modelObject) { setTitleModel(new ResourceModel("privileges")); add(new AjaxPalettePanel.Builder<>().build("privileges", new PropertyModel<>(modelObject, "privileges"), new ListModel<>(new ApplicationRestClient().list().stream(). flatMap(application -> application.getPrivileges().stream()). map(EntityTO::getKey).collect(Collectors.toList()))). hideLabel().setOutputMarkupId(true)); } }
@Override public void onClick(final AjaxRequestTarget target, final PrivilegeTO ignore) { try { application.getPrivileges().remove(model.getObject()); restClient.update(application); SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED)); customActionOnFinishCallback(target); } catch (SyncopeClientException e) { LOG.error("While deleting {}", model.getObject().getKey(), e); SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage()); } ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target); } }, ActionLink.ActionType.DELETE, StandardEntitlement.APPLICATION_UPDATE, true);
applicationTO.getPrivileges().forEach(privilegeTO -> { if (privilegeTO == null) { LOG.error("Null {}", PrivilegeTO.class.getSimpleName()); if (!applicationTO.getPrivileges().stream(). anyMatch(privilegeTO -> privilege.getKey().equals(privilegeTO.getKey()))) {