public bool Exists(SearchObjectId identity)
        {
            MailboxDataProvider.Tracer.TraceDebug <SearchObjectId>((long)this.GetHashCode(), "Querying existence of search object {0}", identity);
            bool result;

            using (MailboxDataStore mailboxDataStore = this.OpenMailboxStore())
            {
                result = mailboxDataStore.Exists(identity);
            }
            return(result);
        }
Example #2
0
        private string GetObjectMessageClass <T>(Guid guid) where T : IConfigurable, new()
        {
            SearchObjectBase searchObjectBase = ((default(T) == null) ? Activator.CreateInstance <T>() : default(T)) as SearchObjectBase;

            if (searchObjectBase == null)
            {
                throw new ArgumentException(string.Format("Invalid type: {0}, only SearchObject or SearchStatus are supported!", typeof(T).Name));
            }
            SearchObjectId searchObjectId = new SearchObjectId(this.MailboxOwnerId, searchObjectBase.ObjectType, guid);

            return("IPM.Configuration." + searchObjectId.ConfigurationName);
        }
Example #3
0
 internal void SetId(SearchObjectId identity)
 {
     if (identity == null)
     {
         throw new ArgumentNullException("identity");
     }
     if (identity.ObjectType != this.ObjectType)
     {
         throw new ArgumentException("identity.ObjectType " + identity.ObjectType.ToString());
     }
     this[SearchObjectBaseSchema.Id] = identity;
 }
Example #4
0
 public bool Exists(SearchObjectId identity)
 {
     this.CheckDisposed("Exists");
     if (identity == null || string.IsNullOrEmpty(identity.ConfigurationName))
     {
         throw new ArgumentNullException("identity");
     }
     using (UserConfiguration userConfiguration = this.OpenFaiMessage(identity.ConfigurationName, false))
     {
         if (userConfiguration != null)
         {
             return(true);
         }
     }
     return(false);
 }
Example #5
0
        public IConfigurable Read <T>(SearchObjectId identity) where T : IConfigurable, new()
        {
            this.CheckDisposed("Read");
            if (identity == null)
            {
                throw new ArgumentNullException("identity");
            }
            SearchObjectBase searchObjectBase = ((default(T) == null) ? Activator.CreateInstance <T>() : default(T)) as SearchObjectBase;

            if (searchObjectBase == null || searchObjectBase.ObjectType != identity.ObjectType)
            {
                return(null);
            }
            IConfigurable result;

            using (UserConfiguration userConfiguration = this.OpenFaiMessage(identity.ConfigurationName, false))
            {
                if (userConfiguration == null)
                {
                    result = null;
                }
                else
                {
                    using (Stream stream = userConfiguration.GetStream())
                    {
                        T t = default(T);
                        try
                        {
                            IFormatter formatter = ExchangeBinaryFormatterFactory.CreateBinaryFormatter(null);
                            t = (T)((object)formatter.Deserialize(stream));
                        }
                        catch (InvalidOperationException ex)
                        {
                            MailboxDataStore.Tracer.TraceError <InvalidOperationException, SearchObjectId>((long)this.GetHashCode(), "SerializationException: {0} for search {1}!", ex, identity);
                            throw new CorruptDataException(ServerStrings.StoreDataInvalid(identity.ToString()), ex);
                        }
                        catch (SerializationException ex2)
                        {
                            MailboxDataStore.Tracer.TraceError <SerializationException, SearchObjectId>((long)this.GetHashCode(), "SerializationException: {0} for search {1}!", ex2, identity);
                            throw new CorruptDataException(ServerStrings.StoreDataInvalid(identity.ToString()), ex2);
                        }
                        if (t == null || t.Identity == null || !t.Identity.Equals(identity))
                        {
                            MailboxDataStore.Tracer.TraceError <SearchObjectId, IExchangePrincipal>((long)this.GetHashCode(), "Reading {0} from discovery mailbox {1} failed with null object or incorrect identity!", identity, this.MailboxSession.MailboxOwner);
                            throw new CorruptDataException(ServerStrings.StoreDataInvalid(identity.ToString()));
                        }
                        (t as SearchObjectBase).Id.MailboxOwnerId = this.MailboxOwnerId;
                        MailboxDataStore.Tracer.TraceDebug <T, IExchangePrincipal>((long)this.GetHashCode(), "Read {0} from discovery mailbox {1}.", t, this.MailboxSession.MailboxOwner);
                        ValidationError[] array = (t as ConfigurableObject).ValidateRead();
                        if (array.Length > 0)
                        {
                            throw new DataValidationException(array[0]);
                        }
                        if (t.GetType() == typeof(SearchObject))
                        {
                            this.CacheSearchStatus(t as SearchObject);
                        }
                        result = t;
                    }
                }
            }
            return(result);
        }
Example #6
0
        private void CacheSearchStatus(SearchObject searchObject)
        {
            SearchObjectId identity = new SearchObjectId(searchObject.Id, ObjectType.SearchStatus);

            searchObject.SearchStatus = (SearchStatus)this.Read <SearchStatus>(identity);
        }