Search in sources :

Example 16 with FilterBuilder

use of org.elasticsearch.index.query.FilterBuilder in project alien4cloud by alien4cloud.

the class ResourcePermissionEventsListener method deleteEnvironmentPermissionOn.

private void deleteEnvironmentPermissionOn(String environmentId, Class<?>... resourceClasses) throws IOException, ClassNotFoundException {
    FilterBuilder resourceFilter = FilterBuilders.nestedFilter("environmentPermissions", FilterBuilders.termFilter("environmentPermissions.key", environmentId));
    deletePermissions(resourceFilter, environmentId, ((resource, subjectId) -> resourcePermissionService.revokePermission(resource, Subject.ENVIRONMENT, subjectId)), resourceClasses);
}
Also used : BeforeApplicationDeleted(org.alien4cloud.alm.events.BeforeApplicationDeleted) Arrays(java.util.Arrays) TypeScanner(alien4cloud.utils.TypeScanner) GetMultipleDataResult(alien4cloud.dao.model.GetMultipleDataResult) FilterBuilder(org.elasticsearch.index.query.FilterBuilder) Subject(alien4cloud.security.Subject) AbstractSecurityEnabledResource(alien4cloud.security.AbstractSecurityEnabledResource) GroupDeletedEvent(alien4cloud.security.event.GroupDeletedEvent) FilterBuilders(org.elasticsearch.index.query.FilterBuilders) Resource(javax.annotation.Resource) EventListener(org.springframework.context.event.EventListener) Set(java.util.Set) IGenericSearchDAO(alien4cloud.dao.IGenericSearchDAO) ArrayUtils(org.apache.commons.lang3.ArrayUtils) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) BeforeApplicationEnvironmentDeleted(org.alien4cloud.alm.events.BeforeApplicationEnvironmentDeleted) Component(org.springframework.stereotype.Component) BeforeApplicationEnvironmentTypeDeleted(org.alien4cloud.alm.events.BeforeApplicationEnvironmentTypeDeleted) UserDeletedEvent(alien4cloud.security.event.UserDeletedEvent) LocationResourceTemplate(alien4cloud.model.orchestrators.locations.LocationResourceTemplate) AfterPermissionRevokedEvent(org.alien4cloud.alm.events.AfterPermissionRevokedEvent) FilterBuilder(org.elasticsearch.index.query.FilterBuilder)

Example 17 with FilterBuilder

use of org.elasticsearch.index.query.FilterBuilder in project alien4cloud by alien4cloud.

the class ResourcePermissionEventsListener method deleteUserPermissionOn.

private void deleteUserPermissionOn(String username, Class<?>... resourceClasses) throws IOException, ClassNotFoundException {
    FilterBuilder resourceFilter = FilterBuilders.nestedFilter("userPermissions", FilterBuilders.termFilter("userPermissions.key", username));
    deletePermissions(resourceFilter, username, ((resource, subjectId) -> resourcePermissionService.revokePermission(resource, Subject.USER, subjectId)), resourceClasses);
}
Also used : BeforeApplicationDeleted(org.alien4cloud.alm.events.BeforeApplicationDeleted) Arrays(java.util.Arrays) TypeScanner(alien4cloud.utils.TypeScanner) GetMultipleDataResult(alien4cloud.dao.model.GetMultipleDataResult) FilterBuilder(org.elasticsearch.index.query.FilterBuilder) Subject(alien4cloud.security.Subject) AbstractSecurityEnabledResource(alien4cloud.security.AbstractSecurityEnabledResource) GroupDeletedEvent(alien4cloud.security.event.GroupDeletedEvent) FilterBuilders(org.elasticsearch.index.query.FilterBuilders) Resource(javax.annotation.Resource) EventListener(org.springframework.context.event.EventListener) Set(java.util.Set) IGenericSearchDAO(alien4cloud.dao.IGenericSearchDAO) ArrayUtils(org.apache.commons.lang3.ArrayUtils) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) BeforeApplicationEnvironmentDeleted(org.alien4cloud.alm.events.BeforeApplicationEnvironmentDeleted) Component(org.springframework.stereotype.Component) BeforeApplicationEnvironmentTypeDeleted(org.alien4cloud.alm.events.BeforeApplicationEnvironmentTypeDeleted) UserDeletedEvent(alien4cloud.security.event.UserDeletedEvent) LocationResourceTemplate(alien4cloud.model.orchestrators.locations.LocationResourceTemplate) AfterPermissionRevokedEvent(org.alien4cloud.alm.events.AfterPermissionRevokedEvent) FilterBuilder(org.elasticsearch.index.query.FilterBuilder)

Example 18 with FilterBuilder

use of org.elasticsearch.index.query.FilterBuilder in project alien4cloud by alien4cloud.

