Search in sources :

Example 16 with MemberGroupMismatchException

use of cz.metacentrum.perun.core.api.exceptions.MemberGroupMismatchException in project perun by CESNET.

the class MembersManagerBlImpl method getRichMembersWithAttributesByNames.

@Override
public List<RichMember> getRichMembersWithAttributesByNames(PerunSession sess, Group group, List<String> attrsNames) throws AttributeNotExistsException {
    List<Member> members = new ArrayList<>(perunBl.getGroupsManagerBl().getGroupMembers(sess, group));
    List<RichMember> richMembers = this.convertMembersToRichMembers(sess, members);
    List<AttributeDefinition> attrsDef = new ArrayList<>();
    for (String atrrName : attrsNames) {
        AttributeDefinition attrDef = perunBl.getAttributesManagerBl().getAttributeDefinition(sess, atrrName);
        attrsDef.add(attrDef);
    }
    List<RichMember> richMembersWithAttributes = null;
    try {
        richMembersWithAttributes = this.convertMembersToRichMembersWithAttributes(sess, group, richMembers, attrsDef);
    } catch (MemberGroupMismatchException e) {
        throw new InternalErrorException(e);
    }
    return richMembersWithAttributes;
}
Also used : MemberGroupMismatchException(cz.metacentrum.perun.core.api.exceptions.MemberGroupMismatchException) ArrayList(java.util.ArrayList) AttributeDefinition(cz.metacentrum.perun.core.api.AttributeDefinition) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) RichMember(cz.metacentrum.perun.core.api.RichMember) Member(cz.metacentrum.perun.core.api.Member) RichMember(cz.metacentrum.perun.core.api.RichMember)

Example 17 with MemberGroupMismatchException

use of cz.metacentrum.perun.core.api.exceptions.MemberGroupMismatchException in project perun by CESNET.

the class ModulesUtilsBlImpl method getSendRightFromAttributes.

@Override
public boolean getSendRightFromAttributes(PerunSessionImpl sess, Member member, Group group, String booleanAttribute, String listAttribute) {
    try {
        Attribute sendAs = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, member, group, booleanAttribute);
        if (sendAs.getValue() != null && sendAs.valueAsBoolean()) {
            return true;
        }
        Attribute sendAsGroups = sess.getPerunBl().getAttributesManagerBl().getAttribute(sess, group, listAttribute);
        if (sendAsGroups.getValue() == null) {
            return false;
        }
        List<String> subgroups = sendAsGroups.valueAsList();
        for (String groupId : subgroups) {
            Group subgroup = sess.getPerunBl().getGroupsManagerBl().getGroupById(sess, Integer.parseInt(groupId));
            if (sess.getPerunBl().getGroupsManagerBl().isGroupMember(sess, subgroup, member)) {
                return true;
            }
        }
        return false;
    } catch (MemberGroupMismatchException | GroupNotExistsException e) {
        throw new InternalErrorException(e);
    } catch (WrongAttributeAssignmentException | AttributeNotExistsException e) {
        throw new ConsistencyErrorException(e);
    }
}
Also used : Group(cz.metacentrum.perun.core.api.Group) MemberGroupMismatchException(cz.metacentrum.perun.core.api.exceptions.MemberGroupMismatchException) ConsistencyErrorException(cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException) GroupNotExistsException(cz.metacentrum.perun.core.api.exceptions.GroupNotExistsException) Attribute(cz.metacentrum.perun.core.api.Attribute) WrongAttributeAssignmentException(cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException) AttributeNotExistsException(cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException)

Example 18 with MemberGroupMismatchException

use of cz.metacentrum.perun.core.api.exceptions.MemberGroupMismatchException in project perun by CESNET.

the class MembersManagerBlImpl method getRichMembersWithAttributes.

@Override
public List<RichMember> getRichMembersWithAttributes(PerunSession sess, Group group, List<Member> members, List<AttributeDefinition> attrsDef) {
    List<RichMember> richMembers = this.convertMembersToRichMembers(sess, members);
    List<RichMember> richMembersWithAttributes;
    try {
        richMembersWithAttributes = this.convertMembersToRichMembersWithAttributes(sess, group, richMembers, attrsDef);
    } catch (MemberGroupMismatchException e) {
        throw new InternalErrorException(e);
    }
    return richMembersWithAttributes;
}
Also used : MemberGroupMismatchException(cz.metacentrum.perun.core.api.exceptions.MemberGroupMismatchException) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) RichMember(cz.metacentrum.perun.core.api.RichMember)

Example 19 with MemberGroupMismatchException

use of cz.metacentrum.perun.core.api.exceptions.MemberGroupMismatchException in project perun by CESNET.

the class GenDataProviderImpl method loadMemberGroupAttributes.

@Override
public void loadMemberGroupAttributes(Group group, List<Member> members) {
    lastLoadedGroup = group;
    memberGroupAttrs = new HashMap<>();
    try {
        memberGroupAttrs.putAll(sess.getPerunBl().getAttributesManagerBl().getRequiredAttributes(sess, service, members, group));
    } catch (MemberGroupMismatchException e) {
        throw new InternalErrorException(e);
    }
}
Also used : MemberGroupMismatchException(cz.metacentrum.perun.core.api.exceptions.MemberGroupMismatchException) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException)

Aggregations

MemberGroupMismatchException (cz.metacentrum.perun.core.api.exceptions.MemberGroupMismatchException)19 InternalErrorException (cz.metacentrum.perun.core.api.exceptions.InternalErrorException)14 Attribute (cz.metacentrum.perun.core.api.Attribute)8 Member (cz.metacentrum.perun.core.api.Member)8 ConsistencyErrorException (cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException)8 Group (cz.metacentrum.perun.core.api.Group)7 RichMember (cz.metacentrum.perun.core.api.RichMember)7 ArrayList (java.util.ArrayList)7 DirectMemberRemovedFromGroup (cz.metacentrum.perun.audit.events.GroupManagerEvents.DirectMemberRemovedFromGroup)5 IndirectMemberRemovedFromGroup (cz.metacentrum.perun.audit.events.GroupManagerEvents.IndirectMemberRemovedFromGroup)5 WrongAttributeAssignmentException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException)5 WrongAttributeValueException (cz.metacentrum.perun.core.api.exceptions.WrongAttributeValueException)5 WrongReferenceAttributeValueException (cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException)5 DirectMemberAddedToGroup (cz.metacentrum.perun.audit.events.GroupManagerEvents.DirectMemberAddedToGroup)4 IndirectMemberAddedToGroup (cz.metacentrum.perun.audit.events.GroupManagerEvents.IndirectMemberAddedToGroup)4 MemberExpiredInGroup (cz.metacentrum.perun.audit.events.GroupManagerEvents.MemberExpiredInGroup)4 MemberValidatedInGroup (cz.metacentrum.perun.audit.events.GroupManagerEvents.MemberValidatedInGroup)4 AttributeDefinition (cz.metacentrum.perun.core.api.AttributeDefinition)4 CandidateGroup (cz.metacentrum.perun.core.api.CandidateGroup)4 EnrichedGroup (cz.metacentrum.perun.core.api.EnrichedGroup)4