// Token: 0x06001355 RID: 4949 RVA: 0x000778B0 File Offset: 0x00075AB0
 public QueryFilter Execute(string searchString, bool isContentIndexingEnabled, Folder folder, SearchScope searchScope)
 {
     this.searchScope = searchScope;
     this.folderClass = folder.ClassName;
     if (searchString != null)
     {
         this.queryFilter = AqsParser.ParseAndBuildQuery(searchString, SearchFilterGenerator.GetAqsParseOption(folder, isContentIndexingEnabled), this.userCultureInfo, RescopedAll.Default, null, this.policyTagProvider);
     }
     if (this.advancedQueryFilter != null)
     {
         if (this.queryFilter == null)
         {
             this.queryFilter = this.advancedQueryFilter;
         }
         else
         {
             this.queryFilter = new AndFilter(new QueryFilter[]
             {
                 this.queryFilter,
                 this.advancedQueryFilter
             });
         }
     }
     if (this.queryFilter == null)
     {
         return(null);
     }
     this.AddItemTypeFilter();
     return(this.queryFilter);
 }
Exemple #2
0
        public SearchWorkDefinition ParseSearch(ComplianceMessage target, SearchWorkDefinition definition)
        {
            QueryFilter     queryFilter = null;
            string          query       = definition.Query;
            CultureInfo     culture;
            FaultDefinition faultDefinition;

            ExceptionHandler.Parser.TryRun(delegate
            {
                if (string.IsNullOrEmpty(target.Culture))
                {
                    culture = CultureInfo.InvariantCulture;
                }
                else
                {
                    culture = CultureInfo.GetCultureInfo(target.Culture);
                }
                Func <IRecipientResolver, IPolicyTagProvider, QueryFilter> func = null;
                switch (definition.Parser)
                {
                case SearchWorkDefinition.QueryParser.KQL:
                    func = ((IRecipientResolver r, IPolicyTagProvider p) => KqlParser.ParseAndBuildQuery(query, KqlParser.ParseOption.EDiscoveryMode, culture, r, p));
                    break;

                case SearchWorkDefinition.QueryParser.AQS:
                    func = delegate(IRecipientResolver r, IPolicyTagProvider p)
                    {
                        AqsParser.ParseOption parseOption = AqsParser.ParseOption.UseCiKeywordOnly | AqsParser.ParseOption.DisablePrefixMatch | AqsParser.ParseOption.AllowShortWildcards;
                        return(AqsParser.ParseAndBuildQuery(query, parseOption, culture, r, p));
                    };
                    break;
                }
                if (func != null)
                {
                    OrganizationId scopingOrganizationId = null;
                    IPolicyTagProvider arg  = null;
                    IRecipientResolver arg2 = null;
                    if (OrganizationId.TryCreateFromBytes(target.TenantId, Encoding.UTF8, out scopingOrganizationId))
                    {
                        ADSessionSettings adsessionSettings               = ADSessionSettings.FromOrganizationIdWithoutRbacScopesServiceOnly(scopingOrganizationId);
                        adsessionSettings.IncludeInactiveMailbox          = true;
                        IRecipientSession tenantOrRootOrgRecipientSession = DirectorySessionFactory.Default.GetTenantOrRootOrgRecipientSession(ConsistencyMode.PartiallyConsistent, adsessionSettings, 146, "ParseSearch", "f:\\15.00.1497\\sources\\dev\\EDiscovery\\src\\TaskDistributionSystem\\ApplicationPlugins\\EDiscovery\\FastLocalSearchResultsProvider.cs");
                        arg2 = new FastLocalSearchResultsProvider.RecipientIdentityResolver(tenantOrRootOrgRecipientSession);
                        IConfigurationSession tenantOrTopologyConfigurationSession = DirectorySessionFactory.Default.GetTenantOrTopologyConfigurationSession(ConsistencyMode.IgnoreInvalid, adsessionSettings, 149, "ParseSearch", "f:\\15.00.1497\\sources\\dev\\EDiscovery\\src\\TaskDistributionSystem\\ApplicationPlugins\\EDiscovery\\FastLocalSearchResultsProvider.cs");
                        arg = new PolicyTagAdProvider(tenantOrTopologyConfigurationSession);
                    }
                    queryFilter = func(arg2, arg);
                }
                if (queryFilter != null)
                {
                    definition.Query = FqlQueryBuilder.ToFqlString(queryFilter, culture);
                }
            }, TimeSpan.FromMinutes(1.0), out faultDefinition, target, null, default(CancellationToken), null, "ParseSearch", "f:\\15.00.1497\\sources\\dev\\EDiscovery\\src\\TaskDistributionSystem\\ApplicationPlugins\\EDiscovery\\FastLocalSearchResultsProvider.cs", 102);
            if (faultDefinition != null)
            {
                ExceptionHandler.FaultMessage(target, faultDefinition, true);
            }
            return(definition);
        }
