Search in sources :

Example 6 with AssignedResource

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

the class GroupsManagerBlImpl method createGroup.

@Override
public Group createGroup(PerunSession sess, Group parentGroup, Group group) throws GroupExistsException, GroupRelationNotAllowed, GroupRelationAlreadyExists {
    Vo vo = this.getVo(sess, parentGroup);
    group = getGroupsManagerImpl().createGroup(sess, vo, parentGroup, group);
    try {
        parentGroup = createGroupUnion(sess, parentGroup, group, true);
    // We catch those exceptions, but they should never be thrown, so we just log them.
    } catch (WrongAttributeValueException | WrongReferenceAttributeValueException e) {
        log.error("Exception thrown in createGroup method, while it shouldn't be thrown. Cause:{}", e);
    } catch (GroupNotExistsException e) {
        throw new ConsistencyErrorException("Database consistency error while creating group: {}", e);
    }
    getPerunBl().getAuditer().log(sess, new GroupCreatedAsSubgroup(group, vo, parentGroup));
    // check if new subgroup should be automatically assigned to resources
    List<AssignedResource> assignedResources = getPerunBl().getResourcesManagerBl().getResourceAssignments(sess, parentGroup, null).stream().filter(AssignedResource::isAutoAssignSubgroups).collect(toList());
    for (AssignedResource assignedResource : assignedResources) {
        try {
            Group sourceGroup = assignedResource.getSourceGroupId() == null ? parentGroup : getPerunBl().getGroupsManagerBl().getGroupById(sess, assignedResource.getSourceGroupId());
            getPerunBl().getResourcesManagerBl().assignAutomaticGroupToResource(sess, sourceGroup, group, assignedResource.getEnrichedResource().getResource());
        } catch (GroupResourceMismatchException | GroupNotExistsException | WrongReferenceAttributeValueException | WrongAttributeValueException e) {
        // silently skip, assignment will have to be repeated after failure cause is solved
        } catch (GroupAlreadyAssignedException e) {
        // skip, periodic checker might have assigned it already
        }
    }
    return group;
}
Also used : GroupCreatedAsSubgroup(cz.metacentrum.perun.audit.events.GroupManagerEvents.GroupCreatedAsSubgroup) EnrichedGroup(cz.metacentrum.perun.core.api.EnrichedGroup) IndirectMemberRemovedFromGroup(cz.metacentrum.perun.audit.events.GroupManagerEvents.IndirectMemberRemovedFromGroup) CandidateGroup(cz.metacentrum.perun.core.api.CandidateGroup) RichGroup(cz.metacentrum.perun.core.api.RichGroup) MemberExpiredInGroup(cz.metacentrum.perun.audit.events.GroupManagerEvents.MemberExpiredInGroup) MemberValidatedInGroup(cz.metacentrum.perun.audit.events.GroupManagerEvents.MemberValidatedInGroup) DirectMemberRemovedFromGroup(cz.metacentrum.perun.audit.events.GroupManagerEvents.DirectMemberRemovedFromGroup) Group(cz.metacentrum.perun.core.api.Group) DirectMemberAddedToGroup(cz.metacentrum.perun.audit.events.GroupManagerEvents.DirectMemberAddedToGroup) IndirectMemberAddedToGroup(cz.metacentrum.perun.audit.events.GroupManagerEvents.IndirectMemberAddedToGroup) ConsistencyErrorException(cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException) GroupNotExistsException(cz.metacentrum.perun.core.api.exceptions.GroupNotExistsException) ParentGroupNotExistsException(cz.metacentrum.perun.core.api.exceptions.ParentGroupNotExistsException) GroupAlreadyAssignedException(cz.metacentrum.perun.core.api.exceptions.GroupAlreadyAssignedException) GroupResourceMismatchException(cz.metacentrum.perun.core.api.exceptions.GroupResourceMismatchException) AssignedResource(cz.metacentrum.perun.core.api.AssignedResource) WrongReferenceAttributeValueException(cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException) Vo(cz.metacentrum.perun.core.api.Vo) GroupCreatedInVo(cz.metacentrum.perun.audit.events.GroupManagerEvents.GroupCreatedInVo) WrongAttributeValueException(cz.metacentrum.perun.core.api.exceptions.WrongAttributeValueException)

