use of org.apache.syncope.common.lib.patch.GroupPatch in project syncope by apache.
the class DefaultGroupPullResultHandler method doUpdate.
@Override
protected AnyPatch doUpdate(final AnyTO before, final AnyPatch anyPatch, final SyncDelta delta, final ProvisioningReport result) {
GroupPatch groupPatch = GroupPatch.class.cast(anyPatch);
Pair<GroupPatch, List<PropagationStatus>> updated = groupProvisioningManager.update(groupPatch, Collections.singleton(profile.getTask().getResource().getKey()), true);
String groupOwner = null;
for (AttrPatch attrPatch : groupPatch.getPlainAttrs()) {
if (attrPatch.getOperation() == PatchOperation.ADD_REPLACE && attrPatch.getAttrTO() != null && attrPatch.getAttrTO().getSchema().isEmpty() && !attrPatch.getAttrTO().getValues().isEmpty()) {
groupOwner = attrPatch.getAttrTO().getValues().get(0);
}
}
if (groupOwner != null) {
groupOwnerMap.put(updated.getLeft().getKey(), groupOwner);
}
return anyPatch;
}
use of org.apache.syncope.common.lib.patch.GroupPatch in project syncope by apache.
the class GroupServiceImpl method newPatch.
@Override
protected GroupPatch newPatch(final String key) {
GroupPatch patch = new GroupPatch();
patch.setKey(key);
return patch;
}
use of org.apache.syncope.common.lib.patch.GroupPatch in project syncope by apache.
the class GroupLogic method update.
@PreAuthorize("hasRole('" + StandardEntitlement.GROUP_UPDATE + "')")
@Override
public ProvisioningResult<GroupTO> update(final GroupPatch groupPatch, final boolean nullPriorityAsync) {
GroupTO groupTO = binder.getGroupTO(groupPatch.getKey());
Set<String> dynRealmsBefore = new HashSet<>(groupTO.getDynRealms());
Pair<GroupPatch, List<LogicActions>> before = beforeUpdate(groupPatch, groupTO.getRealm());
String realm = before.getLeft().getRealm() != null && StringUtils.isNotBlank(before.getLeft().getRealm().getValue()) ? before.getLeft().getRealm().getValue() : groupTO.getRealm();
Set<String> effectiveRealms = RealmUtils.getEffective(AuthContextUtils.getAuthorizations().get(StandardEntitlement.GROUP_UPDATE), realm);
boolean authDynRealms = securityChecks(effectiveRealms, realm, before.getLeft().getKey());
Pair<GroupPatch, List<PropagationStatus>> updated = provisioningManager.update(groupPatch, nullPriorityAsync);
return afterUpdate(binder.getGroupTO(updated.getLeft().getKey()), updated.getRight(), before.getRight(), authDynRealms, dynRealmsBefore);
}
use of org.apache.syncope.common.lib.patch.GroupPatch in project syncope by apache.
the class GroupLogic method unassign.
@PreAuthorize("hasRole('" + StandardEntitlement.GROUP_UPDATE + "')")
@Override
public ProvisioningResult<GroupTO> unassign(final String key, final Collection<String> resources, final boolean nullPriorityAsync) {
// security checks
GroupTO group = binder.getGroupTO(key);
Set<String> effectiveRealms = RealmUtils.getEffective(AuthContextUtils.getAuthorizations().get(StandardEntitlement.GROUP_UPDATE), group.getRealm());
securityChecks(effectiveRealms, group.getRealm(), group.getKey());
GroupPatch patch = new GroupPatch();
patch.setKey(key);
patch.getResources().addAll(resources.stream().map(resource -> new StringPatchItem.Builder().operation(PatchOperation.DELETE).value(resource).build()).collect(Collectors.toList()));
patch.getADynMembershipConds().putAll(group.getADynMembershipConds());
patch.setUDynMembershipCond(group.getUDynMembershipCond());
return update(patch, nullPriorityAsync);
}
use of org.apache.syncope.common.lib.patch.GroupPatch in project syncope by apache.
the class GroupLogic method link.
@PreAuthorize("hasRole('" + StandardEntitlement.GROUP_UPDATE + "')")
@Override
public GroupTO link(final String key, final Collection<String> resources) {
// security checks
GroupTO group = binder.getGroupTO(key);
Set<String> effectiveRealms = RealmUtils.getEffective(AuthContextUtils.getAuthorizations().get(StandardEntitlement.GROUP_UPDATE), group.getRealm());
securityChecks(effectiveRealms, group.getRealm(), group.getKey());
GroupPatch patch = new GroupPatch();
patch.setKey(key);
patch.getResources().addAll(resources.stream().map(resource -> new StringPatchItem.Builder().operation(PatchOperation.ADD_REPLACE).value(resource).build()).collect(Collectors.toList()));
patch.getADynMembershipConds().putAll(group.getADynMembershipConds());
patch.setUDynMembershipCond(group.getUDynMembershipCond());
return binder.getGroupTO(provisioningManager.link(patch));
}
Aggregations