Exemple #3
0
 internal void GenerateSubQueryFilters(IRecipientSession recipientSession, IConfigurationSession configurationSession)
 {
     if (!string.IsNullOrEmpty(this.userQuery))
     {
         SearchMailboxCriteria.RecipientIdentityResolver recipientResolver = null;
         if (recipientSession != null)
         {
             recipientResolver = new SearchMailboxCriteria.RecipientIdentityResolver(recipientSession);
         }
         PolicyTagAdProvider policyTagProvider = null;
         if (configurationSession != null)
         {
             policyTagProvider = new PolicyTagAdProvider(configurationSession);
         }
         QueryFilter queryFilter = KqlParser.ParseAndBuildQuery(this.userQuery, KqlParser.ParseOption.ImplicitOr | KqlParser.ParseOption.UseCiKeywordOnly | KqlParser.ParseOption.DisablePrefixMatch | KqlParser.ParseOption.AllowShortWildcards | KqlParser.ParseOption.EDiscoveryMode, this.QueryCulture, RescopedAll.Default, recipientResolver, policyTagProvider);
         if (queryFilter == null)
         {
             throw new SearchQueryEmptyException();
         }
         ICollection <QueryFilter> collection = null;
         if (queryFilter != null && queryFilter.GetType() == typeof(OrFilter))
         {
             collection = AqsParser.FlattenQueryFilter(queryFilter);
         }
         if (collection != null && collection.Count > 1)
         {
             string      text         = this.searchQuery.Replace(this.userQuery, "");
             QueryFilter queryFilter2 = null;
             if (!string.IsNullOrEmpty(text))
             {
                 queryFilter2 = KqlParser.ParseAndBuildQuery(text, KqlParser.ParseOption.ImplicitOr | KqlParser.ParseOption.UseCiKeywordOnly | KqlParser.ParseOption.DisablePrefixMatch | KqlParser.ParseOption.AllowShortWildcards | KqlParser.ParseOption.EDiscoveryMode, this.QueryCulture, RescopedAll.Default, recipientResolver, policyTagProvider);
             }
             this.subfilters = new Dictionary <string, QueryFilter>(collection.Count);
             int num = 0;
             foreach (QueryFilter queryFilter3 in collection)
             {
                 string      keywordPhrase = MailboxDiscoverySearch.GetKeywordPhrase(queryFilter3, this.userQuery, ref num);
                 QueryFilter value;
                 if (queryFilter2 == null)
                 {
                     value = queryFilter3;
                 }
                 else
                 {
                     value = new AndFilter(new QueryFilter[]
                     {
                         queryFilter2,
                         queryFilter3
                     });
                 }
                 if (!this.subfilters.ContainsKey(keywordPhrase))
                 {
                     this.subfilters.Add(keywordPhrase, value);
                 }
             }
         }
     }
 }
 public QueryFilter Execute(string searchString, bool contentIndexingEnabled, Dictionary <string, bool> folderClass, SearchScope searchScope, CultureInfo cultureInfo)
 {
     if (searchString.Trim().Length == 0)
     {
         return(null);
     }
     this.queryFilter = AqsParser.ParseAndBuildQuery(searchString, AqsParser.ParseOption.SuppressError | (contentIndexingEnabled ? AqsParser.ParseOption.None : AqsParser.ParseOption.ContentIndexingDisabled), cultureInfo, RescopedAll.Default, null, null);
     if (this.queryFilter == null)
     {
         return(null);
     }
     this.AddItemTypeFilter(searchScope, folderClass);
     return(this.queryFilter);
 }
Exemple #5
0
        internal static string ConvertAqsToKql(string aqsString, CultureInfo culture)
        {
            if (string.IsNullOrEmpty(aqsString))
            {
                return(aqsString);
            }
            Exception   ex          = null;
            QueryFilter queryFilter = null;

            try
            {
                queryFilter = AqsParser.ParseAndBuildQuery(aqsString, AqsParser.ParseOption.UseCiKeywordOnly | AqsParser.ParseOption.DisablePrefixMatch | AqsParser.ParseOption.QueryConverting | AqsParser.ParseOption.AllowShortWildcards, culture, RescopedAll.Default, null, null);
            }
            catch (ParserException ex2)
            {
                ex = ex2;
            }
            if (queryFilter == null)
            {
                throw new MailboxSearchTaskException(Strings.CannotConvertAqsToKql(ex.Message ?? string.Empty));
            }
            string text = null;

            ex = null;
            try
            {
                text = queryFilter.GenerateInfixString(FilterLanguage.Kql);
                QueryFilter aqsFilter = AqsParser.ParseAndBuildQuery(aqsString, AqsParser.ParseOption.UseCiKeywordOnly | AqsParser.ParseOption.DisablePrefixMatch | AqsParser.ParseOption.AllowShortWildcards, culture, RescopedAll.Default, null, null);
                QueryFilter kqlFilter = KqlParser.ParseAndBuildQuery(text, KqlParser.ParseOption.ImplicitOr | KqlParser.ParseOption.UseCiKeywordOnly | KqlParser.ParseOption.DisablePrefixMatch | KqlParser.ParseOption.AllowShortWildcards, culture, RescopedAll.Default, null, null);
                if (!Utils.VerifyQueryFilters(aqsFilter, kqlFilter))
                {
                    throw new MailboxSearchTaskException(Strings.CannotConvertAqsToKql(string.Empty));
                }
            }
            catch (ParserException ex3)
            {
                ex = ex3;
            }
            catch (ArgumentOutOfRangeException ex4)
            {
                ex = ex4;
            }
            if (ex != null)
            {
                throw new MailboxSearchTaskException(Strings.CannotConvertAqsToKql(ex.Message));
            }
            return(text);
        }