Example 7 with AssignedResource

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

the class ResourcesManagerEntryIntegrationTest method getAssignedResourcesForMemberWithStatus_twoGroupsToOneResource.

@Test
public void getAssignedResourcesForMemberWithStatus_twoGroupsToOneResource() throws Exception {
    System.out.println(CLASS_NAME + "getAssignedResourcesForMemberWithStatus_twoGroupsToOneResource");
    vo = setUpVo();
    member = setUpMember(vo);
    group = setUpGroup(vo, member);
    Group group2 = new Group("ResourcesManagerTestGroup2", "");
    group2 = perun.getGroupsManager().createGroup(sess, vo, group2);
    perun.getGroupsManager().addMember(sess, group2, member);
    facility = setUpFacility();
    resource = setUpResource();
    // both the resources assign to the group
    resourcesManager.assignGroupToResource(sess, group2, resource, false, false, false);
    resourcesManager.deactivateGroupResourceAssignment(sess, group2, resource);
    resourcesManager.assignGroupToResource(sess, group, resource, false, false, false);
    AssignedResource resourceActive = new AssignedResource(new EnrichedResource(resource, null), GroupResourceStatus.ACTIVE, null, null, facility, false);
    AssignedResource resourceInactive = new AssignedResource(new EnrichedResource(resource, null), GroupResourceStatus.INACTIVE, null, null, facility, false);
    List<AssignedResource> resources = resourcesManager.getAssignedResourcesWithStatus(sess, member);
    assertEquals("member should be assigned to a single resources", 1, resources.size());
    assertTrue("assigned resources should be in returned list", resources.contains(resourceActive));
    // removing group should change the status
    resourcesManager.removeGroupFromResource(sess, group, resource);
    resources = resourcesManager.getAssignedResourcesWithStatus(sess, member);
    assertEquals("member should be assigned to a single resources", 1, resources.size());
    assertTrue("assigned resource should be in returned list", resources.contains(resourceInactive));
}
Also used : EnrichedGroup(cz.metacentrum.perun.core.api.EnrichedGroup) AssignedGroup(cz.metacentrum.perun.core.api.AssignedGroup) Group(cz.metacentrum.perun.core.api.Group) EnrichedResource(cz.metacentrum.perun.core.api.EnrichedResource) AssignedResource(cz.metacentrum.perun.core.api.AssignedResource) AbstractPerunIntegrationTest(cz.metacentrum.perun.core.AbstractPerunIntegrationTest) Test(org.junit.Test)

Example 8 with AssignedResource

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

the class GroupsManagerBlImpl method fixMovedTreeAutoassignments.

/**
 * Checks, if moving group would still belong under source group tree of automatic assignments on all assigned resources
 * and removes together with subgroups from source group's autoassignments if not
 * @param sess
 * @param destinationGroup
 * @param movingGroup
 */
