/// <summary>
        /// Gets the raw string (xml) from the broker db by URL
        /// </summary>
        /// <param name="Url">URL of the page</param>
        /// <returns>String with page xml or empty string if no page was found</returns>
        public string GetContentByUrl(string Url)
        {
            LoggerService.Debug(">>GetContentByUrl({0})", LoggingCategory.Performance, Url);
            string retVal = string.Empty;

            LoggerService.Debug("GetContentByUrl: about to create query", LoggingCategory.Performance);
            Query pageQuery = new Query();

            LoggerService.Debug("GetContentByUrl: created query", LoggingCategory.Performance);
            ItemTypeCriteria isPage  = new ItemTypeCriteria(64); // TODO There must be an enum of these somewhere
            PageURLCriteria  pageUrl = new PageURLCriteria(Url);

            Criteria allCriteria = CriteriaFactory.And(isPage, pageUrl);

            if (this.PublicationId != 0)
            {
                PublicationCriteria correctSite = new PublicationCriteria(this.PublicationId);
                allCriteria.AddCriteria(correctSite);
            }
            pageQuery.Criteria = allCriteria;
            LoggerService.Debug("GetContentByUrl: added criteria to query", LoggingCategory.Performance);

            LoggerService.Debug("GetContentByUrl: about to execute query", LoggingCategory.Performance);
            string[] resultUris = pageQuery.ExecuteQuery();
            LoggerService.Debug("GetContentByUrl: executed query", LoggingCategory.Performance);


            if (resultUris.Length > 0)
            {
                retVal = PageContentAssembler.GetContent(resultUris[0]);
                LoggerService.Debug("GetContentByUrl: executed PageContentAssembler", LoggingCategory.Performance);
            }
            LoggerService.Debug("<<GetContentByUrl({0})", LoggingCategory.Performance, Url);
            return(retVal);
        }
        /// <summary>
        /// Gets the raw string (xml) from the broker db by URL
        /// </summary>
        /// <param name="Url">URL of the page</param>
        /// <returns>String with page xml or empty string if no page was found</returns>
        public string GetContentByUrl(string Url)
        {
            string retVal = string.Empty;

            Query            pageQuery = new Query();
            ItemTypeCriteria isPage    = new ItemTypeCriteria(64); // TODO There must be an enum of these somewhere
            PageURLCriteria  pageUrl   = new PageURLCriteria(Url);

            Criteria allCriteria = CriteriaFactory.And(isPage, pageUrl);

            if (this.PublicationId != 0)
            {
                PublicationCriteria correctSite = new PublicationCriteria(this.PublicationId);
                allCriteria.AddCriteria(correctSite);
            }
            pageQuery.Criteria = allCriteria;

            string[] resultUris = pageQuery.ExecuteQuery();

            if (resultUris.Length > 0)
            {
                PageContentAssembler loadPage = new PageContentAssembler();
                retVal = loadPage.GetContent(resultUris[0]);
            }
            return(retVal);
        }
Beispiel #3
0
        /// <summary>
        /// Gets the raw string (xml) from the broker db by URL
        /// </summary>
        /// <param name="Url">URL of the page</param>
        /// <returns>String with page xml or empty string if no page was found</returns>
        private string GetStringContentFromBrokerByUrl(string Url)
        {
            string retVal = string.Empty;

            Query               pageQuery   = new Query();
            ItemTypeCriteria    isPage      = new ItemTypeCriteria(64);               // TODO There must be an enum of these somewhere
            PageURLCriteria     pageUrl     = new PageURLCriteria(Url);
            PublicationCriteria correctSite = new PublicationCriteria(PublicationId); //Todo: add logic to determine site on url



            Criteria allCriteria = CriteriaFactory.And(isPage, pageUrl);

            allCriteria.AddCriteria(correctSite);

            pageQuery.Criteria = allCriteria;

            string[] resultUris = pageQuery.ExecuteQuery();

            if (resultUris.Length > 0)
            {
                PageContentAssembler loadPage = new PageContentAssembler();
                retVal = loadPage.GetContent(resultUris[0]);
            }
            return(retVal);
        }