Exemple #6
0
 protected override void ValidateWrite(List <ValidationError> errors)
 {
     base.ValidateWrite(errors);
     if (this.SourceMailboxes.Contains(base.Id.MailboxOwnerId))
     {
         errors.Add(new PropertyValidationError(ServerStrings.DiscoveryMailboxCannotBeSourceOrTarget(base.Id.MailboxOwnerId.DistinguishedName), SearchObjectSchema.SourceMailboxes, this.SourceMailboxes));
     }
     if (this.TargetMailbox != null)
     {
         if (this.SourceMailboxes.Contains(this.TargetMailbox))
         {
             errors.Add(new PropertyValidationError(ServerStrings.SearchTargetInSource, SearchObjectSchema.TargetMailbox, this.TargetMailbox));
         }
         if (this.TargetMailbox.Equals(base.Id.MailboxOwnerId))
         {
             errors.Add(new PropertyValidationError(ServerStrings.DiscoveryMailboxCannotBeSourceOrTarget(base.Id.MailboxOwnerId.DistinguishedName), SearchObjectSchema.TargetMailbox, this.TargetMailbox));
         }
     }
     if (this.StartDate != null && this.EndDate != null && this.StartDate > this.EndDate)
     {
         errors.Add(new PropertyValidationError(ServerStrings.InvalidateDateRange, SearchObjectSchema.StartDate, this.StartDate));
     }
     KindKeyword[] second = new KindKeyword[]
     {
         KindKeyword.faxes,
         KindKeyword.voicemail,
         KindKeyword.rssfeeds,
         KindKeyword.posts
     };
     if (this.MessageTypes.Intersect(second).Count <KindKeyword>() > 0)
     {
         errors.Add(new PropertyValidationError(ServerStrings.UnsupportedKindKeywords, SearchObjectSchema.MessageTypes, this.MessageTypes));
     }
     if (!string.IsNullOrEmpty(this.SearchQuery))
     {
         try
         {
             AqsParser aqsParser = new AqsParser();
             aqsParser.Parse(this.SearchQuery, AqsParser.ParseOption.None, this.Language).Dispose();
         }
         catch (ParserException ex)
         {
             errors.Add(new PropertyValidationError(ex.LocalizedString, SearchObjectSchema.SearchQuery, this.SearchQuery));
         }
     }
 }
        private bool InternalTryAqsMatch(IList <StoreObjectId> storeIds, string searchString, CultureInfo cultureinfo, out IList <string> bodySearchString, out List <IConversationTreeNode> nodes)
        {
            nodes            = null;
            bodySearchString = null;
            AqsParser aqsParser = new AqsParser();

            using (Condition condition = aqsParser.Parse(searchString, AqsParser.ParseOption.SuppressError, cultureinfo))
            {
                bodySearchString = Conversation.ConditionToBodyQueryString(condition);
                if (bodySearchString == null || bodySearchString.Count < 1)
                {
                    nodes = this.MatchAllNodes(storeIds);
                    return(true);
                }
            }
            return(false);
        }
        private IDictionary <string, QueryFilter> GetSubFilters(QueryFilter filter)
        {
            if (filter == null)
            {
                return(null);
            }
            if (!(filter.GetType() == typeof(OrFilter)))
            {
                return(null);
            }
            IDictionary <string, QueryFilter> subQueryString = this.GetSubQueryString(AqsParser.FlattenQueryFilter(filter));

            if (subQueryString != null && subQueryString.Count == 1)
            {
                Factory.Current.LocalTaskTracer.TraceInformation <Guid, string>(this.GetHashCode(), 0L, "Correlation Id:{0}. The query filter {1} is an OrFilter, but it only returns one sub filter.", this.queryCorrelationId, filter.ToString());
                return(null);
            }
            return(subQueryString);
        }