private void fixMovedTreeAutoassignments(PerunSession sess, Group destinationGroup, Group movingGroup) {
    List<AssignedResource> autoAssignedResources = perunBl.getResourcesManagerBl().getResourceAssignments(sess, movingGroup, List.of()).stream().filter(g -> g.getSourceGroupId() != null).collect(toList());
    for (AssignedResource autoAssignedResource : autoAssignedResources) {
        int sourceGroupId = autoAssignedResource.getSourceGroupId();
        try {
            Group sourceGroup = this.getGroupById(sess, sourceGroupId);
            List<Group> sourceSubgroups = this.getAllSubGroups(sess, sourceGroup);
            if (destinationGroup == null || !sourceSubgroups.contains(destinationGroup)) {
                // remove automatic group and subgroups' assignments
                List<Group> groupsToRemove = this.getAllSubGroups(sess, movingGroup);
                groupsToRemove.add(movingGroup);
                for (Group groupToRemove : groupsToRemove) {
                    try {
                        perunBl.getResourcesManagerBl().removeAutomaticGroupFromResource(sess, groupToRemove, autoAssignedResource.getEnrichedResource().getResource(), sourceGroupId);
                    } catch (GroupAlreadyRemovedFromResourceException | GroupNotDefinedOnResourceException e) {
                    // skip
                    }
                }
            }
        } catch (GroupNotExistsException e) {
            log.error("Assignment source group doesn't exist: " + autoAssignedResource, e);
        }
    }
}
Also used : Pair(cz.metacentrum.perun.core.api.Pair) Arrays(java.util.Arrays) RichUserExtSource(cz.metacentrum.perun.core.api.RichUserExtSource) GroupSynchronizationAlreadyRunningException(cz.metacentrum.perun.core.api.exceptions.GroupSynchronizationAlreadyRunningException) Vo(cz.metacentrum.perun.core.api.Vo) GroupSyncStarted(cz.metacentrum.perun.audit.events.GroupManagerEvents.GroupSyncStarted) GroupExistsException(cz.metacentrum.perun.core.api.exceptions.GroupExistsException) ExtSource(cz.metacentrum.perun.core.api.ExtSource) Matcher(java.util.regex.Matcher) RelationExistsException(cz.metacentrum.perun.core.api.exceptions.RelationExistsException) Collections.reverseOrder(java.util.Collections.reverseOrder) Map(java.util.Map) AssignedResource(cz.metacentrum.perun.core.api.AssignedResource) MemberGroupStatus(cz.metacentrum.perun.core.api.MemberGroupStatus) PerunPrincipal(cz.metacentrum.perun.core.api.PerunPrincipal) ExtSourceApi(cz.metacentrum.perun.core.implApi.ExtSourceApi) Attribute(cz.metacentrum.perun.core.api.Attribute) Facility(cz.metacentrum.perun.core.api.Facility) GroupResourceStatus(cz.metacentrum.perun.core.api.GroupResourceStatus) GroupRelationCannotBeRemoved(cz.metacentrum.perun.core.api.exceptions.GroupRelationCannotBeRemoved) MemberAlreadyRemovedException(cz.metacentrum.perun.core.api.exceptions.MemberAlreadyRemovedException) ParserException(cz.metacentrum.perun.core.api.exceptions.ParserException) BeansUtils(cz.metacentrum.perun.core.api.BeansUtils) UserExtSource(cz.metacentrum.perun.core.api.UserExtSource) GroupMoveNotAllowedException(cz.metacentrum.perun.core.api.exceptions.GroupMoveNotAllowedException) AttributeDefinition(cz.metacentrum.perun.core.api.AttributeDefinition) Set(java.util.Set) PerunSessionImpl(cz.metacentrum.perun.core.impl.PerunSessionImpl) ExtSourceNotExistsException(cz.metacentrum.perun.core.api.exceptions.ExtSourceNotExistsException) AttributeNotExistsException(cz.metacentrum.perun.core.api.exceptions.AttributeNotExistsException) RoleCannotBeManagedException(cz.metacentrum.perun.core.api.exceptions.RoleCannotBeManagedException) User(cz.metacentrum.perun.core.api.User) GroupResourceMismatchException(cz.metacentrum.perun.core.api.exceptions.GroupResourceMismatchException) EnrichedGroup(cz.metacentrum.perun.core.api.EnrichedGroup) SecurityTeam(cz.metacentrum.perun.core.api.SecurityTeam) IndirectMemberRemovedFromGroup(cz.metacentrum.perun.audit.events.GroupManagerEvents.IndirectMemberRemovedFromGroup) RichMember(cz.metacentrum.perun.core.api.RichMember) WrongAttributeAssignmentException(cz.metacentrum.perun.core.api.exceptions.WrongAttributeAssignmentException) MemberResourceMismatchException(cz.metacentrum.perun.core.api.exceptions.MemberResourceMismatchException) GroupSyncFinished(cz.metacentrum.perun.audit.events.GroupManagerEvents.GroupSyncFinished) ExtSourceNotAssignedException(cz.metacentrum.perun.core.api.exceptions.ExtSourceNotAssignedException) ExtSourceUnsupportedOperationException(cz.metacentrum.perun.core.api.exceptions.ExtSourceUnsupportedOperationException) GroupNotExistsException(cz.metacentrum.perun.core.api.exceptions.GroupNotExistsException) SynchronizationPool(cz.metacentrum.perun.core.impl.SynchronizationPool) GroupCreatedAsSubgroup(cz.metacentrum.perun.audit.events.GroupManagerEvents.GroupCreatedAsSubgroup) MemberGroupMismatchException(cz.metacentrum.perun.core.api.exceptions.MemberGroupMismatchException) CandidateGroup(cz.metacentrum.perun.core.api.CandidateGroup) GroupSyncFinishedWithErrors(cz.metacentrum.perun.audit.events.GroupManagerEvents.GroupSyncFinishedWithErrors) GroupNotAllowedToAutoRegistrationException(cz.metacentrum.perun.core.api.exceptions.GroupNotAllowedToAutoRegistrationException) LocalDateTime(java.time.LocalDateTime) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) GroupsManagerBl(cz.metacentrum.perun.core.bl.GroupsManagerBl) ExtSourceAlreadyAssignedException(cz.metacentrum.perun.core.api.exceptions.ExtSourceAlreadyAssignedException) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) UserExtSourceExistsException(cz.metacentrum.perun.core.api.exceptions.UserExtSourceExistsException) GroupsManagerImplApi(cz.metacentrum.perun.core.implApi.GroupsManagerImplApi) GroupRelationDoesNotExist(cz.metacentrum.perun.core.api.exceptions.GroupRelationDoesNotExist) GroupAlreadyAssignedException(cz.metacentrum.perun.core.api.exceptions.GroupAlreadyAssignedException) GroupCreatedInVo(cz.metacentrum.perun.audit.events.GroupManagerEvents.GroupCreatedInVo) AlreadyAdminException(cz.metacentrum.perun.core.api.exceptions.AlreadyAdminException) ExtSourceSimpleApi(cz.metacentrum.perun.core.implApi.ExtSourceSimpleApi) RichUser(cz.metacentrum.perun.core.api.RichUser) GroupStructureSynchronizationAlreadyRunningException(cz.metacentrum.perun.core.api.exceptions.GroupStructureSynchronizationAlreadyRunningException) Member(cz.metacentrum.perun.core.api.Member) GroupUpdated(cz.metacentrum.perun.audit.events.GroupManagerEvents.GroupUpdated) RichGroup(cz.metacentrum.perun.core.api.RichGroup) AbstractMembershipExpirationRulesModule(cz.metacentrum.perun.core.implApi.modules.attributes.AbstractMembershipExpirationRulesModule) ResourceNotExistsException(cz.metacentrum.perun.core.api.exceptions.ResourceNotExistsException) AlreadyMemberException(cz.metacentrum.perun.core.api.exceptions.AlreadyMemberException) AttributesManager(cz.metacentrum.perun.core.api.AttributesManager) ExtendMembershipException(cz.metacentrum.perun.core.api.exceptions.ExtendMembershipException) MemberExpiredInGroup(cz.metacentrum.perun.audit.events.GroupManagerEvents.MemberExpiredInGroup) MemberValidatedInGroup(cz.metacentrum.perun.audit.events.GroupManagerEvents.MemberValidatedInGroup) ChronoUnit(java.time.temporal.ChronoUnit) TreeMap(java.util.TreeMap) Utils(cz.metacentrum.perun.core.impl.Utils) MDC(org.slf4j.MDC) InvalidLoginException(cz.metacentrum.perun.core.api.exceptions.InvalidLoginException) GroupsPageQuery(cz.metacentrum.perun.core.api.GroupsPageQuery) UserExtSourceNotExistsException(cz.metacentrum.perun.core.api.exceptions.UserExtSourceNotExistsException) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) Candidate(cz.metacentrum.perun.core.api.Candidate) AuthzResolver(cz.metacentrum.perun.core.api.AuthzResolver) Date(java.util.Date) MemberNotExistsException(cz.metacentrum.perun.core.api.exceptions.MemberNotExistsException) LoggerFactory(org.slf4j.LoggerFactory) MemberRemovedFromGroupTotally(cz.metacentrum.perun.audit.events.GroupManagerEvents.MemberRemovedFromGroupTotally) UserNotAdminException(cz.metacentrum.perun.core.api.exceptions.UserNotAdminException) LoginNotExistsException(cz.metacentrum.perun.core.api.exceptions.LoginNotExistsException) ExtSourcesManager(cz.metacentrum.perun.core.api.ExtSourcesManager) GroupAlreadyRemovedFromResourceException(cz.metacentrum.perun.core.api.exceptions.GroupAlreadyRemovedFromResourceException) Role(cz.metacentrum.perun.core.api.Role) ParseException(java.text.ParseException) GroupsManager(cz.metacentrum.perun.core.api.GroupsManager) GroupRelationNotAllowed(cz.metacentrum.perun.core.api.exceptions.GroupRelationNotAllowed) MemberNotValidYetException(cz.metacentrum.perun.core.api.exceptions.MemberNotValidYetException) ImmutableSet(com.google.common.collect.ImmutableSet) CandidateNotExistsException(cz.metacentrum.perun.core.api.exceptions.CandidateNotExistsException) Timestamp(java.sql.Timestamp) Collection(java.util.Collection) Objects(java.util.Objects) VosManager(cz.metacentrum.perun.core.api.VosManager) DirectMemberRemovedFromGroup(cz.metacentrum.perun.audit.events.GroupManagerEvents.DirectMemberRemovedFromGroup) List(java.util.List) LocalDate(java.time.LocalDate) ConsistencyErrorException(cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException) Queue(java.util.Queue) Pattern(java.util.regex.Pattern) PerunBl(cz.metacentrum.perun.core.bl.PerunBl) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) GroupMoved(cz.metacentrum.perun.audit.events.GroupManagerEvents.GroupMoved) Resource(cz.metacentrum.perun.core.api.Resource) PerunSession(cz.metacentrum.perun.core.api.PerunSession) GroupNotAdminException(cz.metacentrum.perun.core.api.exceptions.GroupNotAdminException) TemporalUnit(java.time.temporal.TemporalUnit) Paginated(cz.metacentrum.perun.core.api.Paginated) HashMap(java.util.HashMap) GroupStructureSyncFailed(cz.metacentrum.perun.audit.events.GroupManagerEvents.GroupStructureSyncFailed) Group(cz.metacentrum.perun.core.api.Group) GroupSynchronizationNotEnabledException(cz.metacentrum.perun.core.api.exceptions.GroupSynchronizationNotEnabledException) PasswordDeletionFailedException(cz.metacentrum.perun.core.api.exceptions.PasswordDeletionFailedException) HashSet(java.util.HashSet) ParentGroupNotExistsException(cz.metacentrum.perun.core.api.exceptions.ParentGroupNotExistsException) GroupStructureSyncFinishedWithErrors(cz.metacentrum.perun.audit.events.GroupManagerEvents.GroupStructureSyncFinishedWithErrors) GroupAlreadyRemovedException(cz.metacentrum.perun.core.api.exceptions.GroupAlreadyRemovedException) GroupDeleted(cz.metacentrum.perun.audit.events.GroupManagerEvents.GroupDeleted) PerunLocksUtils.lockGroupMembership(cz.metacentrum.perun.core.impl.PerunLocksUtils.lockGroupMembership) NotGroupMemberException(cz.metacentrum.perun.core.api.exceptions.NotGroupMemberException) DirectMemberAddedToGroup(cz.metacentrum.perun.audit.events.GroupManagerEvents.DirectMemberAddedToGroup) PasswordOperationTimeoutException(cz.metacentrum.perun.core.api.exceptions.PasswordOperationTimeoutException) AttributeValueException(cz.metacentrum.perun.core.api.exceptions.AttributeValueException) Comparator.comparingInt(java.util.Comparator.comparingInt) GroupRelationAlreadyExists(cz.metacentrum.perun.core.api.exceptions.GroupRelationAlreadyExists) Logger(org.slf4j.Logger) Iterator(java.util.Iterator) GroupSyncFailed(cz.metacentrum.perun.audit.events.GroupManagerEvents.GroupSyncFailed) WrongReferenceAttributeValueException(cz.metacentrum.perun.core.api.exceptions.WrongReferenceAttributeValueException) ActionType(cz.metacentrum.perun.core.api.ActionType) WrongAttributeValueException(cz.metacentrum.perun.core.api.exceptions.WrongAttributeValueException) MembershipType(cz.metacentrum.perun.core.api.MembershipType) Host(cz.metacentrum.perun.core.api.Host) IndirectMemberAddedToGroup(cz.metacentrum.perun.audit.events.GroupManagerEvents.IndirectMemberAddedToGroup) VoNotExistsException(cz.metacentrum.perun.core.api.exceptions.VoNotExistsException) Collectors.toList(java.util.stream.Collectors.toList) PerunClient(cz.metacentrum.perun.core.api.PerunClient) DateTimeFormatter(java.time.format.DateTimeFormatter) ExtSourceAlreadyRemovedException(cz.metacentrum.perun.core.api.exceptions.ExtSourceAlreadyRemovedException) UserNotExistsException(cz.metacentrum.perun.core.api.exceptions.UserNotExistsException) Comparator(java.util.Comparator) Collections(java.util.Collections) Status(cz.metacentrum.perun.core.api.Status) GroupNotDefinedOnResourceException(cz.metacentrum.perun.core.api.exceptions.GroupNotDefinedOnResourceException) EnrichedGroup(cz.metacentrum.perun.core.api.EnrichedGroup) IndirectMemberRemovedFromGroup(cz.metacentrum.perun.audit.events.GroupManagerEvents.IndirectMemberRemovedFromGroup) CandidateGroup(cz.metacentrum.perun.core.api.CandidateGroup) RichGroup(cz.metacentrum.perun.core.api.RichGroup) MemberExpiredInGroup(cz.metacentrum.perun.audit.events.GroupManagerEvents.MemberExpiredInGroup) MemberValidatedInGroup(cz.metacentrum.perun.audit.events.GroupManagerEvents.MemberValidatedInGroup) DirectMemberRemovedFromGroup(cz.metacentrum.perun.audit.events.GroupManagerEvents.DirectMemberRemovedFromGroup) Group(cz.metacentrum.perun.core.api.Group) DirectMemberAddedToGroup(cz.metacentrum.perun.audit.events.GroupManagerEvents.DirectMemberAddedToGroup) IndirectMemberAddedToGroup(cz.metacentrum.perun.audit.events.GroupManagerEvents.IndirectMemberAddedToGroup) GroupNotExistsException(cz.metacentrum.perun.core.api.exceptions.GroupNotExistsException) ParentGroupNotExistsException(cz.metacentrum.perun.core.api.exceptions.ParentGroupNotExistsException) GroupNotDefinedOnResourceException(cz.metacentrum.perun.core.api.exceptions.GroupNotDefinedOnResourceException) GroupAlreadyRemovedFromResourceException(cz.metacentrum.perun.core.api.exceptions.GroupAlreadyRemovedFromResourceException) AssignedResource(cz.metacentrum.perun.core.api.AssignedResource)

