public StatusBean(final RealmTO realm, final String resource) { this.key = realm.getKey(); this.name = realm.getFullPath(); this.resource = resource; }
private void getChildren( final List<Pair<String, RealmTO>> full, final String key, final Map<String, Pair<RealmTO, List<RealmTO>>> tree, final String indent) { if (tree.containsKey(key)) { Pair<RealmTO, List<RealmTO>> subtree = tree.get(key); subtree.getValue().forEach(child -> { full.add(Pair.of(indent + child.getName(), child)); getChildren(full, child.getKey(), tree, " " + indent + (indent.isEmpty() ? "|--- " : "")); }); } }
private Map<String, Pair<RealmTO, List<RealmTO>>> reloadRealmParentMap(final List<RealmTO> realms) { tree.clear(); tree.put(null, Pair.<RealmTO, List<RealmTO>>of(realms.get(0), new ArrayList<>())); final Map<String, List<RealmTO>> cache = new HashMap<>(); realms.forEach(realm -> { final List<RealmTO> children = new ArrayList<>(); tree.put(realm.getKey(), Pair.<RealmTO, List<RealmTO>>of(realm, children)); if (cache.containsKey(realm.getKey())) { children.addAll(cache.get(realm.getKey())); cache.remove(realm.getKey()); } if (tree.containsKey(realm.getParent())) { tree.get(realm.getParent()).getRight().add(realm); } else if (cache.containsKey(realm.getParent())) { cache.get(realm.getParent()).add(realm); } else { cache.put(realm.getParent(), new ArrayList<>(Collections.singleton(realm))); } }); return tree; }
@Override protected Serializable onApplyInternal(final RealmTO modelObject) { ProvisioningResult<RealmTO> result; if (modelObject.getKey() == null) { result = realmRestClient.create(this.parentPath, modelObject); } else { result = realmRestClient.update(modelObject); } return result; }
@Override protected void onClickDelete(final AjaxRequestTarget target, final RealmTO realmTO) { try { if (realmTO.getKey() == null) { throw new Exception("Root realm cannot be deleted"); } realmRestClient.delete(realmTO.getFullPath()); RealmTO parent = realmChoicePanel.moveToParentRealm(realmTO.getKey()); target.add(realmChoicePanel.reloadRealmTree(target)); SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED)); updateRealmContent(parent, selectedIndex); target.add(content); } catch (Exception e) { LOG.error("While deleting realm", e); // Escape line breaks SyncopeConsoleSession.get().error(e.getMessage().replace("\n", " ")); } ((BasePage) Realms.this.getPage()).getNotificationPanel().refresh(target); } });
new Model<RealmTO>(), Buttons.Type.Link, new Model<>(realmTO.getKey())) {
precond = StringUtils.EMPTY; } else { precond = String.format("$dynRealms=~%s;", realmTO.getKey());
} else { realm = SyncopeConstants.ROOT_REALM; dynRealm = realmTO.getKey();