private static <T extends AnyTO, K extends AnyPatch> void patch(final T to, final K patch, final T result) { if (to.getKey() == null || !to.getKey().equals(patch.getKey())) { throw new IllegalArgumentException( to.getClass().getSimpleName() + " and " + patch.getClass().getSimpleName() result.setRealm(patch.getRealm().getValue()); switch (auxClassPatch.getOperation()) { case ADD_REPLACE: result.getAuxClasses().add(auxClassPatch.getValue()); break; result.getAuxClasses().remove(auxClassPatch.getValue()); result.getPlainAttrs().clear(); result.getPlainAttrs().addAll(patch(EntityTOUtils.buildAttrMap(to.getPlainAttrs()), patch.getPlainAttrs())); result.getVirAttrs().clear(); result.getVirAttrs().addAll(patch.getVirAttrs()); switch (resourcePatch.getOperation()) { case ADD_REPLACE: result.getResources().add(resourcePatch.getValue()); break; result.getResources().remove(resourcePatch.getValue());
/** * Reload data if the realm changes (see SYNCOPE-1135). */ private void reload() { boolean reload; if (Groups.this.templateMode) { reload = realm == null; realm = SyncopeConstants.ROOT_REALM; } else { reload = !Groups.this.anyTO.getRealm().equalsIgnoreCase(realm); realm = Groups.this.anyTO.getRealm(); } if (reload) { reloadObject(); reloadMemberships(); reloadDynMemberships(); } } }
Map<String, AttrTO> attrMap = EntityTOUtils.buildAttrMap(anyTO.getPlainAttrs()); anyTO.getClass().getSimpleName(), anyTO.getKey()); Map<String, AttrTO> derAttrMap = EntityTOUtils.buildAttrMap(anyTO.getDerAttrs()); anyTO.getClass().getSimpleName(), anyTO.getKey()); Map<String, AttrTO> virAttrMap = EntityTOUtils.buildAttrMap(anyTO.getVirAttrs()); anyTO.getClass().getSimpleName(), anyTO.getKey());
@Override public Set<AttrTO> read(final String key, final SchemaType schemaType) { TO any = read(key); Set<AttrTO> result; switch (schemaType) { case DERIVED: result = any.getDerAttrs(); break; case VIRTUAL: result = any.getVirAttrs(); break; case PLAIN: default: result = any.getPlainAttrs(); } return result; }
private void doExtractResources(final ContentHandler handler, final AnyTO anyTO) throws SAXException { if (anyTO.getResources().isEmpty()) { LOG.debug("No resources found for {}[{}]", anyTO.getClass().getSimpleName(), anyTO.getKey()); } else { AttributesImpl atts = new AttributesImpl(); handler.startElement("", "", "resources", null); for (String resourceName : anyTO.getResources()) { atts.clear(); atts.addAttribute("", "", ReportXMLConst.ATTR_NAME, ReportXMLConst.XSD_STRING, resourceName); handler.startElement("", "", "resource", atts); handler.endElement("", "", "resource"); } handler.endElement("", "", "resources"); } }
if (updated.getKey() == null && original.getKey() != null || (updated.getKey() != null && !updated.getKey().equals(original.getKey()))) { result.setKey(updated.getKey()); result.setRealm(replacePatchItem(updated.getRealm(), original.getRealm(), new StringReplacePatchItem())); original.getAuxClasses().stream().filter(auxClass -> !updated.getAuxClasses().contains(auxClass)). forEach(auxClass -> { result.getAuxClasses().add(new StringPatchItem.Builder(). updated.getAuxClasses().stream().filter(auxClass -> !original.getAuxClasses().contains(auxClass)). forEach(auxClass -> { result.getAuxClasses().add(new StringPatchItem.Builder(). Map<String, Attr> updatedAttrs = EntityTOUtils.buildAttrMap(updated.getPlainAttrs()); Map<String, Attr> originalAttrs = EntityTOUtils.buildAttrMap(original.getPlainAttrs()); result.getVirAttrs().addAll(updated.getVirAttrs()); original.getResources().stream().filter(resource -> !updated.getResources().contains(resource)). forEach(resource -> { result.getResources().add(new StringPatchItem.Builder(). updated.getResources().stream().filter(resource -> !original.getResources().contains(resource)). forEach(resource -> { result.getResources().add(new StringPatchItem.Builder().
@Override protected void provision(final Any<?> any, final Boolean enabled, final ProvisioningReport result) { AnyTO before = getAnyTO(any.getKey()); List<String> noPropResources = new ArrayList<>(before.getResources()); noPropResources.remove(profile.getTask().getResource().getKey()); PropagationByResource propByRes = new PropagationByResource(); propByRes.add(ResourceOperation.CREATE, profile.getTask().getResource().getKey()); PropagationReporter reporter = taskExecutor.execute(propagationManager.getUserCreateTasks( before.getKey(), null, enabled, propByRes, before.getVirAttrs(), noPropResources), false); reportPropagation(result, reporter); }
protected void fixPlainAndVirAttrs(final AnyTO updated, final AnyTO original) { for (Attr plainAttr : original.getPlainAttrs()) { if (!updated.getPlainAttr(plainAttr.getSchema()).isPresent()) { updated.getPlainAttrs().add(plainAttr); for (Attr virAttr : original.getVirAttrs()) { if (!updated.getVirAttr(virAttr.getSchema()).isPresent()) { updated.getVirAttrs().add(virAttr); updated.getPlainAttrs().removeIf(attr -> attr.getValues().isEmpty()); updated.getVirAttrs().removeIf(attr -> attr.getValues().isEmpty()); if (updated instanceof GroupableRelatableTO) { GroupableRelatableTO.class.cast(updated).getMemberships().forEach(memb -> {
protected Details<A> addOptionalDetailsPanel(final AnyWrapper<A> modelObject) { if (modelObject.getInnerObject().getKey() == null) { return null; } else { return new Details<>( modelObject, mode == AjaxWizard.Mode.TEMPLATE, true, pageRef); } }
anyTO.getAuxClasses().stream(). map(className -> anyTypeClassDAO.find(className)). forEachOrdered(auxClass -> { anyTO.getPlainAttrs().stream(). filter(attrTO -> !attrTO.getValues().isEmpty()). forEach(attrTO -> { anyTO.getResources().forEach(resourceKey -> { ExternalResource resource = resourceDAO.find(resourceKey); if (resource == null) {
@Override protected List<StatusBean> getStatusBeans(final long first, final long count) { final AnyTO actual = restClient.read(anyTO.getKey()); List<StatusBean> statusBeans = actual.getResources().stream().map(resource -> { List<Pair<String, ReconStatus>> statuses = Collections.emptyList(); if (statusOnly) { statuses = ReconStatusUtils. getReconStatuses(anyTypeKind, anyTO.getKey(), Arrays.asList(resource)); if (actual.getStatus() != null) { try { syncopeStatus = Status.valueOf(actual.getStatus().toUpperCase()); } catch (IllegalArgumentException e) { LOG.warn("Unexpected status found: {}", actual.getStatus(), e); } else { statusBeans.addAll(resources.stream(). filter(resource -> !anyTO.getResources().contains(resource)). map(resource -> { StatusBean statusBean = StatusUtils.getStatusBean(actual,
@Override public void setObject(final List<String> object) { entityTO.getResources().clear(); entityTO.getResources().addAll(object); } }, available).hideLabel().setOutputMarkupId(true));
protected void provision(final Any<?> any, final Boolean enable, final ProvisioningReport result) { AnyTO before = getAnyTO(any.getKey()); List<String> noPropResources = new ArrayList<>(before.getResources()); noPropResources.remove(profile.getTask().getResource().getKey()); PropagationByResource propByRes = new PropagationByResource(); propByRes.add(ResourceOperation.CREATE, profile.getTask().getResource().getKey()); List<PropagationTaskInfo> taskInfos = propagationManager.getCreateTasks( any.getType().getKind(), any.getKey(), enable, propByRes, before.getVirAttrs(), noPropResources); if (!taskInfos.isEmpty()) { taskInfos.get(0).setBeforeObj(Optional.ofNullable(null)); PropagationReporter reporter = new DefaultPropagationReporter(); taskExecutor.execute(taskInfos.get(0), reporter); reportPropagation(result, reporter); } }
value.getPlainAttrs().stream(). filter(attrTO -> !attrTO.getValues().isEmpty() && !JexlUtils.isExpressionValid(attrTO.getValues().get(0))). }); value.getVirAttrs().stream(). filter(attrTO -> !attrTO.getValues().isEmpty() && !JexlUtils.isExpressionValid(attrTO.getValues().get(0))).
protected Pair<TO, List<LogicActions>> beforeCreate(final TO input) { Realm realm = realmDAO.findByFullPath(input.getRealm()); if (realm == null) { SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRealm); sce.getElements().add(input.getRealm()); throw sce; } AnyType anyType = input instanceof UserTO ? anyTypeDAO.findUser() : input instanceof GroupTO ? anyTypeDAO.findGroup() : anyTypeDAO.find(input.getType()); if (anyType == null) { SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidAnyType); sce.getElements().add(input.getType()); throw sce; } TO any = input; templateUtils.apply(any, realm.getTemplate(anyType)); List<LogicActions> actions = getActions(realm); for (LogicActions action : actions) { any = action.beforeCreate(any); } LOG.debug("Input: {}\nOutput: {}\n", input, any); return ImmutablePair.of(any, actions); }
AnyTO created = doCreate(anyTO, delta); output = created; result.setKey(created.getKey()); result.setName(getName(created)); resultStatus = Result.SUCCESS; LOG.debug("{} {} successfully created", created.getType(), created.getKey()); } catch (PropagationException e) { LOG.error("Could not propagate {} {}", anyTO.getType(), delta.getUid().getUidValue(), e); output = e; resultStatus = Result.FAILURE; LOG.error("Could not create {} {} ", anyTO.getType(), delta.getUid().getUidValue(), e); output = e; resultStatus = Result.FAILURE;
@Override protected List<Attr> getAttrsFromTO() { return anyTO.getVirAttrs().stream().sorted(attrComparator).collect(Collectors.toList()); }
@Override protected List<Attr> getAttrsFromTO() { return anyTO.getPlainAttrs().stream().sorted(attrComparator).collect(Collectors.toList()); }
protected ProvisioningResult<TO> afterUpdate( final TO input, final List<PropagationStatus> statuses, final List<LogicActions> actions, final boolean authDynRealms, final Set<String> dynRealmsBefore) { Set<String> dynRealmsAfter = new HashSet<>(input.getDynRealms()); if (authDynRealms && !dynRealmsBefore.equals(dynRealmsAfter)) { throw new DelegatedAdministrationException( this instanceof UserLogic ? AnyTypeKind.USER : this instanceof GroupLogic ? AnyTypeKind.GROUP : AnyTypeKind.ANY_OBJECT, input.getKey()); } TO any = input; for (LogicActions action : actions) { any = action.afterUpdate(any); } ProvisioningResult<TO> result = new ProvisioningResult<>(); result.setEntity(any); result.getPropagationStatuses().addAll(statuses); return result; }
String etag = anyRestClient.read(key).getETagValue(); AnyTO any = (AnyTO) item; batchAnyService.delete(any.getKey()); deletedAnys.add(any.getKey()); } else if (singleItem instanceof TaskTO) { TaskTO task = (TaskTO) item; : AnyObjectRestClient.class.cast(batchExecutor); for (int i = 0; i < items.size(); i++) { String key = ((AnyTO) items.get(i)).getKey(); if (!deletedAnys.contains(key)) { items.set(i, (T) anyRestClient.read(key));