Example 9 with AssignedResource

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

the class ResourcesManagerImpl method getAssignedResourcesWithStatus.

@Override
public List<AssignedResource> getAssignedResourcesWithStatus(PerunSession sess, Member member) {
    try {
        List<AssignedResource> resources = jdbc.query("select distinct " + assignedResourceMappingSelectQuery + " from resources" + " join (SELECT group_id, resource_id, NULL as source_group_id, auto_assign_subgroups FROM groups_resources" + "	UNION" + "	SELECT group_id, resource_id, source_group_id, true as auto_assign_subgroups FROM groups_resources_automatic)" + " 	groups_resources_automatic on groups_resources_automatic.resource_id = resources.id" + " join groups_resources_state on groups_resources_automatic.resource_id=groups_resources_state.resource_id and groups_resources_automatic.group_id=groups_resources_state.group_id" + " join facilities on resources.facility_id=facilities.id" + " join groups on groups_resources_state.group_id=groups.id" + " join groups_members on groups.id=groups_members.group_id" + " where groups_members.member_id=?", ASSIGNED_RESOURCE_MAPPER, member.getId());
        resources.removeIf(r1 -> resources.stream().anyMatch(r2 -> r2.getEnrichedResource().equals(r1.getEnrichedResource()) && r2.getStatus().isMoreImportantThan(r1.getStatus())));
        return resources;
    } catch (EmptyResultDataAccessException e) {
        return new ArrayList<>();
    } catch (RuntimeException e) {
        throw new InternalErrorException(e);
    }
}
Also used : InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) JdbcPerunTemplate(org.springframework.jdbc.core.JdbcPerunTemplate) Arrays(java.util.Arrays) ResourceTag(cz.metacentrum.perun.core.api.ResourceTag) Vo(cz.metacentrum.perun.core.api.Vo) ServiceNotAssignedException(cz.metacentrum.perun.core.api.exceptions.ServiceNotAssignedException) LoggerFactory(org.slf4j.LoggerFactory) GroupResourceAssignment(cz.metacentrum.perun.core.api.GroupResourceAssignment) Array(java.sql.Array) GroupAlreadyRemovedFromResourceException(cz.metacentrum.perun.core.api.exceptions.GroupAlreadyRemovedFromResourceException) ResultSet(java.sql.ResultSet) Map(java.util.Map) Role(cz.metacentrum.perun.core.api.Role) AssignedResource(cz.metacentrum.perun.core.api.AssignedResource) MemberGroupStatus(cz.metacentrum.perun.core.api.MemberGroupStatus) EmptyResultDataAccessException(org.springframework.dao.EmptyResultDataAccessException) Attribute(cz.metacentrum.perun.core.api.Attribute) Facility(cz.metacentrum.perun.core.api.Facility) GroupResourceStatus(cz.metacentrum.perun.core.api.GroupResourceStatus) PreparedStatementCallback(org.springframework.jdbc.core.PreparedStatementCallback) BeansUtils(cz.metacentrum.perun.core.api.BeansUtils) ResourceAlreadyRemovedException(cz.metacentrum.perun.core.api.exceptions.ResourceAlreadyRemovedException) Set(java.util.Set) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) User(cz.metacentrum.perun.core.api.User) List(java.util.List) RowMapper(org.springframework.jdbc.core.RowMapper) AssignedGroup(cz.metacentrum.perun.core.api.AssignedGroup) ConsistencyErrorException(cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException) Service(cz.metacentrum.perun.core.api.Service) Resource(cz.metacentrum.perun.core.api.Resource) PerunSession(cz.metacentrum.perun.core.api.PerunSession) ObjectUtils.isEmpty(org.apache.commons.lang3.ObjectUtils.isEmpty) AssignedMember(cz.metacentrum.perun.core.api.AssignedMember) HashMap(java.util.HashMap) Group(cz.metacentrum.perun.core.api.Group) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) SQLException(java.sql.SQLException) GroupAlreadyAssignedException(cz.metacentrum.perun.core.api.exceptions.GroupAlreadyAssignedException) DataSource(javax.sql.DataSource) AuthzResolverBlImpl(cz.metacentrum.perun.core.blImpl.AuthzResolverBlImpl) BanOnResource(cz.metacentrum.perun.core.api.BanOnResource) MEMBER_MAPPER(cz.metacentrum.perun.core.impl.MembersManagerImpl.MEMBER_MAPPER) RichResource(cz.metacentrum.perun.core.api.RichResource) ServiceAlreadyAssignedException(cz.metacentrum.perun.core.api.exceptions.ServiceAlreadyAssignedException) Member(cz.metacentrum.perun.core.api.Member) Logger(org.slf4j.Logger) DatabaseManagerBl(cz.metacentrum.perun.core.bl.DatabaseManagerBl) ResourceNotExistsException(cz.metacentrum.perun.core.api.exceptions.ResourceNotExistsException) BanNotExistsException(cz.metacentrum.perun.core.api.exceptions.BanNotExistsException) EnrichedResource(cz.metacentrum.perun.core.api.EnrichedResource) ResourcesManagerImplApi(cz.metacentrum.perun.core.implApi.ResourcesManagerImplApi) Status(cz.metacentrum.perun.core.api.Status) ResourceTagNotExistsException(cz.metacentrum.perun.core.api.exceptions.ResourceTagNotExistsException) ResultSetExtractor(org.springframework.jdbc.core.ResultSetExtractor) GroupNotDefinedOnResourceException(cz.metacentrum.perun.core.api.exceptions.GroupNotDefinedOnResourceException) EmptyResultDataAccessException(org.springframework.dao.EmptyResultDataAccessException) InternalErrorException(cz.metacentrum.perun.core.api.exceptions.InternalErrorException) AssignedResource(cz.metacentrum.perun.core.api.AssignedResource)

