Search in sources :

Example 21 with FilterBuilder

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

the class ResourcePermissionEventsListener method deleteGroupPermissionOn.

private void deleteGroupPermissionOn(String groupId, Class<?>... resourceClasses) throws IOException, ClassNotFoundException {
    FilterBuilder resourceFilter = FilterBuilders.nestedFilter("groupPermissions", FilterBuilders.termFilter("groupPermissions.key", groupId));
    deletePermissions(resourceFilter, groupId, ((resource, subjectId) -> resourcePermissionService.revokePermission(resource, Subject.GROUP, 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 22 with FilterBuilder

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

the class ResourcePermissionEventsListener method deleteApplicationPermissionOn.

private void deleteApplicationPermissionOn(String applicationId, Class<?>... resourceClasses) throws IOException, ClassNotFoundException {
    FilterBuilder resourceFilter = FilterBuilders.nestedFilter("applicationPermissions", FilterBuilders.termFilter("applicationPermissions.key", applicationId));
    deletePermissions(resourceFilter, applicationId, ((resource, subjectId) -> resourcePermissionService.revokePermission(resource, Subject.APPLICATION, 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 23 with FilterBuilder

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

the class ResourcePermissionEventsListener method deleteEnvironmentTypePermissionOn.

private void deleteEnvironmentTypePermissionOn(String environmentId, Class<?>... resourceClasses) throws IOException, ClassNotFoundException {
    FilterBuilder resourceFilter = FilterBuilders.nestedFilter("environmentTypePermissions", FilterBuilders.termFilter("environmentTypePermissions.key", environmentId));
    deletePermissions(resourceFilter, environmentId, ((resource, subjectId) -> resourcePermissionService.revokePermission(resource, Subject.ENVIRONMENT_TYPE, 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 24 with FilterBuilder

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

the class DeploymentService method getDeployments.

/**
 * Get all deployments for a given orchestrator an application
 *
 * @param orchestratorId Id of the cloud for which to get deployments (can be null to get deployments for all clouds).
 * @param sourceId Id of the application for which to get deployments (can be null to get deployments for all applications).
 * @param environmentId Id of the environment for which to get deployments (can be null to get deployments for all environments).
 * @return An array of deployments.
 */
public Deployment[] getDeployments(String orchestratorId, String sourceId, String environmentId, int from, int size) {
    FilterBuilder filterBuilder = buildDeploymentFilters(orchestratorId, sourceId, environmentId);
    IESQueryBuilderHelper<Deployment> queryBuilderHelper = alienDao.buildQuery(Deployment.class);
    return queryBuilderHelper.setFilters(filterBuilder).prepareSearch().setFieldSort("startDate", true).search(from, size).getData();
}
Also used : FilterBuilder(org.elasticsearch.index.query.FilterBuilder) Deployment(alien4cloud.model.deployment.Deployment)

Example 25 with FilterBuilder

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

the class CsarService method getDependantTopologies.

/**
 * Get teh topologies that depends on this csar.
 * Do not return a topology if this csar is his own
 *
 * @return an array of <code>Topology</code>s that depend on this name:version.
 */
public Topology[] getDependantTopologies(String name, String version) {
    FilterBuilder notSelf = FilterBuilders.notFilter(FilterBuilders.andFilter(FilterBuilders.termFilter("archiveName", name), FilterBuilders.termFilter("archiveVersion", version)));
    GetMultipleDataResult<Topology> result = csarDAO.buildQuery(Topology.class).prepareSearch().setFilters(fromKeyValueCouples("dependencies.name", name, "dependencies.version", version), notSelf).search(0, Integer.MAX_VALUE);
    return result.getData();
}
Also used : FilterBuilder(org.elasticsearch.index.query.FilterBuilder) Topology(org.alien4cloud.tosca.model.templates.Topology)

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