using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using Examine;
using Examine.Azure;
using Examine.LuceneEngine.Config;
using Lucene.Net.Analysis;
using Lucene.Net.QueryParsers;
using Lucene.Net.Store.Azure;
using Microsoft.WindowsAzure;
using Microsoft.WindowsAzure.ServiceRuntime;
using UmbracoExamine.Azure;
using UmbracoExamine.DataServices;
namespace UmbracoExamine.PDF.Azure
{
public class AzurePDFIndexer : PDFIndexer, IAzureCatalogue
{
///
/// static constructor run to initialize azure settings
///
static AzurePDFIndexer()
{
AzureExtensions.EnsureAzureConfig();
}
///
/// Default constructor
///
public AzurePDFIndexer()
{
SupportedExtensions = new[] { ".pdf" };
UmbracoFileProperty = "umbracoFile";
//By default, we will be using the UmbracoAzureDataService
DataService = new UmbracoAzureDataService();
}
///
/// Constructor to allow for creating an indexer at runtime
///
///
///
///
///
public AzurePDFIndexer(DirectoryInfo indexPath, IDataService dataService, Analyzer analyzer, bool async)
: base(indexPath, dataService, analyzer, async)
{
}
public override void Initialize(string name, System.Collections.Specialized.NameValueCollection config)
{
base.Initialize(name, config);
this.SetOptimizationThresholdOnInit(config);
var indexSet = IndexSets.Instance.Sets[IndexSetName];
Catalogue = indexSet.IndexPath;
}
///
/// The blob storage catalogue name to store the index in
///
public string Catalogue { get; private set; }
private Lucene.Net.Store.Directory _directory;
public override Lucene.Net.Store.Directory GetLuceneDirectory()
{
return _directory ?? (_directory = this.GetAzureDirectory());
}
public override Lucene.Net.Index.IndexWriter GetIndexWriter()
{
return this.GetAzureIndexWriter();
}
protected override void OnIndexingError(IndexingErrorEventArgs e)
{
AzureExtensions.LogExceptionFile(Name, e);
base.OnIndexingError(e);
}
}
}