Beispiel #4
0
        public byte[] GetBinaryByUrl(string url)
        {
            string encodedUrl = HttpUtility.UrlPathEncode(url); // ?? why here? why now?

            Query findBinary = new Query();
            PublicationURLCriteria urlCriteria = new PublicationURLCriteria(url);
            //MultimediaCriteria isBinary = new MultimediaCriteria(true);

            //Criteria allCriteria = CriteriaFactory.And(isBinary, urlCriteria);
            Criteria allCriteria = urlCriteria;

            findBinary.Criteria = allCriteria;
            if (this.PublicationId != 0)
            {
                PublicationCriteria correctSite = new PublicationCriteria(this.PublicationId);
                allCriteria.AddCriteria(correctSite);
            }

            string[] binaryUri = findBinary.ExecuteQuery();

            if (binaryUri.Length == 0)
            {
                // TODO: find out how to retrieve binary data
            }

            throw new NotImplementedException();
        }
        public byte[] GetBinaryByUrl(string url)
        {
            string encodedUrl = HttpUtility.UrlPathEncode(url); // ?? why here? why now?
            
            Query findBinary = new Query();
            PublicationURLCriteria urlCriteria = new PublicationURLCriteria(url);
            //MultimediaCriteria isBinary = new MultimediaCriteria(true);

            //Criteria allCriteria = CriteriaFactory.And(isBinary, urlCriteria);
            Criteria allCriteria = urlCriteria;
            findBinary.Criteria = allCriteria;
            if (this.PublicationId != 0)
            {
                PublicationCriteria correctSite = new PublicationCriteria(this.PublicationId);
                allCriteria.AddCriteria(correctSite);
            }

            string[] binaryUri = findBinary.ExecuteQuery();

            if (binaryUri.Length == 0)
            {
                
                // TODO: find out how to retrieve binary data
            }

            throw new NotImplementedException();
        }
        public bool TryFindBinary(string url, out IBinary binary)
        {
            //string encodedUrl = HttpUtility.UrlPathEncode(url);
            binary = null;
            return(false);

            Query findBinary = new Query();
            PublicationURLCriteria urlCriteria = new PublicationURLCriteria(url);

            MultimediaCriteria isBinary = new MultimediaCriteria(true);

            Com.Tridion.Broker.Querying.Criteria.Criteria allCriteria = Com.Tridion.Broker.Querying.CriteriaFactory.And(isBinary, isBinary);
            //Criteria allCriteria = CriteriaFactory.And(isBinary, urlCriteria);
            //Criteria allCriteria = urlCriteria;
            //findBinary.Criteria = allCriteria;

            string[] binaryUri = findBinary.ExecuteQuery();

            if (binaryUri.Length == 0)
            {
                return(false);
            }
            else
            {
                ComponentPresentation binaryComponent;



                return(true);
            }

            /*
             * using (var sqlBinMetaHome = new Com.Tridion.Broker.Binaries.Meta.SQLBinaryMetaHome())
             * {
             *  Com.Tridion.Meta.BinaryMeta binaryMeta = sqlBinMetaHome.FindByURL(PublicationId, encodedUrl); // "/Images/anubis_pecunia160_tcm70-520973.jpg"
             *  if (binaryMeta != null)
             *  {
             *      using (var sqlBinaryHome = new Com.Tridion.Broker.Binaries.SQLBinaryHome())
             *      {
             *          Com.Tridion.Data.BinaryData binData = sqlBinaryHome.FindByPrimaryKey(PublicationId, (int)binaryMeta.GetId());
             *          if (binData != null)
             *          {
             *              binary = new Binary(this)
             *              {
             *                  Url = url,
             *                  LastPublishedDate = DateTime.Now,
             *                  Multimedia = null,
             *                  VariantId = binData.GetVariantId()
             *              };
             *              return true;
             *          }
             *      }
             *  }
             *  return false;
             * }
             */
        }
        /// <summary>
        /// Get all urls of published pages
        /// </summary>
        /// <param name="includeExtensions"></param>
        /// <param name="pathStarts"></param>
        /// <param name="publicationID"></param>
        /// <returns></returns>
        public string[] GetAllPublishedPageUrls(string[] includeExtensions, string[] pathStarts)
        {
            Query               pageQuery          = new Query();
            ItemTypeCriteria    isPage             = new ItemTypeCriteria(64);               // TODO There must be an enum of these somewhere
            PublicationCriteria currentPublication = new PublicationCriteria(PublicationId); //Todo: add logic to determine site on url

            Criteria pageInPublication = CriteriaFactory.And(isPage, currentPublication);

            if (includeExtensions.Length > 0)
            {
                PageURLCriteria[] extensionsCriteria = new PageURLCriteria[includeExtensions.Length];
                int criteriaCount = 0;
                foreach (string pageExtension in includeExtensions)
                {
                    extensionsCriteria.SetValue(new PageURLCriteria("%" + pageExtension, Criteria.Like), criteriaCount);
                    criteriaCount++;
                }

                Criteria allExtensions = CriteriaFactory.Or(extensionsCriteria);
                pageInPublication = CriteriaFactory.And(pageInPublication, allExtensions);
            }

            if (pathStarts.Length > 0)
            {
                PageURLCriteria[] pathCriteria = new PageURLCriteria[pathStarts.Length];
                int criteriaCount = 0;
                foreach (string requiredPath in pathStarts)
                {
                    pathCriteria.SetValue(new PageURLCriteria(requiredPath + "%", Criteria.Like), criteriaCount);
                    criteriaCount++;
                }

                Criteria allPaths = CriteriaFactory.Or(pathCriteria);
                pageInPublication = CriteriaFactory.And(pageInPublication, allPaths);
            }

            Query findPages = new Query(pageInPublication);

            string[] pageUris = findPages.ExecuteQuery();

            // Need to get PageMeta data to find all the urls
            List <string> pageUrls = new List <string>();

            foreach (string uri in pageUris)
            {
                TcmUri          tcmUri      = new TcmUri(uri);
                PageMetaFactory metaFactory = GetPageMetaFactory(tcmUri.PublicationId);
                IPageMeta       currentMeta = metaFactory.GetMeta(uri);
                pageUrls.Add(currentMeta.UrlPath);
            }
            return(pageUrls.ToArray());
        }
        /// <summary>
        /// Get all urls of published pages
        /// </summary>
        /// <param name="includeExtensions"></param>
        /// <param name="pathStarts"></param>
        /// <param name="publicationID"></param>
        /// <returns></returns>
        public string[] GetAllPublishedPageUrls(string[] includeExtensions, string[] pathStarts)
        {
            Query pageQuery = new Query();
            ItemTypeCriteria isPage = new ItemTypeCriteria(64);  // TODO There must be an enum of these somewhere
            PublicationCriteria currentPublication = new PublicationCriteria(PublicationId); //Todo: add logic to determine site on url

            Criteria pageInPublication = CriteriaFactory.And(isPage, currentPublication);

            if (includeExtensions.Length > 0)
            {
                PageURLCriteria[] extensionsCriteria = new PageURLCriteria[includeExtensions.Length];
                int criteriaCount = 0;
                foreach (string pageExtension in includeExtensions)
                {
                    extensionsCriteria.SetValue(new PageURLCriteria("%" + pageExtension, Criteria.Like), criteriaCount);
                    criteriaCount++;
                }

                Criteria allExtensions = CriteriaFactory.Or(extensionsCriteria);
                pageInPublication = CriteriaFactory.And(pageInPublication, allExtensions);
            }

            if (pathStarts.Length > 0)
            {
                PageURLCriteria[] pathCriteria = new PageURLCriteria[pathStarts.Length];
                int criteriaCount = 0;
                foreach (string requiredPath in pathStarts)
                {
                    pathCriteria.SetValue(new PageURLCriteria(requiredPath + "%", Criteria.Like), criteriaCount);
                    criteriaCount++;
                }

                Criteria allPaths = CriteriaFactory.Or(pathCriteria);
                pageInPublication = CriteriaFactory.And(pageInPublication, allPaths);
            }

            Query findPages = new Query(pageInPublication);
            string[] pageUris = findPages.ExecuteQuery();

            // Need to get PageMeta data to find all the urls
            List<string> pageUrls = new List<string>();
            foreach (string uri in pageUris)
            {
                TcmUri tcmUri = new TcmUri(uri);
                PageMetaFactory metaFactory = GetPageMetaFactory(tcmUri.PublicationId);
                IPageMeta currentMeta = metaFactory.GetMeta(uri);
                pageUrls.Add(currentMeta.UrlPath);
            }
            return pageUrls.ToArray();
        }