Aggregations

AssignedResource (cz.metacentrum.perun.core.api.AssignedResource)9 Group (cz.metacentrum.perun.core.api.Group)6 EnrichedGroup (cz.metacentrum.perun.core.api.EnrichedGroup)5 ConsistencyErrorException (cz.metacentrum.perun.core.api.exceptions.ConsistencyErrorException)5 DirectMemberAddedToGroup (cz.metacentrum.perun.audit.events.GroupManagerEvents.DirectMemberAddedToGroup)4 DirectMemberRemovedFromGroup (cz.metacentrum.perun.audit.events.GroupManagerEvents.DirectMemberRemovedFromGroup)4 IndirectMemberAddedToGroup (cz.metacentrum.perun.audit.events.GroupManagerEvents.IndirectMemberAddedToGroup)4 IndirectMemberRemovedFromGroup (cz.metacentrum.perun.audit.events.GroupManagerEvents.IndirectMemberRemovedFromGroup)4 MemberExpiredInGroup (cz.metacentrum.perun.audit.events.GroupManagerEvents.MemberExpiredInGroup)4 MemberValidatedInGroup (cz.metacentrum.perun.audit.events.GroupManagerEvents.MemberValidatedInGroup)4 CandidateGroup (cz.metacentrum.perun.core.api.CandidateGroup)4 EnrichedResource (cz.metacentrum.perun.core.api.EnrichedResource)4 Resource (cz.metacentrum.perun.core.api.Resource)4 RichGroup (cz.metacentrum.perun.core.api.RichGroup)4 Vo (cz.metacentrum.perun.core.api.Vo)4 GroupAlreadyAssignedException (cz.metacentrum.perun.core.api.exceptions.GroupAlreadyAssignedException)4 GroupCreatedInVo (cz.metacentrum.perun.audit.events.GroupManagerEvents.GroupCreatedInVo)3 AbstractPerunIntegrationTest (cz.metacentrum.perun.core.AbstractPerunIntegrationTest)3 Facility (cz.metacentrum.perun.core.api.Facility)3 Member (cz.metacentrum.perun.core.api.Member)3