protected <T extends Any<?>> List<T> buildResult(final List<Object> raw, final AnyTypeKind kind) { List<T> result = new ArrayList<>(); raw.stream().map(anyKey -> anyKey instanceof Object[] ? (String) ((Object[]) anyKey)[0] : ((String) anyKey)). forEachOrdered(actualKey -> { @SuppressWarnings("unchecked") T any = kind == AnyTypeKind.USER ? (T) userDAO.find(actualKey) : kind == AnyTypeKind.GROUP ? (T) groupDAO.find(actualKey) : (T) anyObjectDAO.find(actualKey); if (any == null) { LOG.error("Could not find {} with id {}, even if returned by native query", kind, actualKey); } else if (!result.contains(any)) { result.add(any); } }); return result; }
@Override public List<PropagationStatus> deprovision( final String key, final Collection<String> resources, final boolean nullPriorityAsync) { PropagationByResource propByRes = new PropagationByResource(); propByRes.addAll(ResourceOperation.DELETE, resources); List<PropagationTaskInfo> taskInfos = propagationManager.getDeleteTasks( AnyTypeKind.ANY_OBJECT, key, propByRes, anyObjectDAO.findAllResourceKeys(key).stream(). filter(resource -> !resources.contains(resource)). collect(Collectors.toList())); PropagationReporter propagationReporter = taskExecutor.execute(taskInfos, nullPriorityAsync); return propagationReporter.getStatuses(); } }
@Transactional(readOnly = true) @Override public Set<ExternalResource> getAllResources(final Any<?> any) { Set<ExternalResource> resources = new HashSet<>(); if (any instanceof User) { resources.addAll(userDAO.findAllResources((User) any)); } else if (any instanceof Group) { resources.addAll(((Group) any).getResources()); } else if (any instanceof AnyObject) { resources.addAll(anyObjectDAO.findAllResources((AnyObject) any)); } return resources; }
@Override public PropagationByResource update(final AnyObject toBeUpdated, final AnyObjectPatch anyObjectPatch) { AnyObject anyObject = anyObjectDAO.save(toBeUpdated); Collection<String> currentResources = anyObjectDAO.findAllResourceKeys(anyObject.getKey()); propByRes.addAll(ResourceOperation.UPDATE, anyObjectDAO.findAllResourceKeys(anyObject.getKey())); scce.addException(invalidAnyType); } else { AnyObject otherEnd = anyObjectDAO.find(patch.getRelationshipTO().getOtherEndKey()); if (otherEnd == null) { LOG.debug("Ignoring invalid any object {}", patch.getRelationshipTO().getOtherEndKey()); Collection<ExternalResource> resources = anyObjectDAO.findAllResources(anyObject); reasons.put(resource.getKey(), new HashSet<>(Collections.singleton(anyObject.getKey()))); }); anyObjectDAO.findAllGroupKeys(anyObject).forEach(group -> { groupDAO.findAllResourceKeys(group).forEach(resource -> { if (!reasons.containsKey(resource)) { }); Pair<Set<String>, Set<String>> dynGroupMembs = anyObjectDAO.saveAndGetDynGroupMembs(anyObject); anyObjectDAO.save(anyObject); return propByRes;
derAttrHandler.getValues(anyObject), virAttrValues, anyObjectDAO.findAllResources(anyObject), details); anyObjectDAO.findAllRelationships(anyObject).stream(). map(relationship -> getRelationshipTO( relationship.getType().getKey(), anyObjectDAO.findDynGroups(anyObject.getKey()).stream().map(group -> { return new MembershipTO.Builder(). group(group.getKey(), group.getName()).
protected String check(final RelationshipCond cond) { String rightAnyObjectKey; if (SyncopeConstants.UUID_PATTERN.matcher(cond.getAnyObject()).matches()) { rightAnyObjectKey = cond.getAnyObject(); } else { AnyObject anyObject = anyObjectDAO.findByName(cond.getAnyObject()); rightAnyObjectKey = anyObject == null ? null : anyObject.getKey(); } if (rightAnyObjectKey == null) { LOG.error("Could not find any object for '" + cond.getAnyObject() + "'"); throw new IllegalArgumentException(); } return rightAnyObjectKey; }
@Override public Set<String> removeDynMemberships(final AnyObject anyObject) { List<Group> dynGroups = anyObjectDAO.findDynGroups(anyObject.getKey()); Query delete = entityManager().createNativeQuery("DELETE FROM " + ADYNMEMB_TABLE + " WHERE any_id=?"); delete.setParameter(1, anyObject.getKey()); delete.executeUpdate(); Set<String> before = new HashSet<>(); dynGroups.forEach(group -> { before.add(group.getKey()); publisher.publishEvent(new AnyCreatedUpdatedEvent<>(this, group, AuthContextUtils.getDomain())); }); return before; }
numbersInfo.getGroupsByRealm().putAll(groupDAO.countByRealm()); Map<AnyType, Integer> anyObjectNumbers = anyObjectDAO.countByType(); int i = 0; for (Iterator<Map.Entry<AnyType, Integer>> itor = anyObjectNumbers.entrySet().iterator(); numbersInfo.setAnyType1(entry.getKey().getKey()); numbersInfo.setTotalAny1(entry.getValue()); numbersInfo.getAny1ByRealm().putAll(anyObjectDAO.countByRealm(entry.getKey())); } else if (i == 1) { numbersInfo.setAnyType2(entry.getKey().getKey()); numbersInfo.setTotalAny2(entry.getValue()); numbersInfo.getAny2ByRealm().putAll(anyObjectDAO.countByRealm(entry.getKey()));
}); anyObjectDAO.save(leftEnd); publisher.publishEvent(new AnyCreatedUpdatedEvent<>(this, leftEnd, AuthContextUtils.getDomain())); });
@Transactional(readOnly = true) @Override public AnyObjectTO getAnyObjectTO(final String key) { return getAnyObjectTO(anyObjectDAO.authFind(key), true); }
@PreAuthorize("hasRole('" + StandardEntitlement.ANYTYPE_DELETE + "')") public AnyTypeTO delete(final String key) { AnyType anyType = anyTypeDAO.find(key); if (anyType == null) { LOG.error("Could not find anyType '" + key + "'"); throw new NotFoundException(key); } Integer anyObjects = anyObjectDAO.countByType().get(anyType); if (anyObjects != null && anyObjects > 0) { LOG.error("{} AnyObject instances found for {}, aborting", anyObjects, anyType); SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidAnyType); sce.getElements().add("AnyObject instances found for " + key); throw sce; } try { return binder.delete(anyType); } catch (IllegalArgumentException e) { SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRequest); sce.getElements().add(e.getMessage()); throw sce; } }
protected String check(final MemberCond cond) { String memberKey; if (SyncopeConstants.UUID_PATTERN.matcher(cond.getMember()).matches()) { memberKey = cond.getMember(); } else { Any<?> member = userDAO.findByUsername(cond.getMember()); if (member == null) { member = anyObjectDAO.findByName(cond.getMember()); } memberKey = member == null ? null : member.getKey(); } if (memberKey == null) { LOG.error("Could not find user or any object for '" + cond.getMember() + "'"); throw new IllegalArgumentException(); } return memberKey; }
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());
stream().map(Entity::getKey).collect(Collectors.toList())); } else { AnyObject anyObject = anyObjectDAO.findByName(connObjectKey); if (anyObject != null) { result.add(anyObject.getKey());
key, propByRes, anyObjectDAO.findAllResourceKeys(key).stream(). filter(resource -> !resources.contains(resource)).collect(Collectors.toList())); propagationReporter = getPropagationTaskExecutor().execute(taskInfos, nullPriorityAsync);
? userDAO.find(anyKey) : init.getMiddle().getKind() == AnyTypeKind.ANY_OBJECT ? anyObjectDAO.find(anyKey) : groupDAO.find(anyKey); if (any == null) {
AnyObject anyObject = anyObjectDAO.findByName(intAttrName.getRelatedAnyObject()); if (anyObject == null || groupableRelatable.getRelationships(anyObject.getKey()).isEmpty()) { LOG.warn("No relationship for {} in {}, ignoring",
@Transactional(propagation = Propagation.REQUIRES_NEW) @Override public List<PropagationStatus> delete( final String key, final Set<String> excludedResources, final boolean nullPriorityAsync) { PropagationByResource propByRes = new PropagationByResource(); propByRes.set(ResourceOperation.DELETE, anyObjectDAO.findAllResourceKeys(key)); // Note here that we can only notify about "delete", not any other // task defined in workflow process definition: this because this // information could only be available after awfAdapter.delete(), which // will also effectively remove user from db, thus making virtually // impossible by NotificationManager to fetch required user information List<PropagationTaskInfo> taskInfos = propagationManager.getDeleteTasks( AnyTypeKind.ANY_OBJECT, key, propByRes, excludedResources); PropagationReporter propagationReporter = taskExecutor.execute(taskInfos, nullPriorityAsync); try { awfAdapter.delete(key); } catch (PropagationException e) { throw e; } return propagationReporter.getStatuses(); }
AnyObject otherEnd = anyObjectDAO.find(patch.getRelationshipTO().getOtherEndKey()); if (otherEnd == null) { LOG.debug("Ignoring invalid any object {}", patch.getRelationshipTO().getOtherEndKey());
default: try { resources = anyObjectDAO.findAllResourceKeys(task.getEntityKey()); } catch (Exception e) { LOG.error("Could not read any object {}", task.getEntityKey(), e);