Beispiel #9
0
        /// <summary>
        /// Gets the raw string (xml) from the broker db by URL
        /// </summary>
        /// <param name="Url">URL of the page</param>
        /// <returns>String with page xml or empty string if no page was found</returns>
        public string GetContentByUrl(string Url)
        {
            LoggerService.Debug(">>GetContentByUrl({0})", LoggingCategory.Performance, Url);
            string retVal = string.Empty;

            LoggerService.Debug("GetContentByUrl: about to create query", LoggingCategory.Performance);
            using (var pageQuery = new Query())
            {
                LoggerService.Debug("GetContentByUrl: created query", LoggingCategory.Performance);
                using (var isPage = new ItemTypeCriteria(64))
                {
                    using (var pageUrl = new PageURLCriteria(Url))
                    {
                        using (var allCriteria = CriteriaFactory.And(isPage, pageUrl))
                        {
                            if (this.PublicationId != 0)
                            {
                                using (var correctSite = new PublicationCriteria(this.PublicationId))
                                {
                                    allCriteria.AddCriteria(correctSite);
                                }
                            }

                            pageQuery.Criteria = allCriteria;
                        }
                    }
                }
                LoggerService.Debug("GetContentByUrl: added criteria to query", LoggingCategory.Performance);

                LoggerService.Debug("GetContentByUrl: about to execute query", LoggingCategory.Performance);
                string[] resultUris = pageQuery.ExecuteQuery();
                pageQuery.Dispose();
                LoggerService.Debug("GetContentByUrl: executed query", LoggingCategory.Performance);


                if (resultUris.Length > 0)
                {
                    retVal = PageContentAssembler.GetContent(resultUris[0]);
                    LoggerService.Debug("GetContentByUrl: executed PageContentAssembler", LoggingCategory.Performance);
                }
                LoggerService.Debug("<<GetContentByUrl({0})", LoggingCategory.Performance, Url);
                return(retVal);
            }
        }
        /// <summary>
        /// Gets the raw string (xml) from the broker db by URL
        /// </summary>
        /// <param name="Url">URL of the page</param>
        /// <returns>String with page xml or empty string if no page was found</returns>
        public string GetContentByUrl(string Url)
        {

            LoggerService.Debug(">>GetContentByUrl({0})", LoggingCategory.Performance, Url);
            string retVal = string.Empty;

            LoggerService.Debug("GetContentByUrl: about to create query", LoggingCategory.Performance);
            using (var pageQuery = new Query())
            {
                LoggerService.Debug("GetContentByUrl: created query", LoggingCategory.Performance);
                using (var isPage = new ItemTypeCriteria(64))
                {
                    using (var pageUrl = new PageURLCriteria(Url))
                    {
                        using (var allCriteria = CriteriaFactory.And(isPage, pageUrl))
                        {
                            if (this.PublicationId != 0)
                            {
                                using (var correctSite = new PublicationCriteria(this.PublicationId))
                                {
                                    allCriteria.AddCriteria(correctSite);
                                }
                            }

                            pageQuery.Criteria = allCriteria;
                        }
                    }
                }
                LoggerService.Debug("GetContentByUrl: added criteria to query", LoggingCategory.Performance);

                LoggerService.Debug("GetContentByUrl: about to execute query", LoggingCategory.Performance);
                string[] resultUris = pageQuery.ExecuteQuery();
                pageQuery.Dispose();
                LoggerService.Debug("GetContentByUrl: executed query", LoggingCategory.Performance);


                if (resultUris.Length > 0)
                {
                    retVal = PageContentAssembler.GetContent(resultUris[0]);
                    LoggerService.Debug("GetContentByUrl: executed PageContentAssembler", LoggingCategory.Performance);
                }
                LoggerService.Debug("<<GetContentByUrl({0})", LoggingCategory.Performance, Url);
                return retVal;
            }
        }
        public bool TryFindBinary(string url, out IBinary binary)
        {
            string encodedUrl = HttpUtility.UrlPathEncode(url);
            binary = null;
            return false;

            Query findBinary = new Query();
            PublicationURLCriteria urlCriteria = new PublicationURLCriteria(url);
            //MultimediaCriteria isBinary = new MultimediaCriteria(true);

            //Criteria allCriteria = CriteriaFactory.And(isBinary, urlCriteria);
            Criteria allCriteria = urlCriteria;
            findBinary.Criteria = allCriteria;

            string[] binaryUri = findBinary.ExecuteQuery();

            if (binaryUri.Length == 0)
            {
                return false;
            }
            else
            {
                ComponentPresentation binaryComponent ;

                return true;
            }

            /*
            using (var sqlBinMetaHome = new Com.Tridion.Broker.Binaries.Meta.SQLBinaryMetaHome())
            {
                Com.Tridion.Meta.BinaryMeta binaryMeta = sqlBinMetaHome.FindByURL(PublicationId, encodedUrl); // "/Images/anubis_pecunia160_tcm70-520973.jpg"
                if (binaryMeta != null)
                {
                    using (var sqlBinaryHome = new Com.Tridion.Broker.Binaries.SQLBinaryHome())
                    {
                        Com.Tridion.Data.BinaryData binData = sqlBinaryHome.FindByPrimaryKey(PublicationId, (int)binaryMeta.GetId());
                        if (binData != null)
                        {
                            binary = new Binary(this)
                            {
                                Url = url,
                                LastPublishedDate = DateTime.Now,
                                Multimedia = null,
                                VariantId = binData.GetVariantId()
                            };
                            return true;
                        }
                    }
                }
                return false;
            }
            */
        }
        /// <summary>
        /// Gets the raw string (xml) from the broker db by URL
        /// </summary>
        /// <param name="Url">URL of the page</param>
        /// <returns>String with page xml or empty string if no page was found</returns>
        public string GetContentByUrl(string Url)
        {

            LoggerService.Debug(">>GetContentByUrl({0})", LoggingCategory.Performance, Url);
            string retVal = string.Empty;

            LoggerService.Debug("GetContentByUrl: about to create query", LoggingCategory.Performance);
            Query pageQuery = new Query();
            LoggerService.Debug("GetContentByUrl: created query", LoggingCategory.Performance);
            ItemTypeCriteria isPage = new ItemTypeCriteria(64);  // TODO There must be an enum of these somewhere
            PageURLCriteria pageUrl = new PageURLCriteria(Url);

            Criteria allCriteria = CriteriaFactory.And(isPage, pageUrl);
            if (this.PublicationId != 0)
            {
                PublicationCriteria correctSite = new PublicationCriteria(this.PublicationId);
                allCriteria.AddCriteria(correctSite);
            }
            pageQuery.Criteria = allCriteria;
            LoggerService.Debug("GetContentByUrl: added criteria to query", LoggingCategory.Performance);

            LoggerService.Debug("GetContentByUrl: about to execute query", LoggingCategory.Performance);
            string[] resultUris = pageQuery.ExecuteQuery();
            LoggerService.Debug("GetContentByUrl: executed query", LoggingCategory.Performance);


            if (resultUris.Length > 0)
            {
                retVal = PageContentAssembler.GetContent(resultUris[0]);
                LoggerService.Debug("GetContentByUrl: executed PageContentAssembler", LoggingCategory.Performance);
            }
            LoggerService.Debug("<<GetContentByUrl({0})", LoggingCategory.Performance, Url);
            return retVal;
        }
