use of cz.metacentrum.perun.core.api.exceptions.MemberResourceMismatchException in project perun by CESNET.
the class MembersManagerBlImpl method deleteMember.
@Override
public void deleteMember(PerunSession sess, Member member) throws MemberAlreadyRemovedException {
Vo vo = this.getMemberVo(sess, member);
// Remove member from all groups
List<Group> memberGroups = getPerunBl().getGroupsManagerBl().getMemberDirectGroups(sess, member);
for (Group group : memberGroups) {
// Member must be removed from the members group using separate method
if (group.getName().equals(VosManager.MEMBERS_GROUP))
continue;
try {
getPerunBl().getGroupsManagerBl().removeMember(sess, group, member);
} catch (NotGroupMemberException e) {
throw new ConsistencyErrorException("getMemberGroups return group where the member is not member", e);
} catch (GroupNotExistsException e) {
throw new ConsistencyErrorException(e);
}
}
// Remove member from the VO members group
try {
Group g = getPerunBl().getGroupsManagerBl().getGroupByName(sess, vo, VosManager.MEMBERS_GROUP);
try {
getPerunBl().getGroupsManagerBl().removeMemberFromMembersOrAdministratorsGroup(sess, g, member);
} catch (NotGroupMemberException e) {
throw new ConsistencyErrorException("Member is not in the \"members\" group." + member + " " + g, e);
} catch (WrongAttributeValueException | WrongReferenceAttributeValueException e) {
throw new InternalErrorException(e);
}
} catch (GroupNotExistsException e) {
throw new InternalErrorException(e);
}
// Remove member's attributes (namespaces: member and resource-member)
try {
getPerunBl().getAttributesManagerBl().removeAllAttributes(sess, member);
List<Resource> resources = getPerunBl().getResourcesManagerBl().getResources(sess, vo);
for (Resource resource : resources) {
getPerunBl().getAttributesManagerBl().removeAllAttributes(sess, member, resource);
}
} catch (AttributeValueException ex) {
throw new ConsistencyErrorException("Member is removed from all groups. There are no required attribute for this member. Member's attributes can be removed without problem.", ex);
} catch (MemberResourceMismatchException ex) {
throw new InternalErrorException(ex);
}
removeAllMemberBans(sess, member);
// Remove possible links to member's sponsors
membersManagerImpl.deleteSponsorLinks(sess, member);
membersManagerImpl.rejectAllMemberOpenApplications(sess, member);
// Remove member from the DB
getMembersManagerImpl().deleteMember(sess, member);
getPerunBl().getAuditer().log(sess, new MemberDeleted(member));
}
use of cz.metacentrum.perun.core.api.exceptions.MemberResourceMismatchException in project perun by CESNET.
the class ServicesManagerBlImpl method getData.
private ServiceAttributes getData(PerunSession sess, Service service, Facility facility, Resource resource, Member member) {
ServiceAttributes memberServiceAttributes = new ServiceAttributes();
User user;
try {
user = getPerunBl().getUsersManagerBl().getUserById(sess, member.getUserId());
memberServiceAttributes.addAttributes(getPerunBl().getAttributesManagerBl().getRequiredAttributes(sess, service, facility, resource, user, member));
} catch (UserNotExistsException e) {
throw new ConsistencyErrorException("Member has assigned non-existing user.", e);
} catch (MemberResourceMismatchException ex) {
throw new InternalErrorException(ex);
}
return memberServiceAttributes;
}
use of cz.metacentrum.perun.core.api.exceptions.MemberResourceMismatchException in project perun by CESNET.
the class ServicesManagerBlImpl method getData.
private ServiceAttributes getData(PerunSession sess, Service service, Facility facility, Resource resource, boolean filterExpiredMembers) {
ServiceAttributes resourceServiceAttributes = new ServiceAttributes();
resourceServiceAttributes.addAttributes(getPerunBl().getAttributesManagerBl().getRequiredAttributes(sess, service, resource));
List<Member> members;
if (filterExpiredMembers) {
members = getPerunBl().getResourcesManagerBl().getAllowedMembersNotExpiredInGroups(sess, resource);
} else {
members = getPerunBl().getResourcesManagerBl().getAllowedMembers(sess, resource);
}
HashMap<Member, List<Attribute>> attributes;
try {
attributes = getPerunBl().getAttributesManagerBl().getRequiredAttributes(sess, service, facility, resource, members, true);
} catch (MemberResourceMismatchException ex) {
throw new InternalErrorException(ex);
}
for (Member mem : attributes.keySet()) {
ServiceAttributes serviceAttributes = new ServiceAttributes();
serviceAttributes.addAttributes(attributes.get(mem));
resourceServiceAttributes.addChildElement(serviceAttributes);
}
return resourceServiceAttributes;
}
use of cz.metacentrum.perun.core.api.exceptions.MemberResourceMismatchException in project perun by CESNET.
the class ServicesManagerBlImpl method getData.
private ServiceAttributes getData(PerunSession sess, Service service, Resource resource) {
ServiceAttributes resourceServiceAttributes = new ServiceAttributes();
resourceServiceAttributes.addAttributes(getPerunBl().getAttributesManagerBl().getRequiredAttributes(sess, service, resource));
List<Member> members;
members = getPerunBl().getResourcesManagerBl().getAllowedMembers(sess, resource);
HashMap<Member, List<Attribute>> attributes;
try {
attributes = getPerunBl().getAttributesManagerBl().getRequiredAttributes(sess, service, null, resource, members, true);
} catch (MemberResourceMismatchException ex) {
throw new InternalErrorException(ex);
}
for (Member mem : attributes.keySet()) {
ServiceAttributes serviceAttributes = new ServiceAttributes();
serviceAttributes.addAttributes(attributes.get(mem));
resourceServiceAttributes.addChildElement(serviceAttributes);
}
return resourceServiceAttributes;
}
use of cz.metacentrum.perun.core.api.exceptions.MemberResourceMismatchException in project perun by CESNET.
the class ServicesManagerBlImpl method getDataWithGroups.
private ServiceAttributes getDataWithGroups(PerunSession sess, Service service, Facility facility, Resource resource, boolean filterExpiredMembers) {
// append resource attributes
ServiceAttributes resourceServiceAttributes = new ServiceAttributes();
resourceServiceAttributes.addAttributes(getPerunBl().getAttributesManagerBl().getRequiredAttributes(sess, service, resource));
// append also vo attributes to resource object
try {
Vo resourceVo = getPerunBl().getVosManagerBl().getVoById(sess, resource.getVoId());
resourceServiceAttributes.addAttributes(getPerunBl().getAttributesManagerBl().getRequiredAttributes(sess, service, resourceVo));
} catch (VoNotExistsException ex) {
throw new ConsistencyErrorException("There is missing Vo for existing resource " + resource);
}
ServiceAttributes membersAbstractSA = new ServiceAttributes();
Map<Member, ServiceAttributes> memberAttributes = new HashMap<>();
List<Member> members;
if (filterExpiredMembers) {
members = getPerunBl().getResourcesManagerBl().getAllowedMembersNotExpiredInGroups(sess, resource);
} else {
members = getPerunBl().getResourcesManagerBl().getAllowedMembers(sess, resource);
}
HashMap<Member, List<Attribute>> attributes;
try {
// append all member/member_resource/user/user_facility attributes
attributes = getPerunBl().getAttributesManagerBl().getRequiredAttributes(sess, service, facility, resource, members, true);
} catch (MemberResourceMismatchException ex) {
throw new InternalErrorException(ex);
}
for (Member mem : attributes.keySet()) {
ServiceAttributes tmpAttributes = new ServiceAttributes();
tmpAttributes.addAttributes(attributes.get(mem));
memberAttributes.put(mem, tmpAttributes);
membersAbstractSA.addChildElement(tmpAttributes);
}
// get all groups and append their sub structure
ServiceAttributes groupsAbstractSA = new ServiceAttributes();
List<Group> groups = getPerunBl().getResourcesManagerBl().getAssignedGroups(sess, resource);
for (Group group : groups) {
groupsAbstractSA.addChildElement(getData(sess, service, facility, resource, group, memberAttributes, filterExpiredMembers));
}
// assign abstract services attributes to resource service attributes
resourceServiceAttributes.addChildElement(groupsAbstractSA);
resourceServiceAttributes.addChildElement(membersAbstractSA);
return resourceServiceAttributes;
}
Aggregations