the class DeploymentService method buildDeploymentFilters.

private FilterBuilder buildDeploymentFilters(String orchestratorId, String sourceId, String environmentId) {
    FilterBuilder filterBuilder = null;
    if (orchestratorId != null) {
        FilterBuilder orchestratorFilter = FilterBuilders.termFilter("orchestratorId", orchestratorId);
        filterBuilder = filterBuilder == null ? orchestratorFilter : FilterBuilders.andFilter(orchestratorFilter, filterBuilder);
    }
    if (environmentId != null) {
        FilterBuilder environmentFilter = FilterBuilders.termFilter("environmentId", environmentId);
        filterBuilder = filterBuilder == null ? environmentFilter : FilterBuilders.andFilter(environmentFilter, filterBuilder);
    }
    if (sourceId != null) {
        FilterBuilder sourceFilter = FilterBuilders.termFilter("sourceId", sourceId);
        filterBuilder = filterBuilder == null ? sourceFilter : FilterBuilders.andFilter(sourceFilter, filterBuilder);
    }
    return filterBuilder;
}
Also used : FilterBuilder(org.elasticsearch.index.query.FilterBuilder)

Example 19 with FilterBuilder

use of org.elasticsearch.index.query.FilterBuilder in project alien4cloud by alien4cloud.

the class ResourceRoleService method deleteGroupRoles.

/**
 * Delete a groupRoles entry (groupId) in all ISecuredResource object
 *
 * @param groupId group id to remove in groupRoles
 * @throws ClassNotFoundException
 * @throws IOException
 */
private void deleteGroupRoles(String groupId) throws ClassNotFoundException, IOException {
    FilterBuilder resourceFilter = FilterBuilders.nestedFilter("groupRoles", FilterBuilders.termFilter("groupRoles.key", groupId));
    deleteRoles(resourceFilter, groupId, new DeleteRoleVisitor() {

        @Override
        public void deleteRoleOfOwner(Object[] securedResources, String owner) {
            deleteRoleOfGroup(securedResources, owner);
        }
    });
}
Also used : FilterBuilder(org.elasticsearch.index.query.FilterBuilder)

Example 20 with FilterBuilder

use of org.elasticsearch.index.query.FilterBuilder in project alien4cloud by alien4cloud.

the class ResourceRoleService method deleteUserRoles.

/**
 * Delete a userRoles entry (userId) in all ISecuredResource object
 *
 * @param userId user id (username) to remove in userRoles
 * @throws ClassNotFoundException
 * @throws IOException
 */
private void deleteUserRoles(String userId) throws ClassNotFoundException, IOException {
    FilterBuilder resourceFilter = FilterBuilders.nestedFilter("userRoles", FilterBuilders.termFilter("userRoles.key", userId));
    deleteRoles(resourceFilter, userId, new DeleteRoleVisitor() {

        @Override
        public void deleteRoleOfOwner(Object[] securedResources, String owner) {
            deleteRoleOfUser(securedResources, owner);
        }
    });
}
Also used : FilterBuilder(org.elasticsearch.index.query.FilterBuilder)

Aggregations

FilterBuilder (org.elasticsearch.index.query.FilterBuilder)35 TermFilterBuilder (org.elasticsearch.index.query.TermFilterBuilder)14 MatchAllFilterBuilder (org.elasticsearch.index.query.MatchAllFilterBuilder)12 NotFilterBuilder (org.elasticsearch.index.query.NotFilterBuilder)12 TermsFilterBuilder (org.elasticsearch.index.query.TermsFilterBuilder)12 AndFilterBuilder (org.elasticsearch.index.query.AndFilterBuilder)11 BoolFilterBuilder (org.elasticsearch.index.query.BoolFilterBuilder)11 NestedFilterBuilder (org.elasticsearch.index.query.NestedFilterBuilder)11 OrFilterBuilder (org.elasticsearch.index.query.OrFilterBuilder)11 QueryFilterBuilder (org.elasticsearch.index.query.QueryFilterBuilder)11 RangeFilterBuilder (org.elasticsearch.index.query.RangeFilterBuilder)11 GetMultipleDataResult (alien4cloud.dao.model.GetMultipleDataResult)7 IOException (java.io.IOException)6 ArrayList (java.util.ArrayList)6 Set (java.util.Set)6 QueryBuilder (org.elasticsearch.index.query.QueryBuilder)6 IGenericSearchDAO (alien4cloud.dao.IGenericSearchDAO)5 LocationResourceTemplate (alien4cloud.model.orchestrators.locations.LocationResourceTemplate)5 AbstractSecurityEnabledResource (alien4cloud.security.AbstractSecurityEnabledResource)5 Subject (alien4cloud.security.Subject)5