Beispiel #13
0
        /// <summary>
        /// Executes the specified <see cref="T:TcmCDService.Contracts.BrokerQuery" />
        /// </summary>
        /// <param name="brokerQuery"><see cref="T:TcmCDService.Contracts.BrokerQuery" /></param>
        /// <returns><see cref="I:System.Collections.Generic.IEnumerable{System.String}" /></returns>
        public static IEnumerable <String> Execute(BrokerQuery brokerQuery)
        {
            if (brokerQuery != null)
            {
                List <IDisposable> disposableItems = new List <IDisposable>();
                List <Criteria>    criteria        = new List <Criteria>();

                try
                {
                    // Query for ItemType: Component
                    if (brokerQuery.ItemType != 0)
                    {
                        criteria.Add(new ItemTypeCriteria((int)brokerQuery.ItemType));
                    }

                    // Query for Publication
                    if (!String.IsNullOrEmpty(brokerQuery.Publication))
                    {
                        criteria.Add(new PublicationCriteria(new TcmUri(brokerQuery.Publication).ItemId));
                    }

                    // Query based on Schema
                    if (brokerQuery.SchemaUris != null && brokerQuery.SchemaUris.Any())
                    {
                        criteria.Add(CriteriaFactory.Or(brokerQuery.SchemaUris.Select((u) =>
                        {
                            ItemSchemaCriteria itemSchemaCriteria = new ItemSchemaCriteria(new TcmUri(u).ItemId);
                            disposableItems.Add(itemSchemaCriteria);

                            return(itemSchemaCriteria);
                        }).ToArray()));
                    }

                    // Query based on Component Template
                    if (!String.IsNullOrEmpty(brokerQuery.ComponentTemplateUri))
                    {
                        criteria.Add(new ItemTemplateCriteria(new TcmUri(brokerQuery.ComponentTemplateUri).ItemId));
                    }

                    // Add any SubQuery entries (MetaQuery or KeywordQueries which are specified)
                    if (brokerQuery.SubQueries != null && brokerQuery.SubQueries.Any())
                    {
                        criteria.AddRange(brokerQuery.SubQueries.Where(q => q != null).Select((q) =>
                        {
                            Criteria subCriteria = q is MetaQuery ? ToCriteria(q as MetaQuery) : ToCriteria(q as KeywordQuery);
                            disposableItems.Add(subCriteria);

                            return(subCriteria);
                        }));
                    }

                    using (Tridion.ContentDelivery.DynamicContent.Query.Query query = new Tridion.ContentDelivery.DynamicContent.Query.Query(CriteriaFactory.And(criteria.ToArray())))
                    {
                        // Limit the amount of results
                        using (LimitFilter filter = new LimitFilter(brokerQuery.ResultLimit.GetValueOrDefault(100)))
                        {
                            query.SetResultFilter(filter);
                            query.AddSorting(new SortParameter(SortParameter.ItemModificationDate, SortParameter.Descending));

                            return(query.ExecuteQuery());
                        }
                    }
                }
                finally
                {
                    // Ensure all created Java objects are disposed
                    foreach (Criteria entry in criteria)
                    {
                        if (entry != null)
                        {
                            entry.Dispose();
                        }
                    }

                    foreach (IDisposable entry in disposableItems)
                    {
                        if (entry != null)
                        {
                            entry.Dispose();
                        }
                    }
                }
            }

            return(new String[] { });
        }
        /// <summary>
        /// Gets the raw string (xml) from the broker db by URL
        /// </summary>
        /// <param name="Url">URL of the page</param>
        /// <returns>String with page xml or empty string if no page was found</returns>
        public string GetContentByUrl(string Url)
        {
            string retVal = string.Empty;

            Query pageQuery = new Query();
            ItemTypeCriteria isPage = new ItemTypeCriteria(64);  // TODO There must be an enum of these somewhere
            PageURLCriteria pageUrl = new PageURLCriteria(Url);

            Criteria allCriteria = CriteriaFactory.And(isPage, pageUrl);
            if (this.PublicationId != 0)
            {
                PublicationCriteria correctSite = new PublicationCriteria(this.PublicationId);
                allCriteria.AddCriteria(correctSite);
            }
            pageQuery.Criteria = allCriteria;

            string[] resultUris = pageQuery.ExecuteQuery();

            if (resultUris.Length > 0)
            {
                PageContentAssembler loadPage = new PageContentAssembler();
                retVal = loadPage.GetContent(resultUris[0]);
            }
            return retVal;
        }
        /// <summary>
        /// Gets the raw string (xml) from the broker db by URL
        /// </summary>
        /// <param name="Url">URL of the page</param>
        /// <returns>String with page xml or empty string if no page was found</returns>
        private string GetStringContentFromBrokerByUrl(string Url)
        {
            string retVal = string.Empty;

            Query pageQuery = new Query();
            ItemTypeCriteria isPage = new ItemTypeCriteria(64);  // TODO There must be an enum of these somewhere
            PageURLCriteria pageUrl = new PageURLCriteria(Url);
            PublicationCriteria correctSite = new PublicationCriteria(PublicationId); //Todo: add logic to determine site on url

            Criteria allCriteria = CriteriaFactory.And(isPage, pageUrl);
            allCriteria.AddCriteria(correctSite);

            pageQuery.Criteria = allCriteria;

            string[] resultUris = pageQuery.ExecuteQuery();

            if (resultUris.Length > 0)
            {
                PageContentAssembler loadPage = new PageContentAssembler();
                retVal = loadPage.GetContent(resultUris[0]);
            }
            return retVal;
        }
        /// <summary>
        /// Executes the specified <see cref="T:TcmCDService.Contracts.BrokerQuery" />
        /// </summary>
        /// <param name="brokerQuery"><see cref="T:TcmCDService.Contracts.BrokerQuery" /></param>
        /// <returns><see cref="I:System.Collections.Generic.IEnumerable{System.String}" /></returns>
        public static IEnumerable<String> Execute(BrokerQuery brokerQuery)
        {
            if (brokerQuery != null)
            {
                List<IDisposable> disposableItems = new List<IDisposable>();
                List<Criteria> criteria = new List<Criteria>();

                try
                {
                    // Query for ItemType: Component
                    if (brokerQuery.ItemType != 0)
                        criteria.Add(new ItemTypeCriteria((int)brokerQuery.ItemType));

                    // Query for Publication
                    if (!String.IsNullOrEmpty(brokerQuery.Publication))
                        criteria.Add(new PublicationCriteria(new TcmUri(brokerQuery.Publication).ItemId));

                    // Query based on Schema
                    if (brokerQuery.SchemaUris != null && brokerQuery.SchemaUris.Any())
                        criteria.Add(CriteriaFactory.Or(brokerQuery.SchemaUris.Select((u) =>
                        {
                            ItemSchemaCriteria itemSchemaCriteria = new ItemSchemaCriteria(new TcmUri(u).ItemId);
                            disposableItems.Add(itemSchemaCriteria);

                            return itemSchemaCriteria;
                        }).ToArray()));

                    // Query based on Component Template
                    if (!String.IsNullOrEmpty(brokerQuery.ComponentTemplateUri))
                        criteria.Add(new ItemTemplateCriteria(new TcmUri(brokerQuery.ComponentTemplateUri).ItemId));

                    // Add any SubQuery entries (MetaQuery or KeywordQueries which are specified)
                    if (brokerQuery.SubQueries != null && brokerQuery.SubQueries.Any())
                        criteria.AddRange(brokerQuery.SubQueries.Where(q => q != null).Select((q) =>
                        {
                            Criteria subCriteria = q is MetaQuery ? ToCriteria(q as MetaQuery) : ToCriteria(q as KeywordQuery);
                            disposableItems.Add(subCriteria);

                            return subCriteria;
                        }));

                    using (Tridion.ContentDelivery.DynamicContent.Query.Query query = new Tridion.ContentDelivery.DynamicContent.Query.Query(CriteriaFactory.And(criteria.ToArray())))
                    {
                        // Limit the amount of results
                        using (LimitFilter filter = new LimitFilter(brokerQuery.ResultLimit.GetValueOrDefault(100)))
                        {
                            query.SetResultFilter(filter);
                            query.AddSorting(new SortParameter(SortParameter.ItemModificationDate, SortParameter.Descending));

                            return query.ExecuteQuery();
                        }
                    }
                }
                finally
                {
                    // Ensure all created Java objects are disposed
                    foreach (Criteria entry in criteria)
                    {
                        if (entry != null)
                            entry.Dispose();
                    }

                    foreach (IDisposable entry in disposableItems)
                    {
                        if (entry != null)
                            entry.Dispose();
                    }
                }
            }

            return new String[] { };
        }